]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/Test/TestRevolutionFuse_ByPlanesAndOffsets.py
Salome HOME
[Code coverage FeaturesAPI]: Improve coverage of Scale, Rotation, Revolution and...
[modules/shaper.git] / src / FeaturesPlugin / Test / TestRevolutionFuse_ByPlanesAndOffsets.py
diff --git a/src/FeaturesPlugin/Test/TestRevolutionFuse_ByPlanesAndOffsets.py b/src/FeaturesPlugin/Test/TestRevolutionFuse_ByPlanesAndOffsets.py
new file mode 100644 (file)
index 0000000..0e65889
--- /dev/null
@@ -0,0 +1,57 @@
+## 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
+from GeomAPI import *
+
+import math
+
+def checkMiddlePoint(shape, x, y, z, tolerance = 1.e-7):
+    assert(shape is not None)
+    middlePoint = shape.middlePoint()
+    assert(math.fabs(middlePoint.x() - x) < tolerance), "{} != {}".format(middlePoint.x(), x)
+    assert(math.fabs(middlePoint.y() - y) < tolerance), "{} != {}".format(middlePoint.y(), y)
+    assert(math.fabs(middlePoint.z() - z) < tolerance), "{} != {}".format(middlePoint.z(), z)
+
+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)
+
+RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [], model.selection("EDGE", "PartSet/OX"), model.selection("FACE", "Box_1_1/Right"), 0, model.selection(), 0, [model.selection("SOLID", "Box_1_1")])
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Left"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False)
+SketchLine_1 = SketchProjection_1.createdFeature()
+SketchCircle_1 = Sketch_1.addCircle(5, 10, 2)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center())
+RevolutionFuse_1.setNestedSketch(Sketch_1)
+model.do()
+Shape = RevolutionFuse_1.results()[0].resultSubShapePair()[0].shape()
+checkMiddlePoint(Shape, 5, 1.31869538592, 1.538946730649)
+
+RevolutionFuse_1.setPlanesAndOffsets(model.selection(), 0, model.selection("FACE", "Box_1_1/Bottom"), 0)
+model.do()
+Shape = RevolutionFuse_1.results()[0].resultSubShapePair()[0].shape()
+checkMiddlePoint(Shape, 5, 1.98775395252, 5.352665608174)
+
+model.end()
+
+assert(model.checkPythonDump())