Salome HOME
0023272: [CEA] Add a tolerance for basic properties computation
[modules/geom.git] / doc / salome / examples / topological_geom_objs_ex07.py
1 # Creation of a Solid(s) from connected faces
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9
10 # create a box 
11 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
12
13 # make a copy of a box translated by X coordinate
14 box_translation = geompy.MakeTranslation(box, 200, 0, 0)
15
16 # extract shells from boxes
17 box_shell = geompy.SubShapeAllSorted(box, geompy.ShapeType["SHELL"])[0]
18 box_translation_shell = geompy.SubShapeAllSorted(box_translation, geompy.ShapeType["SHELL"])[0]
19
20 # extract faces from boxes 
21 box_faces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
22 box_translation_faces = geompy.SubShapeAllSorted(box_translation, geompy.ShapeType["FACE"])
23
24 # create solids from shells
25 msf_shells_noint = geompy.MakeSolidFromConnectedFaces([box_shell, box_translation_shell],0)
26 msf_shells_int = geompy.MakeSolidFromConnectedFaces([box_shell, box_translation_shell], 1)
27
28 # create solids from faces
29 msf_faces_noint = geompy.MakeSolidFromConnectedFaces(box_faces+box_translation_faces, 0)
30 msf_faces_int = geompy.MakeSolidFromConnectedFaces(box_faces+box_translation_faces, 1)
31
32 # add objects in the study
33 id_solid_shells_noint = geompy.addToStudy(msf_shells_noint,"Solid_from_shells_no_intersect")
34 id_solid_shells_int = geompy.addToStudy(msf_shells_int,"Solid_from_shells_intersect")
35 id_solid_faces_noint = geompy.addToStudy(msf_faces_noint,"Solid_from_faces_no_intersect")
36 id_solid_faces_int = geompy.addToStudy(msf_faces_int,"Solid_from_faces_intersect")
37
38 # display the results
39 gg.createAndDisplayGO(id_solid_shells_noint)
40 gg.setDisplayMode(id_solid_shells_noint,1) 
41 gg.createAndDisplayGO(id_solid_shells_int)
42 gg.setDisplayMode(id_solid_shells_int,1) 
43 gg.createAndDisplayGO(id_solid_faces_noint)
44 gg.setDisplayMode(id_solid_faces_noint,1) 
45 gg.createAndDisplayGO(id_solid_faces_int)
46 gg.setDisplayMode(id_solid_faces_int,1)