]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Bos #23885 [CEA] OCCT 7.5 related regressions in SHAPER
authormpv <mpv@opencascade.com>
Tue, 16 Feb 2021 08:52:00 +0000 (11:52 +0300)
committermpv <mpv@opencascade.com>
Tue, 16 Feb 2021 08:52:23 +0000 (11:52 +0300)
Fix for the first described regression: ExtrusionCut computes intersection of 2 solids in compound in the new and produces 3 solids instead of 2 (as it was before).

src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/Test/Test23885.py [new file with mode: 0644]

index e45e5136b8cbff76cb52f6e15bd2eb87dccbfb12..6d01dc466565c0b86da64b747e38c969916bc8d4 100644 (file)
@@ -708,4 +708,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestPointCoordinates.py
                TestGeometryCalculation.py
                TestBoundingBox.py
+               Test23885.py
 )
index db491704810ad039a277bd1caa1253870fad21d4..70ba0ddbd083eefa041b8acb1e820d23f9243a6d 100644 (file)
@@ -27,6 +27,7 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_MakeShapeCustom.h>
 
 #include <GeomAPI_ShapeIterator.h>
 
@@ -125,6 +126,7 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools,
   // Getting objects.
   ListOfShape anObjects, anEdgesAndFaces, aCompSolids;
   std::map<GeomShapePtr, ListOfShape> aCompSolidsObjects;
+  bool aCompoundsOnly = true; // if there are only compounds and no compsolids, do not use filler to restore compsolids
   AttributeSelectionListPtr anObjectsSelList = myFeature->selectionList(OBJECTS_ID());
   for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
     AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
@@ -147,6 +149,8 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools,
       if(anIt == aCompSolidsObjects.end()) {
         aCompSolidsObjects[aContextShape].push_back(anObject);
         aCompSolids.push_back(aContextShape);
+        if (aContextShape->shapeType() != GeomAPI_Shape::COMPOUND)
+          aCompoundsOnly = false;
       }
     } else {
       if(anObject->shapeType() == GeomAPI_Shape::EDGE ||
@@ -228,14 +232,26 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools,
         GeomShapePtr aBoolRes = aBoolAlgo->shape();
         if (!aShapesToAdd.empty()) {
           aShapesToAdd.push_back(aBoolRes);
-          std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
-            new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
-          if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) {
-            myFeature->setError("Error: PaveFiller algorithm failed.");
-            return false;
+          if (aCompoundsOnly) // 23885: if there are no compsolids in input, do not use filler to make compsolids
+          {
+            aBoolRes = GeomAlgoAPI_CompoundBuilder::compound(aShapesToAdd);
+            std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aComp(new GeomAlgoAPI_MakeShapeCustom);
+            aComp->setResult(aBoolRes);
+            for(ListOfShape::iterator aComps = aCompSolids.begin(); aComps != aCompSolids.end(); aComps++)
+              aComp->addModified(*aComps, aBoolRes);
+            aMakeShapeList->appendAlgo(aComp);
+          }
+          else
+          {
+            std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
+              new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+            if (!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) {
+              myFeature->setError("Error: PaveFiller algorithm failed.");
+              return false;
+            }
+            aBoolRes = aFillerAlgo->shape();
+            aMakeShapeList->appendAlgo(aFillerAlgo);
           }
-          aBoolRes = aFillerAlgo->shape();
-          aMakeShapeList->appendAlgo(aFillerAlgo);
         }
 
         if(GeomAlgoAPI_ShapeTools::area(aBoolRes) > 1.e-27) {
diff --git a/src/FeaturesPlugin/Test/Test23885.py b/src/FeaturesPlugin/Test/Test23885.py
new file mode 100644 (file)
index 0000000..d811b19
--- /dev/null
@@ -0,0 +1,73 @@
+# Copyright (C) 2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_1.addCircle(45, 45, 28)
+model.do()
+
+### Create Sketch
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchCircle
+SketchCircle_2 = Sketch_2.addCircle(79, 72, 29.30)
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0, "Faces|Wires")
+
+### Create Extrusion
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 10, 0, "Faces|Wires")
+
+### Create Compound
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")])
+
+### Create ExtrusionCut
+ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), [model.selection("SOLID", "Compound_1_1_2")])
+
+### Create Sketch
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Compound_1_1_2/Modified_Face&Extrusion_2_1/To_Face"))
+
+### Create SketchCircle
+SketchCircle_3 = Sketch_3.addCircle(88, 78, 6)
+ExtrusionCut_1.setNestedSketch(Sketch_3)
+
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(ExtrusionCut_1, 1)
+model.testNbSubResults(ExtrusionCut_1, [2])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [2])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [7])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [18])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [36])
+model.testResultsVolumes(ExtrusionCut_1, [50469.37182])
+
+assert(model.checkPythonDump())