Salome HOME
5fc397146dad72574053c3b976d708374a6d432e
[modules/geom.git] / src / GEOM_SWIG / GEOM_Partition1.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 #  GEOM GEOM_SWIG : binding of C++ implementation with Python
25 #  File   : GEOM_Partition1.py
26 #  Module : GEOM
27 # appel:
28 # import alveole_3D_01_GEOM
29 # reload(alveole_3D_01_GEOM)
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�parant 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 salome
47 salome.salome_init()
48 import GEOM
49 from salome.geom import geomBuilder
50 geompy = geomBuilder.New()
51
52 boolean_common  = 1
53 boolean_cut     = 2
54 boolean_fuse    = 3
55 boolean_section = 4
56
57 # --
58
59 pnt0 = geompy.MakeVertex(0.,0.,0.)
60 vecz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
61
62 barier = geompy.MakeCylinder(
63     pnt0,
64     vecz,
65     barier_radius,
66     barier_height)
67
68 # --
69
70 colis = geompy.MakeCylinder(pnt0, vecz, colis_radius, barier_height)
71
72 cc = geompy.MakeCylinder(pnt0, vecz, cc_radius, barier_height)
73
74 colis_cc = geompy.MakeCompound([colis, cc])
75
76 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
77
78 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vecz, 4)
79
80 # --
81
82 Compound1 = geompy.MakeCompound([colis_cc_multi, barier])
83 SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"])
84 alveole = geompy.MakePartition(SubShape_theShape)
85 #alveole = geompy.MakePartition([colis_cc_multi, barier])
86
87 geompy.addToStudy(alveole, "alveole before explode")
88
89 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
90
91 ## there are 9 sub-shapes
92
93 comp1 = geompy.MakeCompound([subshapes[0], subshapes[1]]);
94 comp2 = geompy.MakeCompound([subshapes[2], subshapes[3]]);
95 comp3 = geompy.MakeCompound([subshapes[4], subshapes[5]]);
96 comp4 = geompy.MakeCompound([subshapes[6], subshapes[7]]);
97
98 compGOs = []
99 compGOs.append(comp1);
100 compGOs.append(comp2);
101 compGOs.append(comp3);
102 compGOs.append(comp4);
103 comp = geompy.MakeCompound(compGOs);
104
105 alveole = geompy.MakeCompound([comp, subshapes[8]]);
106
107 geompy.addToStudy(alveole, "alveole")