]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_FilterInfinite.cpp
Salome HOME
Issue #555 - Make a number of shifted/rotated copies - selected object does not appea...
[modules/shaper.git] / src / PartSet / PartSet_FilterInfinite.cpp
index 28f6795504dae192cf0e85178db55c7a3f93851a..015701265747e0b6bd397b2a482c2bda04737861 100755 (executable)
@@ -7,16 +7,39 @@
 #include "PartSet_FilterInfinite.h"
 
 #include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <StdSelect_BRepOwner.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(PartSet_FilterInfinite, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(PartSet_FilterInfinite, SelectMgr_Filter);
 
 Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
+  Standard_Boolean aValid = Standard_True;
   Handle(AIS_InteractiveObject) anAISObj =
     Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-  if (!anAISObj.IsNull() && anAISObj->IsInfinite()) {
-    return Standard_False;
+  if (!anAISObj.IsNull()) {
+    Handle(AIS_InteractiveObject) anObj = 
+        Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anObj);
+    if (!aAISShape.IsNull()) {
+      TopoDS_Shape anAISShape = aAISShape->Shape();
+      if (!anAISShape.IsNull() && anAISShape.Infinite()) {
+        aValid = Standard_False;
+        // for infinite object, the selection is possible only for shapes of owners, which are coincide
+        // to the shape of corresponded AIS object. In other words, for axis, only edge can be selected
+        // (vertices are not selectable), for planes, only faces can be selected (not edges or vertices)
+        TopoDS_Shape anOwnerShape;
+        Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+        if( !aBRO.IsNull() ) {
+          anOwnerShape = aBRO->Shape();
+          if (!anOwnerShape.IsNull()) {
+            aValid = anAISShape.ShapeType() == anOwnerShape.ShapeType();
+          }
+        }
+      }
+    }
   }
-  return Standard_True;
+  return aValid;
 }