Thu, 11/04/2021 - 08:14
Forums:
I use AIS_InteractiveContext's Vertex Mode to get a TopoDS_Vertex By MouseClick。
But i don't no how to get it's parent shape.
1.What I do now is to traverse every known TopoDS_ Shape, and get child Vertex to compare with my click Vertex.
However, this method will birng serious efficiency problem when there are a lot of TopoDS_ Shape.
2. I try to call MapShapesAndAncestors Mthod to build a map. But i don't know the rootShape of the selected TopoDS_Vertex.(Actuallly the rootShape is what i'm looking for.)
Similar Question: https://dev.opencascade.org/content/how-many-parent-face-edge
Does anyone know how I can get this information ?
Thank you.
Fri, 11/05/2021 - 18:41
TopoDS_Shape stores only children shapes, not parents. If you would like to find parent(s) of a picked shape, you will need to explode the displayed shape using TopExp_Explorer or using TopExp::MapShapesAndAncestors() as suggested in linked question.
Of course, the same TopoDS_Vertex would normally belong to more than a one parent shape, as they are shared between connected TopoDS_Edge in the TopoDS_Wire.
Sat, 11/06/2021 - 05:11
Thank you for your reply!
If i use TopExp::MapShapesAndAncestors() Method,i should get [Rootshape] to establish mapping relationship.
But my goal is to get RootShape(TopoDS_Vertex's Parent Shape) QQ
It seems that the only way I can do should be [explode the displayed shape using TopExp_Explorer]?
Mon, 11/08/2021 - 10:53
TopExp::MapShapesAndAncestors() wouldn't return a "root shape" - that wouldn't make any sense, as the root would be always the shape passed to function itself. What it returns is the collection of direct ancestors of sub-shapes of specific type. For instance, the parent of TopoDS_Vertex would normally be a TopoDS_Edge, so that map can be used like that:
Internally TopExp::MapShapesAndAncestors() uses the same TopExp_Explorer / TopoDS_Iterator tools to fill in the mape, so that this map is useful for multiple lookups (performance optimization) or just for convenience.