From: mpv Date: Wed, 1 Jul 2015 09:55:22 +0000 (+0300) Subject: Fix problem of selection of Result of Boolean (compound) as argument of another Boole... X-Git-Tag: V_1.3.0~137 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=27fbd6131dcfe0618582edc25222e0506e138a2d;p=modules%2Fshaper.git Fix problem of selection of Result of Boolean (compound) as argument of another Boolean. Also it fixes the MultiBoolean unit test. --- diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 41f127860..bbd1de77b 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -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(this)->impl(); + 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(this)->impl(); diff --git a/src/GeomAPI/GeomAPI_Shape.h b/src/GeomAPI/GeomAPI_Shape.h index 08281bb29..2df3b015b 100644 --- a/src/GeomAPI/GeomAPI_Shape.h +++ b/src/GeomAPI/GeomAPI_Shape.h @@ -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; diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp index 3d68f6a8f..85d21a0ad 100644 --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -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(); diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 2d2bbd7d3..e8acbcbfc 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -59,6 +59,8 @@ void ModuleBase_WidgetSelector::onSelectionChanged() updateFocus(); } +#include + //******************************************************************** 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(); 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();