]> SALOME platform Git repositories - modules/smesh.git/blob - doc/salome/examples/creating_meshes_ex04.py
Salome HOME
update of messages
[modules/smesh.git] / doc / salome / examples / creating_meshes_ex04.py
1 # Editing of a mesh
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New(salome.myStudy)
12
13 def PrintMeshInfo(theMesh):
14     aMesh = theMesh.GetMesh()
15     print "Information about mesh:"
16     print "Number of nodes       : ", aMesh.NbNodes()
17     print "Number of edges       : ", aMesh.NbEdges()
18     print "Number of faces       : ", aMesh.NbFaces()
19     print "Number of volumes     : ", aMesh.NbVolumes()
20     pass
21
22 # create a box
23 box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
24 geompy.addToStudy(box, "box")
25
26 # select one edge of the box for definition of a local hypothesis
27 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
28 edge = subShapeList[0]
29 name = geompy.SubShapeName(edge, box)
30 geompy.addToStudyInFather(box, edge, name)
31
32 # create a mesh
33 tria = smesh.Mesh(box, "Mesh 2D")
34 algo1D = tria.Segment()
35 hyp1 = algo1D.NumberOfSegments(3)
36 algo2D = tria.Triangle()
37 hyp2 = algo2D.MaxElementArea(10.)
38
39 # create a sub-mesh
40 algo_local = tria.Segment(edge)
41 hyp3 = algo_local.Arithmetic1D(1, 6)
42 hyp4 = algo_local.Propagation()
43
44 # compute the mesh
45 tria.Compute()
46 PrintMeshInfo(tria)
47
48 # remove a local hypothesis
49 mesh = tria.GetMesh()
50 mesh.RemoveHypothesis(edge, hyp4)
51
52 # compute the mesh
53 tria.Compute()
54 PrintMeshInfo(tria)
55
56 # change the value of the 2D hypothesis
57 hyp2.SetMaxElementArea(2.)
58
59 # compute the mesh
60 tria.Compute()
61 PrintMeshInfo(tria)