Shape Type to mesh ? Which one to use ?

Hi all,

I red Roman's blog about OCC Shapes, Face, ...

But I have a question about all of that :
What are the Shape kind we need to mesh to have the whole (STEP)file geometry (and assembly)?

For the moment, I have some results meshing TopAbs_SOLID and TopAbs_FACE. But, Solid is composed by Shell, which is composed by Face .... so if I only mesh FACE Shapes, why haven't I the whole geometry ?

What Shape kind I am supposed to mesh ?

I have a bonus question too : how to get the good Shape location ? I get the one for each Shape, but i result I get all the shape in 0,0,0...
For each Face after meshing, I have the Face Location I set on points... but still the same result...

Thanks a lot.


Roman Lygin's picture

Hi Vincent,

Could you rephrase your question for better understanding or give an example of what you are trying to accomplish ? What is your final goal which makes you to mesh your model ? Note that when you import from STEP, there is no mesh inside but there is entirely good topology and geometry model.

Like I mentioned in another your post, you might want to triangulate the entire shape at once - BRepMesh::Mesh(). It will iterate over all faces and edges and add polygonal representations (as was mentioned on my blog).

Don't get your question on location, sorry :-(. When you iterate with TopExp_Explorer it returns you a child shape in a location which is a consecutive product of all interim locations. That is, the shape is located there where you would see it on the screen.

When you deal with Faces don't forget to apply its own internal locations - I mentioned that as well in the post on faces.

Hope this helps.
--- - the Open CASCADE blog

_VincentB_'s picture

Hi Roman,

My goal is to convert the .step file into a personal 3D data file. My format is based on the scenegraph. So I'm looking at a way to get the assembly tree of the step file, to create my own tree, with the good translation/rotation to get all the part of the assembly at the good place.

For the moment, I have all the part (I think) but they are all placed in the scene center.

I only triangulate the low-level entities (not root shape).

My first question is how can I run into the assembly tree, getting Shape Location to have the real 3D scene at the end (and not a lot of sub-assembly at the same place) ?

Concerning the Location problem,
this the code I use :

Notice that the getShapeLocation() get the Shape location, converting the matrix into my own matrix tree node.

STEPCAFControl_Reader Reader;
osg::notify(osg::WARN)<NewDocument("MDTV-XCAF", Doc);

osg::notify(osg::WARN)<<"CasCade Error : Transfer error"<Main());
//get the top level shapes
TDF_LabelSequence l_LabelShapes;

aSequence= new TopTools_HSequenceOfShape();
TopoDS_Shape Shape;
Quantity_Color l_Color;
Handle(XCAFDoc_ColorTool) l_Colors = XCAFDoc_DocumentTool::ColorTool(Doc->Main());
Handle(TDataStd_Name) l_NameAttribute;

osg::ref_ptr grouploaded = new osg::MatrixTransform;

for(int i=1;i<=l_LabelShapes.Length();i++)
Shape = Shape_Tool->GetShape(l_LabelShapes.Value(i));

TraverseShape(Shape, grouploaded.get());

void StepIgesReader::TraverseShape (const TopoDS_Shape& theShape, osg::Group* parent)

osg::ref_ptr mt = new osg::MatrixTransform();

TopoDS_Iterator anIt (theShape);
for (; anIt.More(); anIt.Next())
TopoDS_Shape Shape = anIt.Value();

/* TopoDS_Iterator anIt2 (Shape);
if ( anIt2.More())
TraverseShape(Shape, mt.get());
osg::ref_ptr geode = new osg::Geode();


in the Load() I do :

//convert only the solids and the Faces
if (Shape.ShapeType() != TopAbs_SOLID &&
Shape.ShapeType() != TopAbs_FACE &&
Shape.ShapeType() != TopAbs_VERTEX)
return NULL;

//Build Mesh

//Different Methods of Mesh
BRepMesh_IncrementalMesh* mesh = new BRepMesh_IncrementalMesh(Shape,10/*l_Deflection*/,true,0.5);

TopExp_Explorer ExpFace;

TopoDS_Face Face=TopoDS::Face(ExpFace.Current());
// osg::notify(osg::NOTICE)<<"New face to convert"<