1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/
20 #==============================================================================
22 # Bug (from script, bug) : hexaedre_modified.py, PAL6194, PAL7153
23 # Modified : 25/11/2004
24 # Author : Kovaltchuk Alexey
25 # Project : PAL/SALOME
26 #==============================================================================
35 # -----------------------------------------------------------------------------
37 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 myBuilder = salome.myStudy.NewBuilder()
39 gg = salome.ImportComponentGUI("GEOM")
42 ShapeTypeCompSolid = 1
55 p0 = geompy.MakeVertex(0., 0., 0.)
56 px = geompy.MakeVertex(100., 0., 0.)
57 py = geompy.MakeVertex(0., 100., 0.)
58 pz = geompy.MakeVertex(0., 0., 100.)
59 vx = geompy.MakeVector(p0, px)
60 vy = geompy.MakeVector(p0, py)
61 vz = geompy.MakeVector(p0, pz)
63 sphereExt = geompy.MakeSphere( 0., 0., 0., 400.)
64 sphereInt = geompy.MakeSphere( 0.,-50., 0., 350.)
65 sphereA = geompy.MakeSphere( -400., 50., 50., 400.)
66 sphereB = geompy.MakeSphere( 350.,-50.,-50., 350.)
67 ptcyle = geompy.MakeVertex(0., -300., -450.)
68 cylindre = geompy.MakeCylinder(ptcyle,vz,500.,900.)
70 vol1=geompy.MakeCut(sphereExt,sphereA)
71 vol2=geompy.MakeCut(vol1,sphereB)
72 vol3=geompy.MakeCut(vol2,cylindre)
73 blob=geompy.MakeCut(vol3,sphereInt)
75 idblob = geompy.addToStudy(blob,"blob")
78 aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge)
81 # -------------------------------
82 # --- numerotation des aretes
84 ## edname="arete%d"%eid
85 ## idedge=geompy.addToStudy(edge,edname)
88 salome.sg.updateObjBrowser(1)
90 # --- epaisseur 0 2 8 10
91 # --- hauteur 1 3 9 11
94 # -----------------------------------------------------------------------------
96 print "-------------------------- mesh"
100 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
101 smesh.SetCurrentStudy(salome.myStudy)
103 # ---- create Hypothesis
104 print "-------------------------- create Hypothesis"
106 hypNbSegA=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
107 hypNbSegA.SetNumberOfSegments(numberOfSegments)
108 numberOfSegments = 10
109 hypNbSegB=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
110 hypNbSegB.SetNumberOfSegments(numberOfSegments)
111 numberOfSegments = 15
112 hypNbSegC=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
113 hypNbSegC.SetNumberOfSegments(numberOfSegments)
115 # ---- create Algorithms
116 print "-------------------------- create Algorithms"
117 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
118 quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
119 hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
121 # ---- init a Mesh with the geom shape
123 myMesh=smesh.CreateMesh(shape_mesh)
125 # ---- add hypothesis and algorithms to mesh
126 print "-------------------------- add hypothesis to mesh"
127 myMesh.AddHypothesis(shape_mesh,regular1D)
128 myMesh.AddHypothesis(shape_mesh,quad2D)
129 myMesh.AddHypothesis(shape_mesh,hexa3D)
131 #myMesh.AddHypothesis(shape_mesh,hypNbSeg)
133 myMesh.AddHypothesis(aretes[0],hypNbSegA)
134 myMesh.AddHypothesis(aretes[2],hypNbSegA)
135 myMesh.AddHypothesis(aretes[8],hypNbSegA)
136 myMesh.AddHypothesis(aretes[10],hypNbSegA)
138 myMesh.AddHypothesis(aretes[1],hypNbSegC)
139 myMesh.AddHypothesis(aretes[3],hypNbSegC)
140 myMesh.AddHypothesis(aretes[9],hypNbSegC)
141 myMesh.AddHypothesis(aretes[11],hypNbSegC)
143 myMesh.AddHypothesis(aretes[4],hypNbSegB)
144 myMesh.AddHypothesis(aretes[5],hypNbSegB)
145 myMesh.AddHypothesis(aretes[6],hypNbSegB)
146 myMesh.AddHypothesis(aretes[7],hypNbSegB)
150 print "-------------------------- compute mesh"
151 ret=smesh.Compute(myMesh, shape_mesh)
154 #log=myMesh.GetLog(0) # no erase trace
157 print "Information about the Mesh:"
158 print "Number of nodes : ", myMesh.NbNodes()
159 print "Number of edges : ", myMesh.NbEdges()
160 print "Number of faces : ", myMesh.NbFaces()
161 print "Number of quadrangles : ", myMesh.NbQuadrangles()
162 print "Number of volumes : ", myMesh.NbVolumes()
163 print "Number of hexahedrons : ", myMesh.NbHexas()
165 print "problem when Computing the mesh"
167 salome.sg.updateObjBrowser(1)