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