Mon, 09/05/2022 - 12:05
Here is the code to reproduce the issue:
#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;
} 
I compile this with
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
When I look at the demo1.stl I get what is shown in the attached picture, which I believe is not correct. Perhaps I made a mistake in the input?
        
Mon, 09/05/2022 - 13:31
I think the angle's a1 and a2 should be in range of 0 - 2pi (If you want a full torus of the small radius)
see this example
Mon, 09/05/2022 - 14:41
Thanks for the link and looking into this Guido. I think the explorer has the same issue I am seeing:
This works:
LargeRadius: 60, SmallRadius 10, Angle1 0, Angle2 6,28318530717959, Angle 6,28318530717959
But these do not work:
LargeRadius: 60, SmallRadius 10, Angle1 3.1, Angle2 6,28318530717959, Angle 6,28318530717959
LargeRadius: 60, SmallRadius 10, Angle1 3.1, Angle2 6,28318530717959, Angle 3.1
(This gives a wired rendering (but that a different issue ):
LargeRadius: 60, SmallRadius 10, Angle1 3.0, Angle2 6,28318530717959, Angle 6,28318530717959)
If you can confirm this is an issue, I'd file a bug.
Tue, 09/06/2022 - 09:06
I have reported the issue. Bug number 33133.
https://tracker.dev.opencascade.org/view.php?id=33133
Wed, 09/07/2022 - 15:08
Yes indeed I think its a bug in BRepPrimAPI_MakeTorus.
If |a1-a2| < 2*PI there should only shell(or single face?) created ,no solid? (only sweep the circular arc-edge?)
Thu, 09/08/2022 - 16:32
Thanks Guido.
I'd still expect a solid. For a torus with parameters {{0, 0, 0}, {0, 0, 1}}, 3, 1, Pi, {0, \[Pi]}, I'd expect a solid torus like in the attachment.