Salome HOME
faa30a89ce9934893629ef7e639303451d2c3bd1
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_ExternalFaces_Exclude2.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 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
29 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
30 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
31 SketchLine_1 = Sketch_1.addLine(15, 2, 5, 2)
32 SketchLine_2 = Sketch_1.addLine(5, 2, 5, 8)
33 SketchLine_3 = Sketch_1.addLine(5, 8, 15, 8)
34 SketchLine_4 = Sketch_1.addLine(15, 8, 15, 2)
35 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
36 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
38 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
39 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
40 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
41 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
42 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
43 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
44 SketchPoint_1 = SketchProjection_1.createdFeature()
45 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_2.result(), 5, True)
46 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_4.result(), 15, True)
47 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.result(), 2, True)
48 SketchConstraintDistance_4 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.result(), 8, True)
49 model.do()
50 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
51 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Face_1_1")], keepSubResults = True)
52 Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces", exclude = True)])
53 model.end()
54
55 Reference = {}
56
57 ResultPartition = Partition_1.result().resultSubShapePair()[0]
58 exp = GeomAPI_ShapeExplorer(ResultPartition.shape(), GeomAPI_Shape.FACE)
59 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
60 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
61 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
62 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
63 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
64 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
65 Reference[model.selection(ResultPartition, exp.current())] = True;  exp.next()
66 Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
67 assert(not exp.more())
68
69 model.checkFilter(Part_1_doc, model, Filters, Reference)