1 # Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : SMESH_test1.py
30 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
31 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
33 geom.GetCurrentStudy(salome.myStudy._get_StudyId())
34 smesh.SetCurrentStudy(salome.myStudy)
36 ShapeTypeCompSolid = 1
46 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
47 idbox = geompy.addToStudy(box,"box")
49 # ---- add first face of box in study
51 subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
53 name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
55 idface=geompy.addToStudyInFather(box,face,name)
57 # ---- add shell from box in study
59 subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
60 shell = subShellList[0]
61 name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
63 idshell=geompy.addToStudyInFather(box,shell,name)
65 # ---- add first edge of face in study
67 edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
69 name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
71 idedge=geompy.addToStudyInFather(face,edge,name)
74 smeshgui = salome.ImportComponentGUI("SMESH")
75 smeshgui.Init(salome.myStudyId);
77 # ---- create Hypothesis
79 print "-------------------------- create Hypothesis"
80 print "-------------------------- LocalLength"
82 hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
83 hypLen1.SetLength(100)
84 print hypLen1.GetName()
86 print hypLen1.GetLength()
88 idlength = salome.ObjectToID(hypLen1)
89 smeshgui.SetName(idlength, "Local_Length_100");
91 print "-------------------------- NumberOfSegments"
92 hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
93 hypNbSeg1.SetNumberOfSegments(7)
94 print hypNbSeg1.GetName()
95 print hypNbSeg1.GetId()
96 print hypNbSeg1.GetNumberOfSegments()
98 idseg = salome.ObjectToID(hypNbSeg1)
99 smeshgui.SetName(idseg, "NumberOfSegments_7");
101 print "-------------------------- MaxElementArea"
102 hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
103 hypArea1.SetMaxElementArea(2500)
104 print hypArea1.GetName()
105 print hypArea1.GetId()
106 print hypArea1.GetMaxElementArea()
108 idarea1 = salome.ObjectToID(hypArea1)
109 smeshgui.SetName(idarea1, "MaxElementArea_2500");
111 print "-------------------------- MaxElementArea"
112 hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
113 hypArea2.SetMaxElementArea(500)
114 print hypArea2.GetName()
115 print hypArea2.GetId()
116 print hypArea2.GetMaxElementArea()
118 idarea2 = salome.ObjectToID(hypArea2)
119 smeshgui.SetName(idarea2, "MaxElementArea_500");
121 print "-------------------------- Regular_1D"
122 algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
123 listHyp=algoReg.GetCompatibleHypothesis()
126 print algoReg.GetName()
127 print algoReg.GetId()
129 idreg = salome.ObjectToID(algoReg)
130 smeshgui.SetName(idreg, "Regular_1D");
132 print "-------------------------- MEFISTO_2D"
133 algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
134 listHyp=algoMef.GetCompatibleHypothesis()
137 print algoMef.GetName()
138 print algoMef.GetId()
140 idmef = salome.ObjectToID(algoMef)
141 smeshgui.SetName(idmef, "MEFISTO_2D");
143 # ---- Init a Mesh with the box
145 box=salome.IDToObject(idbox)
146 mesh=smesh.CreateMesh(box)
148 idmesh = salome.ObjectToID(mesh)
149 smeshgui.SetName(idmesh, "Meshbox");
151 # ---- add hypothesis to box
152 print "-------------------------- add hypothesis to box"
153 mesh.AddHypothesis(box,algoReg)
154 mesh.AddHypothesis(box,hypNbSeg1)
155 mesh.AddHypothesis(box,algoMef)
156 mesh.AddHypothesis(box,hypArea1)
158 # ---- add hypothesis to edge
160 print "-------------------------- add hypothesis to edge"
161 edge=salome.IDToObject(idedge)
162 submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
163 mesh.AddHypothesis(edge , algoReg)
164 mesh.AddHypothesis(edge, hypLen1)
166 print "-------------------------- add hypothesis to face"
167 face = salome.IDToObject(idface)
168 submesh =mesh.GetSubMesh(face, "SubMeshFace")
169 mesh.AddHypothesis(face,hypArea2)
171 salome.sg.updateObjBrowser(1);