1 # SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 # File : SMESH_test.py
36 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
37 idb = geompy.addToStudy(box, "box")
39 # ---- add first face of box in study
41 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
42 face = subShapeList[0]
43 name = geompy.SubShapeName(face, box)
44 idf = geompy.addToStudyInFather(box, face, name)
46 # ---- add shell from box in study
48 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
49 shell = subShellList[0]
50 name = geompy.SubShapeName(shell, box)
51 ids = geompy.addToStudyInFather(box, shell, name)
53 # ---- add first edge of face in study
55 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
57 name = geompy.SubShapeName(edge, face)
58 ide = geompy.addToStudyInFather(face, edge, name)
60 # ---- launch SMESH, init a Mesh with the box
62 gen = smeshpy.smeshpy()
63 mesh = gen.CreateMesh(idb)
65 print "-------------------------- create Hypothesis"
67 print "-------------------------- LocalLength"
69 hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
72 print hypo1.GetLength()
74 print hypo1.GetLength()
76 print "-------------------------- bidon"
78 hyp3 = gen.CreateHypothesis("bidon", "")
80 print "-------------------------- NumberOfSegments"
82 hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
83 hypo3.SetNumberOfSegments(7)
85 print hypo3.GetNumberOfSegments()
88 print "-------------------------- MaxElementArea"
90 hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
91 hypo4.SetMaxElementArea(5000)
93 print hypo4.GetMaxElementArea()
96 print "-------------------------- Regular_1D"
98 algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
99 print algo_1.GetName()
101 listHyp = algo_1.GetCompatibleHypothesis()
106 print "-------------------------- MEFISTO_2D"
108 algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
109 print algo_2.GetName()
111 listHyp = algo_2.GetCompatibleHypothesis()
116 print "-------------------------- add hypothesis to edge"
118 edge = salome.IDToObject(ide)
119 submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
120 ret = mesh.AddHypothesis(edge,algo_1)
122 ret = mesh.AddHypothesis(edge,hypo1)
125 ##print "-------------------------- compute edge"
126 ##ret=gen.Compute(mesh,ide)
128 ##log=mesh.GetLog(1);
132 print "-------------------------- add hypothesis to box"
134 box = salome.IDToObject(idb)
135 submesh = mesh.GetSubMesh(box, "SubMeshBox")
136 ret = mesh.AddHypothesis(box,algo_1)
138 ret = mesh.AddHypothesis(box,hypo1)
140 ret = mesh.AddHypothesis(box,algo_2)
142 ret = mesh.AddHypothesis(box,hypo4)
145 print "-------------------------- compute face"
147 ret = gen.Compute(mesh,idf)
149 log = mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after
154 comType = a.commandType
156 for i in range(a.number):
165 print "AddNode %i - %g %g %g" % (ind, r1, r2, r3)
167 for i in range(a.number):
174 print "AddEdge %i - %i %i" % (ind, i1, i2)
176 for i in range(a.number):
185 print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
187 ##print "-------------------------- compute box"
188 ##ret=gen.Compute(mesh,idb)
190 ##log=mesh.GetLog(1);
193 ##shell=salome.IDToObject(ids)
194 ##submesh=mesh.GetElementsOnShape(shell)
195 ##ret=mesh.AddHypothesis(shell,algo_1)
197 ##ret=mesh.AddHypothesis(shell,hypo1)
199 ##ret=gen.Compute(mesh,ids)