Getting pointer to a TopoDS_Shape


I'm very new to OCC,
I want to store pointers to every element of a cube (a topods_shape called aShape) in a vector of pointers so after that I can call them to apply an operation (fillet for example).

So I use this code:

std::vector<TopoDS_Shape*> shapesVector;
TopoDS_Iterator anIterator;
while (anIterator.More())
    TopoDS_Shape *shp = anIterator.Value();

the problem is that the iterator method value() does not returns the "real" topods_shape, but a temporary "copy" wich I can't point to.
I've also tried with top_explorer, and the current() also has this problem.

Is there a way to achieve this? or do you have a better way?



Roman Lygin's picture

Hi Amine,

You should use vector of TopoDS_Shape, not pointers thereto.

std::vector<TopoDS_Shape> shapesVector;

for (TopoDS_Iterator anIterator (aShape); anIterator.More(); {

   shapesVector.push_back (anIterator.Value());


You should store TopoDS_Shape's in container whenever possible. These are not deep copies, the real sharing takes place via sharing TShape and location fields.

Best regards,