Salome HOME
Update copyrights
[modules/shaper.git] / test.API / SHAPER / Primitives / TestBox.py
index 366c5cfc2a4503d0474f94e3be1fa174bec39ca9..9dded65b070fc49b38ea79c85952f26d93003086 100644 (file)
@@ -1,5 +1,24 @@
+# Copyright (C) 2014-2019  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
+#
+
 """
-Test case for Primitive Box feature. 
+Test case for Primitive Box feature.
 Written on High API.
 """
 from salome.shaper import model
@@ -17,7 +36,7 @@ Point_4 = model.addPoint(Part_1_doc, 50, 0, 50).result()
 Point_5 = model.addPoint(Part_1_doc, 50, 50, 0).result()
 Vertex_3 = model.selection("VERTEX", "pnt")
 
-#Sketch
+# Sketch
 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
 SketchLine_1 = Sketch_1.addLine(20, 10, 40, 10)
@@ -34,13 +53,18 @@ SketchLine_7 = Sketch_2.addLine(40, 20, 20, 20)
 SketchLine_8 = Sketch_2.addLine(20, 20, 20, 10)
 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
 SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_8.endPoint())
-Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e")])
-Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")])
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")])
+Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/SketchLine_6_EndVertex")])
 
-#Extrusion
+# Extrusion
 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0)
 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "PartSet/OX"), 100, 0)
 
+# Parameters
+model.addParameter(Part_1_doc, "dx", "10")
+model.addParameter(Part_1_doc, "dy", "25")
+model.addParameter(Part_1_doc, "dz", "15")
+
 # Tests
 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
 Box_2 = model.addBox(Part_1_doc, 0, 10, 10)
@@ -56,9 +80,12 @@ Box_11 = model.addBox(Part_1_doc, Point_1, Point_4)
 Box_12 = model.addBox(Part_1_doc, Point_1, Point_5)
 Box_13 = model.addBox(Part_1_doc, Vertex_3, Point_2)
 Box_14 = model.addBox(Part_1_doc, Point_2, Vertex_3)
-Box_15 = model.addBox(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e"), model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e"))
-Box_16 = model.addBox(Part_1_doc, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_1"))
+Box_15 = model.addBox(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), model.selection("VERTEX", "Sketch_2/SketchLine_6_EndVertex"))
+Box_16 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_2_1/To_Face]"))
 Box_17 = model.addBox(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1"))
+Box_18 = model.addBox(Part_1_doc, "dx", "dy", "dz")
+model.do()
+model.end()
 
 # Checks
 from GeomAPI import GeomAPI_Shape
@@ -93,6 +120,12 @@ model.testNbSubShapes(Box_17, GeomAPI_Shape.SOLID, [1])
 model.testNbSubShapes(Box_17, GeomAPI_Shape.FACE, [6])
 model.testHaveNamingFaces(Box_17, model, Part_1_doc)
 
+model.testNbResults(Box_18, 1)
+model.testNbSubResults(Box_18, [0])
+model.testNbSubShapes(Box_18, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Box_18, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(Box_18, model, Part_1_doc)
+
 model.testNbResults(Box_2, 0)
 assert(Box_2.feature().error() == "Box builder with dimensions :: Dx is null or negative.")