]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/BuildPlugin/Test/TestWire.py
Salome HOME
Copyright update 2022
[modules/shaper.git] / src / BuildPlugin / Test / TestWire.py
index 351a29017c2d4edc72362fd9819b06a34b7adc6c..22ba3bc10a9594297aeea0447082887757d8b2b0 100644 (file)
@@ -1,22 +1,21 @@
-## Copyright (C) 2014-2017  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>
-##
+# Copyright (C) 2014-2022  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
+#
 
 # Initialization of the test
 from ModelAPI import *
@@ -111,7 +110,7 @@ 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()
-Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")])
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")])
 Wire_1.addContour()
 model.end()
 
@@ -134,15 +133,52 @@ aBoxShape = aBoxResult.shape()
 aSession.startOperation()
 aWireFeature2 = aPart.addFeature("Wire")
 aBaseObjectsList = aWireFeature2.selectionList("base_objects")
-aBaseObjectsList.append("Box_1_1/Front&Box_1_1/Bottom", "EDGE")
-aBaseObjectsList.append("Box_1_1/Front&Box_1_1/Right", "EDGE")
-aBaseObjectsList.append("Box_1_1/Right&Box_1_1/Top", "EDGE")
-aBaseObjectsList.append("Box_1_1/Back&Box_1_1/Top", "EDGE")
-aBaseObjectsList.append("Box_1_1/Back&Box_1_1/Left", "EDGE")
-aBaseObjectsList.append("Box_1_1/Left&Box_1_1/Bottom", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Front][Box_1_1/Bottom]", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Front][Box_1_1/Right]", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Right][Box_1_1/Top]", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Back][Box_1_1/Top]", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Back][Box_1_1/Left]", "EDGE")
+aBaseObjectsList.append("[Box_1_1/Left][Box_1_1/Bottom]", "EDGE")
 aSession.finishOperation()
 
 # Test results
 assert (len(aWireFeature2.results()) == 1)
 
-assert(model.checkPythonDump())
+# =============================================================================
+# Test 4. Check Wire feature on the whole sketch
+# =============================================================================
+
+aSession.startOperation()
+aWireFeature3 = aPart.addFeature("Wire")
+aBaseObjectsList = aWireFeature3.selectionList("base_objects")
+aBaseObjectsList.append(aSketchResult, None)
+aSession.finishOperation()
+assert (len(aWireFeature3.results()) == 1)
+
+# =============================================================================
+# Test 5. Check Wire feature failed on incorrect input
+# =============================================================================
+
+aSession.startOperation()
+aWireFeature3 = aPart.addFeature("Wire")
+aBaseObjectsList = aWireFeature3.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aBoxShape, GeomAPI_Shape.VERTEX)
+aShape = aShapeExplorer.current()
+aBaseObjectsList.append(aBoxResult, aShape)
+aSession.finishOperation()
+assert (len(aWireFeature3.results()) == 0)
+
+aSession.startOperation()
+aBaseObjectsList.clear()
+aShapeExplorer = GeomAPI_ShapeExplorer(aBoxShape, GeomAPI_Shape.FACE)
+aShape = aShapeExplorer.current()
+aBaseObjectsList.append(aBoxResult, aShape)
+aSession.finishOperation()
+assert (len(aWireFeature3.results()) == 0)
+
+# remove failed feature
+aSession.startOperation()
+aPart.removeFeature(aWireFeature3)
+aSession.finishOperation()
+
+assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING))