1 # Copyright (C) 2014-2022 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
21 from SketchAPI import *
25 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
31 Box_1 = model.addBox(Part_1_doc, 100, 50, 100)
34 Point_1 = model.addPoint(Part_1_doc, 100, 0, 0)
37 Point_2 = model.addPoint(Part_1_doc, 250, 50, 100)
40 Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "all-in-Point_1"), model.selection("VERTEX", "all-in-Point_2"))
43 Point_3 = model.addPoint(Part_1_doc, 100, 50, 250)
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"))
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)
54 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "inf" , 500000.0 ])])
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]
64 exp = GeomAPI_ShapeExplorer(ResultCompSolid_1.shape(), GeomAPI_Shape.SOLID)
66 Reference[model.selection(ResultCompSolid_1, exp.current())] = False
68 model.checkFilter(Part_1_doc, model, Filters, Reference)
71 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "infEq" , 500000.0 ])])
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
82 model.checkFilter(Part_1_doc, model, Filters, Reference)
85 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "sup" , 500000.0 ])])
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
96 model.checkFilter(Part_1_doc, model, Filters, Reference)
99 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "inf" , 50.0 ])])
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
110 model.checkFilter(Part_1_doc, model, Filters, Reference)
113 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "supEq" , 500000.0 ])])
117 exp = GeomAPI_ShapeExplorer(ResultCompSolid_1.shape(), GeomAPI_Shape.SOLID)
119 Reference[model.selection(ResultCompSolid_1, exp.current())] = True
121 model.checkFilter(Part_1_doc, model, Filters, Reference)
124 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "supEq" , 800000.0 ])])
128 exp = GeomAPI_ShapeExplorer(ResultCompSolid_1.shape(), GeomAPI_Shape.SOLID)
130 Reference[model.selection(ResultCompSolid_1, exp.current())] = False
133 model.checkFilter(Part_1_doc, model, Filters, Reference)
136 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "isBetween" , 50.0 , 600000.0])])
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
146 model.checkFilter(Part_1_doc, model, Filters, Reference)
149 Filters = model.filters(Part_1_doc, [model.addFilter(name = "VolumeSize", args = [ "isStrictlyBetween" , 500.0 , 750000.0])])
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
159 model.checkFilter(Part_1_doc, model, Filters, Reference)