Salome HOME
Tests fix
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPlacement.py
index 47790a2cbf18b1f7041915657e6792855b325a9a..f61759df4474f2e3ccc1e1cff7cd828f10415b19 100644 (file)
@@ -1,3 +1,23 @@
+## 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>
+##
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -75,22 +95,14 @@ aSession.finishOperation()
 #=========================================================================
 # Make extrusion
 #=========================================================================
-aSketchResult = aSketchFeature.firstResult()
-aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
-origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")).pnt()
-dirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX")).dir()
-norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")).dir()
-aSketchFaces = ShapeList()
-GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces)
-assert (len(aSketchFaces) > 0)
-assert (aSketchFaces[0] is not None)
-assert (aSketchFaces[1] is not None)
+aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
+assert (aSketchResult.facesNum() > 1)
 
 aSession.startOperation()
 anExtrusionFt = aPart.addFeature("Extrusion")
 assert (anExtrusionFt.getKind() == "Extrusion")
-anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0])
-anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[1])
+anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0))
+anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1))
 anExtrusionFt.string("CreationMethod").setValue("BySizes")
 anExtrusionFt.real("to_size").setValue(50)
 anExtrusionFt.real("from_size").setValue(0)
@@ -111,8 +123,8 @@ assert (anExtrusionResult is not None)
 aSession.startOperation()
 aPlacementFt = aPart.addFeature("Placement")
 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
-aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/LateralFace_1")
-aPlacementFt.selection("placement_end_shape").selectSubShape("face", "Extrusion_1_2/LateralFace_3")
+aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face_1")
+aPlacementFt.selection("placement_end_shape").selectSubShape("face", "Extrusion_1_2/Generated_Face_3")
 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
 aPlacementFt.boolean("placement_centering").setValue(True)
 aPlacementFt.execute()
@@ -130,8 +142,8 @@ aSession.undo()
 aSession.startOperation()
 aPlacementFt = aPart.addFeature("Placement")
 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
-aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/LateralFace_1")
-aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3")
+aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face_1")
+aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3")
 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
 aPlacementFt.boolean("placement_centering").setValue(True)
 aPlacementFt.execute()
@@ -149,8 +161,8 @@ aSession.undo()
 aSession.startOperation()
 aPlacementFt = aPart.addFeature("Placement")
 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
-aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/LateralFace_1")
-aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2")
+aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face_1")
+aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3&Extrusion_1_2/Generated_Face_2")
 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
 aPlacementFt.boolean("placement_centering").setValue(True)
 aPlacementFt.execute()
@@ -168,8 +180,8 @@ aSession.undo()
 aSession.startOperation()
 aPlacementFt = aPart.addFeature("Placement")
 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
-aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/ToFace_1_1&Extrusion_1_1/LateralFace_1")
-aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3")
+aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/To_Face_1_1&Extrusion_1_1/Generated_Face_1")
+aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3")
 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
 aPlacementFt.boolean("placement_centering").setValue(True)
 aPlacementFt.execute()
@@ -187,8 +199,8 @@ aSession.undo()
 aSession.startOperation()
 aPlacementFt = aPart.addFeature("Placement")
 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
-aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/ToFace_1_1&Extrusion_1_1/LateralFace_1")
-aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2")
+aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/To_Face_1_1&Extrusion_1_1/Generated_Face_1")
+aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3&Extrusion_1_2/Generated_Face_2")
 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
 aPlacementFt.boolean("placement_centering").setValue(True)
 aPlacementFt.execute()
@@ -206,8 +218,8 @@ aSession.undo()
 aSession.startOperation()
 aPlacementFt = aPart.addFeature("Placement")
 aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape())
-aPlacementFt.selection("placement_start_shape").selectSubShape("vertex", "Extrusion_1_1/LateralFace_4&Extrusion_1_1/FromFace_1_1&Extrusion_1_1/LateralFace_1")
-aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/ToFace_1_1&Extrusion_1_2/LateralFace_3&Extrusion_1_2/LateralFace_2")
+aPlacementFt.selection("placement_start_shape").selectSubShape("vertex", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1_1&Extrusion_1_1/Generated_Face_1")
+aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3&Extrusion_1_2/Generated_Face_2")
 aPlacementFt.boolean("placement_reverse_direction").setValue(False)
 aPlacementFt.boolean("placement_centering").setValue(True)
 aPlacementFt.execute()
@@ -217,3 +229,6 @@ aSession.finishOperation()
 assert (len(aPlacementFt.results()) > 0)
 aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
 assert (aPlacementResult is not None)
+
+from salome.shaper import model
+assert(model.checkPythonDump())