1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # File : SMESH_test1.py
32 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
33 idbox = geompy.addToStudy(box, "box")
35 # ---- add first face of box in study
37 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
38 face = subShapeList[0]
39 name = geompy.SubShapeName(face, box)
41 idface = geompy.addToStudyInFather(box, face, name)
43 # ---- add shell from box in study
45 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
46 shell = subShellList[0]
47 name = geompy.SubShapeName(shell, box)
49 idshell = geompy.addToStudyInFather(box, shell, name)
51 # ---- add first edge of face in study
53 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
55 name = geompy.SubShapeName(edge, face)
57 idedge = geompy.addToStudyInFather(face, edge, name)
62 # ---- Init a Mesh with the box
64 mesh = smesh.Mesh(box, "Meshbox")
66 print "-------------------------- add hypothesis to box"
67 algoReg1 = mesh.Segment()
68 hypNbSeg1 = algoReg1.NumberOfSegments(7)
69 print hypNbSeg1.GetName()
70 print hypNbSeg1.GetId()
71 print hypNbSeg1.GetNumberOfSegments()
72 smesh.SetName(hypNbSeg1, "NumberOfSegments_7")
74 algoMef1 = mesh.Triangle()
75 hypArea1 = algoMef1.MaxElementArea(2500)
76 print hypArea1.GetName()
77 print hypArea1.GetId()
78 print hypArea1.GetMaxElementArea()
79 smesh.SetName(hypArea1, "MaxElementArea_2500")
81 # ---- add hypothesis to edge
82 print "-------------------------- add hypothesis to edge"
83 edge = salome.IDToObject(idedge)
85 algoReg2 = mesh.Segment(edge)
86 hypLen1 = algoReg2.LocalLength(100)
87 smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
88 print hypLen1.GetName()
90 print hypLen1.GetLength()
91 smesh.SetName(hypLen1, "Local_Length_100")
93 # ---- add hypothesis to face
94 print "-------------------------- add hypothesis to face"
95 face = salome.IDToObject(idface)
97 algoMef2 = mesh.Triangle(face)
98 hypArea2 = algoMef2.MaxElementArea(500)
99 smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace")
100 print hypArea2.GetName()
101 print hypArea2.GetId()
102 print hypArea2.GetMaxElementArea()
103 smesh.SetName(hypArea2, "MaxElementArea_500")
107 salome.sg.updateObjBrowser(1);
109 sg = salome.ImportComponentGUI('SMESH')
110 if type(sg) != type(salome.salome_ComponentGUI):
111 sg.CreateAndDisplayActor('0:1:2:3')