1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 from salome.geom import geomBuilder
27 geompy = geomBuilder.New(salome.myStudy)
29 import SMESH, SALOMEDS
30 from salome.smesh import smeshBuilder
31 smesh = smeshBuilder.New(salome.myStudy)
33 # -----------------------------------------------------------------------------
35 p0 = geompy.MakeVertex(0., 0., 0.)
36 px = geompy.MakeVertex(100., 0., 0.)
37 py = geompy.MakeVertex(0., 100., 0.)
38 pz = geompy.MakeVertex(0., 0., 100.)
39 vx = geompy.MakeVector(p0, px)
40 vy = geompy.MakeVector(p0, py)
41 vz = geompy.MakeVector(p0, pz)
43 sphereExt = geompy.MakeSphere( 0., 0., 0., 400.)
44 sphereInt = geompy.MakeSphere( 0.,-50., 0., 350.)
45 sphereA = geompy.MakeSphere( -400., 50., 50., 400.)
46 sphereB = geompy.MakeSphere( 350.,-50.,-50., 350.)
47 ptcyle = geompy.MakeVertex(0., -300., -450.)
48 cylindre = geompy.MakeCylinder(ptcyle,vz,500.,900.)
50 vol1=geompy.MakeCut(sphereExt,sphereA)
51 vol2=geompy.MakeCut(vol1,sphereB)
52 vol3=geompy.MakeCut(vol2,cylindre)
53 blob=geompy.MakeCut(vol3,sphereInt)
55 idblob = geompy.addToStudy(blob,"blob")
57 edgeGroups = geompy.Propagate( blob )
58 assert len( edgeGroups ) == 3
60 salome.sg.updateObjBrowser(1)
62 # -----------------------------------------------------------------------------
64 print "-------------------------- mesh"
65 smesh.SetCurrentStudy(salome.myStudy)
67 # ---- define a mesh on the geom shape 'blob'
68 mesh=smesh.Mesh(blob, "MeshBlob")
70 # ---- assign global hypothesis and algorithms to mesh
71 print "-------------------------- add hypothesis to mesh"
72 algo1 = mesh.Segment()
73 algo2 = mesh.Quadrangle()
74 algo3 = mesh.Hexahedron()
76 # ---- assign local hypothesis and algorithms to mesh
77 for edges in edgeGroups: # loop on groups of logically parallel edges
78 length = geompy.BasicProperties( edges )[0]
79 if length < 500: nbSeg = 4
80 elif length < 2000: nbSeg = 10
82 algo = mesh.Segment( edges )
83 algo.NumberOfSegments( nbSeg )
87 print "-------------------------- compute mesh"
90 print "Information about the Mesh:"
91 print "Number of nodes : ", mesh.NbNodes()
92 print "Number of edges : ", mesh.NbEdges()
93 print "Number of faces : ", mesh.NbFaces()
94 print "Number of quadrangles : ", mesh.NbQuadrangles()
95 print "Number of volumes : ", mesh.NbVolumes()
96 print "Number of hexahedrons : ", mesh.NbHexas()
98 print "problem when Computing the mesh"
100 salome.sg.updateObjBrowser(1)