TestPlacement_Face_Vertex.py
TestPlacement_Face_Edge.py
TestPlacement_Face_Face.py
+ TestPlacement_Part_Part.py
+ TestPlacement_ErrorMsg.py
TestTranslation.py
+ TestTranslation_Part.py
TestRotation.py
+ TestRotation_ErrorMsg.py
+ TestMultiRotation_Part.py
+ TestMultiTranslation_Part.py
+ TestSymmetry_Part.py
TestBoolean1.py
TestBoolean2.py
TestBoolean3.py
GeomAPI_ShapeIterator anIt(aShape);
anEdge = anIt.current()->edge();
}
- else
- {
- setError(aSelectionError);
- return;
- }
if (!anEdge.get())
{
GeomAPI_ShapeIterator anIt(aShape);
anEdge = anIt.current()->edge();
}
- else
- {
- setError(aSelectionError);
- return;
- }
if (!anEdge.get())
{
selection(FeaturesPlugin_Rotation::START_POINT_ID());
std::shared_ptr<ModelAPI_AttributeSelection> anEndPointRef =
selection(FeaturesPlugin_Rotation::END_POINT_ID());
- if ((aCenterRef.get() != NULL) && (aStartPointRef.get() != NULL)
- && (anEndPointRef.get() != NULL)) {
+ if ((aCenterRef.get() != NULL) &&
+ (aStartPointRef.get() != NULL) &&
+ (anEndPointRef.get() != NULL)) {
GeomShapePtr aCenterShape = aCenterRef->value();
- if (!aCenterShape.get())
+ if (!aCenterShape.get() && aCenterRef->context().get())
aCenterShape = aCenterRef->context()->shape();
GeomShapePtr aStartShape = aStartPointRef->value();
- if (!aStartShape.get())
+ if (!aStartShape.get() && aStartPointRef->context().get())
aStartShape = aStartPointRef->context()->shape();
- GeomShapePtr anEndShape = anEndPointRef->value();
- if (!anEndShape.get())
+ GeomShapePtr anEndShape = anEndPointRef->value();
+ if (!anEndShape.get() && anEndPointRef->context().get())
anEndShape = anEndPointRef->context()->shape();
if (aStartShape && anEndShape && aCenterShape) {
aCenterPoint = GeomAlgoAPI_PointBuilder::point(aCenterShape);
GeomAPI_ShapeIterator anIt(aShape);
anEdge = anIt.current()->edge();
}
- else
- {
- setError(aSelectionError);
- return;
- }
if (!anEdge.get())
{
GeomAPI_ShapeIterator anIt(aShape);
aFace = anIt.current()->face();
}
- else
- {
- setError(aSelectionError);
- return;
- }
if (!aFace.get())
{
GeomAPI_ShapeIterator anIt(aShape);
anEdge = anIt.current()->edge();
}
- else
- {
- setError(aSelectionError);
- return;
- }
if (!anEdge.get())
{
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+AngularCopy_1 = model.addMultiRotation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OZ"), 2)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(AngularCopy_1, 2)
+model.testNbSubResults(AngularCopy_1, [0, 0])
+model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.SOLID, [1, 1])
+model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.FACE, [6, 6])
+model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.EDGE, [24, 24])
+model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.VERTEX, [48, 48])
+model.testResultsVolumes(AngularCopy_1, [1000, 1000])
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+LinearCopy_1 = model.addMultiTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OX"), 20, 2, model.selection("EDGE", "OY"), 20, 2)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(LinearCopy_1, 4)
+model.testNbSubResults(LinearCopy_1, [0, 0, 0, 0])
+model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.SOLID, [1, 1, 1, 1])
+model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.FACE, [6, 6, 6, 6])
+model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.EDGE, [24, 24, 24, 24])
+model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.VERTEX, [48, 48, 48, 48])
+model.testResultsVolumes(LinearCopy_1, [1000, 1000, 1000, 1000])
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+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"))
+SketchCircle_1 = Sketch_1.addCircle(-16.57843122838298, -30.87163595652513, 16.88033171559421)
+SketchCircle_2 = Sketch_1.addCircle(29.74848722752363, 33.32178840955915, 9.026354269133289)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+model.do()
+model.end()
+
+from ModelAPI import *
+aSession = ModelAPI_Session.get()
+
+aShapeToMove = Extrusion_1.feature().results()[1]
+
+# Verify Placement errors on low-level
+aSession.startOperation()
+aPlacementFt = featureToCompositeFeature(Part_1.feature()).addFeature("Placement")
+aPlacementFt.execute()
+aSession.finishOperation()
+assert(aPlacementFt.error() != "")
+
+aSession.startOperation()
+aPlacementFt.selectionList("placement_objects_list").append(aShapeToMove, aShapeToMove.shape())
+aPlacementFt.execute()
+aSession.finishOperation()
+assert(aPlacementFt.error() != "")
+
+aSession.startOperation()
+aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/To_Face")
+aPlacementFt.execute()
+aSession.finishOperation()
+assert(aPlacementFt.error() != "")
+
+aSession.startOperation()
+aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/Generated_Face&Sketch_1/SketchCircle_2_2")
+aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face")
+aPlacementFt.execute()
+aSession.finishOperation()
+assert(aPlacementFt.error() != "")
+
+aSession.startOperation()
+aPlacementFt.selection("placement_start_shape").selectSubShape("EDGE", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchCircle_2_2][Extrusion_1_2/To_Face]")
+aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face")
+aPlacementFt.execute()
+aSession.finishOperation()
+assert(aPlacementFt.error() != "")
+
+# Create correct Placement
+aSession.startOperation()
+aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/To_Face")
+aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face")
+aPlacementFt.boolean("placement_reverse_direction").setValue(False)
+aPlacementFt.boolean("placement_centering").setValue(True)
+aPlacementFt.execute()
+aSession.finishOperation()
+assert(aPlacementFt.error() == "")
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+Part_2 = model.addPart(partSet)
+Part_2_doc = Part_2.document()
+Cylinder_1 = model.addCylinder(Part_2_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+model.do()
+Placement_1 = model.addPlacement(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("FACE", "Part_2/Cylinder_1_1/Face_2"), model.selection("FACE", "Part_1/Box_1_1/Front"), False, True)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Placement_1, 1)
+model.testNbSubResults(Placement_1, [0])
+model.testNbSubShapes(Placement_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Placement_1, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(Placement_1, GeomAPI_Shape.EDGE, [6])
+model.testNbSubShapes(Placement_1, GeomAPI_Shape.VERTEX, [12])
+model.testResultsVolumes(Placement_1, [785.398163397448342948337085545])
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 =model.addBox(Part_1_doc, 10, 10, 10)
+model.end()
+
+from ModelAPI import *
+aSession = ModelAPI_Session.get()
+
+aShapeToMove = Box_1.feature().lastResult()
+
+# Verify Rotation errors on low-level
+aSession.startOperation()
+aRotation = featureToCompositeFeature(Part_1.feature()).addFeature("Rotation")
+aRotation.string("CreationMethod").setValue("ByAxisAndAngle")
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
+
+aSession.startOperation()
+aRotation.selectionList("main_objects").append(aShapeToMove, aShapeToMove.shape())
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
+
+aSession.startOperation()
+aRotation.selectionList("main_objects").append(None, None)
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
+
+aSession.startOperation()
+aRotation.string("CreationMethod").setValue("ByThreePoints")
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
+
+aSession.startOperation()
+aRotation.selectionList("main_objects").removeLast()
+aRotation.selectionList("main_objects").removeLast()
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
+
+aSession.startOperation()
+aRotation.selectionList("main_objects").append(aShapeToMove, aShapeToMove.shape())
+aRotation.string("CreationMethod").setValue("ByAxisAndAngle")
+aRotation.selection("axis_object").selectSubShape("FACE", "Box_1_1/Back")
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
+
+aSession.startOperation()
+aRotation.selection("axis_object").selectSubShape("COMPOUND", "Box_1_1/Back")
+aRotation.execute()
+aSession.finishOperation()
+assert(aRotation.error() != "")
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+Symmetry_1 = model.addSymmetry(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("VERTEX", "Part_1/[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), False)
+Symmetry_2 = model.addSymmetry(partSet, [model.selection("COMPOUND", "Symmetry_1/")], model.selection("EDGE", "Symmetry_1/[Box_1_1/Back][Box_1_1/Left]"), False)
+Symmetry_3 = model.addSymmetry(partSet, [model.selection("COMPOUND", "Symmetry_2/")], model.selection("FACE", "Symmetry_2/Box_1_1/Bottom"), False)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Symmetry_3, 1)
+model.testNbSubResults(Symmetry_3, [0])
+model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Symmetry_3, [1000])
--- /dev/null
+## Copyright (C) 2018-20xx 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+Translation_1 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OX"), 10)
+Translation_2 = model.addTranslation(partSet, [model.selection("COMPOUND", "Translation_1/")], 0, 10, 0)
+Translation_3 = model.addTranslation(partSet, [model.selection("COMPOUND", "Translation_2/")], model.selection("VERTEX", "Translation_2/[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "Translation_2/[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"))
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Translation_1, 1)
+model.testNbSubResults(Translation_1, [0])
+model.testNbSubShapes(Translation_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Translation_1, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Translation_1, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Translation_1, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Translation_1, [1000])