Salome HOME
Merge from V6_main 01/04/2013
[modules/smesh.git] / doc / salome / examples / 3dmesh.py
1 # 3d mesh generation
2
3 from geompy import * 
4 import smesh 
5
6 ###
7 # Geometry: an assembly of a box, a cylinder and a truncated cone
8 # meshed with tetrahedral 
9 ###
10
11 # Define values
12 name = "ex21_lamp" 
13 cote = 60 
14 section = 20 
15 size = 200 
16 radius_1 = 80 
17 radius_2 = 40 
18 height = 100 
19
20 # Build a box
21 box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) 
22
23 # Build a cylinder
24 pt1 = MakeVertex(0, 0, cote/3) 
25 di1 = MakeVectorDXDYDZ(0, 0, 1) 
26 cyl = MakeCylinder(pt1, di1, section, size) 
27
28 # Build a truncated cone
29 pt2 = MakeVertex(0, 0, size) 
30 cone = MakeCone(pt2, di1, radius_1, radius_2, height) 
31
32 # Fuse
33 box_cyl = MakeFuse(box, cyl) 
34 piece = MakeFuse(box_cyl, cone) 
35
36 # Add to the study
37 addToStudy(piece, name) 
38
39 # Create a group of faces
40 group = CreateGroup(piece, ShapeType["FACE"]) 
41 group_name = name + "_grp" 
42 addToStudy(group, group_name) 
43 group.SetName(group_name) 
44
45 # Add faces to the group
46 faces = SubShapeAllIDs(piece, ShapeType["FACE"]) 
47 UnionIDs(group, faces) 
48
49 ###
50 # Create a mesh
51 ###
52
53 # Define a mesh on a geometry
54 tetra = smesh.Mesh(piece, name) 
55
56 # Define 1D hypothesis
57 algo1d = tetra.Segment() 
58 algo1d.LocalLength(10) 
59
60 # Define 2D hypothesis
61 algo2d = tetra.Triangle() 
62 algo2d.LengthFromEdges() 
63
64 # Define 3D hypothesis
65 algo3d = tetra.Tetrahedron()
66 algo3d.MaxElementVolume(100) 
67
68 # Compute the mesh
69 tetra.Compute() 
70
71 # Create a groupe of faces
72 tetra.Group(group)