Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test1_AndDisplay.py
1 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3
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. 
8
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. 
13
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 
17
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #
21 #
22 #  File   : SMESH_test1.py
23 #  Module : SMESH
24
25 import salome
26 import geompy
27 import smesh
28
29
30 # ---- define a box
31
32 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
33 idbox = geompy.addToStudy(box, "box")
34
35 # ---- add first face of box in study
36
37 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
38 face = subShapeList[0]
39 name = geompy.SubShapeName(face, box)
40 print name
41 idface = geompy.addToStudyInFather(box, face, name)
42
43 # ---- add shell from box  in study
44
45 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
46 shell = subShellList[0]
47 name = geompy.SubShapeName(shell, box)
48 print name
49 idshell = geompy.addToStudyInFather(box, shell, name)
50
51 # ---- add first edge of face in study
52
53 edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
54 edge = edgeList[0]
55 name = geompy.SubShapeName(edge, face)
56 print name
57 idedge = geompy.addToStudyInFather(face, edge, name)
58
59
60 # ---- SMESH
61
62 # ---- Init a Mesh with the box
63
64 mesh = smesh.Mesh(box, "Meshbox")
65
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")
73
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")
80
81 # ---- add hypothesis to edge
82 print "-------------------------- add hypothesis to edge"
83 edge = salome.IDToObject(idedge)
84
85 algoReg2 = mesh.Segment(edge)
86 hypLen1 = algoReg2.LocalLength(100)
87 smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
88 print hypLen1.GetName()
89 print hypLen1.GetId()
90 print hypLen1.GetLength()
91 smesh.SetName(hypLen1, "Local_Length_100")
92
93 # ---- add hypothesis to face
94 print "-------------------------- add hypothesis to face"
95 face = salome.IDToObject(idface)
96
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")
104
105 mesh.Compute()
106
107 salome.sg.updateObjBrowser(1);
108
109 sg = salome.ImportComponentGUI('SMESH')
110 if type(sg) != type(salome.salome_ComponentGUI):
111     sg.CreateAndDisplayActor('0:1:2:3')