Back to index

salome-smesh  6.5.0
ex02_cube2primitive.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 by primitive geometric functionalities
00034 
00035 # Values
00036 # ------
00037 
00038 ox = 0
00039 oy = 0
00040 oz = 0
00041 
00042 arete = 10
00043 
00044 # Points
00045 # ------
00046 
00047 blockPoint111 = MakeVertex(ox      , oy, oz)
00048 blockPoint211 = MakeVertex(ox+arete, oy, oz)
00049 blockPoint112 = MakeVertex(ox      , oy, oz+arete)
00050 blockPoint212 = MakeVertex(ox+arete, oy, oz+arete)
00051 
00052 # Face and solid
00053 # --------------
00054 
00055 blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112)
00056 
00057 blockSolid11  = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete)
00058 
00059 # Translations
00060 # ------------
00061 
00062 blockSolid21  = MakeTranslation(blockSolid11, arete, 0, 0)
00063 blockSolid31  = MakeTranslation(blockSolid21, arete, 0, 0)
00064 
00065 blockSolid12  = MakeTranslation(blockSolid11, 0, 0, arete)
00066 blockSolid22  = MakeTranslation(blockSolid12, arete, 0, 0)
00067 blockSolid32  = MakeTranslation(blockSolid22, arete, 0, 0)
00068 
00069 blockSolid13  = MakeTranslation(blockSolid12, 0, 0, arete)
00070 blockSolid23  = MakeTranslation(blockSolid13, arete, 0, 0)
00071 blockSolid33  = MakeTranslation(blockSolid23, arete, 0, 0)
00072 
00073 blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0)
00074 
00075 # Compound and glue
00076 # -----------------
00077 
00078 c_l = []
00079 c_l.append(blockSolid11)
00080 c_l.append(blockSolid21)
00081 c_l.append(blockSolid31)
00082 c_l.append(blockSolid12)
00083 c_l.append(blockSolid22)
00084 c_l.append(blockSolid32)
00085 c_l.append(blockSolid13)
00086 c_l.append(blockSolid23)
00087 c_l.append(blockSolid33)
00088 c_l.append(blockSolid111)
00089 
00090 c_cpd = MakeCompound(c_l)
00091 
00092 piece = MakeGlueFaces(c_cpd, 1.e-5)
00093 
00094 # Add in study
00095 # ------------
00096 
00097 piece_id = addToStudy(piece, "ex02_cube2primitive")
00098 
00099 # Meshing
00100 # =======
00101 
00102 smesh.SetCurrentStudy(salome.myStudy)
00103 
00104 # Create hexahedrical mesh on piece
00105 # ---------------------------------
00106 
00107 hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa")
00108 
00109 algo = hexa.Segment()
00110 algo.LocalLength(1)
00111 
00112 hexa.Quadrangle()
00113 
00114 hexa.Hexahedron()
00115 
00116 # Compute the mesh
00117 # ----------------
00118 
00119 hexa.Compute()