View Issue Details

IDProjectCategoryView StatusLast Update
0032695CommunityOCCT:Data Exchangepublic2021-12-01 15:43
Reporterchristopher.lackner_140546 Assigned Togka  
PrioritynormalSeveritymajor 
Status assignedResolutionopen 
PlatformLinuxOSArch 
Product Version5.2.4 
Target Version7.7.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)

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.

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