Salome HOME
d9fd3a26a6dd85ec1650b95e2ca0b390c46b1ec9
[modules/shaper.git] / src / FeaturesPlugin / Test / TestRecover.py
1 # Copyright (C) 2014-2021  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 # Test made with high level API
21 # -----------------------------
22
23 from salome.shaper import model
24
25 # Initialisation
26
27 model.begin()
28 mypartset = model.moduleDocument()
29
30
31 # Creating a new Part, two circles, extrusions on them and Boolean CUT
32
33 mypart = model.addPart(mypartset).document()
34
35 sk1 = model.addSketch(mypart, model.defaultPlane("XOY"))
36 c1 = sk1.addCircle(0, 0, 100)
37 model.do()
38 bigcyl = model.addExtrusion(mypart, sk1.selectFace(), 100)
39
40 sk2 = model.addSketch(mypart, model.defaultPlane("XOY"))
41 c2 = sk2.addCircle(20, 30, 30)
42 model.do()
43 smallcyl = model.addExtrusion(mypart, sk2.selectFace(), 150)
44
45 cut = model.addCut(mypart, bigcyl.results(), smallcyl.results())
46
47 model.do()
48
49 # check bodies number is 1: only Boolean result
50 assert(mypart.size("Bodies") == 1)
51
52 model.addRecover(mypart, cut, smallcyl.results())
53
54 model.end()
55
56 # check that one is recovered
57 assert(mypart.size("Bodies") == 2)
58
59 model.undo()
60
61 # check bodies number is 1: recover is canceled
62 assert(mypart.size("Bodies") == 1)
63
64
65 # check persistent flag of recover: never concealed
66 model.begin()
67 recover = model.addRecover(mypart, cut, smallcyl.results())
68 model.end()
69
70 assert(mypart.size("Bodies") == 2)
71
72 model.begin()
73 sk3 = model.addSketch(mypart, model.defaultPlane("XOY"))
74 c3 = sk3.addCircle(0, 0, 90)
75 model.do()
76 big2 = model.addExtrusion(mypart, sk3.selectFace(), 110)
77
78 smallcyl2 = model.addExtrusion(mypart, sk2.selectFace(), 150)
79 cut2 = model.addCut(mypart, big2.results(), smallcyl2.results())
80
81 model.end()
82
83 # two booleans and small cylinder
84 assert(mypart.size("Bodies") == 3)
85
86 assert(model.checkPythonDump())