Salome HOME
Converted placement tests
authordbv <dbv@opencascade.com>
Mon, 29 Oct 2018 11:14:04 +0000 (14:14 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/TestPlacement.py [deleted file]
src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestPlacement_Face_Face.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py [new file with mode: 0644]

index ff684fb3234acd911806841d590d4c1ed0680553..b0ab7042fb93bb876db1ccc4945f4c69c2ee3c5a 100644 (file)
@@ -175,7 +175,12 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestRevolutionFuse.py
                TestCompositeFeaturesOnCompSolids.py
                TestPartition.py
-               TestPlacement.py
+               TestPlacement_Vertex_Vertex.py
+               TestPlacement_Edge_Vertex.py
+               TestPlacement_Edge_Edge.py
+               TestPlacement_Face_Vertex.py
+               TestPlacement_Face_Edge.py
+               TestPlacement_Face_Face.py
                TestTranslation.py
                TestRotation.py
                TestBoolean.py
diff --git a/src/FeaturesPlugin/Test/TestPlacement.py b/src/FeaturesPlugin/Test/TestPlacement.py
deleted file mode 100644 (file)
index f61759d..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-## 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
-#=========================================================================
-from ModelAPI import *
-from GeomDataAPI import *
-from GeomAlgoAPI import *
-from GeomAPI import *
-import math
-
-__updated__ = "2014-12-16"
-
-aSession = ModelAPI_Session.get()
-aDocument = aSession.moduleDocument()
-
-aSession.startOperation()
-aPartFeature = aDocument.addFeature("Part")
-aSession.finishOperation()
-assert (len(aPartFeature.results()) == 1)
-aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
-aPart = aPartResult.partDoc()
-
-#=========================================================================
-# Create a sketch to extrude
-#=========================================================================
-aSession.startOperation()
-aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
-origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
-origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
-dirx.setValue(1, 0, 0)
-norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
-norm.setValue(0, 0, 1)
-aLineA1 = aSketchFeature.addFeature("SketchLine")
-aLineB1 = aSketchFeature.addFeature("SketchLine")
-aLineC1 = aSketchFeature.addFeature("SketchLine")
-aLineD1 = aSketchFeature.addFeature("SketchLine")
-aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
-aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
-aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
-aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
-aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
-aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
-aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
-aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
-aLineA1StartPoint.setValue(-100, 0)
-aLineA1EndPoint.setValue(-50, 0)
-aLineB1StartPoint.setValue(-50, 0)
-aLineB1EndPoint.setValue(-50, 50)
-aLineC1StartPoint.setValue(-50, 50)
-aLineC1EndPoint.setValue(-100, 50)
-aLineD1StartPoint.setValue(-100, 50)
-aLineD1EndPoint.setValue(-100, 0)
-aLineA2 = aSketchFeature.addFeature("SketchLine")
-aLineB2 = aSketchFeature.addFeature("SketchLine")
-aLineC2 = aSketchFeature.addFeature("SketchLine")
-aLineD2 = aSketchFeature.addFeature("SketchLine")
-aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
-aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
-aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
-aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
-aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
-aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
-aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
-aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
-aLineA2StartPoint.setValue(100, 0)
-aLineA2EndPoint.setValue(50, 0)
-aLineB2StartPoint.setValue(50, 0)
-aLineB2EndPoint.setValue(50, 50)
-aLineC2StartPoint.setValue(50, 50)
-aLineC2EndPoint.setValue(100, 50)
-aLineD2StartPoint.setValue(100, 50)
-aLineD2EndPoint.setValue(100, 0)
-aSession.finishOperation()
-
-#=========================================================================
-# Make extrusion
-#=========================================================================
-aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
-assert (aSketchResult.facesNum() > 1)
-
-aSession.startOperation()
-anExtrusionFt = aPart.addFeature("Extrusion")
-assert (anExtrusionFt.getKind() == "Extrusion")
-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)
-anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
-anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
-anExtrusionFt.execute()
-aSession.finishOperation()
-assert (anExtrusionFt.real("to_size").value() == 50.0)
-
-# Check extrusion results
-assert (len(anExtrusionFt.results()) > 0)
-anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
-assert (anExtrusionResult is not None)
-
-#=========================================================================
-# Test placement by face - face
-#=========================================================================
-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/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()
-aSession.finishOperation()
-
-# Check placement results
-assert (len(aPlacementFt.results()) > 0)
-aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
-assert (aPlacementResult is not None)
-aSession.undo()
-
-#=========================================================================
-# Test placement by face - edge
-#=========================================================================
-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/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()
-aSession.finishOperation()
-
-# Check placement results
-assert (len(aPlacementFt.results()) > 0)
-aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
-assert (aPlacementResult is not None)
-aSession.undo()
-
-#=========================================================================
-# Test placement by face - vertex
-#=========================================================================
-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/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()
-aSession.finishOperation()
-
-# Check placement results
-assert (len(aPlacementFt.results()) > 0)
-aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
-assert (aPlacementResult is not None)
-aSession.undo()
-
-#=========================================================================
-# Test placement by edge - edge
-#=========================================================================
-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/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()
-aSession.finishOperation()
-
-# Check placement results
-assert (len(aPlacementFt.results()) > 0)
-aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
-assert (aPlacementResult is not None)
-aSession.undo()
-
-#=========================================================================
-# Test placement by edge - vertex
-#=========================================================================
-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/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()
-aSession.finishOperation()
-
-# Check placement results
-assert (len(aPlacementFt.results()) > 0)
-aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
-assert (aPlacementResult is not None)
-aSession.undo()
-
-#=========================================================================
-# Test placement by vertex - vertex
-#=========================================================================
-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/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()
-aSession.finishOperation()
-
-# Check placement results
-assert (len(aPlacementFt.results()) > 0)
-aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
-assert (aPlacementResult is not None)
-
-from salome.shaper import model
-assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py
new file mode 100644 (file)
index 0000000..ac1cb73
--- /dev/null
@@ -0,0 +1,140 @@
+## 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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch to extrude
+#=========================================================================
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineA1 = aSketchFeature.addFeature("SketchLine")
+aLineB1 = aSketchFeature.addFeature("SketchLine")
+aLineC1 = aSketchFeature.addFeature("SketchLine")
+aLineD1 = aSketchFeature.addFeature("SketchLine")
+aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
+aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
+aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
+aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
+aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
+aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
+aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
+aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
+aLineA1StartPoint.setValue(-100, 0)
+aLineA1EndPoint.setValue(-50, 0)
+aLineB1StartPoint.setValue(-50, 0)
+aLineB1EndPoint.setValue(-50, 50)
+aLineC1StartPoint.setValue(-50, 50)
+aLineC1EndPoint.setValue(-100, 50)
+aLineD1StartPoint.setValue(-100, 50)
+aLineD1EndPoint.setValue(-100, 0)
+aLineA2 = aSketchFeature.addFeature("SketchLine")
+aLineB2 = aSketchFeature.addFeature("SketchLine")
+aLineC2 = aSketchFeature.addFeature("SketchLine")
+aLineD2 = aSketchFeature.addFeature("SketchLine")
+aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
+aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
+aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
+aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
+aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
+aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
+aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
+aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
+aLineA2StartPoint.setValue(100, 0)
+aLineA2EndPoint.setValue(50, 0)
+aLineB2StartPoint.setValue(50, 0)
+aLineB2EndPoint.setValue(50, 50)
+aLineC2StartPoint.setValue(50, 50)
+aLineC2EndPoint.setValue(100, 50)
+aLineD2StartPoint.setValue(100, 50)
+aLineD2EndPoint.setValue(100, 0)
+aSession.finishOperation()
+
+#=========================================================================
+# Make extrusion
+#=========================================================================
+aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
+assert (aSketchResult.facesNum() > 1)
+
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+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)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Test placement by edge - edge
+#=========================================================================
+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/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]")
+aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/To_Face]")
+aPlacementFt.boolean("placement_reverse_direction").setValue(False)
+aPlacementFt.boolean("placement_centering").setValue(True)
+aPlacementFt.execute()
+aSession.finishOperation()
+
+# Check placement results
+assert (len(aPlacementFt.results()) > 0)
+aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
+assert (aPlacementResult is not None)
+aSession.finishOperation()
+
+from salome.shaper import model
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py
new file mode 100644 (file)
index 0000000..40502f8
--- /dev/null
@@ -0,0 +1,140 @@
+## 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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch to extrude
+#=========================================================================
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineA1 = aSketchFeature.addFeature("SketchLine")
+aLineB1 = aSketchFeature.addFeature("SketchLine")
+aLineC1 = aSketchFeature.addFeature("SketchLine")
+aLineD1 = aSketchFeature.addFeature("SketchLine")
+aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
+aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
+aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
+aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
+aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
+aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
+aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
+aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
+aLineA1StartPoint.setValue(-100, 0)
+aLineA1EndPoint.setValue(-50, 0)
+aLineB1StartPoint.setValue(-50, 0)
+aLineB1EndPoint.setValue(-50, 50)
+aLineC1StartPoint.setValue(-50, 50)
+aLineC1EndPoint.setValue(-100, 50)
+aLineD1StartPoint.setValue(-100, 50)
+aLineD1EndPoint.setValue(-100, 0)
+aLineA2 = aSketchFeature.addFeature("SketchLine")
+aLineB2 = aSketchFeature.addFeature("SketchLine")
+aLineC2 = aSketchFeature.addFeature("SketchLine")
+aLineD2 = aSketchFeature.addFeature("SketchLine")
+aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
+aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
+aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
+aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
+aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
+aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
+aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
+aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
+aLineA2StartPoint.setValue(100, 0)
+aLineA2EndPoint.setValue(50, 0)
+aLineB2StartPoint.setValue(50, 0)
+aLineB2EndPoint.setValue(50, 50)
+aLineC2StartPoint.setValue(50, 50)
+aLineC2EndPoint.setValue(100, 50)
+aLineD2StartPoint.setValue(100, 50)
+aLineD2EndPoint.setValue(100, 0)
+aSession.finishOperation()
+
+#=========================================================================
+# Make extrusion
+#=========================================================================
+aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
+assert (aSketchResult.facesNum() > 1)
+
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+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)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Test placement by edge - vertex
+#=========================================================================
+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/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]")
+aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_2/To_Face]")
+aPlacementFt.boolean("placement_reverse_direction").setValue(False)
+aPlacementFt.boolean("placement_centering").setValue(True)
+aPlacementFt.execute()
+aSession.finishOperation()
+
+# Check placement results
+assert (len(aPlacementFt.results()) > 0)
+aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
+assert (aPlacementResult is not None)
+aSession.finishOperation()
+
+from salome.shaper import model
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py
new file mode 100644 (file)
index 0000000..b723c3c
--- /dev/null
@@ -0,0 +1,140 @@
+## 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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch to extrude
+#=========================================================================
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineA1 = aSketchFeature.addFeature("SketchLine")
+aLineB1 = aSketchFeature.addFeature("SketchLine")
+aLineC1 = aSketchFeature.addFeature("SketchLine")
+aLineD1 = aSketchFeature.addFeature("SketchLine")
+aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
+aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
+aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
+aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
+aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
+aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
+aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
+aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
+aLineA1StartPoint.setValue(-100, 0)
+aLineA1EndPoint.setValue(-50, 0)
+aLineB1StartPoint.setValue(-50, 0)
+aLineB1EndPoint.setValue(-50, 50)
+aLineC1StartPoint.setValue(-50, 50)
+aLineC1EndPoint.setValue(-100, 50)
+aLineD1StartPoint.setValue(-100, 50)
+aLineD1EndPoint.setValue(-100, 0)
+aLineA2 = aSketchFeature.addFeature("SketchLine")
+aLineB2 = aSketchFeature.addFeature("SketchLine")
+aLineC2 = aSketchFeature.addFeature("SketchLine")
+aLineD2 = aSketchFeature.addFeature("SketchLine")
+aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
+aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
+aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
+aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
+aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
+aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
+aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
+aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
+aLineA2StartPoint.setValue(100, 0)
+aLineA2EndPoint.setValue(50, 0)
+aLineB2StartPoint.setValue(50, 0)
+aLineB2EndPoint.setValue(50, 50)
+aLineC2StartPoint.setValue(50, 50)
+aLineC2EndPoint.setValue(100, 50)
+aLineD2StartPoint.setValue(100, 50)
+aLineD2EndPoint.setValue(100, 0)
+aSession.finishOperation()
+
+#=========================================================================
+# Make extrusion
+#=========================================================================
+aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
+assert (aSketchResult.facesNum() > 1)
+
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+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)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Test placement by face - edge
+#=========================================================================
+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/Generated_Face&Sketch_1/SketchLine_4")
+aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/To_Face]")
+aPlacementFt.boolean("placement_reverse_direction").setValue(False)
+aPlacementFt.boolean("placement_centering").setValue(True)
+aPlacementFt.execute()
+aSession.finishOperation()
+
+# Check placement results
+assert (len(aPlacementFt.results()) > 0)
+aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
+assert (aPlacementResult is not None)
+aSession.finishOperation()
+
+from salome.shaper import model
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py
new file mode 100644 (file)
index 0000000..ffb334e
--- /dev/null
@@ -0,0 +1,140 @@
+## 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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch to extrude
+#=========================================================================
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineA1 = aSketchFeature.addFeature("SketchLine")
+aLineB1 = aSketchFeature.addFeature("SketchLine")
+aLineC1 = aSketchFeature.addFeature("SketchLine")
+aLineD1 = aSketchFeature.addFeature("SketchLine")
+aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
+aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
+aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
+aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
+aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
+aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
+aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
+aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
+aLineA1StartPoint.setValue(-100, 0)
+aLineA1EndPoint.setValue(-50, 0)
+aLineB1StartPoint.setValue(-50, 0)
+aLineB1EndPoint.setValue(-50, 50)
+aLineC1StartPoint.setValue(-50, 50)
+aLineC1EndPoint.setValue(-100, 50)
+aLineD1StartPoint.setValue(-100, 50)
+aLineD1EndPoint.setValue(-100, 0)
+aLineA2 = aSketchFeature.addFeature("SketchLine")
+aLineB2 = aSketchFeature.addFeature("SketchLine")
+aLineC2 = aSketchFeature.addFeature("SketchLine")
+aLineD2 = aSketchFeature.addFeature("SketchLine")
+aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
+aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
+aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
+aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
+aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
+aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
+aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
+aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
+aLineA2StartPoint.setValue(100, 0)
+aLineA2EndPoint.setValue(50, 0)
+aLineB2StartPoint.setValue(50, 0)
+aLineB2EndPoint.setValue(50, 50)
+aLineC2StartPoint.setValue(50, 50)
+aLineC2EndPoint.setValue(100, 50)
+aLineD2StartPoint.setValue(100, 50)
+aLineD2EndPoint.setValue(100, 0)
+aSession.finishOperation()
+
+#=========================================================================
+# Make extrusion
+#=========================================================================
+aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
+assert (aSketchResult.facesNum() > 1)
+
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+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)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Test placement by face - face
+#=========================================================================
+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/Generated_Face&Sketch_1/SketchLine_4")
+aPlacementFt.selection("placement_end_shape").selectSubShape("face", "Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7")
+aPlacementFt.boolean("placement_reverse_direction").setValue(False)
+aPlacementFt.boolean("placement_centering").setValue(True)
+aPlacementFt.execute()
+aSession.finishOperation()
+
+# Check placement results
+assert (len(aPlacementFt.results()) > 0)
+aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
+assert (aPlacementResult is not None)
+aSession.finishOperation()
+
+from salome.shaper import model
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py
new file mode 100644 (file)
index 0000000..2eed9a2
--- /dev/null
@@ -0,0 +1,140 @@
+## 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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch to extrude
+#=========================================================================
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineA1 = aSketchFeature.addFeature("SketchLine")
+aLineB1 = aSketchFeature.addFeature("SketchLine")
+aLineC1 = aSketchFeature.addFeature("SketchLine")
+aLineD1 = aSketchFeature.addFeature("SketchLine")
+aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint"))
+aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint"))
+aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint"))
+aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint"))
+aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint"))
+aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint"))
+aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint"))
+aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint"))
+aLineA1StartPoint.setValue(-100, 0)
+aLineA1EndPoint.setValue(-50, 0)
+aLineB1StartPoint.setValue(-50, 0)
+aLineB1EndPoint.setValue(-50, 50)
+aLineC1StartPoint.setValue(-50, 50)
+aLineC1EndPoint.setValue(-100, 50)
+aLineD1StartPoint.setValue(-100, 50)
+aLineD1EndPoint.setValue(-100, 0)
+aLineA2 = aSketchFeature.addFeature("SketchLine")
+aLineB2 = aSketchFeature.addFeature("SketchLine")
+aLineC2 = aSketchFeature.addFeature("SketchLine")
+aLineD2 = aSketchFeature.addFeature("SketchLine")
+aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint"))
+aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint"))
+aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint"))
+aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint"))
+aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint"))
+aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint"))
+aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint"))
+aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint"))
+aLineA2StartPoint.setValue(100, 0)
+aLineA2EndPoint.setValue(50, 0)
+aLineB2StartPoint.setValue(50, 0)
+aLineB2EndPoint.setValue(50, 50)
+aLineC2StartPoint.setValue(50, 50)
+aLineC2EndPoint.setValue(100, 50)
+aLineD2StartPoint.setValue(100, 50)
+aLineD2EndPoint.setValue(100, 0)
+aSession.finishOperation()
+
+#=========================================================================
+# Make extrusion
+#=========================================================================
+aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult())
+assert (aSketchResult.facesNum() > 1)
+
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+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)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Test placement by face - vertex
+#=========================================================================
+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/Generated_Face&Sketch_1/SketchLine_4")
+aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_2/To_Face]")
+aPlacementFt.boolean("placement_reverse_direction").setValue(False)
+aPlacementFt.boolean("placement_centering").setValue(True)
+aPlacementFt.execute()
+aSession.finishOperation()
+
+# Check placement results
+assert (len(aPlacementFt.results()) > 0)
+aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult())
+assert (aPlacementResult is not None)
+aSession.finishOperation()
+
+from salome.shaper import model
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py
new file mode 100644 (file)
index 0000000..568564a
--- /dev/null
@@ -0,0 +1,42 @@
+## 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>
+##
+
+# -*- coding: utf-8 -*-
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-100, 0, -50, 0)
+SketchLine_2 = Sketch_1.addLine(-50, 0, -50, 50)
+SketchLine_3 = Sketch_1.addLine(-50, 50, -100, 50)
+SketchLine_4 = Sketch_1.addLine(-100, 50, -100, 0)
+SketchLine_5 = Sketch_1.addLine(100, 0, 50, 0)
+SketchLine_6 = Sketch_1.addLine(50, 0, 50, 50)
+SketchLine_7 = Sketch_1.addLine(50, 50, 100, 50)
+SketchLine_8 = Sketch_1.addLine(100, 50, 100, 0)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_1/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 50, 0)
+Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]"), model.selection("VERTEX", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_2/To_Face]"), False, True)
+model.do()
+model.end()