DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0033133

BRepPrimAPI_MakeTorus does not return a torus

CommunityOCCT:Modeling Algorithmsresolved2 public notes

Search issues

Description


when a1 is not 0 and a2 is not 2 Pi and angle is not 2 Pi things go south:

BRepPrimAPI_MakeTorus(axis, r1, r2, a1, a2, angle)

Other combination of values may also be problematic. See discussion in forum.

Steps to reproduce

#include <iostream>
#include <gp_Ax2.hxx>
#include <TopoDS_Shape.hxx>
#include <BRepPrimAPI_MakeTorus.hxx>
#include <StlAPI_Writer.hxx>
#include <BRepMesh_IncrementalMesh.hxx>

void Generate_Shape(TopoDS_Shape * store)
{
  gp_Ax2 axis = gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1));
  Standard_Real r1 = 1.0;
  Standard_Real r2 = 0.1;
  Standard_Real a1 = -1.5708;
  Standard_Real a2 = 1.5708;
  Standard_Real angle = 2.094;
  TopoDS_Shape shape = BRepPrimAPI_MakeTorus(axis, r1, r2, a1, a2, angle).Shape();

  *store = shape;
}

void Write_STL(TopoDS_Shape * store)
{
  StlAPI_Writer stl_writer;
  BRepMesh_IncrementalMesh Mesh( *store, 0.01 );
  Mesh.Perform();

  if (stl_writer.Write(*store, "demo1.stl")) {
    std::cout << std::endl << "True ";
  } else {
    std::cout << std::endl << "False ";
  }
}

int main()
{
  TopoDS_Shape *store = new TopoDS_Shape();
  Generate_Shape(store);
  Write_STL(store);

  return 0;
} 



g++ -I ~/builds/build/include/opencascade -L ~/builds/build/lin64/gcc/lib demo_simple_13.cpp -lTKBin -lTKBinL -lTKBinTObj -lTKBinXCAF -lTKBO -lTKBool -lTKBRep -lTKCAF -lTKCDF -lTKDCAF -lTKDraw -lTKernel -lTKFeat -lTKFillet -lTKG2d -lTKG3d -lTKGeomAlgo -lTKGeomBase -lTKHLR -lTKIGES -lTKLCAF -lTKMath -lTKMesh -lTKMeshVS -lTKOffset -lTKOpenGl -lTKPrim -lTKQADraw -lTKRWMesh -lTKService -lTKShHealing -lTKStd -lTKStdL -lTKSTEP209 -lTKSTEP -lTKSTEPAttr -lTKSTEPBase -lTKSTL -lTKTObj -lTKTObjDRAW -lTKTopAlgo -lTKTopTest -lTKV3d -lTKVCAF -lTKViewerTest -lTKVRML -lTKXCAF -lTKXDEDRAW -lTKXDEIGES -lTKXDESTEP -lTKXMesh -lTKXml -lTKXmlL -lTKXmlTObj -lTKXmlXCAF -lTKXSBase -lTKXSDRA

Additional information

Public activity

2 archived notes

Participants are labeled by their role within this record.

01Author
The problem persists if you change

Standard_Real a1 = -1.5708;

to

Standard_Real a1 = 1.5708/2;
02Commenter 1

Related records