Help: a mesh program

Hi, everyone. I'm now working on a little CAD program using Open CASCADE, but I came across some problems when using the mesh utility, few examples are available and the reference documentation didn't provide enough imformation on how to use the APIs, can anybody help?

I've made a test program using the example given in the Open CASCADE help PDF file (Modeling Algorithms):

Standard_Real radius=10. ;
Standard_Real height=25. ;
BRepAPI_MakeCylinder myCyl (radius, height) ;
TopoDS_Shape myShape = myCyl.Shape() ;
Standard_Real Deflection = 0.01 ;
BRepMesh::Mesh (myShape, Deflection);

then convert the TopoDS_Shape into AIS object:
Handle(AIS_Shape) aisShape=new AIS_Shape(myShape);

at last display the AIS_Shape:
myContext->Display(aisShape, Standard_False);
where myContext is an instance of Handle_AIS_InteractiveContext.

when the program runs, the cylinder appears, but the mesh result is not displayed, I don't know the reason.

mz's picture

Hi davenkin,

you need to display the mesh explicitely by getting it from the TopoDS_Shape via BRep_Tool::Triangulation() and then either create an AIS_Shape for every triangle or combine these triangles to a compound before displaying (this will be faster).

Maybe this thread can help:

davenkin's picture

Thank you very much. I've read the thread you gave, it helps me a lot, but another question appears:
BRep_Tool::Triangulation (const TopoDS_Face &F, TopLoc_Location &L) only deals with TopoDS_Face, this is only enough for display the mesh result, the thread from gives an example on how to get the nodes from a face which is retruned by calling BRep_Tool::Triangulation, but how can I get the inner nodes of a solid, not a face.

mz's picture

If my understanding is correct, you are not looking for a surface mesh but for a volume mesh. I'm afraid, OCC does not provide volume meshing. But maybe NETGEN can do this for you.

See also:

davenkin's picture

Thank you,mz,you've got what I'm thinking about.