1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2020 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, or (at your option) any later version.
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()
29 import SMESH, SALOMEDS
30 from salome.smesh import smeshBuilder
31 smesh = smeshBuilder.New()
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)
54 blob=geompy.RemoveExtraEdges(blob)
56 idblob = geompy.addToStudy(blob,"blob")
58 edgeGroups = geompy.Propagate( blob )
59 assert len( edgeGroups ) == 3
61 salome.sg.updateObjBrowser()
63 # -----------------------------------------------------------------------------
65 print("-------------------------- mesh")
68 # ---- define a mesh on the geom shape 'blob'
69 mesh=smesh.Mesh(blob, "MeshBlob")
71 # ---- assign global hypothesis and algorithms to mesh
72 print("-------------------------- add hypothesis to mesh")
73 algo1 = mesh.Segment()
74 algo2 = mesh.Quadrangle()
75 algo3 = mesh.Hexahedron()
77 # ---- assign local hypothesis and algorithms to mesh
78 for edges in edgeGroups: # loop on groups of logically parallel edges
79 length = geompy.BasicProperties( edges )[0]
80 if length < 500: nbSeg = 4
81 elif length < 2000: nbSeg = 10
83 algo = mesh.Segment( edges )
84 algo.NumberOfSegments( nbSeg )
88 print("-------------------------- compute mesh")
91 print("Information about the Mesh:")
92 print("Number of nodes : ", mesh.NbNodes())
93 print("Number of edges : ", mesh.NbEdges())
94 print("Number of faces : ", mesh.NbFaces())
95 print("Number of quadrangles : ", mesh.NbQuadrangles())
96 print("Number of volumes : ", mesh.NbVolumes())
97 print("Number of hexahedrons : ", mesh.NbHexas())
99 print("problem when Computing the mesh")
101 salome.sg.updateObjBrowser()