Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FeaturesPlugin / Test / TestDefeaturing_OnCompsolid3.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 SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchLine_1 = Sketch_1.addLine(5, 1.355252715607035e-20, 20, -1.336382355046098e-51)
30 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
31 SketchLine_2 = Sketch_1.addLine(20, -1.336382355046098e-51, 20, 5.85786437626905)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
34 SketchLine_3 = Sketch_1.addLine(20, 5.85786437626905, 15.85786437626905, 10)
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
36 SketchLine_4 = Sketch_1.addLine(15.85786437626905, 10, 20, 14.14213562373095)
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchLine_5 = Sketch_1.addLine(20, 14.14213562373095, 20, 20)
39 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
40 SketchLine_6 = Sketch_1.addLine(20, 20, 0, 20)
41 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
42 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_6.result())
43 SketchLine_7 = Sketch_1.addLine(0, 20, 0, 5)
44 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
45 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_7.result())
46 SketchConstraintVertical_2.setName("SketchConstraintVertical_3")
47 SketchArc_1 = Sketch_1.addArc(0, 0, 5, 1.355252715607035e-20, 0, 5, False)
48 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
49 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchArc_1.endPoint())
50 SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_2.result(), SketchLine_5.result())
51 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_3.result(), SketchLine_4.result())
52 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_1.result())
53 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_7.result())
54 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
55 SketchPoint_1 = SketchProjection_1.createdFeature()
56 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.center(), SketchAPI_Point(SketchPoint_1).coordinates())
57 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.center(), SketchLine_1.endPoint(), 20, True)
58 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchArc_1.center(), SketchLine_7.startPoint(), 20, True)
59 SketchLine_8 = Sketch_1.addLine(10, 0, 10, 20)
60 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_1.result())
61 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_6.result())
62 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
63 SketchConstraintVertical_3.setName("SketchConstraintVertical_4")
64 SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchLine_8.endPoint(), SketchLine_6.result())
65 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_5.result())
66 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_4.result())
67 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5)
68 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_3.result())
69 model.do()
70 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
71 Defeaturing_1 = model.addDefeaturing(Part_1_doc, [model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_3")])
72 model.testHaveNamingSubshapes(Defeaturing_1, model, Part_1_doc)
73 model.end()
74
75 from GeomAPI import *
76
77 model.testNbResults(Defeaturing_1, 1)
78 model.testNbSubResults(Defeaturing_1, [2])
79 model.testNbSubShapes(Defeaturing_1, GeomAPI_Shape.SOLID, [2])
80 model.testNbSubShapes(Defeaturing_1, GeomAPI_Shape.FACE, [12])
81 model.testNbSubShapes(Defeaturing_1, GeomAPI_Shape.EDGE, [48])
82 model.testNbSubShapes(Defeaturing_1, GeomAPI_Shape.VERTEX, [96])
83 model.testResultsVolumes(Defeaturing_1, [4000])
84
85 assert(model.checkPythonDump())