Salome HOME
0020362: EDF SMESH: Smesh commands always generate print logs
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #  File   : smesh.py
23 #  Author : Francis KLOSS, OCC
24 #  Module : SMESH
25 #
26 """
27  \namespace smesh
28  \brief Module smesh
29 """
30
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating  Creating meshes
33 ## @{
34 ##   @defgroup l2_impexp     Importing and exporting meshes
35 ##   @defgroup l2_construct  Constructing meshes
36 ##   @defgroup l2_algorithms Defining Algorithms
37 ##   @{
38 ##     @defgroup l3_algos_basic   Basic meshing algorithms
39 ##     @defgroup l3_algos_proj    Projection Algorithms
40 ##     @defgroup l3_algos_radialp Radial Prism
41 ##     @defgroup l3_algos_segmarv Segments around Vertex
42 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
43
44 ##   @}
45 ##   @defgroup l2_hypotheses Defining hypotheses
46 ##   @{
47 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ##     @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ##     @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ##     @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ##     @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ##     @defgroup l3_hypos_additi Additional Hypotheses
55
56 ##   @}
57 ##   @defgroup l2_submeshes Constructing submeshes
58 ##   @defgroup l2_compounds Building Compounds
59 ##   @defgroup l2_editing   Editing Meshes
60
61 ## @}
62 ## @defgroup l1_meshinfo  Mesh Information
63 ## @defgroup l1_controls  Quality controls and Filtering
64 ## @defgroup l1_grouping  Grouping elements
65 ## @{
66 ##   @defgroup l2_grps_create Creating groups
67 ##   @defgroup l2_grps_edit   Editing groups
68 ##   @defgroup l2_grps_operon Using operations on groups
69 ##   @defgroup l2_grps_delete Deleting Groups
70
71 ## @}
72 ## @defgroup l1_modifying Modifying meshes
73 ## @{
74 ##   @defgroup l2_modif_add      Adding nodes and elements
75 ##   @defgroup l2_modif_del      Removing nodes and elements
76 ##   @defgroup l2_modif_edit     Modifying nodes and elements
77 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
78 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ##   @defgroup l2_modif_movenode Moving nodes
80 ##   @defgroup l2_modif_throughp Mesh through point
81 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
82 ##   @defgroup l2_modif_unitetri Uniting triangles
83 ##   @defgroup l2_modif_changori Changing orientation of elements
84 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
85 ##   @defgroup l2_modif_smooth   Smoothing
86 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
87 ##   @defgroup l2_modif_patterns Pattern mapping
88 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89
90 ## @}
91
92 import salome
93 import geompyDC
94
95 import SMESH # This is necessary for back compatibility
96 from   SMESH import *
97
98 import StdMeshers
99
100 import SALOME
101
102 # import NETGENPlugin module if possible
103 noNETGENPlugin = 0
104 try:
105     import NETGENPlugin
106 except ImportError:
107     noNETGENPlugin = 1
108     pass
109
110 ## @addtogroup l1_auxiliary
111 ## @{
112
113 # Types of algorithms
114 REGULAR    = 1
115 PYTHON     = 2
116 COMPOSITE  = 3
117 SOLE       = 0
118 SIMPLE     = 1
119
120 MEFISTO       = 3
121 NETGEN        = 4
122 GHS3D         = 5
123 FULL_NETGEN   = 6
124 NETGEN_2D     = 7
125 NETGEN_1D2D   = NETGEN
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL   = FULL_NETGEN
128 Hexa    = 8
129 Hexotic = 9
130 BLSURF  = 10
131 GHS3DPRL = 11
132
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS =  SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
137
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
141
142 # Fineness enumeration (for NETGEN)
143 VeryCoarse = 0
144 Coarse     = 1
145 Moderate   = 2
146 Fine       = 3
147 VeryFine   = 4
148 Custom     = 5
149
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
152
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
155
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
158
159 PrecisionConfusion = 1e-07
160
161 ## Converts an angle from degrees to radians
162 def DegreesToRadians(AngleInDegrees):
163     from math import pi
164     return AngleInDegrees * pi / 180.0
165
166 # Salome notebook variable separator
167 var_separator = ":"
168
169 # Parametrized substitute for PointStruct
170 class PointStructStr:
171
172     x = 0
173     y = 0
174     z = 0
175     xStr = ""
176     yStr = ""
177     zStr = ""
178
179     def __init__(self, xStr, yStr, zStr):
180         self.xStr = xStr
181         self.yStr = yStr
182         self.zStr = zStr
183         if isinstance(xStr, str) and notebook.isVariable(xStr):
184             self.x = notebook.get(xStr)
185         else:
186             self.x = xStr
187         if isinstance(yStr, str) and notebook.isVariable(yStr):
188             self.y = notebook.get(yStr)
189         else:
190             self.y = yStr
191         if isinstance(zStr, str) and notebook.isVariable(zStr):
192             self.z = notebook.get(zStr)
193         else:
194             self.z = zStr
195
196 # Parametrized substitute for PointStruct (with 6 parameters)
197 class PointStructStr6:
198
199     x1 = 0
200     y1 = 0
201     z1 = 0
202     x2 = 0
203     y2 = 0
204     z2 = 0
205     xStr1 = ""
206     yStr1 = ""
207     zStr1 = ""
208     xStr2 = ""
209     yStr2 = ""
210     zStr2 = ""
211
212     def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
213         self.x1Str = x1Str
214         self.x2Str = x2Str
215         self.y1Str = y1Str
216         self.y2Str = y2Str
217         self.z1Str = z1Str
218         self.z2Str = z2Str
219         if isinstance(x1Str, str) and notebook.isVariable(x1Str):
220             self.x1 = notebook.get(x1Str)
221         else:
222             self.x1 = x1Str
223         if isinstance(x2Str, str) and notebook.isVariable(x2Str):
224             self.x2 = notebook.get(x2Str)
225         else:
226             self.x2 = x2Str
227         if isinstance(y1Str, str) and notebook.isVariable(y1Str):
228             self.y1 = notebook.get(y1Str)
229         else:
230             self.y1 = y1Str
231         if isinstance(y2Str, str) and notebook.isVariable(y2Str):
232             self.y2 = notebook.get(y2Str)
233         else:
234             self.y2 = y2Str
235         if isinstance(z1Str, str) and notebook.isVariable(z1Str):
236             self.z1 = notebook.get(z1Str)
237         else:
238             self.z1 = z1Str
239         if isinstance(z2Str, str) and notebook.isVariable(z2Str):
240             self.z2 = notebook.get(z2Str)
241         else:
242             self.z2 = z2Str
243
244 # Parametrized substitute for AxisStruct
245 class AxisStructStr:
246
247     x = 0
248     y = 0
249     z = 0
250     dx = 0
251     dy = 0
252     dz = 0
253     xStr = ""
254     yStr = ""
255     zStr = ""
256     dxStr = ""
257     dyStr = ""
258     dzStr = ""
259
260     def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
261         self.xStr = xStr
262         self.yStr = yStr
263         self.zStr = zStr
264         self.dxStr = dxStr
265         self.dyStr = dyStr
266         self.dzStr = dzStr
267         if isinstance(xStr, str) and notebook.isVariable(xStr):
268             self.x = notebook.get(xStr)
269         else:
270             self.x = xStr
271         if isinstance(yStr, str) and notebook.isVariable(yStr):
272             self.y = notebook.get(yStr)
273         else:
274             self.y = yStr
275         if isinstance(zStr, str) and notebook.isVariable(zStr):
276             self.z = notebook.get(zStr)
277         else:
278             self.z = zStr
279         if isinstance(dxStr, str) and notebook.isVariable(dxStr):
280             self.dx = notebook.get(dxStr)
281         else:
282             self.dx = dxStr
283         if isinstance(dyStr, str) and notebook.isVariable(dyStr):
284             self.dy = notebook.get(dyStr)
285         else:
286             self.dy = dyStr
287         if isinstance(dzStr, str) and notebook.isVariable(dzStr):
288             self.dz = notebook.get(dzStr)
289         else:
290             self.dz = dzStr
291
292 # Parametrized substitute for DirStruct
293 class DirStructStr:
294
295     def __init__(self, pointStruct):
296         self.pointStruct = pointStruct
297
298 # Returns list of variable values from salome notebook
299 def ParsePointStruct(Point):
300     Parameters = 2*var_separator
301     if isinstance(Point, PointStructStr):
302         Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
303         Point = PointStruct(Point.x, Point.y, Point.z)
304     return Point, Parameters
305
306 # Returns list of variable values from salome notebook
307 def ParseDirStruct(Dir):
308     Parameters = 2*var_separator
309     if isinstance(Dir, DirStructStr):
310         pntStr = Dir.pointStruct
311         if isinstance(pntStr, PointStructStr6):
312             Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
313             Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator 
314             Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
315             Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
316         else:
317             Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
318             Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
319         Dir = DirStruct(Point)
320     return Dir, Parameters
321
322 # Returns list of variable values from salome notebook
323 def ParseAxisStruct(Axis):
324     Parameters = 5*var_separator
325     if isinstance(Axis, AxisStructStr):
326         Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
327         Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
328         Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
329     return Axis, Parameters
330
331 ## Return list of variable values from salome notebook
332 def ParseAngles(list):
333     Result = []
334     Parameters = ""
335     for parameter in list:
336         if isinstance(parameter,str) and notebook.isVariable(parameter):
337             Result.append(DegreesToRadians(notebook.get(parameter)))
338             pass
339         else:
340             Result.append(parameter)
341             pass
342         
343         Parameters = Parameters + str(parameter)
344         Parameters = Parameters + var_separator
345         pass
346     Parameters = Parameters[:len(Parameters)-1]
347     return Result, Parameters
348     
349 def IsEqual(val1, val2, tol=PrecisionConfusion):
350     if abs(val1 - val2) < tol:
351         return True
352     return False
353
354 NO_NAME = "NoName"
355
356 ## Gets object name
357 def GetName(obj):
358     ior  = salome.orb.object_to_string(obj)
359     sobj = salome.myStudy.FindObjectIOR(ior)
360     if sobj is None:
361         return NO_NAME
362     else:
363         attr = sobj.FindAttribute("AttributeName")[1]
364         return attr.Value()
365
366 ## Prints error message if a hypothesis was not assigned.
367 def TreatHypoStatus(status, hypName, geomName, isAlgo):
368     if isAlgo:
369         hypType = "algorithm"
370     else:
371         hypType = "hypothesis"
372         pass
373     if status == HYP_UNKNOWN_FATAL :
374         reason = "for unknown reason"
375     elif status == HYP_INCOMPATIBLE :
376         reason = "this hypothesis mismatches the algorithm"
377     elif status == HYP_NOTCONFORM :
378         reason = "a non-conform mesh would be built"
379     elif status == HYP_ALREADY_EXIST :
380         reason = hypType + " of the same dimension is already assigned to this shape"
381     elif status == HYP_BAD_DIM :
382         reason = hypType + " mismatches the shape"
383     elif status == HYP_CONCURENT :
384         reason = "there are concurrent hypotheses on sub-shapes"
385     elif status == HYP_BAD_SUBSHAPE :
386         reason = "the shape is neither the main one, nor its subshape, nor a valid group"
387     elif status == HYP_BAD_GEOMETRY:
388         reason = "geometry mismatches the expectation of the algorithm"
389     elif status == HYP_HIDDEN_ALGO:
390         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
391     elif status == HYP_HIDING_ALGO:
392         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
393     elif status == HYP_NEED_SHAPE:
394         reason = "Algorithm can't work without shape"
395     else:
396         return
397     hypName = '"' + hypName + '"'
398     geomName= '"' + geomName+ '"'
399     if status < HYP_UNKNOWN_FATAL:
400         print hypName, "was assigned to",    geomName,"but", reason
401     else:
402         print hypName, "was not assigned to",geomName,":", reason
403         pass
404
405 # end of l1_auxiliary
406 ## @}
407
408 # All methods of this class are accessible directly from the smesh.py package.
409 class smeshDC(SMESH._objref_SMESH_Gen):
410
411     ## Sets the current study and Geometry component
412     #  @ingroup l1_auxiliary
413     def init_smesh(self,theStudy,geompyD):
414         self.SetCurrentStudy(theStudy,geompyD)
415
416     ## Creates an empty Mesh. This mesh can have an underlying geometry.
417     #  @param obj the Geometrical object on which the mesh is built. If not defined,
418     #             the mesh will have no underlying geometry.
419     #  @param name the name for the new mesh.
420     #  @return an instance of Mesh class.
421     #  @ingroup l2_construct
422     def Mesh(self, obj=0, name=0):
423       return Mesh(self,self.geompyD,obj,name)
424
425     ## Returns a long value from enumeration
426     #  Should be used for SMESH.FunctorType enumeration
427     #  @ingroup l1_controls
428     def EnumToLong(self,theItem):
429         return theItem._v
430
431     ## Gets PointStruct from vertex
432     #  @param theVertex a GEOM object(vertex)
433     #  @return SMESH.PointStruct
434     #  @ingroup l1_auxiliary
435     def GetPointStruct(self,theVertex):
436         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
437         return PointStruct(x,y,z)
438
439     ## Gets DirStruct from vector
440     #  @param theVector a GEOM object(vector)
441     #  @return SMESH.DirStruct
442     #  @ingroup l1_auxiliary
443     def GetDirStruct(self,theVector):
444         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
445         if(len(vertices) != 2):
446             print "Error: vector object is incorrect."
447             return None
448         p1 = self.geompyD.PointCoordinates(vertices[0])
449         p2 = self.geompyD.PointCoordinates(vertices[1])
450         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
451         dirst = DirStruct(pnt)
452         return dirst
453
454     ## Makes DirStruct from a triplet
455     #  @param x,y,z vector components
456     #  @return SMESH.DirStruct
457     #  @ingroup l1_auxiliary
458     def MakeDirStruct(self,x,y,z):
459         pnt = PointStruct(x,y,z)
460         return DirStruct(pnt)
461
462     ## Get AxisStruct from object
463     #  @param theObj a GEOM object (line or plane)
464     #  @return SMESH.AxisStruct
465     #  @ingroup l1_auxiliary
466     def GetAxisStruct(self,theObj):
467         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
468         if len(edges) > 1:
469             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
470             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
471             vertex1 = self.geompyD.PointCoordinates(vertex1)
472             vertex2 = self.geompyD.PointCoordinates(vertex2)
473             vertex3 = self.geompyD.PointCoordinates(vertex3)
474             vertex4 = self.geompyD.PointCoordinates(vertex4)
475             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
476             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
477             normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
478             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
479             return axis
480         elif len(edges) == 1:
481             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
482             p1 = self.geompyD.PointCoordinates( vertex1 )
483             p2 = self.geompyD.PointCoordinates( vertex2 )
484             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
485             return axis
486         return None
487
488     # From SMESH_Gen interface:
489     # ------------------------
490
491     ## Sets the given name to the object
492     #  @param obj the object to rename
493     #  @param name a new object name
494     #  @ingroup l1_auxiliary
495     def SetName(self, obj, name):
496         if isinstance( obj, Mesh ):
497             obj = obj.GetMesh()
498         elif isinstance( obj, Mesh_Algorithm ):
499             obj = obj.GetAlgorithm()
500         ior  = salome.orb.object_to_string(obj)
501         SMESH._objref_SMESH_Gen.SetName(self, ior, name)
502
503     ## Sets the current mode
504     #  @ingroup l1_auxiliary
505     def SetEmbeddedMode( self,theMode ):
506         #self.SetEmbeddedMode(theMode)
507         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
508
509     ## Gets the current mode
510     #  @ingroup l1_auxiliary
511     def IsEmbeddedMode(self):
512         #return self.IsEmbeddedMode()
513         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
514
515     ## Sets the current study
516     #  @ingroup l1_auxiliary
517     def SetCurrentStudy( self, theStudy, geompyD = None ):
518         #self.SetCurrentStudy(theStudy)
519         if not geompyD:
520             import geompy
521             geompyD = geompy.geom
522             pass
523         self.geompyD=geompyD
524         self.SetGeomEngine(geompyD)
525         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
526
527     ## Gets the current study
528     #  @ingroup l1_auxiliary
529     def GetCurrentStudy(self):
530         #return self.GetCurrentStudy()
531         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
532
533     ## Creates a Mesh object importing data from the given UNV file
534     #  @return an instance of Mesh class
535     #  @ingroup l2_impexp
536     def CreateMeshesFromUNV( self,theFileName ):
537         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
538         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
539         return aMesh
540
541     ## Creates a Mesh object(s) importing data from the given MED file
542     #  @return a list of Mesh class instances
543     #  @ingroup l2_impexp
544     def CreateMeshesFromMED( self,theFileName ):
545         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
546         aMeshes = []
547         for iMesh in range(len(aSmeshMeshes)) :
548             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
549             aMeshes.append(aMesh)
550         return aMeshes, aStatus
551
552     ## Creates a Mesh object importing data from the given STL file
553     #  @return an instance of Mesh class
554     #  @ingroup l2_impexp
555     def CreateMeshesFromSTL( self, theFileName ):
556         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
557         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
558         return aMesh
559
560     ## Concatenate the given meshes into one mesh.
561     #  @return an instance of Mesh class
562     #  @param meshes the meshes to combine into one mesh
563     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
564     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
565     #  @param mergeTolerance tolerance for merging nodes
566     #  @param allGroups forces creation of groups of all elements
567     def Concatenate( self, meshes, uniteIdenticalGroups,
568                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
569         if allGroups:
570             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
571                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
572         else:
573             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
574                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
575         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
576         return aMesh
577
578     ## From SMESH_Gen interface
579     #  @return the list of integer values
580     #  @ingroup l1_auxiliary
581     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
582         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
583
584     ## From SMESH_Gen interface. Creates a pattern
585     #  @return an instance of SMESH_Pattern
586     #
587     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
588     #  @ingroup l2_modif_patterns
589     def GetPattern(self):
590         return SMESH._objref_SMESH_Gen.GetPattern(self)
591
592     ## Sets number of segments per diagonal of boundary box of geometry by which
593     #  default segment length of appropriate 1D hypotheses is defined.
594     #  Default value is 10
595     #  @ingroup l1_auxiliary
596     def SetBoundaryBoxSegmentation(self, nbSegments):
597         SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
598
599     ## Concatenate the given meshes into one mesh.
600     #  @return an instance of Mesh class
601     #  @param meshes the meshes to combine into one mesh
602     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
603     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
604     #  @param mergeTolerance tolerance for merging nodes
605     #  @param allGroups forces creation of groups of all elements
606     def Concatenate( self, meshes, uniteIdenticalGroups,
607                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
608         mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
609         if allGroups:
610             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
611                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
612         else:
613             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
614                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
615         aSmeshMesh.SetParameters(Parameters)
616         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
617         return aMesh
618
619     # Filtering. Auxiliary functions:
620     # ------------------------------
621
622     ## Creates an empty criterion
623     #  @return SMESH.Filter.Criterion
624     #  @ingroup l1_controls
625     def GetEmptyCriterion(self):
626         Type = self.EnumToLong(FT_Undefined)
627         Compare = self.EnumToLong(FT_Undefined)
628         Threshold = 0
629         ThresholdStr = ""
630         ThresholdID = ""
631         UnaryOp = self.EnumToLong(FT_Undefined)
632         BinaryOp = self.EnumToLong(FT_Undefined)
633         Tolerance = 1e-07
634         TypeOfElement = ALL
635         Precision = -1 ##@1e-07
636         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
637                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
638
639     ## Creates a criterion by the given parameters
640     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
641     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
642     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
643     #  @param Treshold the threshold value (range of ids as string, shape, numeric)
644     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
645     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
646     #                  FT_Undefined (must be for the last criterion of all criteria)
647     #  @return SMESH.Filter.Criterion
648     #  @ingroup l1_controls
649     def GetCriterion(self,elementType,
650                      CritType,
651                      Compare = FT_EqualTo,
652                      Treshold="",
653                      UnaryOp=FT_Undefined,
654                      BinaryOp=FT_Undefined):
655         aCriterion = self.GetEmptyCriterion()
656         aCriterion.TypeOfElement = elementType
657         aCriterion.Type = self.EnumToLong(CritType)
658
659         aTreshold = Treshold
660
661         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
662             aCriterion.Compare = self.EnumToLong(Compare)
663         elif Compare == "=" or Compare == "==":
664             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
665         elif Compare == "<":
666             aCriterion.Compare = self.EnumToLong(FT_LessThan)
667         elif Compare == ">":
668             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
669         else:
670             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
671             aTreshold = Compare
672
673         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
674                         FT_BelongToCylinder, FT_LyingOnGeom]:
675             # Checks the treshold
676             if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
677                 aCriterion.ThresholdStr = GetName(aTreshold)
678                 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
679             else:
680                 print "Error: The treshold should be a shape."
681                 return None
682         elif CritType == FT_RangeOfIds:
683             # Checks the treshold
684             if isinstance(aTreshold, str):
685                 aCriterion.ThresholdStr = aTreshold
686             else:
687                 print "Error: The treshold should be a string."
688                 return None
689         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
690                           FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
691             # At this point the treshold is unnecessary
692             if aTreshold ==  FT_LogicalNOT:
693                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
694             elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
695                 aCriterion.BinaryOp = aTreshold
696         else:
697             # Check treshold
698             try:
699                 aTreshold = float(aTreshold)
700                 aCriterion.Threshold = aTreshold
701             except:
702                 print "Error: The treshold should be a number."
703                 return None
704
705         if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
706             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
707
708         if Treshold in [FT_LogicalAND, FT_LogicalOR]:
709             aCriterion.BinaryOp = self.EnumToLong(Treshold)
710
711         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
712             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
713
714         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
715             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
716
717         return aCriterion
718
719     ## Creates a filter with the given parameters
720     #  @param elementType the type of elements in the group
721     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
722     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
723     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
724     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
725     #  @return SMESH_Filter
726     #  @ingroup l1_controls
727     def GetFilter(self,elementType,
728                   CritType=FT_Undefined,
729                   Compare=FT_EqualTo,
730                   Treshold="",
731                   UnaryOp=FT_Undefined):
732         aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
733         aFilterMgr = self.CreateFilterManager()
734         aFilter = aFilterMgr.CreateFilter()
735         aCriteria = []
736         aCriteria.append(aCriterion)
737         aFilter.SetCriteria(aCriteria)
738         return aFilter
739
740     ## Creates a numerical functor by its type
741     #  @param theCriterion FT_...; functor type
742     #  @return SMESH_NumericalFunctor
743     #  @ingroup l1_controls
744     def GetFunctor(self,theCriterion):
745         aFilterMgr = self.CreateFilterManager()
746         if theCriterion == FT_AspectRatio:
747             return aFilterMgr.CreateAspectRatio()
748         elif theCriterion == FT_AspectRatio3D:
749             return aFilterMgr.CreateAspectRatio3D()
750         elif theCriterion == FT_Warping:
751             return aFilterMgr.CreateWarping()
752         elif theCriterion == FT_MinimumAngle:
753             return aFilterMgr.CreateMinimumAngle()
754         elif theCriterion == FT_Taper:
755             return aFilterMgr.CreateTaper()
756         elif theCriterion == FT_Skew:
757             return aFilterMgr.CreateSkew()
758         elif theCriterion == FT_Area:
759             return aFilterMgr.CreateArea()
760         elif theCriterion == FT_Volume3D:
761             return aFilterMgr.CreateVolume3D()
762         elif theCriterion == FT_MultiConnection:
763             return aFilterMgr.CreateMultiConnection()
764         elif theCriterion == FT_MultiConnection2D:
765             return aFilterMgr.CreateMultiConnection2D()
766         elif theCriterion == FT_Length:
767             return aFilterMgr.CreateLength()
768         elif theCriterion == FT_Length2D:
769             return aFilterMgr.CreateLength2D()
770         else:
771             print "Error: given parameter is not numerucal functor type."
772
773     ## Creates hypothesis
774     #  @param 
775     #  @param 
776     #  @return created hypothesis instance
777     def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
778         return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
779
780 import omniORB
781 #Registering the new proxy for SMESH_Gen
782 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
783
784
785 # Public class: Mesh
786 # ==================
787
788 ## This class allows defining and managing a mesh.
789 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
790 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
791 #  new nodes and elements and by changing the existing entities), to get information
792 #  about a mesh and to export a mesh into different formats.
793 class Mesh:
794
795     geom = 0
796     mesh = 0
797     editor = 0
798
799     ## Constructor
800     #
801     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
802     #  sets the GUI name of this mesh to \a name.
803     #  @param smeshpyD an instance of smeshDC class
804     #  @param geompyD an instance of geompyDC class
805     #  @param obj Shape to be meshed or SMESH_Mesh object
806     #  @param name Study name of the mesh
807     #  @ingroup l2_construct
808     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
809         self.smeshpyD=smeshpyD
810         self.geompyD=geompyD
811         if obj is None:
812             obj = 0
813         if obj != 0:
814             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
815                 self.geom = obj
816                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
817             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
818                 self.SetMesh(obj)
819         else:
820             self.mesh = self.smeshpyD.CreateEmptyMesh()
821         if name != 0:
822             self.smeshpyD.SetName(self.mesh, name)
823         elif obj != 0:
824             self.smeshpyD.SetName(self.mesh, GetName(obj))
825
826         if not self.geom:
827             self.geom = self.mesh.GetShapeToMesh()
828
829         self.editor = self.mesh.GetMeshEditor()
830
831     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
832     #  @param theMesh a SMESH_Mesh object
833     #  @ingroup l2_construct
834     def SetMesh(self, theMesh):
835         self.mesh = theMesh
836         self.geom = self.mesh.GetShapeToMesh()
837
838     ## Returns the mesh, that is an instance of SMESH_Mesh interface
839     #  @return a SMESH_Mesh object
840     #  @ingroup l2_construct
841     def GetMesh(self):
842         return self.mesh
843
844     ## Gets the name of the mesh
845     #  @return the name of the mesh as a string
846     #  @ingroup l2_construct
847     def GetName(self):
848         name = GetName(self.GetMesh())
849         return name
850
851     ## Sets a name to the mesh
852     #  @param name a new name of the mesh
853     #  @ingroup l2_construct
854     def SetName(self, name):
855         self.smeshpyD.SetName(self.GetMesh(), name)
856
857     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
858     #  The subMesh object gives access to the IDs of nodes and elements.
859     #  @param theSubObject a geometrical object (shape)
860     #  @param theName a name for the submesh
861     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
862     #  @ingroup l2_submeshes
863     def GetSubMesh(self, theSubObject, theName):
864         submesh = self.mesh.GetSubMesh(theSubObject, theName)
865         return submesh
866
867     ## Returns the shape associated to the mesh
868     #  @return a GEOM_Object
869     #  @ingroup l2_construct
870     def GetShape(self):
871         return self.geom
872
873     ## Associates the given shape to the mesh (entails the recreation of the mesh)
874     #  @param geom the shape to be meshed (GEOM_Object)
875     #  @ingroup l2_construct
876     def SetShape(self, geom):
877         self.mesh = self.smeshpyD.CreateMesh(geom)
878
879     ## Returns true if the hypotheses are defined well
880     #  @param theSubObject a subshape of a mesh shape
881     #  @return True or False
882     #  @ingroup l2_construct
883     def IsReadyToCompute(self, theSubObject):
884         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
885
886     ## Returns errors of hypotheses definition.
887     #  The list of errors is empty if everything is OK.
888     #  @param theSubObject a subshape of a mesh shape
889     #  @return a list of errors
890     #  @ingroup l2_construct
891     def GetAlgoState(self, theSubObject):
892         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
893
894     ## Returns a geometrical object on which the given element was built.
895     #  The returned geometrical object, if not nil, is either found in the
896     #  study or published by this method with the given name
897     #  @param theElementID the id of the mesh element
898     #  @param theGeomName the user-defined name of the geometrical object
899     #  @return GEOM::GEOM_Object instance
900     #  @ingroup l2_construct
901     def GetGeometryByMeshElement(self, theElementID, theGeomName):
902         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
903
904     ## Returns the mesh dimension depending on the dimension of the underlying shape
905     #  @return mesh dimension as an integer value [0,3]
906     #  @ingroup l1_auxiliary
907     def MeshDimension(self):
908         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
909         if len( shells ) > 0 :
910             return 3
911         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
912             return 2
913         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
914             return 1
915         else:
916             return 0;
917         pass
918
919     ## Creates a segment discretization 1D algorithm.
920     #  If the optional \a algo parameter is not set, this algorithm is REGULAR.
921     #  \n If the optional \a geom parameter is not set, this algorithm is global.
922     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
923     #  @param algo the type of the required algorithm. Possible values are:
924     #     - smesh.REGULAR,
925     #     - smesh.PYTHON for discretization via a python function,
926     #     - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
927     #  @param geom If defined is the subshape to be meshed
928     #  @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
929     #  @ingroup l3_algos_basic
930     def Segment(self, algo=REGULAR, geom=0):
931         ## if Segment(geom) is called by mistake
932         if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
933             algo, geom = geom, algo
934             if not algo: algo = REGULAR
935             pass
936         if algo == REGULAR:
937             return Mesh_Segment(self,  geom)
938         elif algo == PYTHON:
939             return Mesh_Segment_Python(self, geom)
940         elif algo == COMPOSITE:
941             return Mesh_CompositeSegment(self, geom)
942         else:
943             return Mesh_Segment(self, geom)
944
945     ## Enables creation of nodes and segments usable by 2D algoritms.
946     #  The added nodes and segments must be bound to edges and vertices by
947     #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
948     #  If the optional \a geom parameter is not set, this algorithm is global.
949     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
950     #  @param geom the subshape to be manually meshed
951     #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
952     #  @ingroup l3_algos_basic
953     def UseExistingSegments(self, geom=0):
954         algo = Mesh_UseExisting(1,self,geom)
955         return algo.GetAlgorithm()
956
957     ## Enables creation of nodes and faces usable by 3D algoritms.
958     #  The added nodes and faces must be bound to geom faces by SetNodeOnFace()
959     #  and SetMeshElementOnShape()
960     #  If the optional \a geom parameter is not set, this algorithm is global.
961     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
962     #  @param geom the subshape to be manually meshed
963     #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
964     #  @ingroup l3_algos_basic
965     def UseExistingFaces(self, geom=0):
966         algo = Mesh_UseExisting(2,self,geom)
967         return algo.GetAlgorithm()
968
969     ## Creates a triangle 2D algorithm for faces.
970     #  If the optional \a geom parameter is not set, this algorithm is global.
971     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
972     #  @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
973     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
974     #  @return an instance of Mesh_Triangle algorithm
975     #  @ingroup l3_algos_basic
976     def Triangle(self, algo=MEFISTO, geom=0):
977         ## if Triangle(geom) is called by mistake
978         if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
979             geom = algo
980             algo = MEFISTO
981
982         return Mesh_Triangle(self, algo, geom)
983
984     ## Creates a quadrangle 2D algorithm for faces.
985     #  If the optional \a geom parameter is not set, this algorithm is global.
986     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
987     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
988     #  @return an instance of Mesh_Quadrangle algorithm
989     #  @ingroup l3_algos_basic
990     def Quadrangle(self, geom=0):
991         return Mesh_Quadrangle(self,  geom)
992
993     ## Creates a tetrahedron 3D algorithm for solids.
994     #  The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
995     #  If the optional \a geom parameter is not set, this algorithm is global.
996     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
997     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
998     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
999     #  @return an instance of Mesh_Tetrahedron algorithm
1000     #  @ingroup l3_algos_basic
1001     def Tetrahedron(self, algo=NETGEN, geom=0):
1002         ## if Tetrahedron(geom) is called by mistake
1003         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1004             algo, geom = geom, algo
1005             if not algo: algo = NETGEN
1006             pass
1007         return Mesh_Tetrahedron(self,  algo, geom)
1008
1009     ## Creates a hexahedron 3D algorithm for solids.
1010     #  If the optional \a geom parameter is not set, this algorithm is global.
1011     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1012     #  @param algo possible values are: smesh.Hexa, smesh.Hexotic
1013     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
1014     #  @return an instance of Mesh_Hexahedron algorithm
1015     #  @ingroup l3_algos_basic
1016     def Hexahedron(self, algo=Hexa, geom=0):
1017         ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1018         if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1019             if   geom in [Hexa, Hexotic]: algo, geom = geom, algo
1020             elif geom == 0:               algo, geom = Hexa, algo
1021         return Mesh_Hexahedron(self, algo, geom)
1022
1023     ## Deprecated, used only for compatibility!
1024     #  @return an instance of Mesh_Netgen algorithm
1025     #  @ingroup l3_algos_basic
1026     def Netgen(self, is3D, geom=0):
1027         return Mesh_Netgen(self,  is3D, geom)
1028
1029     ## Creates a projection 1D algorithm for edges.
1030     #  If the optional \a geom parameter is not set, this algorithm is global.
1031     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1032     #  @param geom If defined, the subshape to be meshed
1033     #  @return an instance of Mesh_Projection1D algorithm
1034     #  @ingroup l3_algos_proj
1035     def Projection1D(self, geom=0):
1036         return Mesh_Projection1D(self,  geom)
1037
1038     ## Creates a projection 2D algorithm for faces.
1039     #  If the optional \a geom parameter is not set, this algorithm is global.
1040     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1041     #  @param geom If defined, the subshape to be meshed
1042     #  @return an instance of Mesh_Projection2D algorithm
1043     #  @ingroup l3_algos_proj
1044     def Projection2D(self, geom=0):
1045         return Mesh_Projection2D(self,  geom)
1046
1047     ## Creates a projection 3D algorithm for solids.
1048     #  If the optional \a geom parameter is not set, this algorithm is global.
1049     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1050     #  @param geom If defined, the subshape to be meshed
1051     #  @return an instance of Mesh_Projection3D algorithm
1052     #  @ingroup l3_algos_proj
1053     def Projection3D(self, geom=0):
1054         return Mesh_Projection3D(self,  geom)
1055
1056     ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1057     #  If the optional \a geom parameter is not set, this algorithm is global.
1058     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1059     #  @param geom If defined, the subshape to be meshed
1060     #  @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1061     #  @ingroup l3_algos_radialp l3_algos_3dextr
1062     def Prism(self, geom=0):
1063         shape = geom
1064         if shape==0:
1065             shape = self.geom
1066         nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1067         nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1068         if nbSolids == 0 or nbSolids == nbShells:
1069             return Mesh_Prism3D(self,  geom)
1070         return Mesh_RadialPrism3D(self,  geom)
1071
1072     ## Computes the mesh and returns the status of the computation
1073     #  @return True or False
1074     #  @ingroup l2_construct
1075     def Compute(self, geom=0):
1076         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1077             if self.geom == 0:
1078                 geom = self.mesh.GetShapeToMesh()
1079             else:
1080                 geom = self.geom
1081         ok = False
1082         try:
1083             ok = self.smeshpyD.Compute(self.mesh, geom)
1084         except SALOME.SALOME_Exception, ex:
1085             print "Mesh computation failed, exception caught:"
1086             print "    ", ex.details.text
1087         except:
1088             import traceback
1089             print "Mesh computation failed, exception caught:"
1090             traceback.print_exc()
1091         if True:#not ok:
1092             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1093             allReasons = ""
1094             for err in errors:
1095                 if err.isGlobalAlgo:
1096                     glob = "global"
1097                 else:
1098                     glob = "local"
1099                     pass
1100                 dim = err.algoDim
1101                 name = err.algoName
1102                 if len(name) == 0:
1103                     reason = '%s %sD algorithm is missing' % (glob, dim)
1104                 elif err.state == HYP_MISSING:
1105                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1106                               % (glob, dim, name, dim))
1107                 elif err.state == HYP_NOTCONFORM:
1108                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1109                 elif err.state == HYP_BAD_PARAMETER:
1110                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1111                               % ( glob, dim, name ))
1112                 elif err.state == HYP_BAD_GEOMETRY:
1113                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1114                               'geometry' % ( glob, dim, name ))
1115                 else:
1116                     reason = "For unknown reason."+\
1117                              " Revise Mesh.Compute() implementation in smeshDC.py!"
1118                     pass
1119                 if allReasons != "":
1120                     allReasons += "\n"
1121                     pass
1122                 allReasons += reason
1123                 pass
1124             if allReasons != "":
1125                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1126                 print allReasons
1127                 ok = False
1128             elif not ok:
1129                 print '"' + GetName(self.mesh) + '"',"has not been computed."
1130                 pass
1131             pass
1132         if salome.sg.hasDesktop():
1133             smeshgui = salome.ImportComponentGUI("SMESH")
1134             smeshgui.Init(self.mesh.GetStudyId())
1135             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1136             salome.sg.updateObjBrowser(1)
1137             pass
1138         return ok
1139
1140     ## Removes all nodes and elements
1141     #  @ingroup l2_construct
1142     def Clear(self):
1143         self.mesh.Clear()
1144         if salome.sg.hasDesktop():
1145             smeshgui = salome.ImportComponentGUI("SMESH")
1146             smeshgui.Init(self.mesh.GetStudyId())
1147             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1148             salome.sg.updateObjBrowser(1)
1149
1150     ## Removes all nodes and elements of indicated shape
1151     #  @ingroup l2_construct
1152     def ClearSubMesh(self, geomId):
1153         self.mesh.ClearSubMesh(geomId)
1154         if salome.sg.hasDesktop():
1155             smeshgui = salome.ImportComponentGUI("SMESH")
1156             smeshgui.Init(self.mesh.GetStudyId())
1157             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1158             salome.sg.updateObjBrowser(1)
1159
1160     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1161     #  @param fineness [0,-1] defines mesh fineness
1162     #  @return True or False
1163     #  @ingroup l3_algos_basic
1164     def AutomaticTetrahedralization(self, fineness=0):
1165         dim = self.MeshDimension()
1166         # assign hypotheses
1167         self.RemoveGlobalHypotheses()
1168         self.Segment().AutomaticLength(fineness)
1169         if dim > 1 :
1170             self.Triangle().LengthFromEdges()
1171             pass
1172         if dim > 2 :
1173             self.Tetrahedron(NETGEN)
1174             pass
1175         return self.Compute()
1176
1177     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1178     #  @param fineness [0,-1] defines mesh fineness
1179     #  @return True or False
1180     #  @ingroup l3_algos_basic
1181     def AutomaticHexahedralization(self, fineness=0):
1182         dim = self.MeshDimension()
1183         # assign the hypotheses
1184         self.RemoveGlobalHypotheses()
1185         self.Segment().AutomaticLength(fineness)
1186         if dim > 1 :
1187             self.Quadrangle()
1188             pass
1189         if dim > 2 :
1190             self.Hexahedron()
1191             pass
1192         return self.Compute()
1193
1194     ## Assigns a hypothesis
1195     #  @param hyp a hypothesis to assign
1196     #  @param geom a subhape of mesh geometry
1197     #  @return SMESH.Hypothesis_Status
1198     #  @ingroup l2_hypotheses
1199     def AddHypothesis(self, hyp, geom=0):
1200         if isinstance( hyp, Mesh_Algorithm ):
1201             hyp = hyp.GetAlgorithm()
1202             pass
1203         if not geom:
1204             geom = self.geom
1205             if not geom:
1206                 geom = self.mesh.GetShapeToMesh()
1207             pass
1208         status = self.mesh.AddHypothesis(geom, hyp)
1209         isAlgo = hyp._narrow( SMESH_Algo )
1210         TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1211         return status
1212
1213     ## Unassigns a hypothesis
1214     #  @param hyp a hypothesis to unassign
1215     #  @param geom a subshape of mesh geometry
1216     #  @return SMESH.Hypothesis_Status
1217     #  @ingroup l2_hypotheses
1218     def RemoveHypothesis(self, hyp, geom=0):
1219         if isinstance( hyp, Mesh_Algorithm ):
1220             hyp = hyp.GetAlgorithm()
1221             pass
1222         if not geom:
1223             geom = self.geom
1224             pass
1225         status = self.mesh.RemoveHypothesis(geom, hyp)
1226         return status
1227
1228     ## Gets the list of hypotheses added on a geometry
1229     #  @param geom a subshape of mesh geometry
1230     #  @return the sequence of SMESH_Hypothesis
1231     #  @ingroup l2_hypotheses
1232     def GetHypothesisList(self, geom):
1233         return self.mesh.GetHypothesisList( geom )
1234
1235     ## Removes all global hypotheses
1236     #  @ingroup l2_hypotheses
1237     def RemoveGlobalHypotheses(self):
1238         current_hyps = self.mesh.GetHypothesisList( self.geom )
1239         for hyp in current_hyps:
1240             self.mesh.RemoveHypothesis( self.geom, hyp )
1241             pass
1242         pass
1243
1244     ## Creates a mesh group based on the geometric object \a grp
1245     #  and gives a \a name, \n if this parameter is not defined
1246     #  the name is the same as the geometric group name \n
1247     #  Note: Works like GroupOnGeom().
1248     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
1249     #  @param name the name of the mesh group
1250     #  @return SMESH_GroupOnGeom
1251     #  @ingroup l2_grps_create
1252     def Group(self, grp, name=""):
1253         return self.GroupOnGeom(grp, name)
1254
1255     ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1256     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
1257     #  @param f the file name
1258     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1259     #  @ingroup l2_impexp
1260     def ExportToMED(self, f, version, opt=0):
1261         self.mesh.ExportToMED(f, opt, version)
1262
1263     ## Exports the mesh in a file in MED format
1264     #  @param f is the file name
1265     #  @param auto_groups boolean parameter for creating/not creating
1266     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1267     #  the typical use is auto_groups=false.
1268     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1269     #  @ingroup l2_impexp
1270     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1271         self.mesh.ExportToMED(f, auto_groups, version)
1272
1273     ## Exports the mesh in a file in DAT format
1274     #  @param f the file name
1275     #  @ingroup l2_impexp
1276     def ExportDAT(self, f):
1277         self.mesh.ExportDAT(f)
1278
1279     ## Exports the mesh in a file in UNV format
1280     #  @param f the file name
1281     #  @ingroup l2_impexp
1282     def ExportUNV(self, f):
1283         self.mesh.ExportUNV(f)
1284
1285     ## Export the mesh in a file in STL format
1286     #  @param f the file name
1287     #  @param ascii defines the file encoding
1288     #  @ingroup l2_impexp
1289     def ExportSTL(self, f, ascii=1):
1290         self.mesh.ExportSTL(f, ascii)
1291
1292
1293     # Operations with groups:
1294     # ----------------------
1295
1296     ## Creates an empty mesh group
1297     #  @param elementType the type of elements in the group
1298     #  @param name the name of the mesh group
1299     #  @return SMESH_Group
1300     #  @ingroup l2_grps_create
1301     def CreateEmptyGroup(self, elementType, name):
1302         return self.mesh.CreateGroup(elementType, name)
1303
1304     ## Creates a mesh group based on the geometrical object \a grp
1305     #  and gives a \a name, \n if this parameter is not defined
1306     #  the name is the same as the geometrical group name
1307     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
1308     #  @param name the name of the mesh group
1309     #  @param typ  the type of elements in the group. If not set, it is
1310     #              automatically detected by the type of the geometry
1311     #  @return SMESH_GroupOnGeom
1312     #  @ingroup l2_grps_create
1313     def GroupOnGeom(self, grp, name="", typ=None):
1314         if name == "":
1315             name = grp.GetName()
1316
1317         if typ == None:
1318             tgeo = str(grp.GetShapeType())
1319             if tgeo == "VERTEX":
1320                 typ = NODE
1321             elif tgeo == "EDGE":
1322                 typ = EDGE
1323             elif tgeo == "FACE":
1324                 typ = FACE
1325             elif tgeo == "SOLID":
1326                 typ = VOLUME
1327             elif tgeo == "SHELL":
1328                 typ = VOLUME
1329             elif tgeo == "COMPOUND":
1330                 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1331                     print "Mesh.Group: empty geometric group", GetName( grp )
1332                     return 0
1333                 tgeo = self.geompyD.GetType(grp)
1334                 if tgeo == geompyDC.ShapeType["VERTEX"]:
1335                     typ = NODE
1336                 elif tgeo == geompyDC.ShapeType["EDGE"]:
1337                     typ = EDGE
1338                 elif tgeo == geompyDC.ShapeType["FACE"]:
1339                     typ = FACE
1340                 elif tgeo == geompyDC.ShapeType["SOLID"]:
1341                     typ = VOLUME
1342
1343         if typ == None:
1344             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1345             return 0
1346         else:
1347             return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1348
1349     ## Creates a mesh group by the given ids of elements
1350     #  @param groupName the name of the mesh group
1351     #  @param elementType the type of elements in the group
1352     #  @param elemIDs the list of ids
1353     #  @return SMESH_Group
1354     #  @ingroup l2_grps_create
1355     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1356         group = self.mesh.CreateGroup(elementType, groupName)
1357         group.Add(elemIDs)
1358         return group
1359
1360     ## Creates a mesh group by the given conditions
1361     #  @param groupName the name of the mesh group
1362     #  @param elementType the type of elements in the group
1363     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1364     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1365     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
1366     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
1367     #  @return SMESH_Group
1368     #  @ingroup l2_grps_create
1369     def MakeGroup(self,
1370                   groupName,
1371                   elementType,
1372                   CritType=FT_Undefined,
1373                   Compare=FT_EqualTo,
1374                   Treshold="",
1375                   UnaryOp=FT_Undefined):
1376         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1377         group = self.MakeGroupByCriterion(groupName, aCriterion)
1378         return group
1379
1380     ## Creates a mesh group by the given criterion
1381     #  @param groupName the name of the mesh group
1382     #  @param Criterion the instance of Criterion class
1383     #  @return SMESH_Group
1384     #  @ingroup l2_grps_create
1385     def MakeGroupByCriterion(self, groupName, Criterion):
1386         aFilterMgr = self.smeshpyD.CreateFilterManager()
1387         aFilter = aFilterMgr.CreateFilter()
1388         aCriteria = []
1389         aCriteria.append(Criterion)
1390         aFilter.SetCriteria(aCriteria)
1391         group = self.MakeGroupByFilter(groupName, aFilter)
1392         return group
1393
1394     ## Creates a mesh group by the given criteria (list of criteria)
1395     #  @param groupName the name of the mesh group
1396     #  @param theCriteria the list of criteria
1397     #  @return SMESH_Group
1398     #  @ingroup l2_grps_create
1399     def MakeGroupByCriteria(self, groupName, theCriteria):
1400         aFilterMgr = self.smeshpyD.CreateFilterManager()
1401         aFilter = aFilterMgr.CreateFilter()
1402         aFilter.SetCriteria(theCriteria)
1403         group = self.MakeGroupByFilter(groupName, aFilter)
1404         return group
1405
1406     ## Creates a mesh group by the given filter
1407     #  @param groupName the name of the mesh group
1408     #  @param theFilter the instance of Filter class
1409     #  @return SMESH_Group
1410     #  @ingroup l2_grps_create
1411     def MakeGroupByFilter(self, groupName, theFilter):
1412         anIds = theFilter.GetElementsId(self.mesh)
1413         anElemType = theFilter.GetElementType()
1414         group = self.MakeGroupByIds(groupName, anElemType, anIds)
1415         return group
1416
1417     ## Passes mesh elements through the given filter and return IDs of fitting elements
1418     #  @param theFilter SMESH_Filter
1419     #  @return a list of ids
1420     #  @ingroup l1_controls
1421     def GetIdsFromFilter(self, theFilter):
1422         return theFilter.GetElementsId(self.mesh)
1423
1424     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1425     #  Returns a list of special structures (borders).
1426     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1427     #  @ingroup l1_controls
1428     def GetFreeBorders(self):
1429         aFilterMgr = self.smeshpyD.CreateFilterManager()
1430         aPredicate = aFilterMgr.CreateFreeEdges()
1431         aPredicate.SetMesh(self.mesh)
1432         aBorders = aPredicate.GetBorders()
1433         return aBorders
1434
1435     ## Removes a group
1436     #  @ingroup l2_grps_delete
1437     def RemoveGroup(self, group):
1438         self.mesh.RemoveGroup(group)
1439
1440     ## Removes a group with its contents
1441     #  @ingroup l2_grps_delete
1442     def RemoveGroupWithContents(self, group):
1443         self.mesh.RemoveGroupWithContents(group)
1444
1445     ## Gets the list of groups existing in the mesh
1446     #  @return a sequence of SMESH_GroupBase
1447     #  @ingroup l2_grps_create
1448     def GetGroups(self):
1449         return self.mesh.GetGroups()
1450
1451     ## Gets the number of groups existing in the mesh
1452     #  @return the quantity of groups as an integer value
1453     #  @ingroup l2_grps_create
1454     def NbGroups(self):
1455         return self.mesh.NbGroups()
1456
1457     ## Gets the list of names of groups existing in the mesh
1458     #  @return list of strings
1459     #  @ingroup l2_grps_create
1460     def GetGroupNames(self):
1461         groups = self.GetGroups()
1462         names = []
1463         for group in groups:
1464             names.append(group.GetName())
1465         return names
1466
1467     ## Produces a union of two groups
1468     #  A new group is created. All mesh elements that are
1469     #  present in the initial groups are added to the new one
1470     #  @return an instance of SMESH_Group
1471     #  @ingroup l2_grps_operon
1472     def UnionGroups(self, group1, group2, name):
1473         return self.mesh.UnionGroups(group1, group2, name)
1474         
1475     ## Produces a union list of groups
1476     #  New group is created. All mesh elements that are present in 
1477     #  initial groups are added to the new one
1478     #  @return an instance of SMESH_Group
1479     #  @ingroup l2_grps_operon
1480     def UnionListOfGroups(self, groups, name):
1481       return self.mesh.UnionListOfGroups(groups, name)
1482       
1483     ## Prodices an intersection of two groups
1484     #  A new group is created. All mesh elements that are common
1485     #  for the two initial groups are added to the new one.
1486     #  @return an instance of SMESH_Group
1487     #  @ingroup l2_grps_operon
1488     def IntersectGroups(self, group1, group2, name):
1489         return self.mesh.IntersectGroups(group1, group2, name)
1490         
1491     ## Produces an intersection of groups
1492     #  New group is created. All mesh elements that are present in all 
1493     #  initial groups simultaneously are added to the new one
1494     #  @return an instance of SMESH_Group
1495     #  @ingroup l2_grps_operon
1496     def IntersectListOfGroups(self, groups, name):
1497       return self.mesh.IntersectListOfGroups(groups, name)
1498
1499     ## Produces a cut of two groups
1500     #  A new group is created. All mesh elements that are present in
1501     #  the main group but are not present in the tool group are added to the new one
1502     #  @return an instance of SMESH_Group
1503     #  @ingroup l2_grps_operon
1504     def CutGroups(self, main_group, tool_group, name):
1505         return self.mesh.CutGroups(main_group, tool_group, name)
1506         
1507     ## Produces a cut of groups
1508     #  A new group is created. All mesh elements that are present in main groups 
1509     #  but do not present in tool groups are added to the new one
1510     #  @return an instance of SMESH_Group
1511     #  @ingroup l2_grps_operon
1512     def CutListOfGroups(self, main_groups, tool_groups, name):
1513       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1514       
1515     ## Produces a group of elements with specified element type using list of existing groups
1516     #  A new group is created. System 
1517     #  1) extract all nodes on which groups elements are built
1518     #  2) combine all elements of specified dimension laying on these nodes
1519     #  @return an instance of SMESH_Group
1520     #  @ingroup l2_grps_operon
1521     def CreateDimGroup(self, groups, elem_type, name):
1522       return self.mesh.CreateDimGroup(groups, elem_type, name)
1523
1524
1525     ## Convert group on geom into standalone group
1526     #  @ingroup l2_grps_delete
1527     def ConvertToStandalone(self, group):
1528         return self.mesh.ConvertToStandalone(group)
1529
1530     # Get some info about mesh:
1531     # ------------------------
1532
1533     ## Returns the log of nodes and elements added or removed
1534     #  since the previous clear of the log.
1535     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1536     #  @return list of log_block structures:
1537     #                                        commandType
1538     #                                        number
1539     #                                        coords
1540     #                                        indexes
1541     #  @ingroup l1_auxiliary
1542     def GetLog(self, clearAfterGet):
1543         return self.mesh.GetLog(clearAfterGet)
1544
1545     ## Clears the log of nodes and elements added or removed since the previous
1546     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1547     #  @ingroup l1_auxiliary
1548     def ClearLog(self):
1549         self.mesh.ClearLog()
1550
1551     ## Toggles auto color mode on the object.
1552     #  @param theAutoColor the flag which toggles auto color mode.
1553     #  @ingroup l1_auxiliary
1554     def SetAutoColor(self, theAutoColor):
1555         self.mesh.SetAutoColor(theAutoColor)
1556
1557     ## Gets flag of object auto color mode.
1558     #  @return True or False
1559     #  @ingroup l1_auxiliary
1560     def GetAutoColor(self):
1561         return self.mesh.GetAutoColor()
1562
1563     ## Gets the internal ID
1564     #  @return integer value, which is the internal Id of the mesh
1565     #  @ingroup l1_auxiliary
1566     def GetId(self):
1567         return self.mesh.GetId()
1568
1569     ## Get the study Id
1570     #  @return integer value, which is the study Id of the mesh
1571     #  @ingroup l1_auxiliary
1572     def GetStudyId(self):
1573         return self.mesh.GetStudyId()
1574
1575     ## Checks the group names for duplications.
1576     #  Consider the maximum group name length stored in MED file.
1577     #  @return True or False
1578     #  @ingroup l1_auxiliary
1579     def HasDuplicatedGroupNamesMED(self):
1580         return self.mesh.HasDuplicatedGroupNamesMED()
1581
1582     ## Obtains the mesh editor tool
1583     #  @return an instance of SMESH_MeshEditor
1584     #  @ingroup l1_modifying
1585     def GetMeshEditor(self):
1586         return self.mesh.GetMeshEditor()
1587
1588     ## Gets MED Mesh
1589     #  @return an instance of SALOME_MED::MESH
1590     #  @ingroup l1_auxiliary
1591     def GetMEDMesh(self):
1592         return self.mesh.GetMEDMesh()
1593
1594
1595     # Get informations about mesh contents:
1596     # ------------------------------------
1597
1598     ## Returns the number of nodes in the mesh
1599     #  @return an integer value
1600     #  @ingroup l1_meshinfo
1601     def NbNodes(self):
1602         return self.mesh.NbNodes()
1603
1604     ## Returns the number of elements in the mesh
1605     #  @return an integer value
1606     #  @ingroup l1_meshinfo
1607     def NbElements(self):
1608         return self.mesh.NbElements()
1609
1610     ## Returns the number of edges in the mesh
1611     #  @return an integer value
1612     #  @ingroup l1_meshinfo
1613     def NbEdges(self):
1614         return self.mesh.NbEdges()
1615
1616     ## Returns the number of edges with the given order in the mesh
1617     #  @param elementOrder the order of elements:
1618     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1619     #  @return an integer value
1620     #  @ingroup l1_meshinfo
1621     def NbEdgesOfOrder(self, elementOrder):
1622         return self.mesh.NbEdgesOfOrder(elementOrder)
1623
1624     ## Returns the number of faces in the mesh
1625     #  @return an integer value
1626     #  @ingroup l1_meshinfo
1627     def NbFaces(self):
1628         return self.mesh.NbFaces()
1629
1630     ## Returns the number of faces with the given order in the mesh
1631     #  @param elementOrder the order of elements:
1632     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1633     #  @return an integer value
1634     #  @ingroup l1_meshinfo
1635     def NbFacesOfOrder(self, elementOrder):
1636         return self.mesh.NbFacesOfOrder(elementOrder)
1637
1638     ## Returns the number of triangles in the mesh
1639     #  @return an integer value
1640     #  @ingroup l1_meshinfo
1641     def NbTriangles(self):
1642         return self.mesh.NbTriangles()
1643
1644     ## Returns the number of triangles with the given order in the mesh
1645     #  @param elementOrder is the order of elements:
1646     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1647     #  @return an integer value
1648     #  @ingroup l1_meshinfo
1649     def NbTrianglesOfOrder(self, elementOrder):
1650         return self.mesh.NbTrianglesOfOrder(elementOrder)
1651
1652     ## Returns the number of quadrangles in the mesh
1653     #  @return an integer value
1654     #  @ingroup l1_meshinfo
1655     def NbQuadrangles(self):
1656         return self.mesh.NbQuadrangles()
1657
1658     ## Returns the number of quadrangles with the given order in the mesh
1659     #  @param elementOrder the order of elements:
1660     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1661     #  @return an integer value
1662     #  @ingroup l1_meshinfo
1663     def NbQuadranglesOfOrder(self, elementOrder):
1664         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1665
1666     ## Returns the number of polygons in the mesh
1667     #  @return an integer value
1668     #  @ingroup l1_meshinfo
1669     def NbPolygons(self):
1670         return self.mesh.NbPolygons()
1671
1672     ## Returns the number of volumes in the mesh
1673     #  @return an integer value
1674     #  @ingroup l1_meshinfo
1675     def NbVolumes(self):
1676         return self.mesh.NbVolumes()
1677
1678     ## Returns the number of volumes with the given order in the mesh
1679     #  @param elementOrder  the order of elements:
1680     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1681     #  @return an integer value
1682     #  @ingroup l1_meshinfo
1683     def NbVolumesOfOrder(self, elementOrder):
1684         return self.mesh.NbVolumesOfOrder(elementOrder)
1685
1686     ## Returns the number of tetrahedrons in the mesh
1687     #  @return an integer value
1688     #  @ingroup l1_meshinfo
1689     def NbTetras(self):
1690         return self.mesh.NbTetras()
1691
1692     ## Returns the number of tetrahedrons with the given order in the mesh
1693     #  @param elementOrder  the order of elements:
1694     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1695     #  @return an integer value
1696     #  @ingroup l1_meshinfo
1697     def NbTetrasOfOrder(self, elementOrder):
1698         return self.mesh.NbTetrasOfOrder(elementOrder)
1699
1700     ## Returns the number of hexahedrons in the mesh
1701     #  @return an integer value
1702     #  @ingroup l1_meshinfo
1703     def NbHexas(self):
1704         return self.mesh.NbHexas()
1705
1706     ## Returns the number of hexahedrons with the given order in the mesh
1707     #  @param elementOrder  the order of elements:
1708     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1709     #  @return an integer value
1710     #  @ingroup l1_meshinfo
1711     def NbHexasOfOrder(self, elementOrder):
1712         return self.mesh.NbHexasOfOrder(elementOrder)
1713
1714     ## Returns the number of pyramids in the mesh
1715     #  @return an integer value
1716     #  @ingroup l1_meshinfo
1717     def NbPyramids(self):
1718         return self.mesh.NbPyramids()
1719
1720     ## Returns the number of pyramids with the given order in the mesh
1721     #  @param elementOrder  the order of elements:
1722     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1723     #  @return an integer value
1724     #  @ingroup l1_meshinfo
1725     def NbPyramidsOfOrder(self, elementOrder):
1726         return self.mesh.NbPyramidsOfOrder(elementOrder)
1727
1728     ## Returns the number of prisms in the mesh
1729     #  @return an integer value
1730     #  @ingroup l1_meshinfo
1731     def NbPrisms(self):
1732         return self.mesh.NbPrisms()
1733
1734     ## Returns the number of prisms with the given order in the mesh
1735     #  @param elementOrder  the order of elements:
1736     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1737     #  @return an integer value
1738     #  @ingroup l1_meshinfo
1739     def NbPrismsOfOrder(self, elementOrder):
1740         return self.mesh.NbPrismsOfOrder(elementOrder)
1741
1742     ## Returns the number of polyhedrons in the mesh
1743     #  @return an integer value
1744     #  @ingroup l1_meshinfo
1745     def NbPolyhedrons(self):
1746         return self.mesh.NbPolyhedrons()
1747
1748     ## Returns the number of submeshes in the mesh
1749     #  @return an integer value
1750     #  @ingroup l1_meshinfo
1751     def NbSubMesh(self):
1752         return self.mesh.NbSubMesh()
1753
1754     ## Returns the list of mesh elements IDs
1755     #  @return the list of integer values
1756     #  @ingroup l1_meshinfo
1757     def GetElementsId(self):
1758         return self.mesh.GetElementsId()
1759
1760     ## Returns the list of IDs of mesh elements with the given type
1761     #  @param elementType  the required type of elements
1762     #  @return list of integer values
1763     #  @ingroup l1_meshinfo
1764     def GetElementsByType(self, elementType):
1765         return self.mesh.GetElementsByType(elementType)
1766
1767     ## Returns the list of mesh nodes IDs
1768     #  @return the list of integer values
1769     #  @ingroup l1_meshinfo
1770     def GetNodesId(self):
1771         return self.mesh.GetNodesId()
1772
1773     # Get the information about mesh elements:
1774     # ------------------------------------
1775
1776     ## Returns the type of mesh element
1777     #  @return the value from SMESH::ElementType enumeration
1778     #  @ingroup l1_meshinfo
1779     def GetElementType(self, id, iselem):
1780         return self.mesh.GetElementType(id, iselem)
1781
1782     ## Returns the list of submesh elements IDs
1783     #  @param Shape a geom object(subshape) IOR
1784     #         Shape must be the subshape of a ShapeToMesh()
1785     #  @return the list of integer values
1786     #  @ingroup l1_meshinfo
1787     def GetSubMeshElementsId(self, Shape):
1788         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1789             ShapeID = Shape.GetSubShapeIndices()[0]
1790         else:
1791             ShapeID = Shape
1792         return self.mesh.GetSubMeshElementsId(ShapeID)
1793
1794     ## Returns the list of submesh nodes IDs
1795     #  @param Shape a geom object(subshape) IOR
1796     #         Shape must be the subshape of a ShapeToMesh()
1797     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1798     #  @return the list of integer values
1799     #  @ingroup l1_meshinfo
1800     def GetSubMeshNodesId(self, Shape, all):
1801         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1802             ShapeID = Shape.GetSubShapeIndices()[0]
1803         else:
1804             ShapeID = Shape
1805         return self.mesh.GetSubMeshNodesId(ShapeID, all)
1806
1807     ## Returns the list of IDs of submesh elements with the given type
1808     #  @param Shape a geom object(subshape) IOR
1809     #         Shape must be a subshape of a ShapeToMesh()
1810     #  @return the list of integer values
1811     #  @ingroup l1_meshinfo
1812     def GetSubMeshElementType(self, Shape):
1813         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1814             ShapeID = Shape.GetSubShapeIndices()[0]
1815         else:
1816             ShapeID = Shape
1817         return self.mesh.GetSubMeshElementType(ShapeID)
1818
1819     ## Gets the mesh description
1820     #  @return string value
1821     #  @ingroup l1_meshinfo
1822     def Dump(self):
1823         return self.mesh.Dump()
1824
1825
1826     # Get the information about nodes and elements of a mesh by its IDs:
1827     # -----------------------------------------------------------
1828
1829     ## Gets XYZ coordinates of a node
1830     #  \n If there is no nodes for the given ID - returns an empty list
1831     #  @return a list of double precision values
1832     #  @ingroup l1_meshinfo
1833     def GetNodeXYZ(self, id):
1834         return self.mesh.GetNodeXYZ(id)
1835
1836     ## Returns list of IDs of inverse elements for the given node
1837     #  \n If there is no node for the given ID - returns an empty list
1838     #  @return a list of integer values
1839     #  @ingroup l1_meshinfo
1840     def GetNodeInverseElements(self, id):
1841         return self.mesh.GetNodeInverseElements(id)
1842
1843     ## @brief Returns the position of a node on the shape
1844     #  @return SMESH::NodePosition
1845     #  @ingroup l1_meshinfo
1846     def GetNodePosition(self,NodeID):
1847         return self.mesh.GetNodePosition(NodeID)
1848
1849     ## If the given element is a node, returns the ID of shape
1850     #  \n If there is no node for the given ID - returns -1
1851     #  @return an integer value
1852     #  @ingroup l1_meshinfo
1853     def GetShapeID(self, id):
1854         return self.mesh.GetShapeID(id)
1855
1856     ## Returns the ID of the result shape after
1857     #  FindShape() from SMESH_MeshEditor for the given element
1858     #  \n If there is no element for the given ID - returns -1
1859     #  @return an integer value
1860     #  @ingroup l1_meshinfo
1861     def GetShapeIDForElem(self,id):
1862         return self.mesh.GetShapeIDForElem(id)
1863
1864     ## Returns the number of nodes for the given element
1865     #  \n If there is no element for the given ID - returns -1
1866     #  @return an integer value
1867     #  @ingroup l1_meshinfo
1868     def GetElemNbNodes(self, id):
1869         return self.mesh.GetElemNbNodes(id)
1870
1871     ## Returns the node ID the given index for the given element
1872     #  \n If there is no element for the given ID - returns -1
1873     #  \n If there is no node for the given index - returns -2
1874     #  @return an integer value
1875     #  @ingroup l1_meshinfo
1876     def GetElemNode(self, id, index):
1877         return self.mesh.GetElemNode(id, index)
1878
1879     ## Returns the IDs of nodes of the given element
1880     #  @return a list of integer values
1881     #  @ingroup l1_meshinfo
1882     def GetElemNodes(self, id):
1883         return self.mesh.GetElemNodes(id)
1884
1885     ## Returns true if the given node is the medium node in the given quadratic element
1886     #  @ingroup l1_meshinfo
1887     def IsMediumNode(self, elementID, nodeID):
1888         return self.mesh.IsMediumNode(elementID, nodeID)
1889
1890     ## Returns true if the given node is the medium node in one of quadratic elements
1891     #  @ingroup l1_meshinfo
1892     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1893         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1894
1895     ## Returns the number of edges for the given element
1896     #  @ingroup l1_meshinfo
1897     def ElemNbEdges(self, id):
1898         return self.mesh.ElemNbEdges(id)
1899
1900     ## Returns the number of faces for the given element
1901     #  @ingroup l1_meshinfo
1902     def ElemNbFaces(self, id):
1903         return self.mesh.ElemNbFaces(id)
1904
1905     ## Returns true if the given element is a polygon
1906     #  @ingroup l1_meshinfo
1907     def IsPoly(self, id):
1908         return self.mesh.IsPoly(id)
1909
1910     ## Returns true if the given element is quadratic
1911     #  @ingroup l1_meshinfo
1912     def IsQuadratic(self, id):
1913         return self.mesh.IsQuadratic(id)
1914
1915     ## Returns XYZ coordinates of the barycenter of the given element
1916     #  \n If there is no element for the given ID - returns an empty list
1917     #  @return a list of three double values
1918     #  @ingroup l1_meshinfo
1919     def BaryCenter(self, id):
1920         return self.mesh.BaryCenter(id)
1921
1922
1923     # Mesh edition (SMESH_MeshEditor functionality):
1924     # ---------------------------------------------
1925
1926     ## Removes the elements from the mesh by ids
1927     #  @param IDsOfElements is a list of ids of elements to remove
1928     #  @return True or False
1929     #  @ingroup l2_modif_del
1930     def RemoveElements(self, IDsOfElements):
1931         return self.editor.RemoveElements(IDsOfElements)
1932
1933     ## Removes nodes from mesh by ids
1934     #  @param IDsOfNodes is a list of ids of nodes to remove
1935     #  @return True or False
1936     #  @ingroup l2_modif_del
1937     def RemoveNodes(self, IDsOfNodes):
1938         return self.editor.RemoveNodes(IDsOfNodes)
1939
1940     ## Add a node to the mesh by coordinates
1941     #  @return Id of the new node
1942     #  @ingroup l2_modif_add
1943     def AddNode(self, x, y, z):
1944         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1945         self.mesh.SetParameters(Parameters)
1946         return self.editor.AddNode( x, y, z)
1947
1948     ## Creates a linear or quadratic edge (this is determined
1949     #  by the number of given nodes).
1950     #  @param IDsOfNodes the list of node IDs for creation of the element.
1951     #  The order of nodes in this list should correspond to the description
1952     #  of MED. \n This description is located by the following link:
1953     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1954     #  @return the Id of the new edge
1955     #  @ingroup l2_modif_add
1956     def AddEdge(self, IDsOfNodes):
1957         return self.editor.AddEdge(IDsOfNodes)
1958
1959     ## Creates a linear or quadratic face (this is determined
1960     #  by the number of given nodes).
1961     #  @param IDsOfNodes the list of node IDs for creation of the element.
1962     #  The order of nodes in this list should correspond to the description
1963     #  of MED. \n This description is located by the following link:
1964     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1965     #  @return the Id of the new face
1966     #  @ingroup l2_modif_add
1967     def AddFace(self, IDsOfNodes):
1968         return self.editor.AddFace(IDsOfNodes)
1969
1970     ## Adds a polygonal face to the mesh by the list of node IDs
1971     #  @param IdsOfNodes the list of node IDs for creation of the element.
1972     #  @return the Id of the new face
1973     #  @ingroup l2_modif_add
1974     def AddPolygonalFace(self, IdsOfNodes):
1975         return self.editor.AddPolygonalFace(IdsOfNodes)
1976
1977     ## Creates both simple and quadratic volume (this is determined
1978     #  by the number of given nodes).
1979     #  @param IDsOfNodes the list of node IDs for creation of the element.
1980     #  The order of nodes in this list should correspond to the description
1981     #  of MED. \n This description is located by the following link:
1982     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1983     #  @return the Id of the new volumic element
1984     #  @ingroup l2_modif_add
1985     def AddVolume(self, IDsOfNodes):
1986         return self.editor.AddVolume(IDsOfNodes)
1987
1988     ## Creates a volume of many faces, giving nodes for each face.
1989     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
1990     #  @param Quantities the list of integer values, Quantities[i]
1991     #         gives the quantity of nodes in face number i.
1992     #  @return the Id of the new volumic element
1993     #  @ingroup l2_modif_add
1994     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1995         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1996
1997     ## Creates a volume of many faces, giving the IDs of the existing faces.
1998     #  @param IdsOfFaces the list of face IDs for volume creation.
1999     #
2000     #  Note:  The created volume will refer only to the nodes
2001     #         of the given faces, not to the faces themselves.
2002     #  @return the Id of the new volumic element
2003     #  @ingroup l2_modif_add
2004     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2005         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2006
2007
2008     ## @brief Binds a node to a vertex
2009     #  @param NodeID a node ID
2010     #  @param Vertex a vertex or vertex ID
2011     #  @return True if succeed else raises an exception
2012     #  @ingroup l2_modif_add
2013     def SetNodeOnVertex(self, NodeID, Vertex):
2014         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2015             VertexID = Vertex.GetSubShapeIndices()[0]
2016         else:
2017             VertexID = Vertex
2018         try:
2019             self.editor.SetNodeOnVertex(NodeID, VertexID)
2020         except SALOME.SALOME_Exception, inst:
2021             raise ValueError, inst.details.text
2022         return True
2023
2024
2025     ## @brief Stores the node position on an edge
2026     #  @param NodeID a node ID
2027     #  @param Edge an edge or edge ID
2028     #  @param paramOnEdge a parameter on the edge where the node is located
2029     #  @return True if succeed else raises an exception
2030     #  @ingroup l2_modif_add
2031     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2032         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2033             EdgeID = Edge.GetSubShapeIndices()[0]
2034         else:
2035             EdgeID = Edge
2036         try:
2037             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2038         except SALOME.SALOME_Exception, inst:
2039             raise ValueError, inst.details.text
2040         return True
2041
2042     ## @brief Stores node position on a face
2043     #  @param NodeID a node ID
2044     #  @param Face a face or face ID
2045     #  @param u U parameter on the face where the node is located
2046     #  @param v V parameter on the face where the node is located
2047     #  @return True if succeed else raises an exception
2048     #  @ingroup l2_modif_add
2049     def SetNodeOnFace(self, NodeID, Face, u, v):
2050         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2051             FaceID = Face.GetSubShapeIndices()[0]
2052         else:
2053             FaceID = Face
2054         try:
2055             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2056         except SALOME.SALOME_Exception, inst:
2057             raise ValueError, inst.details.text
2058         return True
2059
2060     ## @brief Binds a node to a solid
2061     #  @param NodeID a node ID
2062     #  @param Solid  a solid or solid ID
2063     #  @return True if succeed else raises an exception
2064     #  @ingroup l2_modif_add
2065     def SetNodeInVolume(self, NodeID, Solid):
2066         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2067             SolidID = Solid.GetSubShapeIndices()[0]
2068         else:
2069             SolidID = Solid
2070         try:
2071             self.editor.SetNodeInVolume(NodeID, SolidID)
2072         except SALOME.SALOME_Exception, inst:
2073             raise ValueError, inst.details.text
2074         return True
2075
2076     ## @brief Bind an element to a shape
2077     #  @param ElementID an element ID
2078     #  @param Shape a shape or shape ID
2079     #  @return True if succeed else raises an exception
2080     #  @ingroup l2_modif_add
2081     def SetMeshElementOnShape(self, ElementID, Shape):
2082         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2083             ShapeID = Shape.GetSubShapeIndices()[0]
2084         else:
2085             ShapeID = Shape
2086         try:
2087             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2088         except SALOME.SALOME_Exception, inst:
2089             raise ValueError, inst.details.text
2090         return True
2091
2092
2093     ## Moves the node with the given id
2094     #  @param NodeID the id of the node
2095     #  @param x  a new X coordinate
2096     #  @param y  a new Y coordinate
2097     #  @param z  a new Z coordinate
2098     #  @return True if succeed else False
2099     #  @ingroup l2_modif_movenode
2100     def MoveNode(self, NodeID, x, y, z):
2101         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2102         self.mesh.SetParameters(Parameters)
2103         return self.editor.MoveNode(NodeID, x, y, z)
2104
2105     ## Finds the node closest to a point and moves it to a point location
2106     #  @param x  the X coordinate of a point
2107     #  @param y  the Y coordinate of a point
2108     #  @param z  the Z coordinate of a point
2109     #  @return the ID of a node
2110     #  @ingroup l2_modif_throughp
2111     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2112         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2113         self.mesh.SetParameters(Parameters)
2114         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2115
2116     ## Finds the node closest to a point
2117     #  @param x  the X coordinate of a point
2118     #  @param y  the Y coordinate of a point
2119     #  @param z  the Z coordinate of a point
2120     #  @return the ID of a node
2121     #  @ingroup l2_modif_throughp
2122     def FindNodeClosestTo(self, x, y, z):
2123         preview = self.mesh.GetMeshEditPreviewer()
2124         return preview.MoveClosestNodeToPoint(x, y, z, -1)
2125
2126     ## Finds the node closest to a point and moves it to a point location
2127     #  @param x  the X coordinate of a point
2128     #  @param y  the Y coordinate of a point
2129     #  @param z  the Z coordinate of a point
2130     #  @return the ID of a moved node
2131     #  @ingroup l2_modif_throughp
2132     def MeshToPassThroughAPoint(self, x, y, z):
2133         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2134
2135     ## Replaces two neighbour triangles sharing Node1-Node2 link
2136     #  with the triangles built on the same 4 nodes but having other common link.
2137     #  @param NodeID1  the ID of the first node
2138     #  @param NodeID2  the ID of the second node
2139     #  @return false if proper faces were not found
2140     #  @ingroup l2_modif_invdiag
2141     def InverseDiag(self, NodeID1, NodeID2):
2142         return self.editor.InverseDiag(NodeID1, NodeID2)
2143
2144     ## Replaces two neighbour triangles sharing Node1-Node2 link
2145     #  with a quadrangle built on the same 4 nodes.
2146     #  @param NodeID1  the ID of the first node
2147     #  @param NodeID2  the ID of the second node
2148     #  @return false if proper faces were not found
2149     #  @ingroup l2_modif_unitetri
2150     def DeleteDiag(self, NodeID1, NodeID2):
2151         return self.editor.DeleteDiag(NodeID1, NodeID2)
2152
2153     ## Reorients elements by ids
2154     #  @param IDsOfElements if undefined reorients all mesh elements
2155     #  @return True if succeed else False
2156     #  @ingroup l2_modif_changori
2157     def Reorient(self, IDsOfElements=None):
2158         if IDsOfElements == None:
2159             IDsOfElements = self.GetElementsId()
2160         return self.editor.Reorient(IDsOfElements)
2161
2162     ## Reorients all elements of the object
2163     #  @param theObject mesh, submesh or group
2164     #  @return True if succeed else False
2165     #  @ingroup l2_modif_changori
2166     def ReorientObject(self, theObject):
2167         if ( isinstance( theObject, Mesh )):
2168             theObject = theObject.GetMesh()
2169         return self.editor.ReorientObject(theObject)
2170
2171     ## Fuses the neighbouring triangles into quadrangles.
2172     #  @param IDsOfElements The triangles to be fused,
2173     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
2174     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2175     #                       is still performed; theMaxAngle is mesured in radians.
2176     #                       Also it could be a name of variable which defines angle in degrees.
2177     #  @return TRUE in case of success, FALSE otherwise.
2178     #  @ingroup l2_modif_unitetri
2179     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2180         flag = False
2181         if isinstance(MaxAngle,str):
2182             flag = True
2183         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2184         if flag:
2185             MaxAngle = DegreesToRadians(MaxAngle)
2186         if IDsOfElements == []:
2187             IDsOfElements = self.GetElementsId()
2188         self.mesh.SetParameters(Parameters)
2189         Functor = 0
2190         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2191             Functor = theCriterion
2192         else:
2193             Functor = self.smeshpyD.GetFunctor(theCriterion)
2194         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2195
2196     ## Fuses the neighbouring triangles of the object into quadrangles
2197     #  @param theObject is mesh, submesh or group
2198     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2199     #  @param MaxAngle   a max angle between element normals at which the fusion
2200     #                   is still performed; theMaxAngle is mesured in radians.
2201     #  @return TRUE in case of success, FALSE otherwise.
2202     #  @ingroup l2_modif_unitetri
2203     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2204         if ( isinstance( theObject, Mesh )):
2205             theObject = theObject.GetMesh()
2206         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2207
2208     ## Splits quadrangles into triangles.
2209     #  @param IDsOfElements the faces to be splitted.
2210     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2211     #  @return TRUE in case of success, FALSE otherwise.
2212     #  @ingroup l2_modif_cutquadr
2213     def QuadToTri (self, IDsOfElements, theCriterion):
2214         if IDsOfElements == []:
2215             IDsOfElements = self.GetElementsId()
2216         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2217
2218     ## Splits quadrangles into triangles.
2219     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
2220     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2221     #  @return TRUE in case of success, FALSE otherwise.
2222     #  @ingroup l2_modif_cutquadr
2223     def QuadToTriObject (self, theObject, theCriterion):
2224         if ( isinstance( theObject, Mesh )):
2225             theObject = theObject.GetMesh()
2226         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2227
2228     ## Splits quadrangles into triangles.
2229     #  @param IDsOfElements the faces to be splitted
2230     #  @param Diag13        is used to choose a diagonal for splitting.
2231     #  @return TRUE in case of success, FALSE otherwise.
2232     #  @ingroup l2_modif_cutquadr
2233     def SplitQuad (self, IDsOfElements, Diag13):
2234         if IDsOfElements == []:
2235             IDsOfElements = self.GetElementsId()
2236         return self.editor.SplitQuad(IDsOfElements, Diag13)
2237
2238     ## Splits quadrangles into triangles.
2239     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2240     #  @param Diag13    is used to choose a diagonal for splitting.
2241     #  @return TRUE in case of success, FALSE otherwise.
2242     #  @ingroup l2_modif_cutquadr
2243     def SplitQuadObject (self, theObject, Diag13):
2244         if ( isinstance( theObject, Mesh )):
2245             theObject = theObject.GetMesh()
2246         return self.editor.SplitQuadObject(theObject, Diag13)
2247
2248     ## Finds a better splitting of the given quadrangle.
2249     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2250     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
2251     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2252     #          diagonal is better, 0 if error occurs.
2253     #  @ingroup l2_modif_cutquadr
2254     def BestSplit (self, IDOfQuad, theCriterion):
2255         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2256
2257     ## Splits quadrangle faces near triangular facets of volumes
2258     #
2259     #  @ingroup l1_auxiliary
2260     def SplitQuadsNearTriangularFacets(self):
2261         faces_array = self.GetElementsByType(SMESH.FACE)
2262         for face_id in faces_array:
2263             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2264                 quad_nodes = self.mesh.GetElemNodes(face_id)
2265                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2266                 isVolumeFound = False
2267                 for node1_elem in node1_elems:
2268                     if not isVolumeFound:
2269                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2270                             nb_nodes = self.GetElemNbNodes(node1_elem)
2271                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2272                                 volume_elem = node1_elem
2273                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2274                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2275                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2276                                         isVolumeFound = True
2277                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2278                                             self.SplitQuad([face_id], False) # diagonal 2-4
2279                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2280                                         isVolumeFound = True
2281                                         self.SplitQuad([face_id], True) # diagonal 1-3
2282                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2283                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2284                                         isVolumeFound = True
2285                                         self.SplitQuad([face_id], True) # diagonal 1-3
2286
2287     ## @brief Splits hexahedrons into tetrahedrons.
2288     #
2289     #  This operation uses pattern mapping functionality for splitting.
2290     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2291     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2292     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2293     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2294     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2295     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2296     #  @return TRUE in case of success, FALSE otherwise.
2297     #  @ingroup l1_auxiliary
2298     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2299         # Pattern:     5.---------.6
2300         #              /|#*      /|
2301         #             / | #*    / |
2302         #            /  |  # * /  |
2303         #           /   |   # /*  |
2304         # (0,0,1) 4.---------.7 * |
2305         #          |#*  |1   | # *|
2306         #          | # *.----|---#.2
2307         #          |  #/ *   |   /
2308         #          |  /#  *  |  /
2309         #          | /   # * | /
2310         #          |/      #*|/
2311         # (0,0,0) 0.---------.3
2312         pattern_tetra = "!!! Nb of points: \n 8 \n\
2313         !!! Points: \n\
2314         0 0 0  !- 0 \n\
2315         0 1 0  !- 1 \n\
2316         1 1 0  !- 2 \n\
2317         1 0 0  !- 3 \n\
2318         0 0 1  !- 4 \n\
2319         0 1 1  !- 5 \n\
2320         1 1 1  !- 6 \n\
2321         1 0 1  !- 7 \n\
2322         !!! Indices of points of 6 tetras: \n\
2323         0 3 4 1 \n\
2324         7 4 3 1 \n\
2325         4 7 5 1 \n\
2326         6 2 5 7 \n\
2327         1 5 2 7 \n\
2328         2 3 1 7 \n"
2329
2330         pattern = self.smeshpyD.GetPattern()
2331         isDone  = pattern.LoadFromFile(pattern_tetra)
2332         if not isDone:
2333             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2334             return isDone
2335
2336         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2337         isDone = pattern.MakeMesh(self.mesh, False, False)
2338         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2339
2340         # split quafrangle faces near triangular facets of volumes
2341         self.SplitQuadsNearTriangularFacets()
2342
2343         return isDone
2344
2345     ## @brief Split hexahedrons into prisms.
2346     #
2347     #  Uses the pattern mapping functionality for splitting.
2348     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2349     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2350     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2351     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2352     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2353     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2354     #  @return TRUE in case of success, FALSE otherwise.
2355     #  @ingroup l1_auxiliary
2356     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2357         # Pattern:     5.---------.6
2358         #              /|#       /|
2359         #             / | #     / |
2360         #            /  |  #   /  |
2361         #           /   |   # /   |
2362         # (0,0,1) 4.---------.7   |
2363         #          |    |    |    |
2364         #          |   1.----|----.2
2365         #          |   / *   |   /
2366         #          |  /   *  |  /
2367         #          | /     * | /
2368         #          |/       *|/
2369         # (0,0,0) 0.---------.3
2370         pattern_prism = "!!! Nb of points: \n 8 \n\
2371         !!! Points: \n\
2372         0 0 0  !- 0 \n\
2373         0 1 0  !- 1 \n\
2374         1 1 0  !- 2 \n\
2375         1 0 0  !- 3 \n\
2376         0 0 1  !- 4 \n\
2377         0 1 1  !- 5 \n\
2378         1 1 1  !- 6 \n\
2379         1 0 1  !- 7 \n\
2380         !!! Indices of points of 2 prisms: \n\
2381         0 1 3 4 5 7 \n\
2382         2 3 1 6 7 5 \n"
2383
2384         pattern = self.smeshpyD.GetPattern()
2385         isDone  = pattern.LoadFromFile(pattern_prism)
2386         if not isDone:
2387             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2388             return isDone
2389
2390         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2391         isDone = pattern.MakeMesh(self.mesh, False, False)
2392         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2393
2394         # Splits quafrangle faces near triangular facets of volumes
2395         self.SplitQuadsNearTriangularFacets()
2396
2397         return isDone
2398
2399     ## Smoothes elements
2400     #  @param IDsOfElements the list if ids of elements to smooth
2401     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2402     #  Note that nodes built on edges and boundary nodes are always fixed.
2403     #  @param MaxNbOfIterations the maximum number of iterations
2404     #  @param MaxAspectRatio varies in range [1.0, inf]
2405     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2406     #  @return TRUE in case of success, FALSE otherwise.
2407     #  @ingroup l2_modif_smooth
2408     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2409                MaxNbOfIterations, MaxAspectRatio, Method):
2410         if IDsOfElements == []:
2411             IDsOfElements = self.GetElementsId()
2412         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2413         self.mesh.SetParameters(Parameters)
2414         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2415                                   MaxNbOfIterations, MaxAspectRatio, Method)
2416
2417     ## Smoothes elements which belong to the given object
2418     #  @param theObject the object to smooth
2419     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2420     #  Note that nodes built on edges and boundary nodes are always fixed.
2421     #  @param MaxNbOfIterations the maximum number of iterations
2422     #  @param MaxAspectRatio varies in range [1.0, inf]
2423     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2424     #  @return TRUE in case of success, FALSE otherwise.
2425     #  @ingroup l2_modif_smooth
2426     def SmoothObject(self, theObject, IDsOfFixedNodes,
2427                      MaxNbOfIterations, MaxAspectRatio, Method):
2428         if ( isinstance( theObject, Mesh )):
2429             theObject = theObject.GetMesh()
2430         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2431                                         MaxNbOfIterations, MaxAspectRatio, Method)
2432
2433     ## Parametrically smoothes the given elements
2434     #  @param IDsOfElements the list if ids of elements to smooth
2435     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2436     #  Note that nodes built on edges and boundary nodes are always fixed.
2437     #  @param MaxNbOfIterations the maximum number of iterations
2438     #  @param MaxAspectRatio varies in range [1.0, inf]
2439     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2440     #  @return TRUE in case of success, FALSE otherwise.
2441     #  @ingroup l2_modif_smooth
2442     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2443                          MaxNbOfIterations, MaxAspectRatio, Method):
2444         if IDsOfElements == []:
2445             IDsOfElements = self.GetElementsId()
2446         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2447         self.mesh.SetParameters(Parameters)
2448         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2449                                             MaxNbOfIterations, MaxAspectRatio, Method)
2450
2451     ## Parametrically smoothes the elements which belong to the given object
2452     #  @param theObject the object to smooth
2453     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2454     #  Note that nodes built on edges and boundary nodes are always fixed.
2455     #  @param MaxNbOfIterations the maximum number of iterations
2456     #  @param MaxAspectRatio varies in range [1.0, inf]
2457     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2458     #  @return TRUE in case of success, FALSE otherwise.
2459     #  @ingroup l2_modif_smooth
2460     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2461                                MaxNbOfIterations, MaxAspectRatio, Method):
2462         if ( isinstance( theObject, Mesh )):
2463             theObject = theObject.GetMesh()
2464         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2465                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2466
2467     ## Converts the mesh to quadratic, deletes old elements, replacing
2468     #  them with quadratic with the same id.
2469     #  @ingroup l2_modif_tofromqu
2470     def ConvertToQuadratic(self, theForce3d):
2471         self.editor.ConvertToQuadratic(theForce3d)
2472
2473     ## Converts the mesh from quadratic to ordinary,
2474     #  deletes old quadratic elements, \n replacing
2475     #  them with ordinary mesh elements with the same id.
2476     #  @return TRUE in case of success, FALSE otherwise.
2477     #  @ingroup l2_modif_tofromqu
2478     def ConvertFromQuadratic(self):
2479         return self.editor.ConvertFromQuadratic()
2480
2481     ## Renumber mesh nodes
2482     #  @ingroup l2_modif_renumber
2483     def RenumberNodes(self):
2484         self.editor.RenumberNodes()
2485
2486     ## Renumber mesh elements
2487     #  @ingroup l2_modif_renumber
2488     def RenumberElements(self):
2489         self.editor.RenumberElements()
2490
2491     ## Generates new elements by rotation of the elements around the axis
2492     #  @param IDsOfElements the list of ids of elements to sweep
2493     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2494     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2495     #  @param NbOfSteps the number of steps
2496     #  @param Tolerance tolerance
2497     #  @param MakeGroups forces the generation of new groups from existing ones
2498     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2499     #                    of all steps, else - size of each step
2500     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2501     #  @ingroup l2_modif_extrurev
2502     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2503                       MakeGroups=False, TotalAngle=False):
2504         flag = False
2505         if isinstance(AngleInRadians,str):
2506             flag = True
2507         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2508         if flag:
2509             AngleInRadians = DegreesToRadians(AngleInRadians)
2510         if IDsOfElements == []:
2511             IDsOfElements = self.GetElementsId()
2512         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2513             Axis = self.smeshpyD.GetAxisStruct(Axis)
2514         Axis,AxisParameters = ParseAxisStruct(Axis)
2515         if TotalAngle and NbOfSteps:
2516             AngleInRadians /= NbOfSteps
2517         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2518         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2519         self.mesh.SetParameters(Parameters)
2520         if MakeGroups:
2521             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2522                                                        AngleInRadians, NbOfSteps, Tolerance)
2523         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2524         return []
2525
2526     ## Generates new elements by rotation of the elements of object around the axis
2527     #  @param theObject object which elements should be sweeped
2528     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2529     #  @param AngleInRadians the angle of Rotation
2530     #  @param NbOfSteps number of steps
2531     #  @param Tolerance tolerance
2532     #  @param MakeGroups forces the generation of new groups from existing ones
2533     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2534     #                    of all steps, else - size of each step
2535     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2536     #  @ingroup l2_modif_extrurev
2537     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2538                             MakeGroups=False, TotalAngle=False):
2539         flag = False
2540         if isinstance(AngleInRadians,str):
2541             flag = True
2542         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2543         if flag:
2544             AngleInRadians = DegreesToRadians(AngleInRadians)
2545         if ( isinstance( theObject, Mesh )):
2546             theObject = theObject.GetMesh()
2547         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2548             Axis = self.smeshpyD.GetAxisStruct(Axis)
2549         Axis,AxisParameters = ParseAxisStruct(Axis)
2550         if TotalAngle and NbOfSteps:
2551             AngleInRadians /= NbOfSteps
2552         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2553         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2554         self.mesh.SetParameters(Parameters)
2555         if MakeGroups:
2556             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2557                                                              NbOfSteps, Tolerance)
2558         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2559         return []
2560
2561     ## Generates new elements by rotation of the elements of object around the axis
2562     #  @param theObject object which elements should be sweeped
2563     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2564     #  @param AngleInRadians the angle of Rotation
2565     #  @param NbOfSteps number of steps
2566     #  @param Tolerance tolerance
2567     #  @param MakeGroups forces the generation of new groups from existing ones
2568     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2569     #                    of all steps, else - size of each step
2570     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2571     #  @ingroup l2_modif_extrurev
2572     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2573                               MakeGroups=False, TotalAngle=False):
2574         flag = False
2575         if isinstance(AngleInRadians,str):
2576             flag = True
2577         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2578         if flag:
2579             AngleInRadians = DegreesToRadians(AngleInRadians)
2580         if ( isinstance( theObject, Mesh )):
2581             theObject = theObject.GetMesh()
2582         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2583             Axis = self.smeshpyD.GetAxisStruct(Axis)
2584         Axis,AxisParameters = ParseAxisStruct(Axis)
2585         if TotalAngle and NbOfSteps:
2586             AngleInRadians /= NbOfSteps
2587         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2588         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2589         self.mesh.SetParameters(Parameters)
2590         if MakeGroups:
2591             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2592                                                                NbOfSteps, Tolerance)
2593         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2594         return []
2595
2596     ## Generates new elements by rotation of the elements of object around the axis
2597     #  @param theObject object which elements should be sweeped
2598     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2599     #  @param AngleInRadians the angle of Rotation
2600     #  @param NbOfSteps number of steps
2601     #  @param Tolerance tolerance
2602     #  @param MakeGroups forces the generation of new groups from existing ones
2603     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2604     #                    of all steps, else - size of each step
2605     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2606     #  @ingroup l2_modif_extrurev
2607     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2608                               MakeGroups=False, TotalAngle=False):
2609         flag = False
2610         if isinstance(AngleInRadians,str):
2611             flag = True
2612         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2613         if flag:
2614             AngleInRadians = DegreesToRadians(AngleInRadians)
2615         if ( isinstance( theObject, Mesh )):
2616             theObject = theObject.GetMesh()
2617         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2618             Axis = self.smeshpyD.GetAxisStruct(Axis)
2619         Axis,AxisParameters = ParseAxisStruct(Axis)
2620         if TotalAngle and NbOfSteps:
2621             AngleInRadians /= NbOfSteps
2622         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2623         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2624         self.mesh.SetParameters(Parameters)
2625         if MakeGroups:
2626             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2627                                                              NbOfSteps, Tolerance)
2628         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2629         return []
2630
2631     ## Generates new elements by extrusion of the elements with given ids
2632     #  @param IDsOfElements the list of elements ids for extrusion
2633     #  @param StepVector vector, defining the direction and value of extrusion
2634     #  @param NbOfSteps the number of steps
2635     #  @param MakeGroups forces the generation of new groups from existing ones
2636     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2637     #  @ingroup l2_modif_extrurev
2638     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2639         if IDsOfElements == []:
2640             IDsOfElements = self.GetElementsId()
2641         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2642             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2643         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2644         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2645         Parameters = StepVectorParameters + var_separator + Parameters
2646         self.mesh.SetParameters(Parameters)
2647         if MakeGroups:
2648             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2649         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2650         return []
2651
2652     ## Generates new elements by extrusion of the elements with given ids
2653     #  @param IDsOfElements is ids of elements
2654     #  @param StepVector vector, defining the direction and value of extrusion
2655     #  @param NbOfSteps the number of steps
2656     #  @param ExtrFlags sets flags for extrusion
2657     #  @param SewTolerance uses for comparing locations of nodes if flag
2658     #         EXTRUSION_FLAG_SEW is set
2659     #  @param MakeGroups forces the generation of new groups from existing ones
2660     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2661     #  @ingroup l2_modif_extrurev
2662     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2663                           ExtrFlags, SewTolerance, MakeGroups=False):
2664         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2665             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2666         if MakeGroups:
2667             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2668                                                            ExtrFlags, SewTolerance)
2669         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2670                                       ExtrFlags, SewTolerance)
2671         return []
2672
2673     ## Generates new elements by extrusion of the elements which belong to the object
2674     #  @param theObject the object which elements should be processed
2675     #  @param StepVector vector, defining the direction and value of extrusion
2676     #  @param NbOfSteps the number of steps
2677     #  @param MakeGroups forces the generation of new groups from existing ones
2678     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2679     #  @ingroup l2_modif_extrurev
2680     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2681         if ( isinstance( theObject, Mesh )):
2682             theObject = theObject.GetMesh()
2683         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2684             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2685         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2686         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2687         Parameters = StepVectorParameters + var_separator + Parameters
2688         self.mesh.SetParameters(Parameters)
2689         if MakeGroups:
2690             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2691         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2692         return []
2693
2694     ## Generates new elements by extrusion of the elements which belong to the object
2695     #  @param theObject object which elements should be processed
2696     #  @param StepVector vector, defining the direction and value of extrusion
2697     #  @param NbOfSteps the number of steps
2698     #  @param MakeGroups to generate new groups from existing ones
2699     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2700     #  @ingroup l2_modif_extrurev
2701     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2702         if ( isinstance( theObject, Mesh )):
2703             theObject = theObject.GetMesh()
2704         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2705             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2706         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2707         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2708         Parameters = StepVectorParameters + var_separator + Parameters
2709         self.mesh.SetParameters(Parameters)
2710         if MakeGroups:
2711             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2712         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2713         return []
2714
2715     ## Generates new elements by extrusion of the elements which belong to the object
2716     #  @param theObject object which elements should be processed
2717     #  @param StepVector vector, defining the direction and value of extrusion
2718     #  @param NbOfSteps the number of steps
2719     #  @param MakeGroups forces the generation of new groups from existing ones
2720     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2721     #  @ingroup l2_modif_extrurev
2722     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2723         if ( isinstance( theObject, Mesh )):
2724             theObject = theObject.GetMesh()
2725         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2726             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2727         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2728         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2729         Parameters = StepVectorParameters + var_separator + Parameters
2730         self.mesh.SetParameters(Parameters)
2731         if MakeGroups:
2732             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2733         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2734         return []
2735
2736     ## Generates new elements by extrusion of the given elements
2737     #  The path of extrusion must be a meshed edge.
2738     #  @param IDsOfElements ids of elements
2739     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2740     #  @param PathShape shape(edge) defines the sub-mesh for the path
2741     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2742     #  @param HasAngles allows the shape to be rotated around the path
2743     #                   to get the resulting mesh in a helical fashion
2744     #  @param Angles list of angles
2745     #  @param HasRefPoint allows using the reference point
2746     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2747     #         The User can specify any point as the Reference Point.
2748     #  @param MakeGroups forces the generation of new groups from existing ones
2749     #  @param LinearVariation forces the computation of rotation angles as linear
2750     #                         variation of the given Angles along path steps
2751     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2752     #          only SMESH::Extrusion_Error otherwise
2753     #  @ingroup l2_modif_extrurev
2754     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2755                            HasAngles, Angles, HasRefPoint, RefPoint,
2756                            MakeGroups=False, LinearVariation=False):
2757         Angles,AnglesParameters = ParseAngles(Angles)
2758         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2759         if IDsOfElements == []:
2760             IDsOfElements = self.GetElementsId()
2761         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2762             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2763             pass
2764         if ( isinstance( PathMesh, Mesh )):
2765             PathMesh = PathMesh.GetMesh()
2766         if HasAngles and Angles and LinearVariation:
2767             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2768             pass
2769         Parameters = AnglesParameters + var_separator + RefPointParameters
2770         self.mesh.SetParameters(Parameters)
2771         if MakeGroups:
2772             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2773                                                             PathShape, NodeStart, HasAngles,
2774                                                             Angles, HasRefPoint, RefPoint)
2775         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2776                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2777
2778     ## Generates new elements by extrusion of the elements which belong to the object
2779     #  The path of extrusion must be a meshed edge.
2780     #  @param theObject the object which elements should be processed
2781     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2782     #  @param PathShape shape(edge) defines the sub-mesh for the path
2783     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2784     #  @param HasAngles allows the shape to be rotated around the path
2785     #                   to get the resulting mesh in a helical fashion
2786     #  @param Angles list of angles
2787     #  @param HasRefPoint allows using the reference point
2788     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2789     #         The User can specify any point as the Reference Point.
2790     #  @param MakeGroups forces the generation of new groups from existing ones
2791     #  @param LinearVariation forces the computation of rotation angles as linear
2792     #                         variation of the given Angles along path steps
2793     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2794     #          only SMESH::Extrusion_Error otherwise
2795     #  @ingroup l2_modif_extrurev
2796     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2797                                  HasAngles, Angles, HasRefPoint, RefPoint,
2798                                  MakeGroups=False, LinearVariation=False):
2799         Angles,AnglesParameters = ParseAngles(Angles)
2800         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2801         if ( isinstance( theObject, Mesh )):
2802             theObject = theObject.GetMesh()
2803         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2804             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2805         if ( isinstance( PathMesh, Mesh )):
2806             PathMesh = PathMesh.GetMesh()
2807         if HasAngles and Angles and LinearVariation:
2808             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2809             pass
2810         Parameters = AnglesParameters + var_separator + RefPointParameters
2811         self.mesh.SetParameters(Parameters)
2812         if MakeGroups:
2813             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2814                                                                   PathShape, NodeStart, HasAngles,
2815                                                                   Angles, HasRefPoint, RefPoint)
2816         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2817                                                     NodeStart, HasAngles, Angles, HasRefPoint,
2818                                                     RefPoint)
2819
2820     ## Generates new elements by extrusion of the elements which belong to the object
2821     #  The path of extrusion must be a meshed edge.
2822     #  @param theObject the object which elements should be processed
2823     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2824     #  @param PathShape shape(edge) defines the sub-mesh for the path
2825     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2826     #  @param HasAngles allows the shape to be rotated around the path
2827     #                   to get the resulting mesh in a helical fashion
2828     #  @param Angles list of angles
2829     #  @param HasRefPoint allows using the reference point
2830     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2831     #         The User can specify any point as the Reference Point.
2832     #  @param MakeGroups forces the generation of new groups from existing ones
2833     #  @param LinearVariation forces the computation of rotation angles as linear
2834     #                         variation of the given Angles along path steps
2835     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2836     #          only SMESH::Extrusion_Error otherwise
2837     #  @ingroup l2_modif_extrurev
2838     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2839                                    HasAngles, Angles, HasRefPoint, RefPoint,
2840                                    MakeGroups=False, LinearVariation=False):
2841         Angles,AnglesParameters = ParseAngles(Angles)
2842         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2843         if ( isinstance( theObject, Mesh )):
2844             theObject = theObject.GetMesh()
2845         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2846             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2847         if ( isinstance( PathMesh, Mesh )):
2848             PathMesh = PathMesh.GetMesh()
2849         if HasAngles and Angles and LinearVariation:
2850             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2851             pass
2852         Parameters = AnglesParameters + var_separator + RefPointParameters
2853         self.mesh.SetParameters(Parameters)
2854         if MakeGroups:
2855             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2856                                                                     PathShape, NodeStart, HasAngles,
2857                                                                     Angles, HasRefPoint, RefPoint)
2858         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2859                                                       NodeStart, HasAngles, Angles, HasRefPoint,
2860                                                       RefPoint)
2861
2862     ## Generates new elements by extrusion of the elements which belong to the object
2863     #  The path of extrusion must be a meshed edge.
2864     #  @param theObject the object which elements should be processed
2865     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2866     #  @param PathShape shape(edge) defines the sub-mesh for the path
2867     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2868     #  @param HasAngles allows the shape to be rotated around the path
2869     #                   to get the resulting mesh in a helical fashion
2870     #  @param Angles list of angles
2871     #  @param HasRefPoint allows using the reference point
2872     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2873     #         The User can specify any point as the Reference Point.
2874     #  @param MakeGroups forces the generation of new groups from existing ones
2875     #  @param LinearVariation forces the computation of rotation angles as linear
2876     #                         variation of the given Angles along path steps
2877     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2878     #          only SMESH::Extrusion_Error otherwise
2879     #  @ingroup l2_modif_extrurev
2880     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2881                                    HasAngles, Angles, HasRefPoint, RefPoint,
2882                                    MakeGroups=False, LinearVariation=False):
2883         Angles,AnglesParameters = ParseAngles(Angles)
2884         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2885         if ( isinstance( theObject, Mesh )):
2886             theObject = theObject.GetMesh()
2887         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2888             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2889         if ( isinstance( PathMesh, Mesh )):
2890             PathMesh = PathMesh.GetMesh()
2891         if HasAngles and Angles and LinearVariation:
2892             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2893             pass
2894         Parameters = AnglesParameters + var_separator + RefPointParameters
2895         self.mesh.SetParameters(Parameters)
2896         if MakeGroups:
2897             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2898                                                                     PathShape, NodeStart, HasAngles,
2899                                                                     Angles, HasRefPoint, RefPoint)
2900         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2901                                                       NodeStart, HasAngles, Angles, HasRefPoint,
2902                                                       RefPoint)
2903
2904     ## Creates a symmetrical copy of mesh elements
2905     #  @param IDsOfElements list of elements ids
2906     #  @param Mirror is AxisStruct or geom object(point, line, plane)
2907     #  @param theMirrorType is  POINT, AXIS or PLANE
2908     #  If the Mirror is a geom object this parameter is unnecessary
2909     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2910     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2911     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2912     #  @ingroup l2_modif_trsf
2913     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2914         if IDsOfElements == []:
2915             IDsOfElements = self.GetElementsId()
2916         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2917             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2918         Mirror,Parameters = ParseAxisStruct(Mirror)
2919         self.mesh.SetParameters(Parameters)
2920         if Copy and MakeGroups:
2921             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2922         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2923         return []
2924
2925     ## Creates a new mesh by a symmetrical copy of mesh elements
2926     #  @param IDsOfElements the list of elements ids
2927     #  @param Mirror is AxisStruct or geom object (point, line, plane)
2928     #  @param theMirrorType is  POINT, AXIS or PLANE
2929     #  If the Mirror is a geom object this parameter is unnecessary
2930     #  @param MakeGroups to generate new groups from existing ones
2931     #  @param NewMeshName a name of the new mesh to create
2932     #  @return instance of Mesh class
2933     #  @ingroup l2_modif_trsf
2934     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2935         if IDsOfElements == []:
2936             IDsOfElements = self.GetElementsId()
2937         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2938             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2939         Mirror,Parameters = ParseAxisStruct(Mirror)
2940         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2941                                           MakeGroups, NewMeshName)
2942         mesh.SetParameters(Parameters)
2943         return Mesh(self.smeshpyD,self.geompyD,mesh)
2944
2945     ## Creates a symmetrical copy of the object
2946     #  @param theObject mesh, submesh or group
2947     #  @param Mirror AxisStruct or geom object (point, line, plane)
2948     #  @param theMirrorType is  POINT, AXIS or PLANE
2949     #  If the Mirror is a geom object this parameter is unnecessary
2950     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2951     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2952     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2953     #  @ingroup l2_modif_trsf
2954     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2955         if ( isinstance( theObject, Mesh )):
2956             theObject = theObject.GetMesh()
2957         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2958             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2959         Mirror,Parameters = ParseAxisStruct(Mirror)
2960         self.mesh.SetParameters(Parameters)
2961         if Copy and MakeGroups:
2962             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2963         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2964         return []
2965
2966     ## Creates a new mesh by a symmetrical copy of the object
2967     #  @param theObject mesh, submesh or group
2968     #  @param Mirror AxisStruct or geom object (point, line, plane)
2969     #  @param theMirrorType POINT, AXIS or PLANE
2970     #  If the Mirror is a geom object this parameter is unnecessary
2971     #  @param MakeGroups forces the generation of new groups from existing ones
2972     #  @param NewMeshName the name of the new mesh to create
2973     #  @return instance of Mesh class
2974     #  @ingroup l2_modif_trsf
2975     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2976         if ( isinstance( theObject, Mesh )):
2977             theObject = theObject.GetMesh()
2978         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2979             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2980         Mirror,Parameters = ParseAxisStruct(Mirror)
2981         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2982                                                 MakeGroups, NewMeshName)
2983         mesh.SetParameters(Parameters)
2984         return Mesh( self.smeshpyD,self.geompyD,mesh )
2985
2986     ## Translates the elements
2987     #  @param IDsOfElements list of elements ids
2988     #  @param Vector the direction of translation (DirStruct or vector)
2989     #  @param Copy allows copying the translated elements
2990     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2991     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2992     #  @ingroup l2_modif_trsf
2993     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2994         if IDsOfElements == []:
2995             IDsOfElements = self.GetElementsId()
2996         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2997             Vector = self.smeshpyD.GetDirStruct(Vector)
2998         Vector,Parameters = ParseDirStruct(Vector)
2999         self.mesh.SetParameters(Parameters)
3000         if Copy and MakeGroups:
3001             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3002         self.editor.Translate(IDsOfElements, Vector, Copy)
3003         return []
3004
3005     ## Creates a new mesh of translated elements
3006     #  @param IDsOfElements list of elements ids
3007     #  @param Vector the direction of translation (DirStruct or vector)
3008     #  @param MakeGroups forces the generation of new groups from existing ones
3009     #  @param NewMeshName the name of the newly created mesh
3010     #  @return instance of Mesh class
3011     #  @ingroup l2_modif_trsf
3012     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3013         if IDsOfElements == []:
3014             IDsOfElements = self.GetElementsId()
3015         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3016             Vector = self.smeshpyD.GetDirStruct(Vector)
3017         Vector,Parameters = ParseDirStruct(Vector)
3018         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3019         mesh.SetParameters(Parameters)
3020         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3021
3022     ## Translates the object
3023     #  @param theObject the object to translate (mesh, submesh, or group)
3024     #  @param Vector direction of translation (DirStruct or geom vector)
3025     #  @param Copy allows copying the translated elements
3026     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3027     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3028     #  @ingroup l2_modif_trsf
3029     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3030         if ( isinstance( theObject, Mesh )):
3031             theObject = theObject.GetMesh()
3032         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3033             Vector = self.smeshpyD.GetDirStruct(Vector)
3034         Vector,Parameters = ParseDirStruct(Vector)
3035         self.mesh.SetParameters(Parameters)
3036         if Copy and MakeGroups:
3037             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3038         self.editor.TranslateObject(theObject, Vector, Copy)
3039         return []
3040
3041     ## Creates a new mesh from the translated object
3042     #  @param theObject the object to translate (mesh, submesh, or group)
3043     #  @param Vector the direction of translation (DirStruct or geom vector)
3044     #  @param MakeGroups forces the generation of new groups from existing ones
3045     #  @param NewMeshName the name of the newly created mesh
3046     #  @return instance of Mesh class
3047     #  @ingroup l2_modif_trsf
3048     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3049         if (isinstance(theObject, Mesh)):
3050             theObject = theObject.GetMesh()
3051         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3052             Vector = self.smeshpyD.GetDirStruct(Vector)
3053         Vector,Parameters = ParseDirStruct(Vector)
3054         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3055         mesh.SetParameters(Parameters)
3056         return Mesh( self.smeshpyD, self.geompyD, mesh )
3057
3058     ## Rotates the elements
3059     #  @param IDsOfElements list of elements ids
3060     #  @param Axis the axis of rotation (AxisStruct or geom line)
3061     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3062     #  @param Copy allows copying the rotated elements
3063     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3064     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3065     #  @ingroup l2_modif_trsf
3066     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3067         flag = False
3068         if isinstance(AngleInRadians,str):
3069             flag = True
3070         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3071         if flag:
3072             AngleInRadians = DegreesToRadians(AngleInRadians)
3073         if IDsOfElements == []:
3074             IDsOfElements = self.GetElementsId()
3075         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3076             Axis = self.smeshpyD.GetAxisStruct(Axis)
3077         Axis,AxisParameters = ParseAxisStruct(Axis)
3078         Parameters = AxisParameters + var_separator + Parameters
3079         self.mesh.SetParameters(Parameters)
3080         if Copy and MakeGroups:
3081             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3082         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3083         return []
3084
3085     ## Creates a new mesh of rotated elements
3086     #  @param IDsOfElements list of element ids
3087     #  @param Axis the axis of rotation (AxisStruct or geom line)
3088     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3089     #  @param MakeGroups forces the generation of new groups from existing ones
3090     #  @param NewMeshName the name of the newly created mesh
3091     #  @return instance of Mesh class
3092     #  @ingroup l2_modif_trsf
3093     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3094         flag = False
3095         if isinstance(AngleInRadians,str):
3096             flag = True
3097         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3098         if flag:
3099             AngleInRadians = DegreesToRadians(AngleInRadians)
3100         if IDsOfElements == []:
3101             IDsOfElements = self.GetElementsId()
3102         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3103             Axis = self.smeshpyD.GetAxisStruct(Axis)
3104         Axis,AxisParameters = ParseAxisStruct(Axis)
3105         Parameters = AxisParameters + var_separator + Parameters
3106         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3107                                           MakeGroups, NewMeshName)
3108         mesh.SetParameters(Parameters)
3109         return Mesh( self.smeshpyD, self.geompyD, mesh )
3110
3111     ## Rotates the object
3112     #  @param theObject the object to rotate( mesh, submesh, or group)
3113     #  @param Axis the axis of rotation (AxisStruct or geom line)
3114     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3115     #  @param Copy allows copying the rotated elements
3116     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3117     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3118     #  @ingroup l2_modif_trsf
3119     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3120         flag = False
3121         if isinstance(AngleInRadians,str):
3122             flag = True
3123         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3124         if flag:
3125             AngleInRadians = DegreesToRadians(AngleInRadians)
3126         if (isinstance(theObject, Mesh)):
3127             theObject = theObject.GetMesh()
3128         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3129             Axis = self.smeshpyD.GetAxisStruct(Axis)
3130         Axis,AxisParameters = ParseAxisStruct(Axis)
3131         Parameters = AxisParameters + ":" + Parameters
3132         self.mesh.SetParameters(Parameters)
3133         if Copy and MakeGroups:
3134             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3135         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3136         return []
3137
3138     ## Creates a new mesh from the rotated object
3139     #  @param theObject the object to rotate (mesh, submesh, or group)
3140     #  @param Axis the axis of rotation (AxisStruct or geom line)
3141     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3142     #  @param MakeGroups forces the generation of new groups from existing ones
3143     #  @param NewMeshName the name of the newly created mesh
3144     #  @return instance of Mesh class
3145     #  @ingroup l2_modif_trsf
3146     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3147         flag = False
3148         if isinstance(AngleInRadians,str):
3149             flag = True
3150         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3151         if flag:
3152             AngleInRadians = DegreesToRadians(AngleInRadians)
3153         if (isinstance( theObject, Mesh )):
3154             theObject = theObject.GetMesh()
3155         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3156             Axis = self.smeshpyD.GetAxisStruct(Axis)
3157         Axis,AxisParameters = ParseAxisStruct(Axis)
3158         Parameters = AxisParameters + ":" + Parameters
3159         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3160                                                        MakeGroups, NewMeshName)
3161         mesh.SetParameters(Parameters)
3162         return Mesh( self.smeshpyD, self.geompyD, mesh )
3163
3164     ## Finds groups of ajacent nodes within Tolerance.
3165     #  @param Tolerance the value of tolerance
3166     #  @return the list of groups of nodes
3167     #  @ingroup l2_modif_trsf
3168     def FindCoincidentNodes (self, Tolerance):
3169         return self.editor.FindCoincidentNodes(Tolerance)
3170
3171     ## Finds groups of ajacent nodes within Tolerance.
3172     #  @param Tolerance the value of tolerance
3173     #  @param SubMeshOrGroup SubMesh or Group
3174     #  @return the list of groups of nodes
3175     #  @ingroup l2_modif_trsf
3176     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3177         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3178
3179     ## Merges nodes
3180     #  @param GroupsOfNodes the list of groups of nodes
3181     #  @ingroup l2_modif_trsf
3182     def MergeNodes (self, GroupsOfNodes):
3183         self.editor.MergeNodes(GroupsOfNodes)
3184
3185     ## Finds the elements built on the same nodes.
3186     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3187     #  @return a list of groups of equal elements
3188     #  @ingroup l2_modif_trsf
3189     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3190         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3191
3192     ## Merges elements in each given group.
3193     #  @param GroupsOfElementsID groups of elements for merging
3194     #  @ingroup l2_modif_trsf
3195     def MergeElements(self, GroupsOfElementsID):
3196         self.editor.MergeElements(GroupsOfElementsID)
3197
3198     ## Leaves one element and removes all other elements built on the same nodes.
3199     #  @ingroup l2_modif_trsf
3200     def MergeEqualElements(self):
3201         self.editor.MergeEqualElements()
3202
3203     ## Sews free borders
3204     #  @return SMESH::Sew_Error
3205     #  @ingroup l2_modif_trsf
3206     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3207                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3208                         CreatePolygons, CreatePolyedrs):
3209         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3210                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3211                                           CreatePolygons, CreatePolyedrs)
3212
3213     ## Sews conform free borders
3214     #  @return SMESH::Sew_Error
3215     #  @ingroup l2_modif_trsf
3216     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3217                                FirstNodeID2, SecondNodeID2):
3218         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3219                                                  FirstNodeID2, SecondNodeID2)
3220
3221     ## Sews border to side
3222     #  @return SMESH::Sew_Error
3223     #  @ingroup l2_modif_trsf
3224     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3225                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3226         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3227                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3228
3229     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3230     #  merged with the nodes of elements of Side2.
3231     #  The number of elements in theSide1 and in theSide2 must be
3232     #  equal and they should have similar nodal connectivity.
3233     #  The nodes to merge should belong to side borders and
3234     #  the first node should be linked to the second.
3235     #  @return SMESH::Sew_Error
3236     #  @ingroup l2_modif_trsf
3237     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3238                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3239                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3240         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3241                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3242                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3243
3244     ## Sets new nodes for the given element.
3245     #  @param ide the element id
3246     #  @param newIDs nodes ids
3247     #  @return If the number of nodes does not correspond to the type of element - returns false
3248     #  @ingroup l2_modif_edit
3249     def ChangeElemNodes(self, ide, newIDs):
3250         return self.editor.ChangeElemNodes(ide, newIDs)
3251
3252     ## If during the last operation of MeshEditor some nodes were
3253     #  created, this method returns the list of their IDs, \n
3254     #  if new nodes were not created - returns empty list
3255     #  @return the list of integer values (can be empty)
3256     #  @ingroup l1_auxiliary
3257     def GetLastCreatedNodes(self):
3258         return self.editor.GetLastCreatedNodes()
3259
3260     ## If during the last operation of MeshEditor some elements were
3261     #  created this method returns the list of their IDs, \n
3262     #  if new elements were not created - returns empty list
3263     #  @return the list of integer values (can be empty)
3264     #  @ingroup l1_auxiliary
3265     def GetLastCreatedElems(self):
3266         return self.editor.GetLastCreatedElems()
3267     
3268     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3269     #  @param theNodes identifiers of nodes to be doubled
3270     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
3271     #         nodes. If list of element identifiers is empty then nodes are doubled but 
3272     #         they not assigned to elements
3273     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3274     #  @ingroup l2_modif_edit
3275     def DoubleNodes(self, theNodes, theModifiedElems):
3276         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3277         
3278     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3279     #  This method provided for convenience works as DoubleNodes() described above.
3280     #  @param theNodes identifiers of node to be doubled
3281     #  @param theModifiedElems identifiers of elements to be updated
3282     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3283     #  @ingroup l2_modif_edit
3284     def DoubleNode(self, theNodeId, theModifiedElems):
3285         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3286         
3287     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3288     #  This method provided for convenience works as DoubleNodes() described above.
3289     #  @param theNodes group of nodes to be doubled
3290     #  @param theModifiedElems group of elements to be updated.
3291     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3292     #  @ingroup l2_modif_edit
3293     def DoubleNodeGroup(self, theNodes, theModifiedElems):
3294         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3295         
3296     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3297     #  This method provided for convenience works as DoubleNodes() described above.
3298     #  @param theNodes list of groups of nodes to be doubled
3299     #  @param theModifiedElems list of groups of elements to be updated.
3300     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3301     #  @ingroup l2_modif_edit
3302     def DoubleNodeGroups(self, theNodes, theModifiedElems):
3303         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3304
3305 ## The mother class to define algorithm, it is not recommended to use it directly.
3306 #
3307 #  More details.
3308 #  @ingroup l2_algorithms
3309 class Mesh_Algorithm:
3310     #  @class Mesh_Algorithm
3311     #  @brief Class Mesh_Algorithm
3312
3313     #def __init__(self,smesh):
3314     #    self.smesh=smesh
3315     def __init__(self):
3316         self.mesh = None
3317         self.geom = None
3318         self.subm = None
3319         self.algo = None
3320
3321     ## Finds a hypothesis in the study by its type name and parameters.
3322     #  Finds only the hypotheses created in smeshpyD engine.
3323     #  @return SMESH.SMESH_Hypothesis
3324     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3325         study = smeshpyD.GetCurrentStudy()
3326         #to do: find component by smeshpyD object, not by its data type
3327         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3328         if scomp is not None:
3329             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3330             # Check if the root label of the hypotheses exists
3331             if res and hypRoot is not None:
3332                 iter = study.NewChildIterator(hypRoot)
3333                 # Check all published hypotheses
3334                 while iter.More():
3335                     hypo_so_i = iter.Value()
3336                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3337                     if attr is not None:
3338                         anIOR = attr.Value()
3339                         hypo_o_i = salome.orb.string_to_object(anIOR)
3340                         if hypo_o_i is not None:
3341                             # Check if this is a hypothesis
3342                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3343                             if hypo_i is not None:
3344                                 # Check if the hypothesis belongs to current engine
3345                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3346                                     # Check if this is the required hypothesis
3347                                     if hypo_i.GetName() == hypname:
3348                                         # Check arguments
3349                                         if CompareMethod(hypo_i, args):
3350                                             # found!!!
3351                                             return hypo_i
3352                                         pass
3353                                     pass
3354                                 pass
3355                             pass
3356                         pass
3357                     iter.Next()
3358                     pass
3359                 pass
3360             pass
3361         return None
3362
3363     ## Finds the algorithm in the study by its type name.
3364     #  Finds only the algorithms, which have been created in smeshpyD engine.
3365     #  @return SMESH.SMESH_Algo
3366     def FindAlgorithm (self, algoname, smeshpyD):
3367         study = smeshpyD.GetCurrentStudy()
3368         #to do: find component by smeshpyD object, not by its data type
3369         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3370         if scomp is not None:
3371             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3372             # Check if the root label of the algorithms exists
3373             if res and hypRoot is not None:
3374                 iter = study.NewChildIterator(hypRoot)
3375                 # Check all published algorithms
3376                 while iter.More():
3377                     algo_so_i = iter.Value()
3378                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3379                     if attr is not None:
3380                         anIOR = attr.Value()
3381                         algo_o_i = salome.orb.string_to_object(anIOR)
3382                         if algo_o_i is not None:
3383                             # Check if this is an algorithm
3384                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3385                             if algo_i is not None:
3386                                 # Checks if the algorithm belongs to the current engine
3387                                 if smeshpyD.GetObjectId(algo_i) > 0:
3388                                     # Check if this is the required algorithm
3389                                     if algo_i.GetName() == algoname:
3390                                         # found!!!
3391                                         return algo_i
3392                                     pass
3393                                 pass
3394                             pass
3395                         pass
3396                     iter.Next()
3397                     pass
3398                 pass
3399             pass
3400         return None
3401
3402     ## If the algorithm is global, returns 0; \n
3403     #  else returns the submesh associated to this algorithm.
3404     def GetSubMesh(self):
3405         return self.subm
3406
3407     ## Returns the wrapped mesher.
3408     def GetAlgorithm(self):
3409         return self.algo
3410
3411     ## Gets the list of hypothesis that can be used with this algorithm
3412     def GetCompatibleHypothesis(self):
3413         mylist = []
3414         if self.algo:
3415             mylist = self.algo.GetCompatibleHypothesis()
3416         return mylist
3417
3418     ## Gets the name of the algorithm
3419     def GetName(self):
3420         GetName(self.algo)
3421
3422     ## Sets the name to the algorithm
3423     def SetName(self, name):
3424         self.mesh.smeshpyD.SetName(self.algo, name)
3425
3426     ## Gets the id of the algorithm
3427     def GetId(self):
3428         return self.algo.GetId()
3429
3430     ## Private method.
3431     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3432         if geom is None:
3433             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3434         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3435         if algo is None:
3436             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3437             pass
3438         self.Assign(algo, mesh, geom)
3439         return self.algo
3440
3441     ## Private method
3442     def Assign(self, algo, mesh, geom):
3443         if geom is None:
3444             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3445         self.mesh = mesh
3446         piece = mesh.geom
3447         if not geom:
3448             self.geom = piece
3449         else:
3450             self.geom = geom
3451             name = GetName(geom)
3452             if name==NO_NAME:
3453                 name = mesh.geompyD.SubShapeName(geom, piece)
3454                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3455             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3456
3457         self.algo = algo
3458         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3459         TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3460
3461     def CompareHyp (self, hyp, args):
3462         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3463         return False
3464
3465     def CompareEqualHyp (self, hyp, args):
3466         return True
3467
3468     ## Private method
3469     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3470                     UseExisting=0, CompareMethod=""):
3471         hypo = None
3472         if UseExisting:
3473             if CompareMethod == "": CompareMethod = self.CompareHyp
3474             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3475             pass
3476         if hypo is None:
3477             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3478             a = ""
3479             s = "="
3480             i = 0
3481             n = len(args)
3482             while i<n:
3483                 a = a + s + str(args[i])
3484                 s = ","
3485                 i = i + 1
3486                 pass
3487             self.mesh.smeshpyD.SetName(hypo, hyp + a)
3488             pass
3489         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3490         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3491         return hypo
3492
3493
3494 # Public class: Mesh_Segment
3495 # --------------------------
3496
3497 ## Class to define a segment 1D algorithm for discretization
3498 #
3499 #  More details.
3500 #  @ingroup l3_algos_basic
3501 class Mesh_Segment(Mesh_Algorithm):
3502
3503     ## Private constructor.
3504     def __init__(self, mesh, geom=0):
3505         Mesh_Algorithm.__init__(self)
3506         self.Create(mesh, geom, "Regular_1D")
3507
3508     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3509     #  @param l for the length of segments that cut an edge
3510     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3511     #                    the same parameters, else (default) - creates a new one
3512     #  @param p precision, used for calculation of the number of segments.
3513     #           The precision should be a positive, meaningful value within the range [0,1].
3514     #           In general, the number of segments is calculated with the formula:
3515     #           nb = ceil((edge_length / l) - p)
3516     #           Function ceil rounds its argument to the higher integer.
3517     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3518     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3519     #               p=1 means rounding of (edge_length / l) to the lower integer.
3520     #           Default value is 1e-07.
3521     #  @return an instance of StdMeshers_LocalLength hypothesis
3522     #  @ingroup l3_hypos_1dhyps
3523     def LocalLength(self, l, UseExisting=0, p=1e-07):
3524         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3525                               CompareMethod=self.CompareLocalLength)
3526         hyp.SetLength(l)
3527         hyp.SetPrecision(p)
3528         return hyp
3529
3530     ## Private method
3531     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3532     def CompareLocalLength(self, hyp, args):
3533         if IsEqual(hyp.GetLength(), args[0]):
3534             return IsEqual(hyp.GetPrecision(), args[1])
3535         return False
3536
3537     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3538     #  @param length is optional maximal allowed length of segment, if it is omitted
3539     #                the preestimated length is used that depends on geometry size
3540     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3541     #                     the same parameters, else (default) - create a new one
3542     #  @return an instance of StdMeshers_MaxLength hypothesis
3543     #  @ingroup l3_hypos_1dhyps
3544     def MaxSize(self, length=0.0, UseExisting=0):
3545         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3546         if length > 0.0:
3547             # set given length
3548             hyp.SetLength(length)
3549         if not UseExisting:
3550             # set preestimated length
3551             gen = self.mesh.smeshpyD
3552             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3553                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
3554                                                        False) # <- byMesh
3555             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3556             if preHyp:
3557                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3558                 pass
3559             pass
3560         hyp.SetUsePreestimatedLength( length == 0.0 )
3561         return hyp
3562         
3563     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3564     #  @param n for the number of segments that cut an edge
3565     #  @param s for the scale factor (optional)
3566     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3567     #                     the same parameters, else (default) - create a new one
3568     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
3569     #  @ingroup l3_hypos_1dhyps
3570     def NumberOfSegments(self, n, s=[], UseExisting=0):
3571         if s == []:
3572             hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3573                                   CompareMethod=self.CompareNumberOfSegments)
3574         else:
3575             hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3576                                   CompareMethod=self.CompareNumberOfSegments)
3577             hyp.SetDistrType( 1 )
3578             hyp.SetScaleFactor(s)
3579         hyp.SetNumberOfSegments(n)
3580         return hyp
3581
3582     ## Private method
3583     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3584     def CompareNumberOfSegments(self, hyp, args):
3585         if hyp.GetNumberOfSegments() == args[0]:
3586             if len(args) == 1:
3587                 return True
3588             else:
3589                 if hyp.GetDistrType() == 1:
3590                     if IsEqual(hyp.GetScaleFactor(), args[1]):
3591                         return True
3592         return False
3593
3594     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3595     #  @param start defines the length of the first segment
3596     #  @param end   defines the length of the last  segment
3597     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3598     #                     the same parameters, else (default) - creates a new one
3599     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
3600     #  @ingroup l3_hypos_1dhyps
3601     def Arithmetic1D(self, start, end, UseExisting=0):
3602         hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3603                               CompareMethod=self.CompareArithmetic1D)
3604         hyp.SetLength(start, 1)
3605         hyp.SetLength(end  , 0)
3606         return hyp
3607
3608     ## Private method
3609     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3610     def CompareArithmetic1D(self, hyp, args):
3611         if IsEqual(hyp.GetLength(1), args[0]):
3612             if IsEqual(hyp.GetLength(0), args[1]):
3613                 return True
3614         return False
3615
3616     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3617     #  @param start defines the length of the first segment
3618     #  @param end   defines the length of the last  segment
3619     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3620     #                     the same parameters, else (default) - creates a new one
3621     #  @return an instance of StdMeshers_StartEndLength hypothesis
3622     #  @ingroup l3_hypos_1dhyps
3623     def StartEndLength(self, start, end, UseExisting=0):
3624         hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3625                               CompareMethod=self.CompareStartEndLength)
3626         hyp.SetLength(start, 1)
3627         hyp.SetLength(end  , 0)
3628         return hyp
3629
3630     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3631     def CompareStartEndLength(self, hyp, args):
3632         if IsEqual(hyp.GetLength(1), args[0]):
3633             if IsEqual(hyp.GetLength(0), args[1]):
3634                 return True
3635         return False
3636
3637     ## Defines "Deflection1D" hypothesis
3638     #  @param d for the deflection
3639     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3640     #                     the same parameters, else (default) - create a new one
3641     #  @ingroup l3_hypos_1dhyps
3642     def Deflection1D(self, d, UseExisting=0):
3643         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3644                               CompareMethod=self.CompareDeflection1D)
3645         hyp.SetDeflection(d)
3646         return hyp
3647
3648     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3649     def CompareDeflection1D(self, hyp, args):
3650         return IsEqual(hyp.GetDeflection(), args[0])
3651
3652     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3653     #  the opposite side in case of quadrangular faces
3654     #  @ingroup l3_hypos_additi
3655     def Propagation(self):
3656         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3657
3658     ## Defines "AutomaticLength" hypothesis
3659     #  @param fineness for the fineness [0-1]
3660     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
3661     #                     same parameters, else (default) - create a new one
3662     #  @ingroup l3_hypos_1dhyps
3663     def AutomaticLength(self, fineness=0, UseExisting=0):
3664         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3665                               CompareMethod=self.CompareAutomaticLength)
3666         hyp.SetFineness( fineness )
3667         return hyp
3668
3669     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3670     def CompareAutomaticLength(self, hyp, args):
3671         return IsEqual(hyp.GetFineness(), args[0])
3672
3673     ## Defines "SegmentLengthAroundVertex" hypothesis
3674     #  @param length for the segment length
3675     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
3676     #         Any other integer value means that the hypothesis will be set on the
3677     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
3678     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3679     #                   the same parameters, else (default) - creates a new one
3680     #  @ingroup l3_algos_segmarv
3681     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3682         import types
3683         store_geom = self.geom
3684         if type(vertex) is types.IntType:
3685             if vertex == 0 or vertex == 1:
3686                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3687                 self.geom = vertex
3688                 pass
3689             pass
3690         else:
3691             self.geom = vertex
3692             pass
3693         ### 0D algorithm
3694         if self.geom is None:
3695             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3696         name = GetName(self.geom)
3697         if name == NO_NAME:
3698             piece = self.mesh.geom
3699             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3700             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3701         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3702         if algo is None:
3703             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3704             pass
3705         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3706         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3707         ###
3708         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3709                               CompareMethod=self.CompareLengthNearVertex)
3710         self.geom = store_geom
3711         hyp.SetLength( length )
3712         return hyp
3713
3714     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3715     #  @ingroup l3_algos_segmarv
3716     def CompareLengthNearVertex(self, hyp, args):
3717         return IsEqual(hyp.GetLength(), args[0])
3718
3719     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3720     #  If the 2D mesher sees that all boundary edges are quadratic,
3721     #  it generates quadratic faces, else it generates linear faces using
3722     #  medium nodes as if they are vertices.
3723     #  The 3D mesher generates quadratic volumes only if all boundary faces
3724     #  are quadratic, else it fails.
3725     #
3726     #  @ingroup l3_hypos_additi
3727     def QuadraticMesh(self):
3728         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3729         return hyp
3730
3731 # Public class: Mesh_CompositeSegment
3732 # --------------------------
3733
3734 ## Defines a segment 1D algorithm for discretization
3735 #
3736 #  @ingroup l3_algos_basic
3737 class Mesh_CompositeSegment(Mesh_Segment):
3738
3739     ## Private constructor.
3740     def __init__(self, mesh, geom=0):
3741         self.Create(mesh, geom, "CompositeSegment_1D")
3742
3743
3744 # Public class: Mesh_Segment_Python
3745 # ---------------------------------
3746
3747 ## Defines a segment 1D algorithm for discretization with python function
3748 #
3749 #  @ingroup l3_algos_basic
3750 class Mesh_Segment_Python(Mesh_Segment):
3751
3752     ## Private constructor.
3753     def __init__(self, mesh, geom=0):
3754         import Python1dPlugin
3755         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3756
3757     ## Defines "PythonSplit1D" hypothesis
3758     #  @param n for the number of segments that cut an edge
3759     #  @param func for the python function that calculates the length of all segments
3760     #  @param UseExisting if ==true - searches for the existing hypothesis created with
3761     #                     the same parameters, else (default) - creates a new one
3762     #  @ingroup l3_hypos_1dhyps
3763     def PythonSplit1D(self, n, func, UseExisting=0):
3764         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3765                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3766         hyp.SetNumberOfSegments(n)
3767         hyp.SetPythonLog10RatioFunction(func)
3768         return hyp
3769
3770     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3771     def ComparePythonSplit1D(self, hyp, args):
3772         #if hyp.GetNumberOfSegments() == args[0]:
3773         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
3774         #        return True
3775         return False
3776
3777 # Public class: Mesh_Triangle
3778 # ---------------------------
3779
3780 ## Defines a triangle 2D algorithm
3781 #
3782 #  @ingroup l3_algos_basic
3783 class Mesh_Triangle(Mesh_Algorithm):
3784
3785     # default values
3786     algoType = 0
3787     params = 0
3788
3789     _angleMeshS = 8
3790     _gradation  = 1.1
3791
3792     ## Private constructor.
3793     def __init__(self, mesh, algoType, geom=0):
3794         Mesh_Algorithm.__init__(self)
3795
3796         self.algoType = algoType
3797         if algoType == MEFISTO:
3798             self.Create(mesh, geom, "MEFISTO_2D")
3799             pass
3800         elif algoType == BLSURF:
3801             import BLSURFPlugin
3802             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3803             #self.SetPhysicalMesh() - PAL19680
3804         elif algoType == NETGEN:
3805             if noNETGENPlugin:
3806                 print "Warning: NETGENPlugin module unavailable"
3807                 pass
3808             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3809             pass
3810         elif algoType == NETGEN_2D:
3811             if noNETGENPlugin:
3812                 print "Warning: NETGENPlugin module unavailable"
3813                 pass
3814             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3815             pass
3816
3817     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3818     #  @param area for the maximum area of each triangle
3819     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
3820     #                     same parameters, else (default) - creates a new one
3821     #
3822     #  Only for algoType == MEFISTO || NETGEN_2D
3823     #  @ingroup l3_hypos_2dhyps
3824     def MaxElementArea(self, area, UseExisting=0):
3825         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3826             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3827                                   CompareMethod=self.CompareMaxElementArea)
3828         elif self.algoType == NETGEN:
3829             hyp = self.Parameters(SIMPLE)
3830         hyp.SetMaxElementArea(area)
3831         return hyp
3832
3833     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3834     def CompareMaxElementArea(self, hyp, args):
3835         return IsEqual(hyp.GetMaxElementArea(), args[0])
3836
3837     ## Defines "LengthFromEdges" hypothesis to build triangles
3838     #  based on the length of the edges taken from the wire
3839     #
3840     #  Only for algoType == MEFISTO || NETGEN_2D
3841     #  @ingroup l3_hypos_2dhyps
3842     def LengthFromEdges(self):
3843         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3844             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3845             return hyp
3846         elif self.algoType == NETGEN:
3847             hyp = self.Parameters(SIMPLE)
3848             hyp.LengthFromEdges()
3849             return hyp
3850
3851     ## Sets a way to define size of mesh elements to generate.
3852     #  @param thePhysicalMesh is: DefaultSize or Custom.
3853     #  @ingroup l3_hypos_blsurf
3854     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3855         # Parameter of BLSURF algo
3856         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3857
3858     ## Sets size of mesh elements to generate.
3859     #  @ingroup l3_hypos_blsurf
3860     def SetPhySize(self, theVal):
3861         # Parameter of BLSURF algo
3862         self.Parameters().SetPhySize(theVal)
3863
3864     ## Sets lower boundary of mesh element size (PhySize).
3865     #  @ingroup l3_hypos_blsurf
3866     def SetPhyMin(self, theVal=-1):
3867         #  Parameter of BLSURF algo
3868         self.Parameters().SetPhyMin(theVal)
3869
3870     ## Sets upper boundary of mesh element size (PhySize).
3871     #  @ingroup l3_hypos_blsurf
3872     def SetPhyMax(self, theVal=-1):
3873         #  Parameter of BLSURF algo
3874         self.Parameters().SetPhyMax(theVal)
3875
3876     ## Sets a way to define maximum angular deflection of mesh from CAD model.
3877     #  @param theGeometricMesh is: DefaultGeom or Custom
3878     #  @ingroup l3_hypos_blsurf
3879     def SetGeometricMesh(self, theGeometricMesh=0):
3880         #  Parameter of BLSURF algo
3881         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3882         self.params.SetGeometricMesh(theGeometricMesh)
3883
3884     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3885     #  @ingroup l3_hypos_blsurf
3886     def SetAngleMeshS(self, theVal=_angleMeshS):
3887         #  Parameter of BLSURF algo
3888         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3889         self.params.SetAngleMeshS(theVal)
3890
3891     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3892     #  @ingroup l3_hypos_blsurf
3893     def SetAngleMeshC(self, theVal=_angleMeshS):
3894         #  Parameter of BLSURF algo
3895         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3896         self.params.SetAngleMeshC(theVal)
3897
3898     ## Sets lower boundary of mesh element size computed to respect angular deflection.
3899     #  @ingroup l3_hypos_blsurf
3900     def SetGeoMin(self, theVal=-1):
3901         #  Parameter of BLSURF algo
3902         self.Parameters().SetGeoMin(theVal)
3903
3904     ## Sets upper boundary of mesh element size computed to respect angular deflection.
3905     #  @ingroup l3_hypos_blsurf
3906     def SetGeoMax(self, theVal=-1):
3907         #  Parameter of BLSURF algo
3908         self.Parameters().SetGeoMax(theVal)
3909
3910     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3911     #  @ingroup l3_hypos_blsurf
3912     def SetGradation(self, theVal=_gradation):
3913         #  Parameter of BLSURF algo
3914         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3915         self.params.SetGradation(theVal)
3916
3917     ## Sets topology usage way.
3918     # @param way defines how mesh conformity is assured <ul>
3919     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3920     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3921     #  @ingroup l3_hypos_blsurf
3922     def SetTopology(self, way):
3923         #  Parameter of BLSURF algo
3924         self.Parameters().SetTopology(way)
3925
3926     ## To respect geometrical edges or not.
3927     #  @ingroup l3_hypos_blsurf
3928     def SetDecimesh(self, toIgnoreEdges=False):
3929         #  Parameter of BLSURF algo
3930         self.Parameters().SetDecimesh(toIgnoreEdges)
3931
3932     ## Sets verbosity level in the range 0 to 100.
3933     #  @ingroup l3_hypos_blsurf
3934     def SetVerbosity(self, level):
3935         #  Parameter of BLSURF algo
3936         self.Parameters().SetVerbosity(level)
3937
3938     ## Sets advanced option value.
3939     #  @ingroup l3_hypos_blsurf
3940     def SetOptionValue(self, optionName, level):
3941         #  Parameter of BLSURF algo
3942         self.Parameters().SetOptionValue(optionName,level)
3943
3944     ## Sets QuadAllowed flag.
3945     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
3946     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
3947     def SetQuadAllowed(self, toAllow=True):
3948         if self.algoType == NETGEN_2D:
3949             if toAllow: # add QuadranglePreference
3950                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3951             else:       # remove QuadranglePreference
3952                 for hyp in self.mesh.GetHypothesisList( self.geom ):
3953                     if hyp.GetName() == "QuadranglePreference":
3954                         self.mesh.RemoveHypothesis( self.geom, hyp )
3955                         pass
3956                     pass
3957                 pass
3958             return
3959         if self.Parameters():
3960             self.params.SetQuadAllowed(toAllow)
3961             return
3962
3963     ## Defines hypothesis having several parameters
3964     #
3965     #  @ingroup l3_hypos_netgen
3966     def Parameters(self, which=SOLE):
3967         if self.params:
3968             return self.params
3969         if self.algoType == NETGEN:
3970             if which == SIMPLE:
3971                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3972                                               "libNETGENEngine.so", UseExisting=0)
3973             else:
3974                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3975                                               "libNETGENEngine.so", UseExisting=0)
3976             return self.params
3977         elif self.algoType == MEFISTO:
3978             print "Mefisto algo support no multi-parameter hypothesis"
3979             return None
3980         elif self.algoType == NETGEN_2D:
3981             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3982             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3983             return None
3984         elif self.algoType == BLSURF:
3985             self.params = self.Hypothesis("BLSURF_Parameters", [],
3986                                           "libBLSURFEngine.so", UseExisting=0)
3987             return self.params
3988         else:
3989             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3990         return None
3991
3992     ## Sets MaxSize
3993     #
3994     #  Only for algoType == NETGEN
3995     #  @ingroup l3_hypos_netgen
3996     def SetMaxSize(self, theSize):
3997         if self.Parameters():
3998             self.params.SetMaxSize(theSize)
3999
4000     ## Sets SecondOrder flag
4001     #
4002     #  Only for algoType == NETGEN
4003     #  @ingroup l3_hypos_netgen
4004     def SetSecondOrder(self, theVal):
4005         if self.Parameters():
4006             self.params.SetSecondOrder(theVal)
4007
4008     ## Sets Optimize flag
4009     #
4010     #  Only for algoType == NETGEN
4011     #  @ingroup l3_hypos_netgen
4012     def SetOptimize(self, theVal):
4013         if self.Parameters():
4014             self.params.SetOptimize(theVal)
4015
4016     ## Sets Fineness
4017     #  @param theFineness is:
4018     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4019     #
4020     #  Only for algoType == NETGEN
4021     #  @ingroup l3_hypos_netgen
4022     def SetFineness(self, theFineness):
4023         if self.Parameters():
4024             self.params.SetFineness(theFineness)
4025
4026     ## Sets GrowthRate
4027     #
4028     #  Only for algoType == NETGEN
4029     #  @ingroup l3_hypos_netgen
4030     def SetGrowthRate(self, theRate):
4031         if self.Parameters():
4032             self.params.SetGrowthRate(theRate)
4033
4034     ## Sets NbSegPerEdge
4035     #
4036     #  Only for algoType == NETGEN
4037     #  @ingroup l3_hypos_netgen
4038     def SetNbSegPerEdge(self, theVal):
4039         if self.Parameters():
4040             self.params.SetNbSegPerEdge(theVal)
4041
4042     ## Sets NbSegPerRadius
4043     #
4044     #  Only for algoType == NETGEN
4045     #  @ingroup l3_hypos_netgen
4046     def SetNbSegPerRadius(self, theVal):
4047         if self.Parameters():
4048             self.params.SetNbSegPerRadius(theVal)
4049
4050     ## Sets number of segments overriding value set by SetLocalLength()
4051     #
4052     #  Only for algoType == NETGEN
4053     #  @ingroup l3_hypos_netgen
4054     def SetNumberOfSegments(self, theVal):
4055         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4056
4057     ## Sets number of segments overriding value set by SetNumberOfSegments()
4058     #
4059     #  Only for algoType == NETGEN
4060     #  @ingroup l3_hypos_netgen
4061     def SetLocalLength(self, theVal):
4062         self.Parameters(SIMPLE).SetLocalLength(theVal)
4063
4064     pass
4065
4066
4067 # Public class: Mesh_Quadrangle
4068 # -----------------------------
4069
4070 ## Defines a quadrangle 2D algorithm
4071 #
4072 #  @ingroup l3_algos_basic
4073 class Mesh_Quadrangle(Mesh_Algorithm):
4074
4075     ## Private constructor.
4076     def __init__(self, mesh, geom=0):
4077         Mesh_Algorithm.__init__(self)
4078         self.Create(mesh, geom, "Quadrangle_2D")
4079
4080     ## Defines "QuadranglePreference" hypothesis, forcing construction
4081     #  of quadrangles if the number of nodes on the opposite edges is not the same
4082     #  while the total number of nodes on edges is even
4083     #
4084     #  @ingroup l3_hypos_additi
4085     def QuadranglePreference(self):
4086         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4087                               CompareMethod=self.CompareEqualHyp)
4088         return hyp
4089
4090     ## Defines "TrianglePreference" hypothesis, forcing construction
4091     #  of triangles in the refinement area if the number of nodes
4092     #  on the opposite edges is not the same
4093     #
4094     #  @ingroup l3_hypos_additi
4095     def TrianglePreference(self):
4096         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4097                               CompareMethod=self.CompareEqualHyp)
4098         return hyp
4099
4100 # Public class: Mesh_Tetrahedron
4101 # ------------------------------
4102
4103 ## Defines a tetrahedron 3D algorithm
4104 #
4105 #  @ingroup l3_algos_basic
4106 class Mesh_Tetrahedron(Mesh_Algorithm):
4107
4108     params = 0
4109     algoType = 0
4110
4111     ## Private constructor.
4112     def __init__(self, mesh, algoType, geom=0):
4113         Mesh_Algorithm.__init__(self)
4114
4115         if algoType == NETGEN:
4116             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4117             pass
4118
4119         elif algoType == FULL_NETGEN:
4120             if noNETGENPlugin:
4121                 print "Warning: NETGENPlugin module has not been imported."
4122             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4123             pass
4124
4125         elif algoType == GHS3D:
4126             import GHS3DPlugin
4127             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4128             pass
4129
4130         elif algoType == GHS3DPRL:
4131             import GHS3DPRLPlugin
4132             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4133             pass
4134
4135         self.algoType = algoType
4136
4137     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4138     #  @param vol for the maximum volume of each tetrahedron
4139     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4140     #                   the same parameters, else (default) - creates a new one
4141     #  @ingroup l3_hypos_maxvol
4142     def MaxElementVolume(self, vol, UseExisting=0):
4143         if self.algoType == NETGEN:
4144             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4145                                   CompareMethod=self.CompareMaxElementVolume)
4146             hyp.SetMaxElementVolume(vol)
4147             return hyp
4148         elif self.algoType == FULL_NETGEN:
4149             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4150         return None
4151
4152     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4153     def CompareMaxElementVolume(self, hyp, args):
4154         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4155
4156     ## Defines hypothesis having several parameters
4157     #
4158     #  @ingroup l3_hypos_netgen
4159     def Parameters(self, which=SOLE):
4160         if self.params:
4161             return self.params
4162
4163         if self.algoType == FULL_NETGEN:
4164             if which == SIMPLE:
4165                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4166                                               "libNETGENEngine.so", UseExisting=0)
4167             else:
4168                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4169                                               "libNETGENEngine.so", UseExisting=0)
4170             return self.params
4171
4172         if self.algoType == GHS3D:
4173             self.params = self.Hypothesis("GHS3D_Parameters", [],
4174                                           "libGHS3DEngine.so", UseExisting=0)
4175             return self.params
4176
4177         if self.algoType == GHS3DPRL:
4178             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4179                                           "libGHS3DPRLEngine.so", UseExisting=0)
4180             return self.params
4181
4182         print "Algo supports no multi-parameter hypothesis"
4183         return None
4184
4185     ## Sets MaxSize
4186     #  Parameter of FULL_NETGEN
4187     #  @ingroup l3_hypos_netgen
4188     def SetMaxSize(self, theSize):
4189         self.Parameters().SetMaxSize(theSize)
4190
4191     ## Sets SecondOrder flag
4192     #  Parameter of FULL_NETGEN
4193     #  @ingroup l3_hypos_netgen
4194     def SetSecondOrder(self, theVal):
4195         self.Parameters().SetSecondOrder(theVal)
4196
4197     ## Sets Optimize flag
4198     #  Parameter of FULL_NETGEN
4199     #  @ingroup l3_hypos_netgen
4200     def SetOptimize(self, theVal):
4201         self.Parameters().SetOptimize(theVal)
4202
4203     ## Sets Fineness
4204     #  @param theFineness is:
4205     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4206     #  Parameter of FULL_NETGEN
4207     #  @ingroup l3_hypos_netgen
4208     def SetFineness(self, theFineness):
4209         self.Parameters().SetFineness(theFineness)
4210
4211     ## Sets GrowthRate
4212     #  Parameter of FULL_NETGEN
4213     #  @ingroup l3_hypos_netgen
4214     def SetGrowthRate(self, theRate):
4215         self.Parameters().SetGrowthRate(theRate)
4216
4217     ## Sets NbSegPerEdge
4218     #  Parameter of FULL_NETGEN
4219     #  @ingroup l3_hypos_netgen
4220     def SetNbSegPerEdge(self, theVal):
4221         self.Parameters().SetNbSegPerEdge(theVal)
4222
4223     ## Sets NbSegPerRadius
4224     #  Parameter of FULL_NETGEN
4225     #  @ingroup l3_hypos_netgen
4226     def SetNbSegPerRadius(self, theVal):
4227         self.Parameters().SetNbSegPerRadius(theVal)
4228
4229     ## Sets number of segments overriding value set by SetLocalLength()
4230     #  Only for algoType == NETGEN_FULL
4231     #  @ingroup l3_hypos_netgen
4232     def SetNumberOfSegments(self, theVal):
4233         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4234
4235     ## Sets number of segments overriding value set by SetNumberOfSegments()
4236     #  Only for algoType == NETGEN_FULL
4237     #  @ingroup l3_hypos_netgen
4238     def SetLocalLength(self, theVal):
4239         self.Parameters(SIMPLE).SetLocalLength(theVal)
4240
4241     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4242     #  Overrides value set by LengthFromEdges()
4243     #  Only for algoType == NETGEN_FULL
4244     #  @ingroup l3_hypos_netgen
4245     def MaxElementArea(self, area):
4246         self.Parameters(SIMPLE).SetMaxElementArea(area)
4247
4248     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4249     #  Overrides value set by MaxElementArea()
4250     #  Only for algoType == NETGEN_FULL
4251     #  @ingroup l3_hypos_netgen
4252     def LengthFromEdges(self):
4253         self.Parameters(SIMPLE).LengthFromEdges()
4254
4255     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4256     #  Overrides value set by MaxElementVolume()
4257     #  Only for algoType == NETGEN_FULL
4258     #  @ingroup l3_hypos_netgen
4259     def LengthFromFaces(self):
4260         self.Parameters(SIMPLE).LengthFromFaces()
4261
4262     ## To mesh "holes" in a solid or not. Default is to mesh.
4263     #  @ingroup l3_hypos_ghs3dh
4264     def SetToMeshHoles(self, toMesh):
4265         #  Parameter of GHS3D
4266         self.Parameters().SetToMeshHoles(toMesh)
4267
4268     ## Set Optimization level:
4269     #   None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4270     #  Default is Medium_Optimization
4271     #  @ingroup l3_hypos_ghs3dh
4272     def SetOptimizationLevel(self, level):
4273         #  Parameter of GHS3D
4274         self.Parameters().SetOptimizationLevel(level)
4275
4276     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4277     #  @ingroup l3_hypos_ghs3dh
4278     def SetMaximumMemory(self, MB):
4279         #  Advanced parameter of GHS3D
4280         self.Parameters().SetMaximumMemory(MB)
4281
4282     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4283     #  automatic memory adjustment mode.
4284     #  @ingroup l3_hypos_ghs3dh
4285     def SetInitialMemory(self, MB):
4286         #  Advanced parameter of GHS3D
4287         self.Parameters().SetInitialMemory(MB)
4288
4289     ## Path to working directory.
4290     #  @ingroup l3_hypos_ghs3dh
4291     def SetWorkingDirectory(self, path):
4292         #  Advanced parameter of GHS3D
4293         self.Parameters().SetWorkingDirectory(path)
4294
4295     ## To keep working files or remove them. Log file remains in case of errors anyway.
4296     #  @ingroup l3_hypos_ghs3dh
4297     def SetKeepFiles(self, toKeep):
4298         #  Advanced parameter of GHS3D and GHS3DPRL
4299         self.Parameters().SetKeepFiles(toKeep)
4300
4301     ## To set verbose level [0-10]. <ul>
4302     #<li> 0 - no standard output,
4303     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4304     #     indicates when the final mesh is being saved. In addition the software
4305     #     gives indication regarding the CPU time.
4306     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4307     #     histogram of the skin mesh, quality statistics histogram together with
4308     #     the characteristics of the final mesh.</ul>
4309     #  @ingroup l3_hypos_ghs3dh
4310     def SetVerboseLevel(self, level):
4311         #  Advanced parameter of GHS3D
4312         self.Parameters().SetVerboseLevel(level)
4313
4314     ## To create new nodes.
4315     #  @ingroup l3_hypos_ghs3dh
4316     def SetToCreateNewNodes(self, toCreate):
4317         #  Advanced parameter of GHS3D
4318         self.Parameters().SetToCreateNewNodes(toCreate)
4319
4320     ## To use boundary recovery version which tries to create mesh on a very poor
4321     #  quality surface mesh.
4322     #  @ingroup l3_hypos_ghs3dh
4323     def SetToUseBoundaryRecoveryVersion(self, toUse):
4324         #  Advanced parameter of GHS3D
4325         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4326
4327     ## Sets command line option as text.
4328     #  @ingroup l3_hypos_ghs3dh
4329     def SetTextOption(self, option):
4330         #  Advanced parameter of GHS3D
4331         self.Parameters().SetTextOption(option)
4332
4333     ## Sets MED files name and path.
4334     def SetMEDName(self, value):
4335         self.Parameters().SetMEDName(value)
4336
4337     ## Sets the number of partition of the initial mesh
4338     def SetNbPart(self, value):
4339         self.Parameters().SetNbPart(value)
4340
4341     ## When big mesh, start tepal in background
4342     def SetBackground(self, value):
4343         self.Parameters().SetBackground(value)
4344
4345 # Public class: Mesh_Hexahedron
4346 # ------------------------------
4347
4348 ## Defines a hexahedron 3D algorithm
4349 #
4350 #  @ingroup l3_algos_basic
4351 class Mesh_Hexahedron(Mesh_Algorithm):
4352
4353     params = 0
4354     algoType = 0
4355
4356     ## Private constructor.
4357     def __init__(self, mesh, algoType=Hexa, geom=0):
4358         Mesh_Algorithm.__init__(self)
4359
4360         self.algoType = algoType
4361
4362         if algoType == Hexa:
4363             self.Create(mesh, geom, "Hexa_3D")
4364             pass
4365
4366         elif algoType == Hexotic:
4367             import HexoticPlugin
4368             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4369             pass
4370
4371     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4372     #  @ingroup l3_hypos_hexotic
4373     def MinMaxQuad(self, min=3, max=8, quad=True):
4374         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4375                                       UseExisting=0)
4376         self.params.SetHexesMinLevel(min)
4377         self.params.SetHexesMaxLevel(max)
4378         self.params.SetHexoticQuadrangles(quad)
4379         return self.params
4380
4381 # Deprecated, only for compatibility!
4382 # Public class: Mesh_Netgen
4383 # ------------------------------
4384
4385 ## Defines a NETGEN-based 2D or 3D algorithm
4386 #  that needs no discrete boundary (i.e. independent)
4387 #
4388 #  This class is deprecated, only for compatibility!
4389 #
4390 #  More details.
4391 #  @ingroup l3_algos_basic
4392 class Mesh_Netgen(Mesh_Algorithm):
4393
4394     is3D = 0
4395
4396     ## Private constructor.
4397     def __init__(self, mesh, is3D, geom=0):
4398         Mesh_Algorithm.__init__(self)
4399
4400         if noNETGENPlugin:
4401             print "Warning: NETGENPlugin module has not been imported."
4402
4403         self.is3D = is3D
4404         if is3D:
4405             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4406             pass
4407
4408         else:
4409             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4410             pass
4411
4412     ## Defines the hypothesis containing parameters of the algorithm
4413     def Parameters(self):
4414         if self.is3D:
4415             hyp = self.Hypothesis("NETGEN_Parameters", [],
4416                                   "libNETGENEngine.so", UseExisting=0)
4417         else:
4418             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4419                                   "libNETGENEngine.so", UseExisting=0)
4420         return hyp
4421
4422 # Public class: Mesh_Projection1D
4423 # ------------------------------
4424
4425 ## Defines a projection 1D algorithm
4426 #  @ingroup l3_algos_proj
4427 #
4428 class Mesh_Projection1D(Mesh_Algorithm):
4429
4430     ## Private constructor.
4431     def __init__(self, mesh, geom=0):
4432         Mesh_Algorithm.__init__(self)
4433         self.Create(mesh, geom, "Projection_1D")
4434
4435     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4436     #  a mesh pattern is taken, and, optionally, the association of vertices
4437     #  between the source edge and a target edge (to which a hypothesis is assigned)
4438     #  @param edge from which nodes distribution is taken
4439     #  @param mesh from which nodes distribution is taken (optional)
4440     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4441     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4442     #  to associate with \a srcV (optional)
4443     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4444     #                     the same parameters, else (default) - creates a new one
4445     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4446         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4447                               UseExisting=0)
4448                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4449         hyp.SetSourceEdge( edge )
4450         if not mesh is None and isinstance(mesh, Mesh):
4451             mesh = mesh.GetMesh()
4452         hyp.SetSourceMesh( mesh )
4453         hyp.SetVertexAssociation( srcV, tgtV )
4454         return hyp
4455
4456     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4457     #def CompareSourceEdge(self, hyp, args):
4458     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4459     #    return False
4460
4461
4462 # Public class: Mesh_Projection2D
4463 # ------------------------------
4464
4465 ## Defines a projection 2D algorithm
4466 #  @ingroup l3_algos_proj
4467 #
4468 class Mesh_Projection2D(Mesh_Algorithm):
4469
4470     ## Private constructor.
4471     def __init__(self, mesh, geom=0):
4472         Mesh_Algorithm.__init__(self)
4473         self.Create(mesh, geom, "Projection_2D")
4474
4475     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4476     #  a mesh pattern is taken, and, optionally, the association of vertices
4477     #  between the source face and the target face (to which a hypothesis is assigned)
4478     #  @param face from which the mesh pattern is taken
4479     #  @param mesh from which the mesh pattern is taken (optional)
4480     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4481     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4482     #               to associate with \a srcV1 (optional)
4483     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4484     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4485     #               to associate with \a srcV2 (optional)
4486     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
4487     #                     the same parameters, else (default) - forces the creation a new one
4488     #
4489     #  Note: all association vertices must belong to one edge of a face
4490     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4491                    srcV2=None, tgtV2=None, UseExisting=0):
4492         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4493                               UseExisting=0)
4494                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4495         hyp.SetSourceFace( face )
4496         if not mesh is None and isinstance(mesh, Mesh):
4497             mesh = mesh.GetMesh()
4498         hyp.SetSourceMesh( mesh )
4499         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4500         return hyp
4501
4502     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4503     #def CompareSourceFace(self, hyp, args):
4504     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4505     #    return False
4506
4507 # Public class: Mesh_Projection3D
4508 # ------------------------------
4509
4510 ## Defines a projection 3D algorithm
4511 #  @ingroup l3_algos_proj
4512 #
4513 class Mesh_Projection3D(Mesh_Algorithm):
4514
4515     ## Private constructor.
4516     def __init__(self, mesh, geom=0):
4517         Mesh_Algorithm.__init__(self)
4518         self.Create(mesh, geom, "Projection_3D")
4519
4520     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4521     #  the mesh pattern is taken, and, optionally, the  association of vertices
4522     #  between the source and the target solid  (to which a hipothesis is assigned)
4523     #  @param solid from where the mesh pattern is taken
4524     #  @param mesh from where the mesh pattern is taken (optional)
4525     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4526     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4527     #  to associate with \a srcV1 (optional)
4528     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4529     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4530     #  to associate with \a srcV2 (optional)
4531     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
4532     #                     the same parameters, else (default) - creates a new one
4533     #
4534     #  Note: association vertices must belong to one edge of a solid
4535     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4536                       srcV2=0, tgtV2=0, UseExisting=0):
4537         hyp = self.Hypothesis("ProjectionSource3D",
4538                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4539                               UseExisting=0)
4540                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4541         hyp.SetSource3DShape( solid )
4542         if not mesh is None and isinstance(mesh, Mesh):
4543             mesh = mesh.GetMesh()
4544         hyp.SetSourceMesh( mesh )
4545         if srcV1 and srcV2 and tgtV1 and tgtV2:
4546             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4547         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4548         return hyp
4549
4550     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4551     #def CompareSourceShape3D(self, hyp, args):
4552     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4553     #    return False
4554
4555
4556 # Public class: Mesh_Prism
4557 # ------------------------
4558
4559 ## Defines a 3D extrusion algorithm
4560 #  @ingroup l3_algos_3dextr
4561 #
4562 class Mesh_Prism3D(Mesh_Algorithm):
4563
4564     ## Private constructor.
4565     def __init__(self, mesh, geom=0):
4566         Mesh_Algorithm.__init__(self)
4567         self.Create(mesh, geom, "Prism_3D")
4568
4569 # Public class: Mesh_RadialPrism
4570 # -------------------------------
4571
4572 ## Defines a Radial Prism 3D algorithm
4573 #  @ingroup l3_algos_radialp
4574 #
4575 class Mesh_RadialPrism3D(Mesh_Algorithm):
4576
4577     ## Private constructor.
4578     def __init__(self, mesh, geom=0):
4579         Mesh_Algorithm.__init__(self)
4580         self.Create(mesh, geom, "RadialPrism_3D")
4581
4582         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4583         self.nbLayers = None
4584
4585     ## Return 3D hypothesis holding the 1D one
4586     def Get3DHypothesis(self):
4587         return self.distribHyp
4588
4589     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4590     #  hypothesis. Returns the created hypothesis
4591     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4592         #print "OwnHypothesis",hypType
4593         if not self.nbLayers is None:
4594             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4595             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4596         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4597         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4598         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4599         self.distribHyp.SetLayerDistribution( hyp )
4600         return hyp
4601
4602     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4603     #  prisms to build between the inner and outer shells
4604     #  @param n number of layers
4605     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4606     #                     the same parameters, else (default) - creates a new one
4607     def NumberOfLayers(self, n, UseExisting=0):
4608         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4609         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4610                                         CompareMethod=self.CompareNumberOfLayers)
4611         self.nbLayers.SetNumberOfLayers( n )
4612         return self.nbLayers
4613
4614     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4615     def CompareNumberOfLayers(self, hyp, args):
4616         return IsEqual(hyp.GetNumberOfLayers(), args[0])
4617
4618     ## Defines "LocalLength" hypothesis, specifying the segment length
4619     #  to build between the inner and the outer shells
4620     #  @param l the length of segments
4621     #  @param p the precision of rounding
4622     def LocalLength(self, l, p=1e-07):
4623         hyp = self.OwnHypothesis("LocalLength", [l,p])
4624         hyp.SetLength(l)
4625         hyp.SetPrecision(p)
4626         return hyp
4627
4628     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4629     #  prisms to build between the inner and the outer shells.
4630     #  @param n the number of layers
4631     #  @param s the scale factor (optional)
4632     def NumberOfSegments(self, n, s=[]):
4633         if s == []:
4634             hyp = self.OwnHypothesis("NumberOfSegments", [n])
4635         else:
4636             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4637             hyp.SetDistrType( 1 )
4638             hyp.SetScaleFactor(s)
4639         hyp.SetNumberOfSegments(n)
4640         return hyp
4641
4642     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4643     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
4644     #  @param start  the length of the first segment
4645     #  @param end    the length of the last  segment
4646     def Arithmetic1D(self, start, end ):
4647         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4648         hyp.SetLength(start, 1)
4649         hyp.SetLength(end  , 0)
4650         return hyp
4651
4652     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4653     #  to build between the inner and the outer shells as geometric length increasing
4654     #  @param start for the length of the first segment
4655     #  @param end   for the length of the last  segment
4656     def StartEndLength(self, start, end):
4657         hyp = self.OwnHypothesis("StartEndLength", [start, end])
4658         hyp.SetLength(start, 1)
4659         hyp.SetLength(end  , 0)
4660         return hyp
4661
4662     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4663     #  to build between the inner and outer shells
4664     #  @param fineness defines the quality of the mesh within the range [0-1]
4665     def AutomaticLength(self, fineness=0):
4666         hyp = self.OwnHypothesis("AutomaticLength")
4667         hyp.SetFineness( fineness )
4668         return hyp
4669
4670 # Private class: Mesh_UseExisting
4671 # -------------------------------
4672 class Mesh_UseExisting(Mesh_Algorithm):
4673
4674     def __init__(self, dim, mesh, geom=0):
4675         if dim == 1:
4676             self.Create(mesh, geom, "UseExisting_1D")
4677         else:
4678             self.Create(mesh, geom, "UseExisting_2D")
4679
4680
4681 import salome_notebook
4682 notebook = salome_notebook.notebook
4683
4684 ##Return values of the notebook variables
4685 def ParseParameters(last, nbParams,nbParam, value):
4686     result = None
4687     strResult = ""
4688     counter = 0
4689     listSize = len(last)
4690     for n in range(0,nbParams):
4691         if n+1 != nbParam:
4692             if counter < listSize:
4693                 strResult = strResult + last[counter]
4694             else:
4695                 strResult = strResult + ""
4696         else:
4697             if isinstance(value, str):
4698                 if notebook.isVariable(value):
4699                     result = notebook.get(value)
4700                     strResult=strResult+value
4701                 else:
4702                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4703             else:
4704                 strResult=strResult+str(value)
4705                 result = value
4706         if nbParams - 1 != counter:
4707             strResult=strResult+var_separator #":"
4708         counter = counter+1
4709     return result, strResult
4710
4711 #Wrapper class for StdMeshers_LocalLength hypothesis
4712 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4713
4714     ## Set Length parameter value
4715     #  @param length numerical value or name of variable from notebook
4716     def SetLength(self, length):
4717         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4718         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4719         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4720
4721    ## Set Precision parameter value
4722    #  @param precision numerical value or name of variable from notebook
4723     def SetPrecision(self, precision):
4724         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4725         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4726         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4727
4728 #Registering the new proxy for LocalLength
4729 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4730
4731
4732 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4733 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4734     
4735     def SetLayerDistribution(self, hypo):
4736         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4737         hypo.ClearParameters();
4738         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4739
4740 #Registering the new proxy for LayerDistribution
4741 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4742
4743 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4744 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4745     
4746     ## Set Length parameter value
4747     #  @param length numerical value or name of variable from notebook    
4748     def SetLength(self, length):
4749         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4750         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4751         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4752
4753 #Registering the new proxy for SegmentLengthAroundVertex
4754 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4755
4756
4757 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4758 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4759     
4760     ## Set Length parameter value
4761     #  @param length   numerical value or name of variable from notebook
4762     #  @param isStart  true is length is Start Length, otherwise false
4763     def SetLength(self, length, isStart):
4764         nb = 2
4765         if isStart:
4766             nb = 1
4767         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4768         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4769         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4770         
4771 #Registering the new proxy for Arithmetic1D
4772 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4773
4774 #Wrapper class for StdMeshers_Deflection1D hypothesis
4775 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4776     
4777     ## Set Deflection parameter value
4778     #  @param deflection numerical value or name of variable from notebook    
4779     def SetDeflection(self, deflection):
4780         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4781         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4782         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4783
4784 #Registering the new proxy for Deflection1D
4785 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4786
4787 #Wrapper class for StdMeshers_StartEndLength hypothesis
4788 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4789     
4790     ## Set Length parameter value
4791     #  @param length  numerical value or name of variable from notebook
4792     #  @param isStart true is length is Start Length, otherwise false
4793     def SetLength(self, length, isStart):
4794         nb = 2
4795         if isStart:
4796             nb = 1
4797         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4798         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4799         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4800         
4801 #Registering the new proxy for StartEndLength
4802 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4803
4804 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4805 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4806     
4807     ## Set Max Element Area parameter value
4808     #  @param area  numerical value or name of variable from notebook
4809     def SetMaxElementArea(self, area):
4810         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4811         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4812         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4813         
4814 #Registering the new proxy for MaxElementArea
4815 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4816
4817
4818 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4819 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4820     
4821     ## Set Max Element Volume parameter value
4822     #  @param area  numerical value or name of variable from notebook
4823     def SetMaxElementVolume(self, volume):
4824         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4825         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4826         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4827         
4828 #Registering the new proxy for MaxElementVolume
4829 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4830
4831
4832 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4833 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4834     
4835     ## Set Number Of Layers parameter value
4836     #  @param nbLayers  numerical value or name of variable from notebook
4837     def SetNumberOfLayers(self, nbLayers):
4838         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4839         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4840         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4841         
4842 #Registering the new proxy for NumberOfLayers
4843 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4844
4845 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4846 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4847     
4848     ## Set Number Of Segments parameter value
4849     #  @param nbSeg numerical value or name of variable from notebook
4850     def SetNumberOfSegments(self, nbSeg):
4851         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4852         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4853         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4854         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4855         
4856     ## Set Scale Factor parameter value
4857     #  @param factor numerical value or name of variable from notebook
4858     def SetScaleFactor(self, factor):
4859         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4860         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4861         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4862         
4863 #Registering the new proxy for NumberOfSegments
4864 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4865
4866
4867 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4868 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4869
4870     ## Set Max Size parameter value
4871     #  @param maxsize numerical value or name of variable from notebook
4872     def SetMaxSize(self, maxsize):
4873         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4874         maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4875         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4876         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4877         
4878     ## Set Growth Rate parameter value
4879     #  @param value  numerical value or name of variable from notebook
4880     def SetGrowthRate(self, value):
4881         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4882         value, parameters = ParseParameters(lastParameters,4,2,value)
4883         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4884         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4885         
4886     ## Set Number of Segments per Edge parameter value
4887     #  @param value  numerical value or name of variable from notebook
4888     def SetNbSegPerEdge(self, value):
4889         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4890         value, parameters = ParseParameters(lastParameters,4,3,value)
4891         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4892         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4893         
4894     ## Set Number of Segments per Radius parameter value
4895     #  @param value  numerical value or name of variable from notebook
4896     def SetNbSegPerRadius(self, value):
4897         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4898         value, parameters = ParseParameters(lastParameters,4,4,value)
4899         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4900         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4901         
4902 #Registering the new proxy for NETGENPlugin_Hypothesis
4903 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4904
4905
4906 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4907 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4908     pass
4909
4910 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4911 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4912
4913 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4914 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4915     
4916     ## Set Number of Segments parameter value
4917     #  @param nbSeg numerical value or name of variable from notebook
4918     def SetNumberOfSegments(self, nbSeg):
4919         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4920         nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
4921         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4922         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
4923
4924     ## Set Local Length parameter value
4925     #  @param length numerical value or name of variable from notebook
4926     def SetLocalLength(self, length):
4927         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4928         length, parameters = ParseParameters(lastParameters,2,1,length)
4929         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4930         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
4931
4932     ## Set Max Element Area parameter value
4933     #  @param area numerical value or name of variable from notebook    
4934     def SetMaxElementArea(self, area):
4935         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4936         area, parameters = ParseParameters(lastParameters,2,2,area)
4937         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4938         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
4939
4940     def LengthFromEdges(self):
4941         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4942         value = 0;
4943         value, parameters = ParseParameters(lastParameters,2,2,value)
4944         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4945         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
4946         
4947 #Registering the new proxy for NETGEN_SimpleParameters_2D
4948 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
4949
4950
4951 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
4952 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
4953     ## Set Max Element Volume parameter value
4954     #  @param volume numerical value or name of variable from notebook    
4955     def SetMaxElementVolume(self, volume):
4956         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4957         volume, parameters = ParseParameters(lastParameters,3,3,volume)
4958         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4959         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
4960
4961     def LengthFromFaces(self):
4962         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4963         value = 0;
4964         value, parameters = ParseParameters(lastParameters,3,3,value)
4965         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4966         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
4967         
4968 #Registering the new proxy for NETGEN_SimpleParameters_3D
4969 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
4970
4971 class Pattern(SMESH._objref_SMESH_Pattern):
4972
4973     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4974         flag = False
4975         if isinstance(theNodeIndexOnKeyPoint1,str):
4976             flag = True
4977         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
4978         if flag:
4979             theNodeIndexOnKeyPoint1 -= 1
4980         theMesh.SetParameters(Parameters)
4981         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4982
4983     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4984         flag0 = False
4985         flag1 = False
4986         if isinstance(theNode000Index,str):
4987             flag0 = True
4988         if isinstance(theNode001Index,str):
4989             flag1 = True
4990         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
4991         if flag0:
4992             theNode000Index -= 1
4993         if flag1:
4994             theNode001Index -= 1
4995         theMesh.SetParameters(Parameters)
4996         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4997
4998 #Registering the new proxy for Pattern
4999 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)