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
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
Fri, 12/19/2008 - 19:33
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.
Fri, 01/23/2009 - 14:09
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!
Fri, 01/23/2009 - 16:22
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
Fri, 01/23/2009 - 16:56
The root shape is the shape associated with the AIS_Shape. Just get it from its Shape() method.
Fri, 01/23/2009 - 17:13
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
Fri, 01/23/2009 - 17:49
You may get your AIS_Shape object using the method Selectable of SelectMgr_EntityOwner returned by the method SelectedOwner of context.