How can I extract Shapes

I am using the following code to read STEP files,

Handle(TopTools_HSequenceOfShape) aSequence = CImportExport::ReadSTEP();

After that I am using the following code to extract the shapes,

ShapeExtend_Explorer extendExp;

Handle(TopTools_HSequenceOfShape) vertices=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) edges=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) wires=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) faces=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) shells=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) solids=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) compsols=new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) compounds=new TopTools_HSequenceOfShape;

extendExp.DispatchList(aSequence,vertices,edges,wires,faces,shells,solids,compsols,compounds);

But I am getting only one shape(Compound of solid). How can I get all the shapes from aSequence??

siyamalan's picture

But I am getting only one shape(Compound OR solid). How can I get all the shapes from aSequence??

Dmitry Khabi's picture

What you need is specified in the OpenCascade Documentation,

"Modeling Data
User's Guide"
Chapter 5: TOPOLOGY

siyamalan's picture

Could you please give me a sample code......?

Roman Lygin's picture

Hi,
Not sure if I got your initial query correctly.
To recursively traverse the topology structure you can use TopoDS_Iterator in a way similar to one demonstrated using TopExp_Explorer at http://www.opencascade.org/org/forum/thread_15540/

Another way is to classify everything into sequences with ShapeExtend_Explorer. Then you just iterate over each sequence.
for (i = 1; i <= asequence->Length(); i++) {
const TopoDS_Shape& aShape = asequence->Value(i);
...
}

There is yet another method TopExp::MapShapes() which creates an indexed map of all subshapes (down to the lowest level). Then you iterate over it.

Hope this helps.
Roman

---
opencascade.blogspot.com - blog on Open CASCADE