View Issue Details

IDProjectCategoryView StatusLast Update
0032695CommunityOCCT:Data Exchangepublic2023-01-16 19:15
Reporterchristopher.lackner_140546 Assigned Tobugmaster  
PrioritynormalSeveritymajor 
Status closedResolutionfixed 
PlatformLinuxOSArch 
Product Version5.2.4 
Target Version7.8.0 
Summary0032695: Data Exchange - Wrong cut sphere face in step export
DescriptionWhen exporting a sphere cut by a cylinder to step the result has the wrong face of the sphere leading to the cut-out cylinder as a result instead of the sphere minus the cylinder.

This issue was raised by one of our open source users of Netgen here:
https://ngsolve.org/forum/ngspy-forum/1506-saving-geometry-bug

and can be reproduced with the attached code.

Best, Christopher
Steps To Reproduce
pload XDE OCAF MODELING VISUALIZATION
psphere s 0.5
plane p 0 0 0 1 0 0
pcylinder c p 0.1 1.0
bcut r s c
vinit View1
#vdisplay -dispMode 1 r; vsetcolor r RED
vfit
testwritestep test.stp r
testreadstep  test.stp s
vdisplay -dispMode 1 s; vsetcolor s GREEN
vfit


#include <BRepPrimAPI_MakeSphere.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <XCAFApp_Application.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSControl_WorkSession.hxx>

#include <iostream>
using namespace std;

int main()
{
  auto sphere = BRepPrimAPI_MakeSphere({ 0., 0., 0. }, 0.5).Solid();
  auto cyl = BRepPrimAPI_MakeCylinder(gp_Ax2({0., 0., 0.}, {1., 0., 0.}),
                                  0.1, 1.);
  auto cut =  BRepAlgoAPI_Cut(sphere, cyl).Shape();


  Handle(XCAFApp_Application) app = XCAFApp_Application::GetApplication();
  Handle(TDocStd_Document) doc;
          
  app->NewDocument("STEP-XCAF", doc);
  Handle(XCAFDoc_ShapeTool) shapetool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
  auto label = shapetool->NewShape();
  shapetool->SetShape(label, cut);

  Handle(XSControl_WorkSession) session = new XSControl_WorkSession;
  STEPCAFControl_Writer writer(session);

  writer.Transfer(doc, STEPControl_AsIs);

  writer.Write("geo.step");
  return 0;
}
Additional information
and documentation updates
This is the CMakeLists.txt file to build the executable:


cmake_minimum_required(VERSION 3.12)

project(occ_bug)

find_package(OpenCascade NAMES OpenCASCADE opencascade REQUIRED)
set(OCC_LIBRARIES
  TKBO
  TKBRep
  TKBool
  TKCAF
  TKCDF
  TKFillet
  TKG2d
  TKG3d
  TKGeomAlgo
  TKGeomBase
  TKHLR
  TKIGES
  TKLCAF
  TKMath
  TKMesh
  TKOffset
  TKPrim
  TKSTEP
  TKSTEP209
  TKSTEPAttr
  TKSTEPBase
  TKSTL
  TKService
  TKShHealing
  TKTopAlgo
  TKV3d
  TKVCAF
  TKXCAF
  TKXDEIGES
  TKXDESTEP
  TKXSBase
  TKernel
  )
include_directories(${OpenCASCADE_INCLUDE_DIR})

add_executable(occ_bug occ_bug.cpp)
target_link_libraries(occ_bug ${OCC_LIBRARIES})
TagsNo tags attached.
Test case number

Attached Files

  • occ_bug.cpp (1,097 bytes)
  • DeepinScreenshot_select-area_20211201104739.png (36,562 bytes)
  • sphere_cyl_654.png (11,440 bytes)
  • bug32695.png (53,629 bytes)

Activities

christopher.lackner_140546

2021-11-28 22:45

reporter  

occ_bug.cpp (1,097 bytes)

kgv

2021-11-30 16:34

developer   ~0105544

Could you please clarify, how you determined result being wrong?
I see exactly the same shape after STEP export/import.

pload XDE OCAF MODELING VISUALIZATION
psphere s 0.5
pcylinder c 0.1 1.0
bcut r s c
vinit View1
#vdisplay -dispMode 1 r; vsetcolor r RED
vfit
testwritestep test.stp r
testreadstep  test.stp s
vdisplay -dispMode 1 s; vsetcolor s GREEN
vfit

christopher.lackner_140546

2021-12-01 12:48

reporter  

DeepinScreenshot_select-area_20211201104739.png (36,562 bytes)

christopher.lackner_140546

2021-12-01 12:50

reporter   ~0105559

Last edited: 2021-12-01 12:57

If I execute your script the stp file is correct, but if I load the step created from my script it is the attached file.

christopher.lackner_140546

2021-12-01 13:23

reporter   ~0105560

It seems the difference is the axis of the cylinder.
If I set the cylinder in Z direction it works, if in x direction not

kgv

2021-12-01 15:35

developer   ~0105568

Thanks, I've updated steps to reproduce.

kgv

2021-12-01 15:42

developer  

sphere_cyl_654.png (11,440 bytes)

kgv

2021-12-01 15:43

developer   ~0105569

Last edited: 2021-12-01 15:43

Interesting, before OCCT 6.6.0 (e.g. OCCT 6.5.4) produced a different STEP, although broken.

git

2022-11-14 16:56

administrator   ~0112099

Branch CR32695 has been created by ona.

SHA-1: ef2b0e5e8882d1927e44db41467070da55c89f4d


Detailed log of new commits:

Author: ona
Date: Mon Nov 14 16:52:38 2022 +0300

    0032695: Data Exchange - Wrong cut sphere face in step export
    
    - Test is added

git

2022-11-15 10:36

administrator   ~0112105

Branch CR32695 has been updated forcibly by ona.

SHA-1: 343c1ac06a4a29b8ffa250ce07f7cdeaa39839df

ona

2022-11-15 15:09

developer   ~0112116

Bug is not reproduced on the current master. A test is added.

ona

2022-11-15 15:10

developer   ~0112117

bug32695.png (53,629 bytes)

gka

2022-11-16 16:44

developer   ~0112133

Dear Bugmaster.

Bug is not reproduced in the current version.
Could you please close it.

Issue History

Date Modified Username Field Change
2021-11-28 22:45 christopher.lackner_140546 New Issue
2021-11-28 22:45 christopher.lackner_140546 Assigned To => gka
2021-11-28 22:45 christopher.lackner_140546 File Added: occ_bug.cpp
2021-11-28 22:48 kgv Summary Wrong cut sphere face in step export => Data Exchange - Wrong cut sphere face in step export
2021-11-28 22:48 kgv Steps to Reproduce Updated
2021-11-30 16:27 kgv File Added: sphere_minus_cylinder.png
2021-11-30 16:34 kgv Note Added: 0105544
2021-12-01 12:18 kgv Assigned To gka => christopher.lackner_140546
2021-12-01 12:18 kgv Status new => feedback
2021-12-01 12:48 christopher.lackner_140546 File Added: DeepinScreenshot_select-area_20211201104739.png
2021-12-01 12:50 christopher.lackner_140546 Note Added: 0105559
2021-12-01 12:57 christopher.lackner_140546 Note Edited: 0105559
2021-12-01 13:23 christopher.lackner_140546 Note Added: 0105560
2021-12-01 15:35 kgv Note Added: 0105568
2021-12-01 15:35 kgv Assigned To christopher.lackner_140546 => gka
2021-12-01 15:35 kgv Status feedback => assigned
2021-12-01 15:35 kgv Target Version => 7.7.0
2021-12-01 15:35 kgv Steps to Reproduce Updated
2021-12-01 15:35 kgv File Deleted: sphere_minus_cylinder.png
2021-12-01 15:36 kgv Steps to Reproduce Updated
2021-12-01 15:41 kgv Product Version 7.6.0 => 5.2.4
2021-12-01 15:42 kgv File Added: sphere_cyl_654.png
2021-12-01 15:43 kgv Note Added: 0105569
2021-12-01 15:43 kgv Note Edited: 0105569
2022-10-24 10:38 szy Target Version 7.7.0 => 7.8.0
2022-11-14 13:50 gka Assigned To gka => ona
2022-11-14 16:56 git Note Added: 0112099
2022-11-15 10:36 git Note Added: 0112105
2022-11-15 15:09 ona Note Added: 0112116
2022-11-15 15:10 ona Note Added: 0112117
2022-11-15 15:10 ona File Added: bug32695.png
2022-11-15 15:12 ona Assigned To ona => gka
2022-11-15 15:12 ona Status assigned => resolved
2022-11-16 16:44 gka Assigned To gka => bugmaster
2022-11-16 16:44 gka Status resolved => feedback
2022-11-16 16:44 gka Note Added: 0112133
2023-01-16 19:15 ebelouso Status feedback => closed
2023-01-16 19:15 ebelouso Resolution open => fixed