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