Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / SMESH_SWIG / ex21_lamp.py
1 #  Copyright (C) 2005  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 # CEA/LGLS 2006, Francis KLOSS (OCC)
21 # ==================================
22
23 from geompy import *
24
25 import smesh
26
27 # Geometry
28 # ========
29
30 # an assembly of a box, a cylinder and a truncated cone meshed with tetrahedral.
31
32 # Define values
33 # -------------
34
35 name = "ex21_lamp"
36
37 cote = 60
38
39 section = 20
40 size    = 200
41
42 radius_1 = 80
43 radius_2 = 40
44 height   = 100
45
46 # Build a box
47 # -----------
48
49 box  = MakeBox(-cote, -cote, -cote,  +cote, +cote, +cote)
50
51 # Build a cylinder
52 # ----------------
53
54 pt1 = MakeVertex(0, 0, cote/3)
55 di1 = MakeVectorDXDYDZ(0, 0, 1)
56 cyl = MakeCylinder(pt1, di1, section, size)
57
58 # Build a truncated cone
59 # ----------------------
60
61 pt2 = MakeVertex(0, 0, size)
62 cone = MakeCone(pt2, di1, radius_1, radius_2, height)
63
64 # Fuse
65 # ----
66
67 box_cyl = MakeFuse(box, cyl)
68 piece = MakeFuse(box_cyl, cone)
69
70 # Add in study
71 # ------------
72
73 addToStudy(piece, name)
74
75 # Create a group of faces
76 # -----------------------
77
78 group = CreateGroup(piece, ShapeType["FACE"])
79
80 group_name = name + "_grp"
81 addToStudy(group, group_name)
82 group.SetName(group_name)
83
84 # Add faces in the group
85 # ----------------------
86
87 faces = SubShapeAllIDs(piece, ShapeType["FACE"])
88
89 UnionIDs(group, faces)
90
91 # Create a mesh
92 # =============
93
94 # Define a mesh on a geometry
95 # ---------------------------
96
97 tetra = smesh.Mesh(piece, name)
98
99 # Define 1D hypothesis
100 # --------------------
101
102 algo1d = tetra.Segment()
103 algo1d.LocalLength(10)
104
105 # Define 2D hypothesis
106 # --------------------
107
108 algo2d = tetra.Triangle()
109 algo2d.LengthFromEdges()
110
111 # Define 3D hypothesis
112 # --------------------
113
114 algo3d = tetra.Tetrahedron(smesh.NETGEN)
115 algo3d.MaxElementVolume(100)
116
117 # Compute the mesh
118 # ----------------
119
120 tetra.Compute()
121
122 # Create a groupe of faces
123 # ------------------------
124
125 tetra.Group(group)