1 # Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : SMESH_control.py
23 # Author : Sergey LITONIN
30 smesh = SMESH_mechanic.smesh
31 mesh = SMESH_mechanic.mesh
32 salome = SMESH_mechanic.salome
35 aFilterMgr = smesh.CreateFilterManager()
37 # Criterion : AREA > 100
39 aFunctor = aFilterMgr.CreateArea()
40 aPredicate = aFilterMgr.CreateMoreThan()
41 aPredicate.SetNumFunctor( aFunctor )
42 aPredicate.SetMargin( 100 )
44 aFilter = aFilterMgr.CreateFilter()
45 aFilter.SetPredicate( aPredicate )
47 anIds = aFilter.GetElementsId( mesh )
50 print "Criterion: Area > 100 Nb = ", len( anIds )
51 #for i in range( len( anIds ) ):
55 aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" )
59 # Criterion : Taper > 3e-15
61 aFunctor = aFilterMgr.CreateTaper()
62 aPredicate = aFilterMgr.CreateMoreThan()
63 aPredicate.SetNumFunctor( aFunctor )
64 aPredicate.SetMargin( 3e-15 )
66 aFilter = aFilterMgr.CreateFilter()
67 aFilter.SetPredicate( aPredicate )
69 anIds = aFilter.GetElementsId( mesh )
72 print "Criterion: Taper > 3e-15 Nb = ", len( anIds )
73 #for i in range( len( anIds ) ):
77 aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-15" )
81 # Criterion : ASPECT RATIO > 1.3
83 aFunctor = aFilterMgr.CreateAspectRatio()
84 aPredicate = aFilterMgr.CreateMoreThan()
85 aPredicate.SetNumFunctor( aFunctor )
86 aPredicate.SetMargin( 1.3 )
88 aFilter = aFilterMgr.CreateFilter()
89 aFilter.SetPredicate( aPredicate )
91 anIds = aFilter.GetElementsId( mesh )
94 print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )
95 #for i in range( len( anIds ) ):
99 aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" )
103 # Criterion : MINIMUM ANGLE < 30
105 aFunctor = aFilterMgr.CreateMinimumAngle()
106 aPredicate = aFilterMgr.CreateLessThan()
107 aPredicate.SetNumFunctor( aFunctor )
108 aPredicate.SetMargin( 30 )
110 aFilter = aFilterMgr.CreateFilter()
111 aFilter.SetPredicate( aPredicate )
113 anIds = aFilter.GetElementsId( mesh )
116 print "Criterion: Minimum Angle < 30 Nb = ", len( anIds )
117 #for i in range( len( anIds ) ):
121 aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 30" )
124 # Criterion : Warp > 2e-13
126 aFunctor = aFilterMgr.CreateWarping()
127 aPredicate = aFilterMgr.CreateMoreThan()
128 aPredicate.SetNumFunctor( aFunctor )
129 aPredicate.SetMargin( 2e-13 )
131 aFilter = aFilterMgr.CreateFilter()
132 aFilter.SetPredicate( aPredicate )
134 anIds = aFilter.GetElementsId( mesh )
137 print "Criterion: Warp > 2e-13 Nb = ", len( anIds )
138 #for i in range( len( anIds ) ):
142 aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 2e-13" )
145 # Criterion : Skew > 18
147 aFunctor = aFilterMgr.CreateSkew()
148 aPredicate = aFilterMgr.CreateMoreThan()
149 aPredicate.SetNumFunctor( aFunctor )
150 aPredicate.SetMargin( 18 )
152 aFilter = aFilterMgr.CreateFilter()
153 aFilter.SetPredicate( aPredicate )
155 anIds = aFilter.GetElementsId( mesh )
158 print "Criterion: Skew > 18 Nb = ", len( anIds )
159 #for i in range( len( anIds ) ):
163 aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" )
166 # Criterion : Length > 10
168 aFunctor = aFilterMgr.CreateLength()
169 aPredicate = aFilterMgr.CreateMoreThan()
170 aPredicate.SetNumFunctor( aFunctor )
171 aPredicate.SetMargin( 10 )
173 aFilter = aFilterMgr.CreateFilter()
174 aFilter.SetPredicate( aPredicate )
176 anIds = aFilter.GetElementsId( mesh )
179 print "Criterion: Length > 10 Nb = ", len( anIds )
180 #for i in range( len( anIds ) ):
184 aGroup = mesh.CreateGroup( SMESH.EDGE, "Length > 10" )
187 # Criterion : Borders at multi-connections = 2
189 aFunctor = aFilterMgr.CreateMultiConnection()
190 aPredicate = aFilterMgr.CreateEqualTo()
191 aPredicate.SetNumFunctor( aFunctor )
192 aPredicate.SetMargin( 2 )
194 aFilter = aFilterMgr.CreateFilter()
195 aFilter.SetPredicate( aPredicate )
197 anIds = aFilter.GetElementsId( mesh )
200 print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )
201 #for i in range( len( anIds ) ):
205 aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections = 2" )
209 salome.sg.updateObjBrowser(1)