Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

Draw a torus

Draw a torus
mz 2013/02/26 13:07

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
Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map