How many parent face for an edge ?

I need to now if a TopoDS_Edge belongs to 0, 1 or 2 TopoDS_Face.

Does anyone know how I can get this information ?

Thank you.

Rob Bachrach's picture

You can call:
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, myMap);

Then, just check the map for how many faces are in the map for the desired edge.

Jean-Yves Brud's picture

Then my final code is:

int howManyFacesForThisEdge(const TopoDS_Shape& rootShape, const TopoDS_Edge& edge1)
{
TopTools_IndexedDataMapOfShapeListOfShape myMap;
TopExp::MapShapesAndAncestors(rootShape, TopAbs_EDGE, TopAbs_FACE, myMap);

const TopTools_ListOfShape& listOfShapes = myMap.FindFromKey(edge1);
int nbAncestors = listOfShapes.Extent();
return nbAncestors;
}

and gives great results!

Maili's picture

What if there are some shapes in scene and we just select a random edge of one of them? i.e. if we don't know what rootShape is? Is there a way to find ancestors? (Actually my problem is how to find rootShape given a subshape)
Thanks

Paul Jimenez's picture

The root shape is the shape associated with the AIS_Shape. Just get it from its Shape() method.

Maili's picture

Actually there is an AIS_Shape for each possible rootShape in scene. My question may be changed as: If there are some AIS_Shape's displayed in scene, and when I select an edge, how can I know which AIS_Shape the selection belongs to. (Actually I would expect to find root topologically i.e without using AIS_Shape since maybe the shape is not displayed in scene at the moment)
Thanks for reply

Bearloga's picture

You may get your AIS_Shape object using the method Selectable of SelectMgr_EntityOwner returned by the method SelectedOwner of context.