Back to index

salome-smesh  6.5.0
SMESH_hexaedre.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 #  Info.
00026 #  Bug (from script, bug)   : hexaedre_modified.py, PAL6194, PAL7153
00027 #  Modified                 : 25/11/2004
00028 #  Author                   : Kovaltchuk Alexey
00029 #  Project                  : PAL/SALOME
00030 #==============================================================================
00031 #
00032 import salome
00033 import geompy
00034 import smesh
00035 
00036 import math
00037 
00038 # -----------------------------------------------------------------------------
00039 
00040 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
00041 myBuilder = salome.myStudy.NewBuilder()
00042 gg = salome.ImportComponentGUI("GEOM")
00043 
00044 ShapeTypeCompSolid = 1
00045 ShapeTypeSolid     = 2
00046 ShapeTypeShell     = 3
00047 ShapeTypeFace      = 4
00048 ShapeTypeWire      = 5
00049 ShapeTypeEdge      = 6
00050 ShapeTypeVertex    = 7
00051 
00052 Boolop_common = 1
00053 Boolop_cut = 2
00054 Boolop_fuse = 3
00055 Boolop_section = 4
00056 
00057 p0 = geompy.MakeVertex(0., 0., 0.)
00058 px = geompy.MakeVertex(100., 0., 0.)
00059 py = geompy.MakeVertex(0., 100., 0.)
00060 pz = geompy.MakeVertex(0., 0., 100.)
00061 vx = geompy.MakeVector(p0, px)
00062 vy = geompy.MakeVector(p0, py)
00063 vz = geompy.MakeVector(p0, pz)
00064 
00065 sphereExt = geompy.MakeSphere(    0.,  0.,  0., 400.)
00066 sphereInt = geompy.MakeSphere(    0.,-50.,  0., 350.)
00067 sphereA   = geompy.MakeSphere( -400., 50., 50., 400.)
00068 sphereB   = geompy.MakeSphere(  350.,-50.,-50., 350.)
00069 ptcyle    = geompy.MakeVertex(0., -300., -450.)
00070 cylindre  = geompy.MakeCylinder(ptcyle,vz,500.,900.)
00071 
00072 vol1=geompy.MakeCut(sphereExt,sphereA)
00073 vol2=geompy.MakeCut(vol1,sphereB)
00074 vol3=geompy.MakeCut(vol2,cylindre)
00075 blob=geompy.MakeCut(vol3,sphereInt)
00076 
00077 idblob = geompy.addToStudy(blob,"blob")
00078 
00079 aretes = []
00080 aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge)
00081 eid=0
00082 
00083 # -------------------------------
00084 # --- numerotation des aretes
00085 ##for edge in aretes:
00086 ##    edname="arete%d"%eid
00087 ##    idedge=geompy.addToStudy(edge,edname)
00088 ##    eid=eid+1
00089 
00090 salome.sg.updateObjBrowser(1)
00091 
00092 # --- epaisseur 0 2 8 10
00093 # --- hauteur   1 3 9 11
00094 # --- largeur   4 5 6 7
00095 
00096 # -----------------------------------------------------------------------------
00097 
00098 print "-------------------------- mesh"
00099 smesh.SetCurrentStudy(salome.myStudy)
00100 
00101 # ---- init a Mesh with the geom shape
00102 shape_mesh = blob
00103 mesh=smesh.Mesh(shape_mesh, "MeshBlob")
00104 
00105 # ---- add hypothesis and algorithms to mesh
00106 print "-------------------------- add hypothesis to mesh"
00107 algo1 = mesh.Segment()
00108 algo2 = mesh.Quadrangle()
00109 algo3 = mesh.Hexahedron()
00110 
00111 numberOfSegmentsA = 4
00112 
00113 algo = mesh.Segment(aretes[0])
00114 algo.NumberOfSegments(numberOfSegmentsA)
00115 algo = mesh.Segment(aretes[2])
00116 algo.NumberOfSegments(numberOfSegmentsA)
00117 algo = mesh.Segment(aretes[8])
00118 algo.NumberOfSegments(numberOfSegmentsA)
00119 algo = mesh.Segment(aretes[10])
00120 algo.NumberOfSegments(numberOfSegmentsA)
00121 
00122 
00123 numberOfSegmentsC = 15
00124 
00125 algo = mesh.Segment(aretes[1])
00126 algo.NumberOfSegments(numberOfSegmentsC)
00127 algo = mesh.Segment(aretes[3])
00128 algo.NumberOfSegments(numberOfSegmentsC)
00129 algo = mesh.Segment(aretes[9])
00130 algo.NumberOfSegments(numberOfSegmentsC)
00131 algo = mesh.Segment(aretes[11])
00132 algo.NumberOfSegments(numberOfSegmentsC)
00133 
00134 
00135 numberOfSegmentsB = 10
00136 algo = mesh.Segment(aretes[4])
00137 algo.NumberOfSegments(numberOfSegmentsB)
00138 algo = mesh.Segment(aretes[5])
00139 algo.NumberOfSegments(numberOfSegmentsB)
00140 algo = mesh.Segment(aretes[6])
00141 algo.NumberOfSegments(numberOfSegmentsB)
00142 algo = mesh.Segment(aretes[7])
00143 algo.NumberOfSegments(numberOfSegmentsB)
00144 
00145 
00146 # ---- compute mesh
00147 
00148 print "-------------------------- compute mesh"
00149 ret=mesh.Compute()
00150 print ret
00151 if ret != 0:
00152     #log=mesh.GetLog(0) # no erase trace
00153     #for linelog in log:
00154     #    print linelog
00155     print "Information about the Mesh:"
00156     print "Number of nodes       : ", mesh.NbNodes()
00157     print "Number of edges       : ", mesh.NbEdges()
00158     print "Number of faces       : ", mesh.NbFaces()
00159     print "Number of quadrangles : ", mesh.NbQuadrangles()
00160     print "Number of volumes     : ", mesh.NbVolumes()
00161     print "Number of hexahedrons : ", mesh.NbHexas()
00162 else:
00163     print "problem when Computing the mesh"
00164 
00165 salome.sg.updateObjBrowser(1)