Salome HOME
ModuleBase_WidgetChoice is extended to use in a combo box a list of values read from...
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
index 0dd37b3550efc2c532da7bdea5a515390075ffdf..907fd6a6098ffb50752defe12d7ff04ddbc2d987 100755 (executable)
@@ -105,11 +105,14 @@ void ModuleBase_ResultPrs::Compute(
 }
 
 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                            const Standard_Integer aMode)
+                                            const Standard_Integer theMode)
 {
-  if (aMode > TopAbs_SHAPE) {
+  if (appendVertexSelection(aSelection, theMode))
+    return;
+
+  if (theMode > TopAbs_SHAPE) {
     // In order to avoid using custom selection modes
-    if (aMode == ModuleBase_ResultPrs::Sel_Result) {
+    if (theMode == ModuleBase_ResultPrs::Sel_Result) {
       AIS_Shape::ComputeSelection(aSelection, TopAbs_COMPOUND);
     }
     return;
@@ -117,7 +120,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
 
   // TODO: OCCT issue should be created for the COMPOUND processing
   // before it is fixed, the next workaround in necessary
-  if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) {
+  if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) {
     const TopoDS_Shape& aShape = Shape();
     TopExp_Explorer aCompExp(aShape, TopAbs_COMPOUND);
     // do not activate in compound mode shapes which do not contain compounds
@@ -125,7 +128,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
       return;
   }
 
-  if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
+  if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
     // Limit selection area only by actual object (Shape)
     ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
     if (aCompSolid.get()) {
@@ -154,7 +157,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
     }
     //AIS_Shape::ComputeSelection(aSelection, 0);
   }
-  AIS_Shape::ComputeSelection(aSelection, aMode);
+  AIS_Shape::ComputeSelection(aSelection, theMode);
 
   if (myAdditionalSelectionPriority > 0) {
     for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
@@ -166,23 +169,31 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
   }
 }
 
-void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
-                                                const TopoDS_Shape& theShape)
+bool ModuleBase_ResultPrs::appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                                 const Standard_Integer theMode)
 {
-  static TopAbs_ShapeEnum TypOfSel
-          = AIS_Shape::SelectionType(AIS_Shape::SelectionMode(TopAbs_WIRE));
-  // POP protection against crash in low layers
-  Standard_Real aDeflection = Prs3d::GetDeflection(theShape, myDrawer);
-  try {
-    StdSelect_BRepSelectionTool::Load(theSelection,
-                                      this,
-                                      theShape,
-                                      TypOfSel,
-                                      aDeflection,
-                                      myDrawer->HLRAngle(),
-                                      myDrawer->IsAutoTriangulation());
-  } catch ( Standard_Failure ) {
+  if (Shape().ShapeType() == TopAbs_VERTEX) {
+    const TopoDS_Shape& aShape = Shape();
+
+    int aPriority = StdSelect_BRepSelectionTool::GetStandardPriority(aShape, TopAbs_VERTEX);
+    double aDeflection = Prs3d::GetDeflection(aShape, myDrawer);
+
+    /// The cause of this method is the last parameter of BRep owner setting into True.
+    /// That means that owner should behave like it comes from decomposition. (In this case, OCCT
+    /// visualizes it in Ring style) OCCT version is 7.0.0 with path for SHAPER module.
+    Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(aShape, aPriority, Standard_True);
+    StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection,
+                                                  aDeflection, myDrawer->HLRAngle(), 9, 500);
+
+    for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
+      Handle(SelectMgr_EntityOwner) anOwner =
+        Handle(SelectMgr_EntityOwner)
+        ::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
+      anOwner->Set(this);
+    }
+    return true;
   }
+  return false;
 }
 
 void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,