Salome HOME
updated copyright message
[modules/shaper.git] / test.API / SHAPER / Transformations / TestTranslation_2.py
index f98031e4b4e66ba99949a7be0a83c5283bc17808..35bb5f36c44854f31ee1c6470f0058443ab172ef 100644 (file)
@@ -1,5 +1,24 @@
+# Copyright (C) 2014-2023  CEA, EDF
+#
+# 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 Translation feature. 
+Test case for Translation feature.
 Written on High API.
 """
 from salome.shaper import model
@@ -61,7 +80,7 @@ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint()
 model.do()
 
 # Edges
-Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")])
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2")])
 
 # Axis
 Axis_1 = model.addAxis(Part_1_doc, 10, 10, 10)
@@ -71,47 +90,47 @@ model.addParameter(Part_1_doc, "d", "15")
 
 # Translation 27
 Translation_27_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_2_1")], [model.selection("SOLID", "Translation_1_1")])
+Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_2_1")model.selection("SOLID", "Translation_1_1")])
 Translation_27 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_1_1")], model.selection("EDGE", "PartSet/OX"), 15)
 
 # Translation 28
 Translation_28_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_2 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_4_1")], [model.selection("SOLID", "Translation_3_1")])
+Intersection_2 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_4_1")model.selection("SOLID", "Translation_3_1")])
 Translation_28 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_2_1")], model.selection("EDGE", "PartSet/OX"), 0)
 
 # Translation 29
 Translation_29_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_3 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_6_1")], [model.selection("SOLID", "Translation_5_1")])
+Intersection_3 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_6_1")model.selection("SOLID", "Translation_5_1")])
 Translation_29 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_3_1")], model.selection("EDGE", "PartSet/OX"), -15)
 
 # Translation 30
 Translation_30_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_4 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_8_1")], [model.selection("SOLID", "Translation_7_1")])
+Intersection_4 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_8_1")model.selection("SOLID", "Translation_7_1")])
 Translation_30 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_4_1")], model.selection("EDGE", "InvalidName"), -15)
 
 # Translation 31
 Translation_31_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_5 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_10_1")], [model.selection("SOLID", "Translation_9_1")])
+Intersection_5 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_10_1")model.selection("SOLID", "Translation_9_1")])
 Translation_31 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_5_1")], model.selection("EDGE", "PartSet/OY"), "d")
 
 # Translation 32
 Translation_32_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_6 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_12_1")], [model.selection("SOLID", "Translation_11_1")])
-Translation_32 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 15)
+Intersection_6 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_12_1")model.selection("SOLID", "Translation_11_1")])
+Translation_32 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_6_1")], model.selection("EDGE", "Sketch_1/SketchLine_1"), 15)
 
 # Translation 33
 Translation_33_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_7 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_14_1")], [model.selection("SOLID", "Translation_13_1")])
+Intersection_7 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_14_1")model.selection("SOLID", "Translation_13_1")])
 Translation_33 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_7_1")], model.selection("EDGE", "Edge_1_1"), 15)
 
 # Translation 34
 Translation_34_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_15_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_8 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_16_1")], [model.selection("SOLID", "Translation_15_1")])
+Intersection_8 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_16_1")model.selection("SOLID", "Translation_15_1")])
 Translation_34 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_8_1")], model.selection("EDGE", "Intersection_8_1_6"), 15)
 
 # Translation 35
 Translation_35_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_17_1")], model.selection("EDGE", "PartSet/OX"), 5)
-Intersection_9 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_18_1")], [model.selection("SOLID", "Translation_17_1")])
+Intersection_9 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_18_1")model.selection("SOLID", "Translation_17_1")])
 Translation_35 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_9_1")], model.selection("EDGE", "Axis_1"), 15)
 
 #Translation 36
@@ -142,9 +161,9 @@ Translation_40 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID",
 # Translation 41
 Translation_41_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_29_1")], model.selection("EDGE", "PartSet/OX"), 5)
 Partition_6 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_30_1"), model.selection("SOLID", "Translation_29_1")])
-Translation_41 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 15)
+Translation_41 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_6_1")], model.selection("EDGE", "Sketch_1/SketchLine_1"), 15)
 
-# Translateion 42
+# Translation 42
 Translation_42_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_31_1")], model.selection("EDGE", "PartSet/OX"), 5)
 Partition_7 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_32_1"), model.selection("SOLID", "Translation_31_1")])
 Translation_42 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_7_1")], model.selection("EDGE", "Edge_1_1"), 15)
@@ -152,7 +171,7 @@ Translation_42 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID",
 # Translation 43
 Translation_43_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_33_1")], model.selection("EDGE", "PartSet/OX"), 5)
 Partition_8 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_34_1"), model.selection("SOLID", "Translation_33_1")])
-Translation_43 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_8_1")], model.selection("EDGE", "Partition_8_1/Modified_Face_1_1_1&Partition_8_1/Modified_Face_1_9_1"), 15)
+Translation_43 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_8_1")], model.selection("EDGE", "Partition_8_1_1/Modified_Face_2_5&Partition_8_1_1/Modified_Face_2_2"), 15)
 
 # Translation 44
 Translation_44_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_35_1")], model.selection("EDGE", "PartSet/OX"), 5)
@@ -161,99 +180,64 @@ Translation_44 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID",
 model.do()
 model.end()
 
-
 # Checks
 from GeomAPI import GeomAPI_Shape
-from GeomAPI import GeomAPI_ShapeExplorer
-
-def testHaveNamingEdges(theFeature, theModel, thePartDoc) :
-  """ Tests if all faces of result have a name
-  :param theFeature: feature to test.
-  """
-  # Get feature result/sub-result
-  aResult = theFeature.results()[0].resultSubShapePair()[0]
-  # Get result/sub-result shape
-  shape = aResult.shape()
-  # Create shape explorer with desired shape type
-  shapeExplorer = GeomAPI_ShapeExplorer(shape, GeomAPI_Shape.EDGE)
-  # Create list, and store selections in it
-  selectionList = []
-  while shapeExplorer.more():
-    selection = theModel.selection(aResult, shapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result
-    selectionList.append(selection)
-    shapeExplorer.next()
-  # Create group with this selection list
-  Group_1 = theModel.addGroup(thePartDoc, selectionList)
-  theModel.do()
-  theModel.end()
-
-  # Now you can check that all selected shapes in group have right shape type and name.
-  groupFeature = Group_1.feature()
-  groupSelectionList = groupFeature.selectionList("group_list")
-  theModel.end()
-  assert(groupSelectionList.size() == len(selectionList))
-  for index in range(0, groupSelectionList.size()):
-    attrSelection = groupSelectionList.value(index)
-    shape = attrSelection.value()
-    name = attrSelection.namingName()
-    assert(shape.isEdge())
-    assert(name != ""), "String empty"
 
 # Translation 27
 model.testNbResults(Translation_27, 1)
 model.testNbSubResults(Translation_27, [12])
 model.testNbSubShapes(Translation_27, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_27, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_27, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_27, model, Part_1_doc)
 
 # Translation 28
 model.testNbResults(Translation_28, 1)
 model.testNbSubResults(Translation_28, [12])
 model.testNbSubShapes(Translation_28, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_28, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_28, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_28, model, Part_1_doc)
 
 # Translation 29
 model.testNbResults(Translation_29, 1)
 model.testNbSubResults(Translation_29, [12])
 model.testNbSubShapes(Translation_29, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_29, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_29, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_29, model, Part_1_doc)
 
 # Translation 31
 model.testNbResults(Translation_31, 1)
 model.testNbSubResults(Translation_31, [12])
 model.testNbSubShapes(Translation_31, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_31, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_31, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_31, model, Part_1_doc)
 
 # Translation 32
 model.testNbResults(Translation_32, 1)
 model.testNbSubResults(Translation_32, [12])
 model.testNbSubShapes(Translation_32, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_32, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_32, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_32, model, Part_1_doc)
 
 # Translation 33
 model.testNbResults(Translation_33, 1)
 model.testNbSubResults(Translation_33, [12])
 model.testNbSubShapes(Translation_33, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_33, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_33, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_33, model, Part_1_doc)
 
 # Translation 34
 model.testNbResults(Translation_34, 1)
 model.testNbSubResults(Translation_34, [12])
 model.testNbSubShapes(Translation_34, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_34, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_34, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_34, model, Part_1_doc)
 
 # Translation 35
 model.testNbResults(Translation_35, 1)
 model.testNbSubResults(Translation_35, [12])
 model.testNbSubShapes(Translation_35, GeomAPI_Shape.SOLID, [0])
 model.testNbSubShapes(Translation_35, GeomAPI_Shape.EDGE, [12])
-testHaveNamingEdges(Translation_35, model, Part_1_doc)
+model.testHaveNamingEdges(Translation_35, model, Part_1_doc)
 
 # Translation 36
 model.testNbResults(Translation_36, 1)
@@ -304,12 +288,13 @@ model.testNbSubShapes(Translation_42, GeomAPI_Shape.FACE, [18])
 model.testHaveNamingFaces(Translation_42, model, Part_1_doc)
 
 # Translation 43
-model.testNbResults(Translation_43, 1)
-model.testNbSubResults(Translation_43, [3])
-model.testNbSubShapes(Translation_43, GeomAPI_Shape.COMPSOLID, [1])
-model.testNbSubShapes(Translation_43, GeomAPI_Shape.SOLID, [3])
-model.testNbSubShapes(Translation_43, GeomAPI_Shape.FACE, [18])
-model.testHaveNamingFaces(Translation_43, model, Part_1_doc)
+# It is concealed by Partition_9
+#model.testNbResults(Translation_43, 1)
+#model.testNbSubResults(Translation_43, [3])
+#model.testNbSubShapes(Translation_43, GeomAPI_Shape.COMPSOLID, [1])
+#model.testNbSubShapes(Translation_43, GeomAPI_Shape.SOLID, [3])
+#model.testNbSubShapes(Translation_43, GeomAPI_Shape.FACE, [18])
+#model.testHaveNamingFaces(Translation_43, model, Part_1_doc)
 
 # Translation 44
 model.testNbResults(Translation_44, 1)