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