Salome HOME
Merge multi-study removal branch.
[modules/geom.git] / doc / salome / examples / basic_operations_ex04.py
1 # Get shared sub-shapes
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8 import SALOMEDS
9
10 # create a box and partigion it by two planes
11 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
12 p = geompy.MakeVertex(100, 100, 100)
13 v1 = geompy.MakeVectorDXDYDZ(1, 1, 0)
14 v2 = geompy.MakeVectorDXDYDZ(1, -1, 0)
15 pln1 = geompy.MakePlane(p, v1, 2000)
16 pln2 = geompy.MakePlane(p, v2, 2000)
17 partition = geompy.MakePartition([box], [pln1, pln2])
18
19 # extract solids from result of partition
20 solids = geompy.SubShapeAllSorted(partition, geompy.ShapeType['SOLID'])
21
22 # get shared shapes from the partition (compound of 4 solids)
23 # a) faces that are shared by all 4 solids (0 found)
24 pF_T = geompy.GetSharedShapesMulti(partition, geompy.ShapeType['FACE'])
25 # b) faces that are shared by any couple of solids (4 found)
26 pF_F = geompy.GetSharedShapesMulti(partition, geompy.ShapeType['FACE'], False)
27 # c) edges that are shared by all 4 solids (1 found)
28 pE_T = geompy.GetSharedShapesMulti(partition, geompy.ShapeType['EDGE'])
29 # d) edges that are shared by any couple of solids (13 found)
30 pE_F = geompy.GetSharedShapesMulti(partition, geompy.ShapeType['EDGE'], False)
31
32 # get shared shapes from the list of solids
33 # a) faces that are shared by all 4 solids (0 found)
34 sF_T = geompy.GetSharedShapesMulti(solids, geompy.ShapeType['FACE'])
35 # b) faces that are shared by 1st/2nd, 1st/3rd and 1st/4th solids (2 found)
36 sF_F = geompy.GetSharedShapesMulti(solids, geompy.ShapeType['FACE'], False)
37 # c) edges that are shared by all 4 solids (1 found)
38 sE_T = geompy.GetSharedShapesMulti(solids, geompy.ShapeType['EDGE'])
39 # d) edges that are shared by 1st/2nd, 1st/3rd and 1st/4th solids (7 found)
40 sE_F = geompy.GetSharedShapesMulti(solids, geompy.ShapeType['EDGE'], False)