Salome HOME
NRI : First integration.
[modules/geom.git] / src / GEOM_SWIG / GEOM_Partition1.py
1 #%Make geometry (like CEA script (A1)) using Partition algorithm%
2 # appel: 
3 # import alveole_3D_01_GEOM
4 # reload(alveole_3D_01_GEOM)
5
6 # -- Rayon de la bariere
7
8 barier_height = 7.0
9 barier_radius = 5.6 / 2 # Rayon de la bariere
10 colis_radius = 1.0 / 2  # Rayon du colis
11 colis_step = 2.0        # Distance s\89parant deux colis
12 cc_width = 0.11         # Epaisseur du complement de colisage
13
14 # --
15
16 cc_radius = colis_radius + cc_width
17 from math import sqrt
18 colis_center = sqrt(2.0)*colis_step/2
19
20 # --
21
22 import geompy
23 geom = geompy.geom
24
25 boolean_common  = 1
26 boolean_cut     = 2
27 boolean_fuse    = 3
28 boolean_section = 4
29
30 # --
31
32 barier = geompy.MakeCylinder(
33     geom.MakePointStruct(0.,0.,0.),
34     geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
35     barier_radius,
36     barier_height)
37
38 # --
39
40 colis = geompy.MakeCylinder(
41     geom.MakePointStruct(0.,0.,0.),
42     geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
43     colis_radius,
44     barier_height)
45
46 cc = geompy.MakeCylinder(
47     geom.MakePointStruct(0.,0.,0.),
48     geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
49     cc_radius,
50     barier_height)
51
52 colis_cc = geompy.MakeCompound(
53     [colis._get_Name(), cc._get_Name()])
54
55 colis_cc = geompy.MakeTranslation(
56     colis_cc, colis_center, 0.0, 0.0)
57
58 colis_cc_multi = geompy.MakeMultiRotation1D(
59     colis_cc,
60     geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
61     geom.MakePointStruct(0.,0.,0.),
62     4)
63
64 # --
65
66 alveole = geompy.Partition(
67     [colis_cc_multi._get_Name(), barier._get_Name()])
68
69 subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] )
70
71 ## there are 9 subshapes
72
73 comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] );
74 comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] );
75 comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] );
76 comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] );
77
78 compIORs = []
79 compIORs.append( comp1._get_Name() );
80 compIORs.append( comp2._get_Name() );
81 compIORs.append( comp3._get_Name() );
82 compIORs.append( comp4._get_Name() );
83 comp = geompy.MakeCompound( compIORs );
84
85 alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]);
86         
87 geompy.addToStudy(alveole, "alveole")
88
89