Salome HOME
5823902bc9f37837eec5382f6a3e44276f80e572
[modules/shaper.git] / src / SketchPlugin / Test / TestSketchCopy10.py
1 # Copyright (C) 2020-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from GeomAPI import *
21 from SketchAPI import *
22
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
30 Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
31 SketchIntersectionPoint_1 = Sketch_1.addIntersectionPoint(model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), True)
32 [SketchPoint_1, SketchPoint_2] = SketchIntersectionPoint_1.intersectionPoints()
33 SketchCircle_1 = Sketch_1.addCircle(5, 10, 3)
34 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center())
35 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 3)
36 SketchMultiTranslation_1 = Sketch_1.addTranslation([SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_2).coordinates(), SketchAPI_Point(SketchPoint_1).coordinates(), 3)
37 [SketchCircle_2, SketchCircle_3] = SketchMultiTranslation_1.translated()
38 SketchMultiRotation_1 = Sketch_1.addRotation([SketchCircle_1.results()[1]], SketchAPI_Point(SketchPoint_2).coordinates(), 360, 5, True)
39 [SketchCircle_4, SketchCircle_5, SketchCircle_6, SketchCircle_7] = SketchMultiRotation_1.rotated()
40 SketchLine_1 = Sketch_1.addLine(2.5, 1, 12.5, 5)
41 SketchLine_1.setAuxiliary(True)
42 SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.result())
43 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_1.result(), [SketchCircle_1.results()[1]])
44 [SketchCircle_8] = SketchConstraintMirror_1.mirrored()
45 model.do()
46
47 Sketch_1_Copy = model.copySketch(Part_1_doc, Sketch_1)
48 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", Sketch_1_Copy.name())], model.selection(), 10, 0)
49
50 model.end()
51
52 error = model.compareSketches(Sketch_1, Sketch_1_Copy)
53 assert(error == ""), error
54
55 VOL = 282.743338823
56
57 model.testNbResults(Extrusion_1, 8)
58 model.testNbSubResults(Extrusion_1, [0, 0, 0, 0, 0, 0, 0, 0])
59 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1, 1, 1, 1, 1, 1, 1, 1])
60 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [3, 3, 3, 3, 3, 3, 3, 3])
61 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [6, 6, 6, 6, 6, 6, 6, 6])
62 model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [12, 12, 12, 12, 12, 12, 12, 12])
63 model.testResultsVolumes(Extrusion_1, [VOL, VOL, VOL, VOL, VOL, VOL, VOL, VOL])
64
65 assert(Part_1_doc.size("Features") == 4)
66
67 assert(model.checkPythonDump())