1 # Copyright (C) 2014-2023 CEA, EDF
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
21 Unit test of Check shared faces
23 #=========================================================================
24 # Initialization of the test
25 #=========================================================================
31 from ModelAPI import *
33 from salome.shaper import model
36 __updated__ = "2020-11-12"
39 if __name__ == '__main__':
42 partSet = model.moduleDocument()
43 Part_1 = model.addPart(partSet)
44 Part_1_doc = Part_1.document()
46 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
48 Point_2 = model.addPoint(Part_1_doc, 20, 10, 10)
50 Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "Point_1"))
52 CompSolid_1 = model.addCompSolid(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Box_2_1")])
54 Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
56 Box_4 = model.addBox(Part_1_doc, 10, 10, 10)
57 ### Create Translation
58 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "all-in-Box_4")], axis = model.selection("EDGE", "PartSet/OX"),
59 distance = 10, keepSubResults = True)
61 CompSolid_2 = model.addCompSolid(Part_1_doc, [model.selection("SOLID", "Box_3_1"), model.selection("COMPOUND", "Translation_1_1")])
63 Box_5 = model.addBox(Part_1_doc, 10, 10, 10)
64 ### Create Translation
65 Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], vector = [10, 0, 10], keepSubResults = True)
67 Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "CompSolid_1_1"), model.selection("SOLID", "Translation_2_1")])
68 Compound_1.result().setTransparency(0.5)
69 Compound_1.result().subResult(0).setTransparency(0.5)
70 Compound_1.result().subResult(0).subResult(0).setTransparency(0.5)
71 Compound_1.result().subResult(0).subResult(1).setTransparency(0.5)
72 Compound_1.result().subResult(1).setTransparency(0.5)
74 ### Create Shared_faces for compsolid
75 Shared_faces_1 = model.getSharedFaces(Part_1_doc, model.selection("COMPSOLID", "CompSolid_1_1"), "faces_compsolid")
77 ### Create Shared_faces for compound
78 Shared_faces_2 = model.getSharedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 'faces_compound')
83 assert(Part_1_doc.size("Groups") == 2)
84 Shared_faces_1_Feature = Shared_faces_1.feature()
85 assert Shared_faces_1_Feature.error() == ''
86 assert Shared_faces_1_Feature.name() == "Shared_faces_1"
88 aSelectionList = Shared_faces_1_Feature.selectionList("group_list")
89 assert aSelectionList.size() == 1
91 Shared_faces_2_Feature = Shared_faces_2.feature()
92 assert Shared_faces_2_Feature.error() == ''
93 assert Shared_faces_2_Feature.name() == "Shared_faces_2"
95 aSelectionList = Shared_faces_2_Feature.selectionList("group_list")
96 assert aSelectionList.size() == 1
98 resShape_1 = modelAPI_Result(Part_1_doc.object("Groups", 0)).shape()
99 assert(not resShape_1.isNull())
101 # the group result is a face, check that this is one face
102 aShapeExplorer = GeomAPI_ShapeExplorer(resShape_1, GeomAPI_Shape.FACE)
103 assert(aShapeExplorer.more())
104 assert(aShapeExplorer.current().isFace())
105 aShapeExplorer.next()
106 assert(not aShapeExplorer.more())
108 resShape_2 = modelAPI_Result(Part_1_doc.object("Groups", 1)).shape()
109 assert(not resShape_2.isNull())
111 # the group result is a face, check that this is one face
112 aShapeExplorer = GeomAPI_ShapeExplorer(resShape_2, GeomAPI_Shape.FACE)
113 assert(aShapeExplorer.more())
114 assert(aShapeExplorer.current().isFace())
115 aShapeExplorer.next()
116 assert(not aShapeExplorer.more())
120 #=========================================================================
122 #=========================================================================