]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage FeaturesPlugin]: Cover errors of LinearCopy, AngularCopy and Fillet...
authorazv <azv@opencascade.com>
Tue, 11 Dec 2018 11:40:27 +0000 (14:40 +0300)
committerazv <azv@opencascade.com>
Tue, 11 Dec 2018 11:45:45 +0000 (14:45 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/Test/TestFillet1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiRotation_ErrorMsg.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestMultiTranslation_ErrorMsg.py [new file with mode: 0644]

index 1f3b8934d7e4cc5ffa0d88a5ea114de7abde83a1..35459c7f348fc297960e938edc875152c03dc6b3 100644 (file)
@@ -193,7 +193,9 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestRotation.py
                TestRotation_ErrorMsg.py
                TestMultiRotation_Part.py
+               TestMultiRotation_ErrorMsg.py
                TestMultiTranslation_Part.py
+               TestMultiTranslation_ErrorMsg.py
                TestSymmetry_Part.py
                TestBoolean1.py
                TestBoolean2.py
@@ -410,6 +412,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanFuse_CompSolid_CompSolid.py
                TestBooleanFuse_CompSolidCompound_CompSolidCompound.py
                TestFillet.py
+               TestFillet1.py
                TestFillet_ErrorMsg.py
                Test1816.py
                Test2631.py
index 622ea8de835414dcee174464885e4e51a0fb83ea..4206e904ff8c8e3927f82c3457d95fe55cc52fbb 100644 (file)
@@ -85,6 +85,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
   AttributeSelectionListPtr anObjectsSelList =
     selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID());
   if (anObjectsSelList->size() == 0) {
+    setError("Error: empty selection list");
     return;
   }
   for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
index d0e5360c4cb84c4b62ce5dae05770b381afd0fb2..ba1c1e8dfef99da42399c8960a6a2f15449ea977 100644 (file)
@@ -88,6 +88,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
   AttributeSelectionListPtr anObjectsSelList =
     selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID());
   if (anObjectsSelList->size() == 0) {
+    setError("Error: empty selection list");
     return;
   }
   for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
@@ -125,11 +126,6 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
     GeomAPI_ShapeIterator anIt(aShape);
     anEdge = anIt.current()->edge();
   }
-  else
-  {
-    setError(aSelectionError);
-    return;
-  }
 
   if (!anEdge.get())
   {
@@ -222,6 +218,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
   AttributeSelectionListPtr anObjectsSelList =
     selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID());
   if (anObjectsSelList->size() == 0) {
+    setError("Error: empty selection list");
     return;
   }
   for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
@@ -259,11 +256,6 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
     GeomAPI_ShapeIterator anIt(aShape);
     anEdge = anIt.current()->edge();
   }
-  else
-  {
-    setError(aSelectionError);
-    return;
-  }
 
   if (!anEdge.get())
   {
@@ -296,11 +288,6 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
     GeomAPI_ShapeIterator anIt(aShape);
     anEdge = anIt.current()->edge();
   }
-  else
-  {
-    setError(aSelectionError);
-    return;
-  }
 
   if (!anEdge.get())
   {
diff --git a/src/FeaturesPlugin/Test/TestFillet1.py b/src/FeaturesPlugin/Test/TestFillet1.py
new file mode 100644 (file)
index 0000000..9c5bf93
--- /dev/null
@@ -0,0 +1,50 @@
+## 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
+from GeomAPI import GeomAPI_Shape
+
+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)
+
+Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "all-in-Box_1")], 2)
+assert(Fillet_1.feature().error() == "")
+
+model.testNbResults(Fillet_1, 1)
+model.testNbSubResults(Fillet_1, [0])
+model.testNbSubShapes(Fillet_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Fillet_1, GeomAPI_Shape.FACE, [26])
+model.testNbSubShapes(Fillet_1, GeomAPI_Shape.EDGE, [104])
+model.testNbSubShapes(Fillet_1, GeomAPI_Shape.VERTEX, [208])
+model.testResultsVolumes(Fillet_1, [907.704992710141368661425076425])
+
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
+SketchCircle_1 = Sketch_1.addCircle(20, -15, 5)
+SketchCircle_2 = Sketch_1.addCircle(30, 10, 3)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+
+Fillet_2 = model.addFillet(Part_1_doc, [model.selection("EDGE", "all-in-Extrusion_1")], 2)
+assert(Fillet_2.feature().error() != "")
+
+model.end()
diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_ErrorMsg.py b/src/FeaturesPlugin/Test/TestMultiRotation_ErrorMsg.py
new file mode 100644 (file)
index 0000000..4675f04
--- /dev/null
@@ -0,0 +1,72 @@
+## 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 ModelAPI import *
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create auxiliary box
+aSession.startOperation()
+aBox = aPart.addFeature("Box")
+aBox.string("CreationMethod").setValue("BoxByDimensions")
+aBox.real("dx").setValue(50)
+aBox.real("dy").setValue(50)
+aBox.real("dz").setValue(50)
+aSession.finishOperation()
+
+# Create auxiliary compound
+aSession.startOperation()
+aCompound = aPart.addFeature("Compound")
+aCompound.selectionList("base_objects").append("Box_1_1", "SOLID")
+aSession.finishOperation()
+
+
+aSession.startOperation()
+anAngularCopy1 = aPart.addFeature("AngularCopy")
+anAngularCopy1.execute()
+assert(anAngularCopy1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+anAngularCopy1.selectionList("main_objects").append("Compound_1_1", "COMPOUND")
+anAngularCopy1.execute()
+assert(anAngularCopy1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+anAngularCopy1.selection("axis_angular").selectSubShape("COMPOUND", "Compound_1_1")
+anAngularCopy1.execute()
+assert(anAngularCopy1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+anAngularCopy1.selection("axis_angular").selectSubShape("EDGE", "PartSet/OX")
+anAngularCopy1.integer("nb_angular").setValue(0)
+anAngularCopy1.execute()
+assert(anAngularCopy1.error() != "")
+aSession.finishOperation()
diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_ErrorMsg.py b/src/FeaturesPlugin/Test/TestMultiTranslation_ErrorMsg.py
new file mode 100644 (file)
index 0000000..f5bbd13
--- /dev/null
@@ -0,0 +1,114 @@
+## 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 ModelAPI import *
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create auxiliary box
+aSession.startOperation()
+aBox = aPart.addFeature("Box")
+aBox.string("CreationMethod").setValue("BoxByDimensions")
+aBox.real("dx").setValue(50)
+aBox.real("dy").setValue(50)
+aBox.real("dz").setValue(50)
+aSession.finishOperation()
+
+# Create auxiliary compound
+aSession.startOperation()
+aCompound = aPart.addFeature("Compound")
+aCompound.selectionList("base_objects").append("Box_1_1", "SOLID")
+aSession.finishOperation()
+
+
+aSession.startOperation()
+aLinearCopy1 = aPart.addFeature("LinearCopy")
+aLinearCopy1.execute()
+assert(aLinearCopy1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy1.selectionList("main_objects").append("Compound_1_1", "COMPOUND")
+aLinearCopy1.execute()
+assert(aLinearCopy1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy1.selection("axis_first_dir").selectSubShape("COMPOUND", "Compound_1_1")
+aLinearCopy1.execute()
+assert(aLinearCopy1.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy1.selection("axis_first_dir").selectSubShape("EDGE", "PartSet/OX")
+aLinearCopy1.integer("nb_first_dir").setValue(2)
+aLinearCopy1.execute()
+assert(aLinearCopy1.error() != "")
+aSession.finishOperation()
+
+
+aSession.startOperation()
+aLinearCopy2 = aPart.addFeature("LinearCopy")
+aLinearCopy2.string("use_second_dir").setValue("true")
+aLinearCopy2.execute()
+assert(aLinearCopy2.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy2.selectionList("main_objects").append("Compound_1_1", "COMPOUND")
+aLinearCopy2.execute()
+assert(aLinearCopy2.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy2.selection("axis_first_dir").selectSubShape("COMPOUND", "Compound_1_1")
+aLinearCopy2.execute()
+assert(aLinearCopy2.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy2.selection("axis_first_dir").selectSubShape("EDGE", "PartSet/OX")
+aLinearCopy2.selection("axis_second_dir").selectSubShape("COMPOUND", "Compound_1_1")
+aLinearCopy2.execute()
+assert(aLinearCopy2.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy2.selection("axis_second_dir").selectSubShape("EDGE", "PartSet/OY")
+aLinearCopy2.integer("nb_first_dir").setValue(0)
+aLinearCopy2.integer("nb_second_dir").setValue(0)
+aLinearCopy2.execute()
+assert(aLinearCopy2.error() != "")
+aSession.finishOperation()
+
+aSession.startOperation()
+aLinearCopy2.integer("nb_first_dir").setValue(2)
+aLinearCopy2.integer("nb_second_dir").setValue(2)
+aLinearCopy2.execute()
+assert(aLinearCopy2.error() != "")
+aSession.finishOperation()