Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_TopoConnectedFaces_Multi.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 SketchAPI import *
21 from GeomAPI import *
22
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchLine_1 = Sketch_1.addLine(-21.08194442253927, 8.656344751543489, 0, 30)
31 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
32 SketchLine_2 = SketchProjection_1.createdFeature()
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
34 SketchLine_3 = Sketch_1.addLine(0, 30, 25.98076211353316, 15)
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
36 SketchLine_4 = Sketch_1.addLine(25.98076211353316, 15, 18.03758667002239, -13.92932705531892)
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchLine_5 = Sketch_1.addLine(18.03758667002239, -13.92932705531892, -11.39496253934835, -19.73665406849542)
39 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
40 SketchLine_6 = Sketch_1.addLine(-11.39496253934835, -19.73665406849542, -21.08194442253927, 8.656344751543489)
41 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
42 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint())
43 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_5.result())
44 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_1.result())
45 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_6.result(), SketchLine_3.result())
46 SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result())
47 SketchLine_7 = Sketch_1.addLine(-11.39496253934835, -19.73665406849542, 0, 0)
48 SketchLine_7.setAuxiliary(True)
49 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
50 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_7.endPoint())
51 SketchLine_8 = Sketch_1.addLine(-21.08194442253927, 8.656344751543489, 0, 0)
52 SketchLine_8.setAuxiliary(True)
53 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_8.startPoint())
54 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_8.endPoint())
55 SketchLine_9 = Sketch_1.addLine(0, 30, 0, 0)
56 SketchLine_9.setAuxiliary(True)
57 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_9.startPoint())
58 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_9.endPoint())
59 SketchLine_10 = Sketch_1.addLine(25.98076211353316, 15, 0, 0)
60 SketchLine_10.setAuxiliary(True)
61 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_10.startPoint())
62 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_10.endPoint())
63 SketchLine_11 = Sketch_1.addLine(18.03758667002239, -13.92932705531892, 0, 0)
64 SketchLine_11.setAuxiliary(True)
65 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_11.startPoint())
66 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_11.endPoint())
67 SketchConstraintEqual_5 = Sketch_1.setEqual(SketchLine_7.result(), SketchLine_8.result())
68 SketchConstraintEqual_6 = Sketch_1.setEqual(SketchLine_11.result(), SketchLine_7.result())
69 SketchConstraintEqual_7 = Sketch_1.setEqual(SketchLine_10.result(), SketchLine_9.result())
70 SketchConstraintEqual_8 = Sketch_1.setEqual(SketchLine_10.result(), SketchLine_3.result())
71 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 30)
72 model.do()
73 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection(), 10, 0)
74 model.do()
75 # Two filters TopoConnectedFaces and not horizontal to search lateral face connected to two selected faces
76 Filters = model.filters(Part_1_doc, [
77   model.addFilter(name = "TopoConnectedFaces", args = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5"), False]),
78   model.addFilter(name = "HorizontalFaces", exclude = True),
79   model.addFilter(name = "TopoConnectedFaces", args = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), False])])
80 model.end()
81
82 Result = Extrusion_1.feature().firstResult()
83 exp = GeomAPI_ShapeExplorer(Result.shape(), GeomAPI_Shape.FACE)
84 Reference = {}
85 # 1 face is in result - between two selected faces for filters
86 Reference[model.selection(Result, exp.current())] = False; exp.next()
87 Reference[model.selection(Result, exp.current())] = False;  exp.next()
88 Reference[model.selection(Result, exp.current())] = True; exp.next()
89 Reference[model.selection(Result, exp.current())] = False;  exp.next()
90 Reference[model.selection(Result, exp.current())] = False;  exp.next()
91 Reference[model.selection(Result, exp.current())] = False;  exp.next()
92 Reference[model.selection(Result, exp.current())] = False;  exp.next()
93
94 model.checkFilter(Part_1_doc, model, Filters, Reference)