Is there are array for TopoDS_Shape, or just use the <vector> of C++


CAD community veteran
I try to find all cylinder in BSplineSurface, However, the TopExp_Explorer can only find cyclinder not in BSplineSurface.
So I try to complete it in another way, I try to get all cylinders in my TopoDS_Shape, which comes from STEPControl_Reader.

However, I don't konw should store the cylinders in <vector> of C++, or there is some structure to store TopoDS_Face in OCCT.
If it exits, the two store ways have different in performance.

My question may have been too low T_T


Staff member
To store shapes in a collection, use whatever standard container (e.g., vector) or a native data structure of OpenCascade, like TopTools_ListOfShape.

But i guess what you're asking is more how to detect all cylinders in a shape. Use BRepAdaptor_Surface initialized from TopoDS_Face for this. Smth like

for ( TopExp_Explorer exp(shape, TopAbs_FACE); exp.More(); exp.Next() )
  const TopoDS_Face& face = TopoDS::Face( exp.Current() );

  BRepAdaptor_Surface bas(face);

  // Use bas to get type of the surface, smth like .GetType()

Not sure why you're mentioning splines. Is it that your cylinders are represented with spline geometry?


CAD community veteran
@Quaoar Sorry for not describing my needs clearly.
I get a part, and all the holes I need to machine is in the BSpline Surface of the model, like this:
when I try to get all the cylinders in the model, I get the holes I want and also the cylinders I didn't need, like this:

I was try to get all the cylinders in "GeomAbs_BSplineSurface ", however, the "TopExp_Explorer" seems doesn't support this, so I filter the cylinders through radius. I have to say this is not a good choice, it maybe fail in other type parts.

I know that the Analysis Situs has "recognize holes", it really work. I will learn it.
Maybe beacuse I'm new in OCCT, so I try to do somgthing easy to familiar with it.

Next step, I will try to get a AAG from step file, I'm interesting with it. Actually, I learn it in some paper last year, but I'm not quite sure how exactly to achieve it. So I'm so excited to read your bolg, paper and code. I have to say the work on Analysis Situs is amazing. Thanks for your help.


Staff member
I was try to get all the cylinders in "GeomAbs_BSplineSurface ", however, the "TopExp_Explorer" seems doesn't support this,
Explorer iterates all topological elements of a model, i.e., faces. If what you're trying to achieve is some filtering on the surface type, then keep using the explorer, it's the right tool. You then need to add something more to this logic to filter out the unwanted cylinders:
  1. Make sure that the total accumulated angle in 360 degrees.
  2. Make sure that the cylindrical faces are internal features, i.e., if you slightly shift a probe point along a normal, the radius of a cylinder should only decrease. That's a condition for a cylinder to be a bore.
Having this two rules implemented, you'll end up with a simplest possible bore recognition.