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
32 #import SMESH_BasicHypothesis_idl
36 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
37 myBuilder = salome.myStudy.NewBuilder()
40 ShapeTypeCompSolid = 1
50 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
51 idb = geompy.addToStudy(box,"box")
53 # ---- add first face of box in study
55 subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
57 name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
59 idf=geompy.addToStudyInFather(box,face,name)
61 # ---- add shell from box in study
63 subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
64 shell = subShellList[0]
65 name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
67 ids=geompy.addToStudyInFather(box,shell,name)
69 # ---- add first edge of face in study
71 edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
73 name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
75 ide=geompy.addToStudyInFather(face,edge,name)
77 # ---- launch SMESH, init a Mesh with the box
81 # ---- create Hypothesis
83 print "-------------------------- create Hypothesis"
84 print "-------------------------- LocalLength"
85 hyp1=gen.CreateHypothesis("LocalLength")
88 hypo1 = hyp1._narrow(SMESH.SMESH_LocalLength)
89 print hypo1.GetLength()
91 print hypo1.GetLength()
93 print "-------------------------- bidon"
94 hyp3=gen.CreateHypothesis("bidon")
96 print "-------------------------- NumberOfSegments"
97 hyp3=gen.CreateHypothesis("NumberOfSegments")
98 hypo3=hyp3._narrow(SMESH.SMESH_NumberOfSegments)
99 hypo3.SetNumberOfSegments(7)
100 print hypo3.GetName()
101 print hypo3.GetNumberOfSegments()
104 print "-------------------------- MaxElementArea"
105 hyp4=gen.CreateHypothesis("MaxElementArea")
106 hypo4=hyp4._narrow(SMESH.SMESH_MaxElementArea)
107 hypo4.SetMaxElementArea(5000)
108 print hypo4.GetName()
109 print hypo4.GetMaxElementArea()
112 print "-------------------------- Regular_1D"
113 alg1=gen.CreateHypothesis("Regular_1D")
116 algo1=alg1._narrow(SMESH.SMESH_Algo)
117 listHyp=algo1.GetCompatibleHypothesis()
121 algo_1=alg1._narrow(SMESH.SMESH_Regular_1D)
124 print "-------------------------- MEFISTO_2D"
125 alg2=gen.CreateHypothesis("MEFISTO_2D")
128 algo2=alg2._narrow(SMESH.SMESH_Algo)
129 listHyp=algo2.GetCompatibleHypothesis()
132 algo_2=alg2._narrow(SMESH.SMESH_MEFISTO_2D)
135 # ---- add hypothesis to edge
137 print "-------------------------- add hypothesis to edge"
138 edge=salome.IDToObject(ide)
139 submesh=mesh.GetElementsOnShape(edge)
140 ret=mesh.AddHypothesis(edge,algo_1)
142 ret=mesh.AddHypothesis(edge,hypo1)
147 ##print "-------------------------- compute edge"
148 ##ret=gen.Compute(mesh,ide)
150 ##log=mesh.GetLog(1);
154 # ---- add hypothesis to box
156 print "-------------------------- add hypothesis to box"
157 box=salome.IDToObject(idb)
158 submesh=mesh.GetElementsOnShape(box)
159 ret=mesh.AddHypothesis(box,algo_1)
161 ret=mesh.AddHypothesis(box,hypo1)
163 ret=mesh.AddHypothesis(box,algo_2)
165 ret=mesh.AddHypothesis(box,hypo4)
170 print "-------------------------- compute face"
171 ret=gen.Compute(mesh,idf)
178 comType = a.commandType
180 for i in range(a.number):
189 print "AddNode %i - %g %g %g" % (ind, r1, r2, r3)
191 for i in range(a.number):
198 print "AddEdge %i - %i %i" % (ind, i1, i2)
200 for i in range(a.number):
209 print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
213 ##print "-------------------------- compute box"
214 ##ret=gen.Compute(mesh,idb)
216 ##log=mesh.GetLog(1);
219 ##shell=salome.IDToObject(ids)
220 ##submesh=mesh.GetElementsOnShape(shell)
221 ##ret=mesh.AddHypothesis(shell,algo_1)
223 ##ret=mesh.AddHypothesis(shell,hypo1)
225 ##ret=gen.Compute(mesh,ids)