4 salome.salome_init_without_session()
6 from salome.geom import geomBuilder
7 from salome.smesh import smeshBuilder
9 geom_builder = geomBuilder.New()
10 smesh_builder = smeshBuilder.New()
12 def PrintMeshInfo(theMesh):
13 aMesh = theMesh.GetMesh()
14 print("Information about mesh:")
15 print("Number of nodes : ", aMesh.NbNodes())
16 print("Number of edges : ", aMesh.NbEdges())
17 print("Number of faces : ", aMesh.NbFaces())
18 print("Number of volumes : ", aMesh.NbVolumes())
22 box = geom_builder.MakeBox(0., 0., 0., 20., 20., 20.)
23 geom_builder.addToStudy(box, "box")
25 # select one edge of the box for definition of a local hypothesis
26 subShapeList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["EDGE"])
27 edge = subShapeList[0]
28 name = geom_builder.SubShapeName(edge, box)
29 geom_builder.addToStudyInFather(box, edge, name)
32 tria = smesh_builder.Mesh(box, "Mesh 2D")
33 algo1D = tria.Segment()
34 hyp1 = algo1D.NumberOfSegments(3)
35 algo2D = tria.Triangle()
36 hyp2 = algo2D.MaxElementArea(10.)
39 algo_local = tria.Segment(edge)
40 hyp3 = algo_local.Arithmetic1D(1, 6)
41 hyp4 = algo_local.Propagation()
44 if not tria.Compute(): raise Exception("Error when computing Mesh")
47 # remove a local hypothesis
48 tria.RemoveHypothesis(hyp4, edge)
51 if not tria.Compute(): raise Exception("Error when computing Mesh")
54 # change the value of the 2D hypothesis
55 hyp2.SetMaxElementArea(2.)
58 if not tria.Compute(): raise Exception("Error when computing Mesh")