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

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Shape factory
Shape gallery
What's new
System requirements
Download Center
Public license
Getting started
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
Home / Developer Corner / Forums / Usage issues / Draw a torus

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 Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!

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