Salome HOME
8869f3d696d6d371d06840ff1aa15169022f0423
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_FeatureEdges.py
1 # Copyright (C) 2014-2023  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 chamfer on face=========================================================
28
29 ### Create Part
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32
33 ### Create Box
34 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
35
36 ### Create Chamfer
37 Chamfer_1 = model.addChamfer(Part_1_doc, [model.selection("FACE", "Box_1_1/Left")], True, 2, 2, keepSubResults = True)
38
39 model.do()
40 Filters = model.filters(Part_1_doc, [model.addFilter(name = "FeatureEdges",  args = [ 5.0 ])])
41 model.end()
42
43 Reference = {}
44 ResultChamfer_1_1 = Chamfer_1.result().resultSubShapePair()[0]
45 exp = GeomAPI_ShapeExplorer(ResultChamfer_1_1.shape(), GeomAPI_Shape.EDGE)
46 while exp.more():
47   Reference[model.selection(ResultChamfer_1_1, exp.current())] = True
48   exp.next()
49 model.checkFilter(Part_1_doc, model, Filters, Reference)
50
51 model.do()
52
53 ###===========Test with fillet on solide===========================================================
54
55 ### Create Part
56 Part_2 = model.addPart(partSet)
57 Part_2_doc = Part_2.document()
58
59 ### Create Box
60 Box_2 = model.addBox(Part_2_doc, 10, 10, 10)
61
62 ### Create Fillet
63 Fillet_1_objects_4 = [model.selection("FACE", "Box_1_1/Left"),
64                       model.selection("FACE", "Box_1_1/Front"),
65                       model.selection("FACE", "Box_1_1/Top"),
66                       model.selection("FACE", "Box_1_1/Right"),
67                       model.selection("FACE", "Box_1_1/Bottom")]
68 Fillet_1 = model.addFillet(Part_2_doc, Fillet_1_objects_4, 2, keepSubResults = True)
69
70 model.end()
71
72 model.do()
73 Filters = model.filters(Part_2_doc, [model.addFilter(name = "FeatureEdges",  args = [ 5.0 ])])
74 model.end()
75
76
77 ###===========Test with Chamfer by an angle of 43° and filters with angle 30 and 50 ===========
78 Reference = {}
79 ResultFillet_1_1 = Fillet_1.result().resultSubShapePair()[0]
80 exp = GeomAPI_ShapeExplorer(ResultFillet_1_1.shape(), GeomAPI_Shape.EDGE)
81 while exp.more():
82   Reference[model.selection(ResultFillet_1_1, exp.current())] = False
83   exp.next()
84 model.checkFilter(Part_2_doc, model, Filters, Reference)
85
86 ### Create Part
87 Part_3 = model.addPart(partSet)
88 Part_3_doc = Part_3.document()
89
90 ### Create Box
91 Box_3 = model.addBox(Part_3_doc, 10, 10, 10)
92
93 ### Create Chamfer
94 Chamfer_1_objects = [model.selection("FACE", "Box_1_1/Left"),
95                      model.selection("FACE", "Box_1_1/Front"),
96                      model.selection("FACE", "Box_1_1/Top"),
97                      model.selection("FACE", "Box_1_1/Right"),
98                      model.selection("FACE", "Box_1_1/Bottom")]
99 Chamfer_2 = model.addChamfer(Part_3_doc, Chamfer_1_objects, False, 2, 43, keepSubResults = True)
100
101 model.end()
102
103 model.do()
104 Filters = model.filters(Part_3_doc, [model.addFilter(name = "FeatureEdges",  args = [ 30.0 ])])
105 model.end()
106
107 Reference = {}
108 ResultChamfer_2_1 = Chamfer_2.result().resultSubShapePair()[0]
109 exp = GeomAPI_ShapeExplorer(ResultChamfer_2_1.shape(), GeomAPI_Shape.EDGE)
110 while exp.more():
111   Reference[model.selection(ResultChamfer_2_1, exp.current())] = True
112   exp.next()
113 model.checkFilter(Part_3_doc, model, Filters, Reference)
114
115 model.do()
116 Filters = model.filters(Part_3_doc, [model.addFilter(name = "FeatureEdges",  args = [ 50.0 ])])
117 model.end()
118
119 Reference = {}
120 exp = GeomAPI_ShapeExplorer(ResultChamfer_2_1.shape(), GeomAPI_Shape.EDGE)
121 while exp.more():
122   Reference[model.selection(ResultChamfer_2_1, exp.current())] = False
123   exp.next()
124 model.checkFilter(Part_3_doc, model, Filters, Reference)