Salome HOME
updated copyright message
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_VolumeSize.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 ### Create Part
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29
30 ### Create Box
31 Box_1 = model.addBox(Part_1_doc, 100, 50, 100)
32
33 ### Create Point
34 Point_1 = model.addPoint(Part_1_doc, 100, 0, 0)
35
36 ### Create Point
37 Point_2 = model.addPoint(Part_1_doc, 250, 50, 100)
38
39 ### Create Box
40 Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "all-in-Point_1"), model.selection("VERTEX", "all-in-Point_2"))
41
42 ### Create Point
43 Point_3 = model.addPoint(Part_1_doc, 100, 50, 250)
44
45 ### Create Box
46 Box_3 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "Point_3"))
47
48 ### Create CompSolid
49 CompSolid_1_objects = [model.selection("SOLID", "Box_3_1"),
50                        model.selection("SOLID", "Box_2_1"),
51                        model.selection("SOLID", "Box_1_1")]
52 CompSolid_1 = model.addCompSolid(Part_1_doc, CompSolid_1_objects)
53
54 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "inf" , 500000.0 ])])
55
56 model.end()
57
58 Reference = {}
59 ResultCompSolid_1 = CompSolid_1.result().resultSubShapePair()[0]
60 ResultBox_1 = Box_1.result().resultSubShapePair()[0]
61 ResultBox_2 = Box_2.result().resultSubShapePair()[0]
62 ResultBox_3 = Box_3.result().resultSubShapePair()[0]
63
64 exp = GeomAPI_ShapeExplorer(ResultCompSolid_1.shape(), GeomAPI_Shape.SOLID)
65 while exp.more():
66   Reference[model.selection(ResultCompSolid_1, exp.current())] = False
67   exp.next()
68 model.checkFilter(Part_1_doc, model, Filters, Reference)
69
70 model.begin()
71 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "infEq" , 500000.0 ])])
72 model.end()
73
74 Reference = {}
75 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.SOLID)
76 Reference[model.selection(ResultBox_1, exp.current())] = True
77 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.SOLID)
78 Reference[model.selection(ResultBox_2, exp.current())] = False
79 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.SOLID)
80 Reference[model.selection(ResultBox_3, exp.current())] = False
81
82 model.checkFilter(Part_1_doc, model, Filters, Reference)
83
84 model.begin()
85 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "sup" , 500000.0 ])])
86 model.end()
87
88 Reference = {}
89 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.SOLID)
90 Reference[model.selection(ResultBox_1, exp.current())] = False
91 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.SOLID)
92 Reference[model.selection(ResultBox_2, exp.current())] = True
93 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.SOLID)
94 Reference[model.selection(ResultBox_3, exp.current())] = True
95
96 model.checkFilter(Part_1_doc, model, Filters, Reference)
97
98 model.begin()
99 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "inf" , 50.0 ])])
100 model.end()
101
102 Reference = {}
103 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.SOLID)
104 Reference[model.selection(ResultBox_1, exp.current())] = False
105 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.SOLID)
106 Reference[model.selection(ResultBox_2, exp.current())] = False
107 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.SOLID)
108 Reference[model.selection(ResultBox_3, exp.current())] = False
109
110 model.checkFilter(Part_1_doc, model, Filters, Reference)
111
112 model.begin()
113 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "supEq" , 500000.0 ])])
114 model.end()
115
116 Reference = {}
117 exp = GeomAPI_ShapeExplorer(ResultCompSolid_1.shape(), GeomAPI_Shape.SOLID)
118 while exp.more():
119   Reference[model.selection(ResultCompSolid_1, exp.current())] = True
120   exp.next()
121 model.checkFilter(Part_1_doc, model, Filters, Reference)
122
123 model.begin()
124 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "supEq" , 800000.0 ])])
125 model.end()
126
127 Reference = {}
128 exp = GeomAPI_ShapeExplorer(ResultCompSolid_1.shape(), GeomAPI_Shape.SOLID)
129 while exp.more():
130   Reference[model.selection(ResultCompSolid_1, exp.current())] = False
131   exp.next()
132
133 model.checkFilter(Part_1_doc, model, Filters, Reference)
134
135 model.begin()
136 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "isBetween" , 50.0 , 600000.0])])
137 model.end()
138 Reference = {}
139 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.SOLID)
140 Reference[model.selection(ResultBox_1, exp.current())] = True
141 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.SOLID)
142 Reference[model.selection(ResultBox_2, exp.current())] = False
143 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.SOLID)
144 Reference[model.selection(ResultBox_3, exp.current())] = False
145
146 model.checkFilter(Part_1_doc, model, Filters, Reference)
147
148 model.begin()
149 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "isStrictlyBetween" , 500.0 , 750000.0])])
150 model.end()
151 Reference = {}
152 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.SOLID)
153 Reference[model.selection(ResultBox_1, exp.current())] = True
154 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.SOLID)
155 Reference[model.selection(ResultBox_2, exp.current())] = False
156 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.SOLID)
157 Reference[model.selection(ResultBox_3, exp.current())] = False
158
159 model.checkFilter(Part_1_doc, model, Filters, Reference)