]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix problem of selection of Result of Boolean (compound) as argument of another Boole...
authormpv <mpv@opencascade.com>
Wed, 1 Jul 2015 09:55:22 +0000 (12:55 +0300)
committermpv <mpv@opencascade.com>
Wed, 1 Jul 2015 09:55:22 +0000 (12:55 +0300)
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/GeomValidators/GeomValidators_ShapeType.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp

index 41f1278608c1656de5fac1923b387e989653f260..bbd1de77b3eff2152a5313bdc6bfa2b95bf867c3 100644 (file)
@@ -7,6 +7,7 @@
 #include<GeomAPI_Shape.h>
 
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Iterator.hxx>
 #include <BRepBndLib.hxx>
 #include <Bnd_Box.hxx>
 #include <BRepTools.hxx>
@@ -61,6 +62,20 @@ bool GeomAPI_Shape::isCompound() const
   return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND;
 }
 
+bool GeomAPI_Shape::isCompoundOfSolids() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  if (aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND)
+    return false;
+  bool isAtLeastOne = false;
+  for(TopoDS_Iterator aSubs(aShape); aSubs.More(); aSubs.Next()) {
+    if (aSubs.Value().IsNull() || aSubs.Value().ShapeType() != TopAbs_SOLID)
+      return false;
+    isAtLeastOne = true;
+  }
+  return isAtLeastOne;
+}
+
 bool GeomAPI_Shape::isSolid() const
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
index 08281bb2919ccb1e936323fe76660c23fd48716b..2df3b015b7146086afaf19bdaa689253ab1ff328 100644 (file)
@@ -44,9 +44,12 @@ public:
   /// Returns whether the shape is a face
   virtual bool isFace() const;
 
-  /// Returns whether the shape is a face
+  /// Returns whether the shape is a compound
   virtual bool isCompound() const;
 
+  /// Returns whether the shape is a compound of solids
+  virtual bool isCompoundOfSolids() const;
+
   /// Returns whether the shape is a solid
   virtual bool isSolid() const;
 
index 3d68f6a8f95e598efbf63c3c11401d6abfd504dc..85d21a0ad39c70b387080188a530977d89e2ba41 100644 (file)
@@ -150,7 +150,7 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
         aValid = theShape->isVertex();
       break;
       case Solid:
-        aValid = theShape->isSolid();
+        aValid = theShape->isSolid() || theShape->isCompoundOfSolids();
         break;
       case Face:
         aValid = theShape->isFace();
index 2d2bbd7d380348090ff4000e749e8771882d7882..e8acbcbfc750022fbd07bed0cbf5a7850bb42f05 100755 (executable)
@@ -59,6 +59,8 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
     updateFocus();
 }
 
+#include <TopoDS_Iterator.hxx>
+
 //********************************************************************
 bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
                                                const ResultPtr& theResult) const
@@ -75,6 +77,25 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
     // Check that the selection corresponds to selection type
     TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
     aShapeType = aTopoShape.ShapeType();
+    // for compounds check sub-shapes: it may be compound of needed type:
+    // Booleans may produce compounds of Solids
+    if (aShapeType == TopAbs_COMPOUND) {
+      for(TopoDS_Iterator aSubs(aTopoShape); aSubs.More(); aSubs.Next()) {
+        if (!aSubs.Value().IsNull()) {
+          TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
+          if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
+            aShapeType = TopAbs_COMPOUND;
+            break;
+          }
+          if (aShapeType == TopAbs_COMPOUND) {
+            aShapeType = aSubType;
+          } else if (aShapeType != aSubType) { // compound of shapes of different types
+            aShapeType = TopAbs_COMPOUND;
+            break;
+          }
+        }
+      }
+    }
   }
 
   QIntList aShapeTypes = getShapeTypes();