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
34 #import SMESH_BasicHypothesis_idl
38 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
39 myBuilder = salome.myStudy.NewBuilder()
42 ShapeTypeCompSolid = 1
52 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
53 idb = geompy.addToStudy(box,"box")
55 # ---- add first face of box in study
57 subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
59 name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
61 idf=geompy.addToStudyInFather(box,face,name)
63 # ---- add shell from box in study
65 subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
66 shell = subShellList[0]
67 name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
69 ids=geompy.addToStudyInFather(box,shell,name)
71 # ---- add first edge of face in study
73 edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
75 name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
77 ide=geompy.addToStudyInFather(face,edge,name)
79 # ---- launch SMESH, init a Mesh with the box
81 mesh=gen.CreateMesh(idb)
83 # ---- create Hypothesis
85 print "-------------------------- create Hypothesis"
86 print "-------------------------- LocalLength"
87 hyp1=gen.CreateHypothesis("LocalLength","libStdMeshersEngine.so")
90 hypo1 = hyp1._narrow(StdMeshers.StdMeshers_LocalLength)
91 print hypo1.GetLength()
93 print hypo1.GetLength()
95 print "-------------------------- bidon"
96 hyp3=gen.CreateHypothesis("bidon","")
98 print "-------------------------- NumberOfSegments"
99 hyp3=gen.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
100 hypo3=hyp3._narrow(StdMeshers.StdMeshers_NumberOfSegments)
101 hypo3.SetNumberOfSegments(7)
102 print hypo3.GetName()
103 print hypo3.GetNumberOfSegments()
106 print "-------------------------- MaxElementArea"
107 hyp4=gen.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so")
108 hypo4=hyp4._narrow(StdMeshers.StdMeshers_MaxElementArea)
109 hypo4.SetMaxElementArea(5000)
110 print hypo4.GetName()
111 print hypo4.GetMaxElementArea()
114 print "-------------------------- Regular_1D"
115 alg1=gen.CreateHypothesis("Regular_1D","libStdMeshersEngine.so")
118 algo1=alg1._narrow(SMESH.SMESH_Algo)
119 listHyp=algo1.GetCompatibleHypothesis()
123 algo_1=alg1._narrow(StdMeshers.StdMeshers_Regular_1D)
126 print "-------------------------- MEFISTO_2D"
127 alg2=gen.CreateHypothesis("MEFISTO_2D","libStdMeshersEngine.so")
130 algo2=alg2._narrow(SMESH.SMESH_Algo)
131 listHyp=algo2.GetCompatibleHypothesis()
134 algo_2=alg2._narrow(StdMeshers.StdMeshers_MEFISTO_2D)
137 # ---- add hypothesis to edge
139 print "-------------------------- add hypothesis to edge"
140 edge=salome.IDToObject(ide)
141 submesh=mesh.GetElementsOnShape(edge)
142 ret=mesh.AddHypothesis(edge,algo_1)
144 ret=mesh.AddHypothesis(edge,hypo1)
149 ##print "-------------------------- compute edge"
150 ##ret=gen.Compute(mesh,ide)
152 ##log=mesh.GetLog(1);
156 # ---- add hypothesis to box
158 print "-------------------------- add hypothesis to box"
159 box=salome.IDToObject(idb)
160 submesh=mesh.GetElementsOnShape(box)
161 ret=mesh.AddHypothesis(box,algo_1)
163 ret=mesh.AddHypothesis(box,hypo1)
165 ret=mesh.AddHypothesis(box,algo_2)
167 ret=mesh.AddHypothesis(box,hypo4)
172 print "-------------------------- compute face"
173 ret=gen.Compute(mesh,idf)
180 comType = a.commandType
182 for i in range(a.number):
191 print "AddNode %i - %g %g %g" % (ind, r1, r2, r3)
193 for i in range(a.number):
200 print "AddEdge %i - %i %i" % (ind, i1, i2)
202 for i in range(a.number):
211 print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
215 ##print "-------------------------- compute box"
216 ##ret=gen.Compute(mesh,idb)
218 ##log=mesh.GetLog(1);
221 ##shell=salome.IDToObject(ids)
222 ##submesh=mesh.GetElementsOnShape(shell)
223 ##ret=mesh.AddHypothesis(shell,algo_1)
225 ##ret=mesh.AddHypothesis(shell,hypo1)
227 ##ret=gen.Compute(mesh,ids)