Back to index

salome-geom  6.5.0
GEOM_Partition1.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
00025 #  File   : GEOM_Partition1.py
00026 #  Module : GEOM
00027 # appel:
00028 # import alveole_3D_01_GEOM
00029 # reload(alveole_3D_01_GEOM)
00030 # -- Rayon de la bariere
00031 #
00032 barier_height = 7.0
00033 barier_radius = 5.6 / 2 # Rayon de la bariere
00034 colis_radius = 1.0 / 2  # Rayon du colis
00035 colis_step = 2.0        # Distance s‰parant deux colis
00036 cc_width = 0.11         # Epaisseur du complement de colisage
00037 
00038 # --
00039 
00040 cc_radius = colis_radius + cc_width
00041 from math import sqrt
00042 colis_center = sqrt(2.0)*colis_step/2
00043 
00044 # --
00045 
00046 import geompy
00047 geom = geompy.geom
00048 
00049 boolean_common  = 1
00050 boolean_cut     = 2
00051 boolean_fuse    = 3
00052 boolean_section = 4
00053 
00054 # --
00055 
00056 pnt0 = geompy.MakeVertex(0.,0.,0.)
00057 vecz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
00058 
00059 barier = geompy.MakeCylinder(
00060     pnt0,
00061     vecz,
00062     barier_radius,
00063     barier_height)
00064 
00065 # --
00066 
00067 colis = geompy.MakeCylinder(pnt0, vecz, colis_radius, barier_height)
00068 
00069 cc = geompy.MakeCylinder(pnt0, vecz, cc_radius, barier_height)
00070 
00071 colis_cc = geompy.MakeCompound([colis, cc])
00072 
00073 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
00074 
00075 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vecz, 4)
00076 
00077 # --
00078 
00079 Compound1 = geompy.MakeCompound([colis_cc_multi, barier])
00080 SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"])
00081 alveole = geompy.MakePartition(SubShape_theShape)
00082 #alveole = geompy.MakePartition([colis_cc_multi, barier])
00083 
00084 geompy.addToStudy(alveole, "alveole before explode")
00085 
00086 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
00087 
00088 ## there are 9 sub-shapes
00089 
00090 comp1 = geompy.MakeCompound([subshapes[0], subshapes[1]]);
00091 comp2 = geompy.MakeCompound([subshapes[2], subshapes[3]]);
00092 comp3 = geompy.MakeCompound([subshapes[4], subshapes[5]]);
00093 comp4 = geompy.MakeCompound([subshapes[6], subshapes[7]]);
00094 
00095 compGOs = []
00096 compGOs.append(comp1);
00097 compGOs.append(comp2);
00098 compGOs.append(comp3);
00099 compGOs.append(comp4);
00100 comp = geompy.MakeCompound(compGOs);
00101 
00102 alveole = geompy.MakeCompound([comp, subshapes[8]]);
00103 
00104 geompy.addToStudy(alveole, "alveole")