Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/geom.git] / src / GEOM_SWIG / GEOM_Partition1.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
23 #  File   : GEOM_Partition1.py
24 #  Module : GEOM
25 # appel:
26 # import alveole_3D_01_GEOM
27 # reload(alveole_3D_01_GEOM)
28 # -- Rayon de la bariere
29 #
30 barier_height = 7.0
31 barier_radius = 5.6 / 2 # Rayon de la bariere
32 colis_radius = 1.0 / 2  # Rayon du colis
33 colis_step = 2.0        # Distance s\89parant deux colis
34 cc_width = 0.11         # Epaisseur du complement de colisage
35
36 # --
37
38 cc_radius = colis_radius + cc_width
39 from math import sqrt
40 colis_center = sqrt(2.0)*colis_step/2
41
42 # --
43
44 import geompy
45 geom = geompy.geom
46
47 boolean_common  = 1
48 boolean_cut     = 2
49 boolean_fuse    = 3
50 boolean_section = 4
51
52 # --
53
54 pnt0 = geompy.MakeVertex(0.,0.,0.)
55 vecz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
56
57 barier = geompy.MakeCylinder(
58     pnt0,
59     vecz,
60     barier_radius,
61     barier_height)
62
63 # --
64
65 colis = geompy.MakeCylinder(pnt0, vecz, colis_radius, barier_height)
66
67 cc = geompy.MakeCylinder(pnt0, vecz, cc_radius, barier_height)
68
69 colis_cc = geompy.MakeCompound([colis, cc])
70
71 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
72
73 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vecz, 4)
74
75 # --
76
77 Compound1 = geompy.MakeCompound([colis_cc_multi, barier])
78 SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"])
79 alveole = geompy.MakePartition(SubShape_theShape)
80 #alveole = geompy.MakePartition([colis_cc_multi, barier])
81
82 geompy.addToStudy(alveole, "alveole before explode")
83
84 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
85
86 ## there are 9 subshapes
87
88 comp1 = geompy.MakeCompound([subshapes[0], subshapes[1]]);
89 comp2 = geompy.MakeCompound([subshapes[2], subshapes[3]]);
90 comp3 = geompy.MakeCompound([subshapes[4], subshapes[5]]);
91 comp4 = geompy.MakeCompound([subshapes[6], subshapes[7]]);
92
93 compGOs = []
94 compGOs.append(comp1);
95 compGOs.append(comp2);
96 compGOs.append(comp3);
97 compGOs.append(comp4);
98 comp = geompy.MakeCompound(compGOs);
99
100 alveole = geompy.MakeCompound([comp, subshapes[8]]);
101
102 geompy.addToStudy(alveole, "alveole")