Salome HOME
Merge branch 'V9_11_BR'
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilters_Mixed1.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 GeomAPI import *
22
23 model.begin()
24 partSet = model.moduleDocument()
25 Part_1 = model.addPart(partSet)
26 Part_1_doc = Part_1.document()
27 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
28 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
29 SketchCircle_1 = Sketch_1.addCircle(5, 5, 3)
30 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False)
31 SketchLine_1 = SketchProjection_1.createdFeature()
32 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_1.result(), 5, True)
33 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), False)
34 SketchLine_2 = SketchProjection_2.createdFeature()
35 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.result(), 5, True)
36 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 3)
37 model.do()
38 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 5, 0)
39 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 10, -5)
40 Filters = model.filters(Part_1_doc, [model.addFilter(name = "RelativeToSolid", args = [model.selection("SOLID", "Box_1_1"), "not_in"]),
41                                      model.addFilter(name = "TopoConnectedFaces", args = [model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_2_1/To_Face]")])])
42 model.end()
43
44 Reference = {}
45 # Faces of the box
46 ResultBox = Box_1.result().resultSubShapePair()[0]
47 exp = GeomAPI_ShapeExplorer(ResultBox.shape(), GeomAPI_Shape.FACE)
48 while exp.more():
49   Reference[model.selection(ResultBox, exp.current())] = False
50   exp.next()
51
52 # Faces of the first cylinder
53 ResultCylinder_1 = Extrusion_1.result().resultSubShapePair()[0]
54 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
55 while exp.more():
56   Reference[model.selection(ResultCylinder_1, exp.current())] = False
57   exp.next()
58
59 # Faces of the second cylinder
60 ResultCylinder_2 = Extrusion_2.result().resultSubShapePair()[0]
61 exp = GeomAPI_ShapeExplorer(ResultCylinder_2.shape(), GeomAPI_Shape.FACE)
62 Reference[model.selection(ResultCylinder_2, exp.current())] = True;  exp.next()
63 Reference[model.selection(ResultCylinder_2, exp.current())] = False; exp.next()
64 Reference[model.selection(ResultCylinder_2, exp.current())] = True;  exp.next()
65
66 model.checkFilter(Part_1_doc, model, Filters, Reference)
67
68 model.begin()
69 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_1/SketchCircle_1_2"), Filters])
70 model.end()
71 assert(model.checkPythonDump())