Back to index

salome-smesh  6.5.0
ex03_cube2partition.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 small cube centered and put on a great cube build with partition
00034 
00035 # Values
00036 # ------
00037 
00038 g_ox = 0
00039 g_oy = 0
00040 g_oz = 0
00041 
00042 g_arete = 10
00043 
00044 g_trim = 1000
00045 
00046 # Points
00047 # ------
00048 
00049 v_arete2 = g_arete*2
00050 v_arete3 = g_arete*3
00051 
00052 v_1 = MakeVertex(g_ox         , g_oy         , g_oz         )
00053 v_2 = MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3)
00054 
00055 v_3 = MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete )
00056 v_4 = MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2)
00057 
00058 # Solids
00059 # ------
00060 
00061 s_base = MakeBoxTwoPnt(v_1, v_2)
00062 s_haut = MakeBoxTwoPnt(v_3, v_4)
00063 
00064 # Partition
00065 # ---------
00066 
00067 p_dir1 = MakeVectorDXDYDZ(1, 0, 0)
00068 p_dir2 = MakeVectorDXDYDZ(0, 0, 1)
00069 p_dir3 = MakeVectorDXDYDZ(0, 1, 0)
00070 
00071 p_tools = []
00072 
00073 p_tools.append(MakePlane(v_3, p_dir1, g_trim))
00074 p_tools.append(MakePlane(v_4, p_dir1, g_trim))
00075 p_tools.append(MakePlane(v_3, p_dir2, g_trim))
00076 p_tools.append(MakePlane(v_4, p_dir2, g_trim))
00077 p_tools.append(MakePlane(v_3, p_dir3, g_trim))
00078 
00079 piece = MakePartition([s_base, s_haut], p_tools, [], [], ShapeType["SOLID"])
00080 
00081 # Study
00082 # -----
00083 
00084 piece_id = addToStudy(piece, "ex03_cube2partition")
00085 
00086 # Meshing
00087 # =======
00088 
00089 smesh.SetCurrentStudy(salome.myStudy)
00090 
00091 # Create hexahedrical mesh on piece
00092 # ---------------------------------
00093 
00094 hexa = smesh.Mesh(piece, "ex03_cube2partition:hexa")
00095 
00096 algo = hexa.Segment()
00097 algo.NumberOfSegments(5)
00098 
00099 hexa.Quadrangle()
00100 
00101 hexa.Hexahedron()
00102 
00103 # Compute the mesh
00104 # ----------------
00105 
00106 hexa.Compute()