From d38fce1aa4c15e17d5dcadccb5cdac18fc29cf04 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 27 Feb 2019 15:52:38 +0300 Subject: [PATCH] SALOME quick test is added for the SHAPER --- CMakeLists.txt | 2 ++ shaper_test.py | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 shaper_test.py diff --git a/CMakeLists.txt b/CMakeLists.txt index f7e2f9ad4..7c9dac145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,8 @@ IF(${HAVE_SALOME}) SET(SHAPER_INSTALL_GUI_DOC share/doc/salome/gui/SHAPER CACHE INTERNAL "" FORCE) SET(SHAPER_INSTALL_TUI_DOC share/doc/salome/tui/SHAPER CACHE INTERNAL "" FORCE) # without SALOME there is another kind of documentation, separated one + + SALOME_INSTALL_SCRIPTS("shaper_test.py" ${SHAPER_INSTALL_PYTHON_FILES}) ELSE(${HAVE_SALOME}) SET(SHAPER_INSTALL_ADDONS addons CACHE INTERNAL "" FORCE) SET(SHAPER_INSTALL_BIN bin CACHE INTERNAL "" FORCE) diff --git a/shaper_test.py b/shaper_test.py new file mode 100644 index 000000000..dcbb2a1f4 --- /dev/null +++ b/shaper_test.py @@ -0,0 +1,83 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2018-2019 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +import unittest + +class TestShaper(unittest.TestCase): + + def setUp(self): + import salome + salome.salome_init() + + def test_shaper(self): + """Quick test for Shaper module""" + + print() + print('Testing Shaper module') + + from SketchAPI import SketchAPI_Point + + from salome.shaper import model + + model.begin() + print('... Create Part document') + partSet = model.moduleDocument() + Part_1 = model.addPart(partSet) + Part_1_doc = Part_1.document() + self.assertIsNotNone(Part_1_doc) + + print('... Create Sketch') + Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + self.assertIsNotNone(Sketch_1) + SketchLine_1 = Sketch_1.addLine(10, 10, -10, 10) + SketchLine_2 = Sketch_1.addLine(-10, 10, -10, 30) + SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) + SketchArc_1 = Sketch_1.addArc(10, 30, 10, 10, -10, 30, False) + SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint()) + SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.endPoint()) + SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result()) + SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_2.result(), SketchArc_1.results()[1]) + SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_2.result()) + SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 20) + SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) + SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) + SketchPoint_1 = SketchProjection_1.createdFeature() + SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.endPoint(), 10) + SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_1.endPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 10) + model.do() + self.assertEqual(len(Sketch_1.results()), 1) + + print('... Create Extrusion') + Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 10, 0) + model.do() + self.assertIsNotNone(Extrusion_1) + self.assertEqual(len(Extrusion_1.results()), 1) + self.assertEqual(Extrusion_1.result().shapeType(), 'SOLID') + + print('... Create Partition') + Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("FACE", "PartSet/YOZ")]) + model.end() + self.assertIsNotNone(Partition_1) + self.assertEqual(len(Partition_1.results()), 1) + self.assertEqual(Partition_1.result().shapeType(), 'COMPSOLID') + self.assertEqual(Partition_1.result().numberOfSubs(), 2) + +if __name__ == '__main__': + unittest.main() -- 2.39.2