From 31a523e602df83c87873c459b081bbc97a3ffad8 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 3 Dec 2018 16:02:03 +0300 Subject: [PATCH] [Code coverage FeaturesPlugin]: Improve coverage of Common, Smash, Measurement and MultiRotation features --- src/FeaturesPlugin/CMakeLists.txt | 5 ++ .../FeaturesPlugin_BooleanCommon.cpp | 2 +- .../FeaturesPlugin_MultiRotation.cpp | 15 ++++-- .../FeaturesPlugin_MultiRotation.h | 4 +- .../Test/TestBooleanCommon_Face_Plane.py | 51 ++++++++++++++++++ .../TestBooleanCommon_SubCompound_Solid.py | 52 +++++++++++++++++++ .../Test/TestBooleanCommon_SubSolid_Solid.py | 48 +++++++++++++++++ .../Test/TestBooleanSmash_SubSolid_Solid.py | 48 +++++++++++++++++ 8 files changed, 219 insertions(+), 6 deletions(-) create mode 100644 src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py create mode 100644 src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 80941701e..1ba2b4b3a 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -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 diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp index 539724c33..942279a4f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp @@ -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); diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp index 2a7bec49c..a3af21edb 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp @@ -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( diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h index 45af5b97c..ba5a7a196 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h @@ -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 > theListOfTranslationAlgo, @@ -116,6 +117,7 @@ private: void loadNamingDS3(std::list > theListOfRotationAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape, int nb); +#endif void loadNamingDS(std::list > theListOfRotationAlgo, std::shared_ptr theResultBody, diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py new file mode 100644 index 000000000..6b86e5dba --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py @@ -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 +## + +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 index 000000000..69d741673 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py @@ -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 +## + +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 index 000000000..42be4686c --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py @@ -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 +## + +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 index 000000000..9f2ee792f --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py @@ -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 +## + +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()) -- 2.39.2