From 85e3142f8345ecb5d47bec43987dc92337168345 Mon Sep 17 00:00:00 2001 From: dbv Date: Mon, 29 Oct 2018 14:14:04 +0300 Subject: [PATCH] Converted placement tests --- src/FeaturesPlugin/CMakeLists.txt | 7 +- .../Test/TestPlacement_Edge_Edge.py | 140 ++++++++++++++++++ ...cement.py => TestPlacement_Edge_Vertex.py} | 98 +----------- .../Test/TestPlacement_Face_Edge.py | 140 ++++++++++++++++++ .../Test/TestPlacement_Face_Face.py | 140 ++++++++++++++++++ .../Test/TestPlacement_Face_Vertex.py | 140 ++++++++++++++++++ .../Test/TestPlacement_Vertex_Vertex.py | 42 ++++++ 7 files changed, 610 insertions(+), 97 deletions(-) create mode 100644 src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py rename src/FeaturesPlugin/Test/{TestPlacement.py => TestPlacement_Edge_Vertex.py} (55%) create mode 100644 src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py create mode 100644 src/FeaturesPlugin/Test/TestPlacement_Face_Face.py create mode 100644 src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py create mode 100644 src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index ff684fb32..b0ab7042f 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -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_Edge_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py new file mode 100644 index 000000000..ac1cb7352 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py @@ -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 +## + +#========================================================================= +# 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.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py similarity index 55% rename from src/FeaturesPlugin/Test/TestPlacement.py rename to src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py index f61759df4..40502f8b0 100644 --- a/src/FeaturesPlugin/Test/TestPlacement.py +++ b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py @@ -117,90 +117,14 @@ 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.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() @@ -210,25 +134,7 @@ aSession.finishOperation() 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_Face_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py new file mode 100644 index 000000000..b723c3cc2 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py @@ -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 +## + +#========================================================================= +# 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 index 000000000..ffb334e32 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py @@ -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 +## + +#========================================================================= +# 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 index 000000000..2eed9a251 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py @@ -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 +## + +#========================================================================= +# 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 index 000000000..568564ad5 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py @@ -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 +## + +# -*- 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() -- 2.39.2