Salome HOME
SALOME PAL V1_4_1
[modules/smesh.git] / src / SMESH_SWIG / SMESH_controls.py
1 #  Copyright (C) 2004  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
19 #
20 #
21 #
22 #  File   : SMESH_control.py
23 #  Author : Sergey LITONIN
24 #  Module : SMESH
25
26
27 import SMESH
28 import SMESH_mechanic
29
30 smesh  = SMESH_mechanic.smesh
31 mesh   = SMESH_mechanic.mesh
32 salome = SMESH_mechanic.salome
33
34
35 aFilterMgr = smesh.CreateFilterManager()
36
37 # Criterion : AREA > 100
38
39 aFunctor = aFilterMgr.CreateArea()
40 aPredicate = aFilterMgr.CreateMoreThan()
41 aPredicate.SetNumFunctor( aFunctor )
42 aPredicate.SetMargin( 100 )
43
44 aFilter = aFilterMgr.CreateFilter()
45 aFilter.SetPredicate( aPredicate )
46
47 anIds = aFilter.GetElementsId( mesh )
48
49 # print result
50 print "Criterion: Area > 100 Nb = ", len( anIds )
51 #for i in range( len( anIds ) ):
52   #print anIds[ i ]
53
54 # create group
55 aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" )
56 aGroup.Add( anIds )
57
58
59 # Criterion : Taper > 3e-15
60
61 aFunctor = aFilterMgr.CreateTaper()
62 aPredicate = aFilterMgr.CreateMoreThan()
63 aPredicate.SetNumFunctor( aFunctor )
64 aPredicate.SetMargin( 3e-15 )
65
66 aFilter = aFilterMgr.CreateFilter()
67 aFilter.SetPredicate( aPredicate )
68
69 anIds = aFilter.GetElementsId( mesh )
70
71 # print result
72 print "Criterion: Taper > 3e-15 Nb = ", len( anIds )
73 #for i in range( len( anIds ) ):
74   #print anIds[ i ]
75
76 # create group
77 aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-15" )
78 aGroup.Add( anIds )
79
80
81 # Criterion : ASPECT RATIO > 1.3
82
83 aFunctor = aFilterMgr.CreateAspectRatio()
84 aPredicate = aFilterMgr.CreateMoreThan()
85 aPredicate.SetNumFunctor( aFunctor )
86 aPredicate.SetMargin( 1.3 )
87
88 aFilter = aFilterMgr.CreateFilter()
89 aFilter.SetPredicate( aPredicate )
90
91 anIds = aFilter.GetElementsId( mesh )
92
93 # print result
94 print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )
95 #for i in range( len( anIds ) ):
96   #print anIds[ i ]
97
98 # create group
99 aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" )
100 aGroup.Add( anIds )  
101
102
103 # Criterion : MINIMUM ANGLE < 30
104
105 aFunctor = aFilterMgr.CreateMinimumAngle()
106 aPredicate = aFilterMgr.CreateLessThan()
107 aPredicate.SetNumFunctor( aFunctor )
108 aPredicate.SetMargin( 30 )
109
110 aFilter = aFilterMgr.CreateFilter()
111 aFilter.SetPredicate( aPredicate )
112
113 anIds = aFilter.GetElementsId( mesh )
114
115 # print result
116 print "Criterion: Minimum Angle < 30 Nb = ", len( anIds )
117 #for i in range( len( anIds ) ):
118   #print anIds[ i ]
119
120 # create group
121 aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 30" )
122 aGroup.Add( anIds )
123
124 # Criterion : Warp > 2e-13
125
126 aFunctor = aFilterMgr.CreateWarping()
127 aPredicate = aFilterMgr.CreateMoreThan()
128 aPredicate.SetNumFunctor( aFunctor )
129 aPredicate.SetMargin( 2e-13 )
130
131 aFilter = aFilterMgr.CreateFilter()
132 aFilter.SetPredicate( aPredicate )
133
134 anIds = aFilter.GetElementsId( mesh )
135
136 # print result
137 print "Criterion: Warp > 2e-13 Nb = ", len( anIds )
138 #for i in range( len( anIds ) ):
139   #print anIds[ i ]
140
141 # create group
142 aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 2e-13" )
143 aGroup.Add( anIds )
144
145 # Criterion : Skew > 18
146
147 aFunctor = aFilterMgr.CreateSkew()
148 aPredicate = aFilterMgr.CreateMoreThan()
149 aPredicate.SetNumFunctor( aFunctor )
150 aPredicate.SetMargin( 18 )
151
152 aFilter = aFilterMgr.CreateFilter()
153 aFilter.SetPredicate( aPredicate )
154
155 anIds = aFilter.GetElementsId( mesh )
156
157 # print result
158 print "Criterion: Skew > 18 Nb = ", len( anIds )
159 #for i in range( len( anIds ) ):
160   #print anIds[ i ]
161
162 # create group
163 aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" )
164 aGroup.Add( anIds )
165
166 # Criterion : Length > 10
167
168 aFunctor = aFilterMgr.CreateLength()
169 aPredicate = aFilterMgr.CreateMoreThan()
170 aPredicate.SetNumFunctor( aFunctor )
171 aPredicate.SetMargin( 10 )
172
173 aFilter = aFilterMgr.CreateFilter()
174 aFilter.SetPredicate( aPredicate )
175
176 anIds = aFilter.GetElementsId( mesh )
177
178 # print result
179 print "Criterion: Length > 10 Nb = ", len( anIds )
180 #for i in range( len( anIds ) ):
181   #print anIds[ i ]
182
183 # create group
184 aGroup = mesh.CreateGroup( SMESH.EDGE, "Length > 10" )
185 aGroup.Add( anIds )
186
187 # Criterion : Borders at multi-connections = 2
188
189 aFunctor = aFilterMgr.CreateMultiConnection()
190 aPredicate = aFilterMgr.CreateEqualTo()
191 aPredicate.SetNumFunctor( aFunctor )
192 aPredicate.SetMargin( 2 )
193
194 aFilter = aFilterMgr.CreateFilter()
195 aFilter.SetPredicate( aPredicate )
196
197 anIds = aFilter.GetElementsId( mesh )
198
199 # print result
200 print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )
201 #for i in range( len( anIds ) ):
202   #print anIds[ i ]
203
204 # create group
205 aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections = 2" )
206 aGroup.Add( anIds )
207
208
209 salome.sg.updateObjBrowser(1)
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227