Salome HOME
Merge branch 'V9_9_BR'
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_ContinuousFaces.py
1 # Copyright (C) 2014-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 from SketchAPI import *
22 from GeomAPI import *
23
24 model.begin()
25 partSet = model.moduleDocument()
26
27 ###===========Test with fillet on solide===========================================================
28
29 ### Create Part
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32
33 ### Create Box
34 Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
35
36 ### Create Fillet
37 Fillet_1_objects_4 = [model.selection("FACE", "Box_1_1/Left"),
38                       model.selection("FACE", "Box_1_1/Front"),
39                       model.selection("FACE", "Box_1_1/Top"),
40                       model.selection("FACE", "Box_1_1/Right"),
41                       model.selection("FACE", "Box_1_1/Bottom")]
42 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects_4, 2, keepSubResults = True)
43
44 model.end()
45
46 model.do()
47 Filters = model.filters(Part_1_doc, [model.addFilter(name = "ContinuousFaces", args = [model.selection("FACE", "Fillet_1_1/MF:Fillet&Box_1_1/Left"), 5.0 ])])
48 model.end()
49
50 Reference = {}
51 ResultFillet_1_1 = Fillet_1.result().resultSubShapePair()[0]
52 exp = GeomAPI_ShapeExplorer(ResultFillet_1_1.shape(), GeomAPI_Shape.FACE)
53 while exp.more():
54   Reference[model.selection(ResultFillet_1_1, exp.current())] = True
55   exp.next()
56 model.checkFilter(Part_1_doc, model, Filters, Reference)
57
58 ###===========Test with Chamfer by an angle of 43° on solid and filters with angle 50 ===========
59
60 ### Create Part
61 Part_2 = model.addPart(partSet)
62 Part_2_doc = Part_2.document()
63
64 ### Create Box
65 Box_3 = model.addBox(Part_2_doc, 10, 10, 10)
66
67 ### Create Chamfer
68 Chamfer_1_objects = [model.selection("FACE", "Box_1_1/Left"),
69                      model.selection("FACE", "Box_1_1/Front"),
70                      model.selection("FACE", "Box_1_1/Top"),
71                      model.selection("FACE", "Box_1_1/Right"),
72                      model.selection("FACE", "Box_1_1/Bottom")]
73 Chamfer_2 = model.addChamfer(Part_2_doc, Chamfer_1_objects, False, 2, 43, keepSubResults = True)
74
75 model.end()
76
77 model.do()
78 Filters = model.filters(Part_2_doc, [model.addFilter(name = "ContinuousFaces", args = [model.selection("FACE", "Chamfer_1_1/MF:Chamfer&Box_1_1/Left"), 50.0 ])])
79 model.end()
80
81 Reference = {}
82 ResultChamfer_2_1 = Chamfer_2.result().resultSubShapePair()[0]
83 exp = GeomAPI_ShapeExplorer(ResultChamfer_2_1.shape(), GeomAPI_Shape.FACE)
84 while exp.more():
85   Reference[model.selection(ResultChamfer_2_1, exp.current())] = True
86   exp.next()
87 model.checkFilter(Part_2_doc, model, Filters, Reference)