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