]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage FeaturesPlugin]: Improve coverage of Common, Smash, Measurement and...
authorazv <azv@opencascade.com>
Mon, 3 Dec 2018 13:02:03 +0000 (16:02 +0300)
committerazv <azv@opencascade.com>
Mon, 3 Dec 2018 13:02:03 +0000 (16:02 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h
src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py [new file with mode: 0644]

index 80941701ed6a76475a0f387c423846bae25c6f72..1ba2b4b3a549ffd47476eee08f9c1a6f791a1ea6 100644 (file)
@@ -258,6 +258,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestMeasurementDistance.py
                TestMeasurementRadius.py
                TestMeasurementAngle.py
+               TestMeasurementAngle3Points.py
                TestFusionFaces.py
                Test1379.py
                Test1922.py
@@ -315,6 +316,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanCut_Wire_Wire.py
                TestBooleanCut_WireCompound_WireCompound.py
                TestBooleanSmash_Face_Face.py
+               TestBooleanSmash_SubSolid_Solid.py
                TestBooleanFuse_SimpleMode.py
                TestBooleanFuse_RemoveEdges.py
                TestBooleanCommon_Vertex_Vertex.py
@@ -324,6 +326,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanCommon_Wire_Wire.py
                TestBooleanCommon_WireCompound_WireCompound.py
                TestBooleanCommon_Face_Face.py
+               TestBooleanCommon_Face_Plane.py
                TestBooleanCommon_FaceCompound_FaceCompound.py
                TestBooleanCommon_Shell_Shell.py
                TestBooleanCommon_ShellCompound_ShellCompound.py
@@ -333,6 +336,8 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanCommon_SolidCompound_Face.py
                TestBooleanCommon_SolidCompound_Shell.py
                TestBooleanCommon_SolidCompound_SolidCompound.py
+               TestBooleanCommon_SubCompound_Solid.py
+               TestBooleanCommon_SubSolid_Solid.py
                TestBooleanCommon_CompSolid_Face.py
                TestBooleanCommon_CompSolid_Shell.py
                TestBooleanCommon_CompSolid_CompSolid.py
index 539724c33280e2c9a89f562b9871af59a34c0337..942279a4f125a087bd776b63e710757738aaa860 100644 (file)
@@ -120,7 +120,7 @@ void FeaturesPlugin_BooleanCommon::execute()
     }
   }
 
-  if ((anObjects.empty() && aCompSolidsObjects.empty())
+  if ((anObjects.empty() && aCompSolidsObjects.empty() && aCompoundObjects.empty())
       || (!isSimpleMode && aTools.empty() && aPlanes.empty())) {
     std::string aFeatureError = "Error: Not enough objects for boolean operation.";
     setError(aFeatureError);
index 2a7bec49c74f7f1398f8d790dd2e54f44928f7a1..a3af21edbd8e232a738ff00d5fc463f704d7c6ea 100644 (file)
@@ -50,24 +50,29 @@ void FeaturesPlugin_MultiRotation::initAttributes()
   data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID(),
                        ModelAPI_AttributeInteger::typeId());
 
-  /*data()->addAttribute(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID(),
+#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
+  data()->addAttribute(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID(),
                        ModelAPI_AttributeString::typeId());
   data()->addAttribute(FeaturesPlugin_MultiRotation::STEP_RADIAL_ID(),
                        ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_RADIAL_ID(),
-                       ModelAPI_AttributeInteger::typeId());*/
+                       ModelAPI_AttributeInteger::typeId());
+#endif
 }
 
 //=================================================================================================
 void FeaturesPlugin_MultiRotation::execute()
 {
-  /*std::string useRadialDir = string(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID())->value();
+#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
+  std::string useRadialDir = string(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID())->value();
   if (useRadialDir.empty()) {
     performRotation1D();
   } else {
     performRotation2D();
-  }*/
+  }
+#else
   performRotation1D();
+#endif
 }
 
 //=================================================================================================
@@ -221,6 +226,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
 }
 
 //=================================================================================================
+#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
 void FeaturesPlugin_MultiRotation::performRotation2D()
 {
   // Getting objects.
@@ -447,6 +453,7 @@ void FeaturesPlugin_MultiRotation::loadNamingDS3(
     ++anIndex;
   }
 }
+#endif
 
 //=================================================================================================
 void FeaturesPlugin_MultiRotation::loadNamingDS(
index 45af5b97c9b84cf36168ab0d9110ec27ec5321a2..ba5a7a19637248a817dbf61fba12a3497279a366 100644 (file)
@@ -106,7 +106,8 @@ private:
   /// Perform the multi rotation in one direction.
   void performRotation1D();
 
-  /// Perform the multi totation in two directions.
+#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
+  /// Perform the multi rotation in two directions.
   void performRotation2D();
 
   void loadNamingDS2(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
@@ -116,6 +117,7 @@ private:
   void loadNamingDS3(std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     std::shared_ptr<GeomAPI_Shape> theBaseShape, int nb);
+#endif
 
   void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py
new file mode 100644 (file)
index 0000000..6b86e5d
--- /dev/null
@@ -0,0 +1,51 @@
+## Copyright (C) 2018-20xx  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(32.87583448774056, -21.97399556638079, -28.86536213173501, -21.97399556638079)
+SketchLine_2 = Sketch_1.addLine(-28.86536213173501, -21.97399556638079, -28.86536213173501, 32.11012709159006)
+SketchLine_3 = Sketch_1.addLine(-28.86536213173501, 32.11012709159006, 32.87583448774056, 32.11012709159006)
+SketchLine_4 = Sketch_1.addLine(32.87583448774056, 32.11012709159006, 32.87583448774056, -21.97399556638079)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 0, False)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_1")])
+model.do()
+model.end()
+
+from GeomAPI import  GeomAPI_Shape
+
+model.testNbResults(Common_1, 0)
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py
new file mode 100644 (file)
index 0000000..69d7416
--- /dev/null
@@ -0,0 +1,52 @@
+## Copyright (C) 2018-20xx  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(3.367708126821666, -16.14093028927689, 18.51144913400999)
+SketchCircle_2 = Sketch_1.addCircle(37.37680688568888, 37.3768068856889, 21.5270932014419)
+SketchCircle_3 = Sketch_1.addCircle(-3.554756249974806, 10.65828989222541, 8.503732568675463)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Compound_1_objects = [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")]
+Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1"), model.selection("SOLID", "Compound_1_1_3")], [model.selection("SOLID", "Box_1_1")])
+model.do()
+
+model.testHaveNamingSubshapes(Common_1, model, Part_1_doc)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Common_1, 1)
+model.testNbSubResults(Common_1, [3])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [14])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [48])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [96])
+model.testResultsVolumes(Common_1, [15007.623169576811051229014992714])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py
new file mode 100644 (file)
index 0000000..42be468
--- /dev/null
@@ -0,0 +1,48 @@
+## Copyright (C) 2018-20xx  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), 5, True)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")])
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], 3, 3, 3)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Partition_1_1_2")], [model.selection("SOLID", "Translation_1_1")])
+model.do()
+
+model.testHaveNamingSubshapes(Common_1, model, Part_1_doc)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Common_1, 1)
+model.testNbSubResults(Common_1, [2])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [2])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [13])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [56])
+model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [112])
+model.testResultsVolumes(Common_1, [745])
+
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py
new file mode 100644 (file)
index 0000000..9f2ee79
--- /dev/null
@@ -0,0 +1,48 @@
+## Copyright (C) 2018-20xx  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), 5, True)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")])
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], 3, 3, 3)
+Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Partition_1_1_2")], [model.selection("SOLID", "Translation_1_1")])
+model.do()
+
+model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Smash_1, 1)
+model.testNbSubResults(Smash_1, [3])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [3])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [28])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [130])
+model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [260])
+model.testResultsVolumes(Smash_1, [1657])
+
+assert(model.checkPythonDump())