For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Draw a torus

mz's picture


I try to draw a torus with the following code, but it fails: No shaded solid is drawn. But when switching to wired display mode, the result is as expected. What is wrong?
(I know, there is a torus-shape in OCC, but I need to be more flexible.)

Thank you for your help.

// make a circle with a normal along the x axis
gp_Dir xDir(1, 0, 0);
gp_Ax2 circSystem(gp_Pnt(0, 0, 0), xDir);
outerCircle = gp_Circ(circSystem, 10.0);
// translate the circle along y axis
outerCircle.SetLocation(gp_Pnt(0, 140.0, 0));

// make an edge
BRepBuilderAPI_MakeEdge outerEdgeMaker(outerCircle);
throw GeometryException(0, "edge not done");
TopoDS_Edge outerEdge = outerEdgeMaker;

// make wire
BRepBuilderAPI_MakeWire wireMaker(outerEdge);
throw GeometryException(0, "wire not done");
TopoDS_Wire outerWire = wireMaker;

// make face
BRepBuilderAPI_MakeFace faceMaker(outerWire);
throw GeometryException(0, "face not done");
TopoDS_Face outerFace = faceMaker;

// revolve edge around z axis
gp_Dir zDir(0, 0, 1);
gp_Ax1 revolAxis(gp_Pnt(0, 0, 0), zDir);
TopoDS_Shape revolShape = BRepPrimAPI_MakeRevol(outerFace, revolAxis);

// draw the constructed TopoDS_Shape