Back to index

salome-smesh  6.5.0
ex05_hole1build.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 import math
00031 
00032 # Geometry
00033 # ========
00034 
00035 # A centered holed cube build by  build by points, edges, faces and solids
00036 
00037 # Values
00038 # ------
00039 
00040 ox = 0
00041 oy = 0
00042 oz = 0
00043 
00044 longueur = 100
00045 largeur  =  80
00046 hauteur  =  50
00047 
00048 rayon = 10
00049 
00050 # Points
00051 # ------
00052 
00053 basePoint111 = MakeVertex(ox         ,  oy, oz)
00054 basePoint211 = MakeVertex(ox+longueur,  oy, oz)
00055 basePoint112 = MakeVertex(ox         ,  oy, oz+largeur)
00056 basePoint212 = MakeVertex(ox+longueur,  oy, oz+largeur)
00057 
00058 cx = ox+longueur/2
00059 cy = oy
00060 cz = oz+largeur/2
00061 
00062 ll = longueur/largeur
00063 ll = ll*ll
00064 dx = rayon/math.sqrt(1+ll)
00065 dz = rayon/math.sqrt(1+1/ll)
00066 
00067 circlePoint1 = MakeVertex(cx-dx, cy, cz-dz)
00068 circlePoint2 = MakeVertex(cx+dx, cy, cz-dz)
00069 circlePoint3 = MakeVertex(cx+dx, cy, cz+dz)
00070 circlePoint4 = MakeVertex(cx-dx, cy, cz+dz)
00071 
00072 # Edges
00073 # -----
00074 
00075 squareEdge1 = MakeEdge(basePoint111, basePoint211)
00076 squareEdge2 = MakeEdge(basePoint211, basePoint212)
00077 squareEdge3 = MakeEdge(basePoint212, basePoint112)
00078 squareEdge4 = MakeEdge(basePoint112, basePoint111)
00079 
00080 diagEdge1   = MakeEdge(basePoint111, circlePoint1)
00081 diagEdge2   = MakeEdge(basePoint211, circlePoint2)
00082 diagEdge3   = MakeEdge(basePoint212, circlePoint3)
00083 diagEdge4   = MakeEdge(basePoint112, circlePoint4)
00084 
00085 arcEdge1    = MakeArc(circlePoint1, MakeVertex(cx      , cy, cz-rayon), circlePoint2)
00086 arcEdge2    = MakeArc(circlePoint2, MakeVertex(cx+rayon, cy, cz      ), circlePoint3)
00087 arcEdge3    = MakeArc(circlePoint3, MakeVertex(cx      , cy, cz+rayon), circlePoint4)
00088 arcEdge4    = MakeArc(circlePoint4, MakeVertex(cx-rayon, cy, cz      ), circlePoint1)
00089 
00090 # Faces
00091 # -----
00092 
00093 baseFace1 = MakeQuad(squareEdge1, diagEdge2, arcEdge1, diagEdge1)
00094 baseFace2 = MakeQuad(squareEdge2, diagEdge3, arcEdge2, diagEdge2)
00095 baseFace3 = MakeQuad(squareEdge3, diagEdge4, arcEdge3, diagEdge3)
00096 baseFace4 = MakeQuad(squareEdge4, diagEdge1, arcEdge4, diagEdge4)
00097 
00098 # Solids
00099 # ------
00100 
00101 baseVector = MakeVectorDXDYDZ(0, 1, 0)
00102 
00103 baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur)
00104 baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur)
00105 baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur)
00106 baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur)
00107 
00108 # Compound
00109 # --------
00110 
00111 c_l = []
00112 c_l.append(baseSolid1)
00113 c_l.append(baseSolid2)
00114 c_l.append(baseSolid3)
00115 c_l.append(baseSolid4)
00116 
00117 c_cpd = MakeCompound(c_l)
00118 piece = MakeGlueFaces(c_cpd, 1.e-5)
00119 
00120 # Add in study
00121 # ------------
00122 
00123 piece_id = addToStudy(piece, "ex05_hole1build")
00124 
00125 # Meshing
00126 # =======
00127 
00128 smesh.SetCurrentStudy(salome.myStudy)
00129 
00130 # Create a hexahedral mesh
00131 # ------------------------
00132 
00133 hexa = smesh.Mesh(piece, "ex05_hole1build:hexa")
00134 
00135 algo = hexa.Segment()
00136 
00137 algo.NumberOfSegments(6, 3)
00138 
00139 hexa.Quadrangle()
00140 
00141 hexa.Hexahedron()
00142 
00143 # Mesh calculus
00144 # -------------
00145 
00146 hexa.Compute()