Back to index

salome-smesh  6.5.0
ex07_hole1partition.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 #
00026 from geompy import *
00027 
00028 import smesh
00029 
00030 # Geometry
00031 # ========
00032 
00033 # A holed cube build by partitioning geometric operations
00034 
00035 # Values
00036 # ------
00037 
00038 g_x = 0
00039 g_y = 0
00040 g_z = 0
00041 
00042 g_longueur = 50.0
00043 g_largeur  = 40.0
00044 g_hauteur  = 25.0
00045 
00046 g_rayon = 10
00047 
00048 g_trim = 1000
00049 
00050 # Box
00051 # ---
00052 
00053 b_boite = MakeBox(g_x-g_longueur, g_y-g_hauteur, g_z-g_largeur,  g_x+g_longueur, g_y+g_hauteur, g_z+g_largeur)
00054 
00055 # Cylinder
00056 # --------
00057 
00058 c_axe = MakeVectorDXDYDZ(0, 1, 0)
00059 
00060 c_cyl = MakeCylinder(MakeVertex(g_x, g_y-g_hauteur, g_z), c_axe, g_rayon, g_hauteur*2)
00061 
00062 c_piece = MakeCut(b_boite, c_cyl)
00063 
00064 # Partition and reperation
00065 # ------------------------
00066 
00067 p_centre = MakeVertex(g_x, g_y, g_z)
00068 
00069 p_tools = []
00070 p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ( g_largeur, 0, g_longueur), g_trim))
00071 p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ(-g_largeur, 0, g_longueur), g_trim))
00072 
00073 p_part = MakePartition([c_piece], p_tools, [], [], ShapeType["SOLID"])
00074 
00075 p_blocs = RemoveExtraEdges(p_part, doUnionFaces=True)
00076 piece   = MakeGlueFaces(p_blocs, 1.e-5)
00077 
00078 # Add in study
00079 # ------------
00080 
00081 piece_id = addToStudy(piece, "ex07_hole1partition")
00082 
00083 # Meshing
00084 # =======
00085 
00086 smesh.SetCurrentStudy(salome.myStudy)
00087 
00088 # Create a hexahedral mesh
00089 # ------------------------
00090 
00091 hexa = smesh.Mesh(piece, "ex07_hole1partition:hexa")
00092 
00093 algo = hexa.Segment()
00094 algo.NumberOfSegments(20)
00095 
00096 hexa.Quadrangle()
00097 
00098 hexa.Hexahedron()
00099 
00100 # Mesh calculus
00101 # -------------
00102 
00103 hexa.Compute()