Back to index

salome-geom  6.5.0
GEOM_cyl2complementary.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 #==============================================================================
00025 #  Info.
00026 #  Bug (from script, bug)   : cyl2complementary_modified.py, PAL6700
00027 #  Modified                 : 25/11/2004
00028 #  Author                   : Kovaltchuk Alexey
00029 #  Project                  : PAL/SALOME
00030 #==============================================================================
00031 # Import
00032 # ------
00033 #
00034 import salome
00035 import geompy
00036 geomgui = salome.ImportComponentGUI("GEOM") 
00037 import salome_ComponentGUI
00038 def addToStudy(shape, name):
00039     i = geompy.addToStudy(shape, name)
00040     salome.sg.updateObjBrowser(0)
00041     if not isinstance(geomgui, type(salome_ComponentGUI)):
00042         geomgui.createAndDisplayGO(i)
00043     return i
00044 
00045 # Piece
00046 # -----
00047 
00048 # Creer la geometrie en bloc hexahedrique d'un parallelepipede troue d'une piece en forme de T composee de 2 cylindres de diametre different dont les axes se coupent orthogonalement,
00049 # puis mailler en hexahedrique.
00050 
00051 gx = 0
00052 gy = 0
00053 gz = 0
00054 
00055 g_dx = 250
00056 g_dy = 200
00057 g_dz = 150
00058 
00059 g_rayonGrand = 70
00060 g_rayonPetit = 50
00061 
00062 # Geometrie
00063 # =========
00064 
00065 # Le parallelepipede
00066 # ------------------
00067 
00068 p_boite = geompy.MakeBox(gx-g_dx, gy-g_dy, gz-g_dz,  gx+g_dx, gy+g_dy, gz+g_dz)
00069 
00070 # Le grand cylindre
00071 # -----------------
00072 
00073 g_base = geompy.MakeVertex(gx-g_dx, gy, gz)
00074 g_dir  = geompy.MakeVectorDXDYDZ(1, 0, 0)
00075 g_cyl  = geompy.MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
00076 
00077 # Le petit cylindre
00078 # -----------------
00079 
00080 c_base = geompy.MakeVertex(gx, gy, gz)
00081 c_dir  = geompy.MakeVectorDXDYDZ(0, 0, 1)
00082 c_cyl  = geompy.MakeCylinder(c_base, c_dir, g_rayonPetit, g_dz)
00083 
00084 # Le parallelepipede troue
00085 # ------------------------
00086 
00087 t_boite1 = geompy.MakeBoolean(p_boite , g_cyl, 2)
00088 t_boite  = geompy.MakeBoolean(t_boite1, c_cyl, 2)
00089 
00090 # Partitionner
00091 # ------------
00092 
00093 p_tools = []
00094 
00095 p_tools.append(geompy.MakePlane(c_base, geompy.MakeVectorDXDYDZ(0,  g_dz, g_dy), 10))
00096 p_tools.append(geompy.MakePlane(c_base, geompy.MakeVectorDXDYDZ(0, -g_dz, g_dy), 10))
00097 
00098 p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx-g_rayonPetit, 0, 0), geompy.MakeVectorDXDYDZ(1, 0, 0), 10))
00099 p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx+g_rayonPetit, 0, 0), geompy.MakeVectorDXDYDZ(1, 0, 0), 10))
00100 
00101 addToStudy(t_boite, "t_boite")
00102 
00103 p_element = geompy.MakePartition([t_boite], p_tools, [], [], 4, 0, [], 0)
00104 
00105 # Compound
00106 # --------
00107 
00108 # Ajouter la piece dans l'etude
00109 # -----------------------------
00110 
00111 idpiece = addToStudy(p_element, "BoxHoled2Cylinders")