Back to index

salome-smesh  6.5.0
ex08_hole2build.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 twice holed cube build by points, edges, faces and solids
00034 
00035 # Values
00036 # ------
00037 
00038 ox = 0
00039 oy = 0
00040 oz = 0
00041 
00042 longueur = 200
00043 largeur  = 100
00044 hauteur  =  80
00045 
00046 cylindre = 50
00047 
00048 rayon = 20
00049 
00050 # Points
00051 # ------
00052 
00053 piecePoint1 = MakeVertex(ox         , oy, oz)
00054 piecePoint2 = MakeVertex(ox+longueur, oy, oz)
00055 piecePoint3 = MakeVertex(ox+longueur, oy, oz+largeur)
00056 piecePoint4 = MakeVertex(ox         , oy, oz+largeur)
00057 
00058 cz = oz+largeur/2
00059 
00060 cylPoint1    = MakeVertex(ox+cylindre         , oy, cz-rayon)
00061 cylPoint2    = MakeVertex(ox+longueur-cylindre, oy, cz-rayon)
00062 cylPoint3    = MakeVertex(ox+longueur-cylindre, oy, cz+rayon)
00063 cylPoint4    = MakeVertex(ox+cylindre         , oy, cz+rayon)
00064 
00065 # Edges
00066 # -----
00067 
00068 pieceEdge1 = MakeEdge(piecePoint1, piecePoint4)
00069 pieceEdge2 = MakeEdge(piecePoint1, cylPoint1)
00070 pieceEdge3 = MakeEdge(piecePoint4, cylPoint4)
00071 
00072 pieceEdge4 = MakeEdge(piecePoint2, piecePoint3)
00073 pieceEdge5 = MakeEdge(piecePoint2, cylPoint2)
00074 pieceEdge6 = MakeEdge(piecePoint3, cylPoint3)
00075 
00076 pieceEdge7 = MakeEdge(cylPoint1, cylPoint2)
00077 pieceEdge8 = MakeEdge(cylPoint3, cylPoint4)
00078 
00079 cylEdge1 = MakeArc(cylPoint1, MakeVertex(ox+cylindre-rayon         , oy, cz), cylPoint4)
00080 cylEdge2 = MakeArc(cylPoint1, MakeVertex(ox+cylindre+rayon         , oy, cz), cylPoint4)
00081 cylEdge3 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre-rayon, oy, cz), cylPoint3)
00082 cylEdge4 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre+rayon, oy, cz), cylPoint3)
00083 
00084 # Faces
00085 # -----
00086 
00087 pieceFace1 = MakeQuad4Vertices(piecePoint1, piecePoint2, cylPoint2 , cylPoint1 )
00088 pieceFace2 = MakeQuad         (pieceEdge1 , pieceEdge2 , cylEdge1  , pieceEdge3)
00089 pieceFace3 = MakeQuad4Vertices(piecePoint3, piecePoint4, cylPoint4 , cylPoint3 )
00090 pieceFace4 = MakeQuad         (pieceEdge4 , pieceEdge5 , cylEdge4  , pieceEdge6)
00091 pieceFace5 = MakeQuad         (pieceEdge7 , cylEdge3   , pieceEdge8, cylEdge2  )
00092 
00093 # Solids
00094 # ------
00095 
00096 pieceVector = MakeVectorDXDYDZ(0, 1, 0)
00097 
00098 pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
00099 pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
00100 pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
00101 pieceSolid4 = MakePrismVecH(pieceFace4, pieceVector, hauteur)
00102 pieceSolid5 = MakePrismVecH(pieceFace5, pieceVector, hauteur)
00103 
00104 # Compound and glue
00105 # -----------------
00106 
00107 c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3, pieceSolid4, pieceSolid5])
00108 
00109 piece = MakeGlueFaces(c_cpd, 1.e-5)
00110 
00111 # Add in study
00112 # ------------
00113 
00114 piece_id = addToStudy(piece, "ex08_hole2build")
00115 
00116 # Meshing
00117 # =======
00118 
00119 smesh.SetCurrentStudy(salome.myStudy)
00120 
00121 # Create a hexahedral mesh
00122 # ------------------------
00123 
00124 hexa = smesh.Mesh(piece, "ex08_hole2build:hexa")
00125 
00126 algo = hexa.Segment()
00127 algo.NumberOfSegments(7)
00128 
00129 hexa.Quadrangle()
00130 
00131 hexa.Hexahedron()
00132 
00133 # Mesh calculus
00134 # -------------
00135 
00136 hexa.Compute()