Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FeaturesPlugin / Test / Test19065.py
1 # Copyright (C) 2020-2022  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 salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
27 SketchLine_1 = Sketch_1.addLine(102.3744998618265, 0, 0, 0)
28 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
29 SketchPoint_1 = SketchProjection_1.createdFeature()
30 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
31 SketchLine_2 = Sketch_1.addLine(0, 0, 0, 83.57481045461809)
32 SketchLine_3 = Sketch_1.addLine(0, 83.57481045461809, 102.3744998618265, 83.57481045461809)
33 SketchLine_4 = Sketch_1.addLine(102.3744998618265, 83.57481045461809, 102.3744998618265, 0)
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
35 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
36 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
37 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
39 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
40 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
41 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
42 SketchLine_5 = Sketch_1.addLine(0, 83.57481045461809, 102.3744998618265, 0)
43 SketchLine_5.setAuxiliary(True)
44 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_5.startPoint())
45 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
46 SketchLine_6 = Sketch_1.addLine(0, 0, 102.3744998618265, 83.57481045461809)
47 SketchLine_6.setAuxiliary(True)
48 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_6.startPoint())
49 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_6.endPoint())
50 SketchPoint_2 = Sketch_1.addPoint(51.18724993091325, 41.78740522730904)
51 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_5.result())
52 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_6.result())
53 model.do()
54 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r"), 100, False)
55 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
56 SketchCircle_1 = Sketch_2.addCircle(46.03714617613203, 29.83511540776045, 23.21299794073264)
57 model.do()
58 Edge_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3")]
59 Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects, False)
60 Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchCircle_1_2")], False)
61 Edge_3 = model.addEdge(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_2/SketchCircle_1"))
62 Pipe_1 = model.addPipe(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r")], model.selection("EDGE", "Edge_3_1"), [])
63 Wire_1_objects = [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_3"), model.selection("EDGE", "Edge_1_4")]
64 Wire_1 = model.addWire(Part_1_doc, Wire_1_objects, False)
65 Recover_1 = model.addRecover(Part_1_doc, Pipe_1, [Edge_3.result()])
66 Pipe_2 = model.addPipe(Part_1_doc, [model.selection("EDGE", "Edge_2_1"), model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "Recover_1_1"), [])
67 Pipe_2.result().setColor(255, 0, 0)
68 Cut_1 = model.addCut(Part_1_doc, [model.selection("SHELL", "Pipe_2_1")], [model.selection("SOLID", "Pipe_1_1")], keepSubResults = True)
69
70 model.end()
71
72 from GeomAPI import *
73
74 model.testNbResults(Pipe_1, 1)
75 model.testNbSubResults(Pipe_1, [0])
76 model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [1])
77 model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [7])
78 model.testNbSubShapes(Pipe_1, GeomAPI_Shape.EDGE, [30])
79 model.testNbSubShapes(Pipe_1, GeomAPI_Shape.VERTEX, [60])
80 model.testResultsVolumes(Pipe_1, [470603.7881551325])
81
82 model.testNbResults(Pipe_2, 1)
83 model.testNbSubResults(Pipe_2, [0])
84 model.testNbSubShapes(Pipe_2, GeomAPI_Shape.SOLID, [0])
85 model.testNbSubShapes(Pipe_2, GeomAPI_Shape.FACE, [5])
86 model.testNbSubShapes(Pipe_2, GeomAPI_Shape.EDGE, [20])
87 model.testNbSubShapes(Pipe_2, GeomAPI_Shape.VERTEX, [40])
88 model.testResultsAreas(Pipe_2, [26549.49767585])
89
90 # Cut should have no results
91 model.testNbResults(Cut_1, 0)
92
93 assert(model.checkPythonDump())