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
Hi,

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);
     if(!outerEdgeMaker.IsDone())
     {
          throw GeometryException(0, "edge not done");
     }
TopoDS_Edge outerEdge = outerEdgeMaker;

     // make wire
     BRepBuilderAPI_MakeWire wireMaker(outerEdge);
     if(!wireMaker.IsDone())
     {
          throw GeometryException(0, "wire not done");
     }
     TopoDS_Wire outerWire = wireMaker;

     // make face
     BRepBuilderAPI_MakeFace faceMaker(outerWire);
     if(!faceMaker.IsDone())
     {
          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
     setTopoDSShape(revolShape);
 
 
Latest news
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!

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