Tue, 11/09/2021 - 16:55
Forums:
Hello, what is the best way to select a sub-shape (TopoDS_Shape) of an AIS_Shape?
I want to do the reserve of what AIS_InteractiveContext::DetectedShape() gave me, starting from a state where nothing is selected in AIS_InteractiveContext and add a sub-selection using the API.
Best regards,
François.
Mon, 11/15/2021 - 10:46
There is a method AIS_InteractiveContext::AddOrRemoveSelected() to select (and highlight) or unselect specific Owner within Interactive Context. You may check if specific Owner is already selected or not through it's property SelectMgr_EntityOwner::IsSelected().
But I guess your main question is where to find SelectMgr_EntityOwner for a subshape (TopoDS_Shape)? When activating local selection modes, AIS_Shape::ComputeSelection(), or StdSelect_BRepSelectionTool to be precise, iterates over sub-shapes, creates individual StdSelect_BRepOwner (storing sub-shape as property StdSelect_BRepOwner::Shape()) and adds them to selection SelectMgr_Selection of active selection mode.
This routine creates transient StdSelect_BRepOwner objects, so that there is no map or some other structure which would directly return you a StdSelect_BRepOwner from TopoDS_Shape, as it is normally used in opposite way (a Shape is retrieved from picked Owner). To find such association, you may iterator over computed selections and find a match on your own (and fill in some lookup map in case if this has to be done many times):
Each StdSelect_BRepOwner might be shared by more than one SelectMgr_SensitiveEntity (for instance, TopoDS_Wire will be decomposed into TopoDS_Edge).
Wed, 11/17/2021 - 01:19
Hello Kirill,
thank you for the information, I was able to implement re-selection of sub-shape using part of your answer.
The right way the sensitive could be explored back using the ::Selection() method is what I was looking for.
Thank you,
François.