]> SALOME platform Git repositories - modules/shaper.git/blob - shaper_test.py
Salome HOME
Delegate to KERNEL salome module the Session Status
[modules/shaper.git] / shaper_test.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2018-2020  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import unittest
22
23 class TestShaper(unittest.TestCase):
24
25     def setUp(self):
26         import salome
27         salome.salome_init()
28
29     def test_shaper(self):
30         """Quick test for Shaper module"""
31
32         print()
33         print('Testing Shaper module')
34
35         from SketchAPI import SketchAPI_Point
36
37         from salome.shaper import model
38
39         model.begin()
40         print('... Create Part document')
41         partSet = model.moduleDocument()
42         Part_1 = model.addPart(partSet)
43         Part_1_doc = Part_1.document()
44         self.assertIsNotNone(Part_1_doc)
45
46         print('... Create Sketch')
47         Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
48         self.assertIsNotNone(Sketch_1)
49         SketchLine_1 = Sketch_1.addLine(10, 10, -10, 10)
50         SketchLine_2 = Sketch_1.addLine(-10, 10, -10, 30)
51         SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
52         SketchArc_1 = Sketch_1.addArc(10, 30, 10, 10, -10, 30, False)
53         SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
54         SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.endPoint())
55         SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result())
56         SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_2.result(), SketchArc_1.results()[1])
57         SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_2.result())
58         SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 20)
59         SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
60         SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
61         SketchPoint_1 = SketchProjection_1.createdFeature()
62         SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.endPoint(), 10)
63         SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_1.endPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 10)
64         model.do()
65         self.assertEqual(len(Sketch_1.results()), 1)
66
67         print('... Create Extrusion')
68         Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 10, 0)
69         model.do()
70         self.assertIsNotNone(Extrusion_1)
71         self.assertEqual(len(Extrusion_1.results()), 1)
72         self.assertEqual(Extrusion_1.result().shapeType(), 'SOLID')
73
74         print('... Create Partition')
75         Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("FACE", "PartSet/YOZ")])
76         model.end()
77         self.assertIsNotNone(Partition_1)
78         self.assertEqual(len(Partition_1.results()), 1)
79         self.assertEqual(Partition_1.result().shapeType(), 'COMPSOLID')
80         self.assertEqual(Partition_1.result().numberOfSubs(), 2)
81
82 if __name__ == '__main__':
83     unittest.main()