2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # File : SMESH_test1.py
34 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
35 idbox = geompy.addToStudy(box, "box")
37 # ---- add first face of box in study
39 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
40 face = subShapeList[0]
41 name = geompy.SubShapeName(face, box)
43 idface = geompy.addToStudyInFather(box, face, name)
45 # ---- add shell from box in study
47 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
48 shell = subShellList[0]
49 name = geompy.SubShapeName(shell, box)
51 idshell = 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)
59 idedge = geompy.addToStudyInFather(face, edge, name)
64 # ---- Init a Mesh with the box
66 mesh = smesh.Mesh(box, "Meshbox")
68 print "-------------------------- add hypothesis to box"
69 algoReg1 = mesh.Segment()
70 hypNbSeg1 = algoReg1.NumberOfSegments(7)
71 print hypNbSeg1.GetName()
72 print hypNbSeg1.GetId()
73 print hypNbSeg1.GetNumberOfSegments()
74 smesh.SetName(hypNbSeg1, "NumberOfSegments_7")
76 algoMef1 = mesh.Triangle()
77 hypArea1 = algoMef1.MaxElementArea(2500)
78 print hypArea1.GetName()
79 print hypArea1.GetId()
80 print hypArea1.GetMaxElementArea()
81 smesh.SetName(hypArea1, "MaxElementArea_2500")
83 # ---- add hypothesis to edge
84 print "-------------------------- add hypothesis to edge"
85 edge = salome.IDToObject(idedge)
87 algoReg2 = mesh.Segment(edge)
88 hypLen1 = algoReg2.LocalLength(100)
89 smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
90 print hypLen1.GetName()
92 print hypLen1.GetLength()
93 smesh.SetName(hypLen1, "Local_Length_100")
95 # ---- add hypothesis to face
96 print "-------------------------- add hypothesis to face"
97 face = salome.IDToObject(idface)
99 algoMef2 = mesh.Triangle(face)
100 hypArea2 = algoMef2.MaxElementArea(500)
101 smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace")
102 print hypArea2.GetName()
103 print hypArea2.GetId()
104 print hypArea2.GetMaxElementArea()
105 smesh.SetName(hypArea2, "MaxElementArea_500")
109 salome.sg.updateObjBrowser(1);
111 sg = salome.ImportComponentGUI('SMESH')
112 if type(sg) != type(salome.salome_ComponentGUI):
113 sg.CreateAndDisplayActor('0:1:2:3')