]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH_SWIG/smeshDC.py
Salome HOME
21382: EDF 1985 SMESH: Read/write of .mesh files (GMF format)
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
1 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 #  File   : smesh.py
20 #  Author : Francis KLOSS, OCC
21 #  Module : SMESH
22
23 ## @package smesh
24 #  Python API for SALOME %Mesh module
25
26 ## @defgroup l1_auxiliary Auxiliary methods and structures
27 ## @defgroup l1_creating  Creating meshes
28 ## @{
29 ##   @defgroup l2_impexp     Importing and exporting meshes
30 ##   @defgroup l2_construct  Constructing meshes
31 ##   @defgroup l2_algorithms Defining Algorithms
32 ##   @{
33 ##     @defgroup l3_algos_basic   Basic meshing algorithms
34 ##     @defgroup l3_algos_proj    Projection Algorithms
35 ##     @defgroup l3_algos_radialp Radial Prism
36 ##     @defgroup l3_algos_segmarv Segments around Vertex
37 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
38
39 ##   @}
40 ##   @defgroup l2_hypotheses Defining hypotheses
41 ##   @{
42 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
43 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
44 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
45 ##     @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
46 ##     @defgroup l3_hypos_additi Additional Hypotheses
47
48 ##   @}
49 ##   @defgroup l2_submeshes Constructing submeshes
50 ##   @defgroup l2_compounds Building Compounds
51 ##   @defgroup l2_editing   Editing Meshes
52
53 ## @}
54 ## @defgroup l1_meshinfo  Mesh Information
55 ## @defgroup l1_controls  Quality controls and Filtering
56 ## @defgroup l1_grouping  Grouping elements
57 ## @{
58 ##   @defgroup l2_grps_create Creating groups
59 ##   @defgroup l2_grps_edit   Editing groups
60 ##   @defgroup l2_grps_operon Using operations on groups
61 ##   @defgroup l2_grps_delete Deleting Groups
62
63 ## @}
64 ## @defgroup l1_modifying Modifying meshes
65 ## @{
66 ##   @defgroup l2_modif_add      Adding nodes and elements
67 ##   @defgroup l2_modif_del      Removing nodes and elements
68 ##   @defgroup l2_modif_edit     Modifying nodes and elements
69 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
70 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
71 ##   @defgroup l2_modif_movenode Moving nodes
72 ##   @defgroup l2_modif_throughp Mesh through point
73 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
74 ##   @defgroup l2_modif_unitetri Uniting triangles
75 ##   @defgroup l2_modif_changori Changing orientation of elements
76 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
77 ##   @defgroup l2_modif_smooth   Smoothing
78 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
79 ##   @defgroup l2_modif_patterns Pattern mapping
80 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
81
82 ## @}
83 ## @defgroup l1_measurements Measurements
84
85 import salome
86 import geompyDC
87
88 import SMESH # This is necessary for back compatibility
89 from   SMESH import *
90 from   smesh_algorithm import Mesh_Algorithm
91
92 import SALOME
93 import SALOMEDS
94
95 ## @addtogroup l1_auxiliary
96 ## @{
97
98 # MirrorType enumeration
99 POINT = SMESH_MeshEditor.POINT
100 AXIS =  SMESH_MeshEditor.AXIS
101 PLANE = SMESH_MeshEditor.PLANE
102
103 # Smooth_Method enumeration
104 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
105 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
106
107 PrecisionConfusion = 1e-07
108
109 # TopAbs_State enumeration
110 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
111
112 # Methods of splitting a hexahedron into tetrahedra
113 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
114
115 ## Converts an angle from degrees to radians
116 def DegreesToRadians(AngleInDegrees):
117     from math import pi
118     return AngleInDegrees * pi / 180.0
119
120 import salome_notebook
121 notebook = salome_notebook.notebook
122 # Salome notebook variable separator
123 var_separator = ":"
124
125 ## Return list of variable values from salome notebook.
126 #  The last argument, if is callable, is used to modify values got from notebook
127 def ParseParameters(*args):
128     Result = []
129     Parameters = ""
130     hasVariables = False
131     varModifFun=None
132     if args and callable( args[-1] ):
133         args, varModifFun = args[:-1], args[-1]
134     for parameter in args:
135
136         Parameters += str(parameter) + var_separator
137
138         if isinstance(parameter,str):
139             # check if there is an inexistent variable name
140             if not notebook.isVariable(parameter):
141                 raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
142             parameter = notebook.get(parameter)
143             hasVariables = True
144             if varModifFun:
145                 parameter = varModifFun(parameter)
146                 pass
147             pass
148         Result.append(parameter)
149
150         pass
151     Parameters = Parameters[:-1]
152     Result.append( Parameters )
153     Result.append( hasVariables )
154     return Result
155
156 # Parse parameters converting variables to radians
157 def ParseAngles(*args):
158     return ParseParameters( *( args + (DegreesToRadians, )))
159
160 # Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
161 # Parameters are stored in PointStruct.parameters attribute
162 def __initPointStruct(point,*args):
163     point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
164     pass
165 SMESH.PointStruct.__init__ = __initPointStruct
166
167 # Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
168 # Parameters are stored in AxisStruct.parameters attribute
169 def __initAxisStruct(ax,*args):
170     ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
171     pass
172 SMESH.AxisStruct.__init__ = __initAxisStruct
173
174
175 def IsEqual(val1, val2, tol=PrecisionConfusion):
176     if abs(val1 - val2) < tol:
177         return True
178     return False
179
180 NO_NAME = "NoName"
181
182 ## Gets object name
183 def GetName(obj):
184     if obj:
185         # object not null
186         if isinstance(obj, SALOMEDS._objref_SObject):
187             # study object
188             return obj.GetName()
189         ior  = salome.orb.object_to_string(obj)
190         if ior:
191             # CORBA object
192             studies = salome.myStudyManager.GetOpenStudies()
193             for sname in studies:
194                 s = salome.myStudyManager.GetStudyByName(sname)
195                 if not s: continue
196                 sobj = s.FindObjectIOR(ior)
197                 if not sobj: continue
198                 return sobj.GetName()
199             if hasattr(obj, "GetName"):
200                 # unknown CORBA object, having GetName() method
201                 return obj.GetName()
202             else:
203                 # unknown CORBA object, no GetName() method
204                 return NO_NAME
205             pass
206         if hasattr(obj, "GetName"):
207             # unknown non-CORBA object, having GetName() method
208             return obj.GetName()
209         pass
210     raise RuntimeError, "Null or invalid object"
211
212 ## Prints error message if a hypothesis was not assigned.
213 def TreatHypoStatus(status, hypName, geomName, isAlgo):
214     if isAlgo:
215         hypType = "algorithm"
216     else:
217         hypType = "hypothesis"
218         pass
219     if status == HYP_UNKNOWN_FATAL :
220         reason = "for unknown reason"
221     elif status == HYP_INCOMPATIBLE :
222         reason = "this hypothesis mismatches the algorithm"
223     elif status == HYP_NOTCONFORM :
224         reason = "a non-conform mesh would be built"
225     elif status == HYP_ALREADY_EXIST :
226         if isAlgo: return # it does not influence anything
227         reason = hypType + " of the same dimension is already assigned to this shape"
228     elif status == HYP_BAD_DIM :
229         reason = hypType + " mismatches the shape"
230     elif status == HYP_CONCURENT :
231         reason = "there are concurrent hypotheses on sub-shapes"
232     elif status == HYP_BAD_SUBSHAPE :
233         reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
234     elif status == HYP_BAD_GEOMETRY:
235         reason = "geometry mismatches the expectation of the algorithm"
236     elif status == HYP_HIDDEN_ALGO:
237         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
238     elif status == HYP_HIDING_ALGO:
239         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
240     elif status == HYP_NEED_SHAPE:
241         reason = "Algorithm can't work without shape"
242     else:
243         return
244     hypName = '"' + hypName + '"'
245     geomName= '"' + geomName+ '"'
246     if status < HYP_UNKNOWN_FATAL and not geomName =='""':
247         print hypName, "was assigned to",    geomName,"but", reason
248     elif not geomName == '""':
249         print hypName, "was not assigned to",geomName,":", reason
250     else:
251         print hypName, "was not assigned:", reason
252         pass
253
254 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
255 def AssureGeomPublished(mesh, geom, name=''):
256     if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
257         return
258     if not geom.GetStudyEntry() and \
259            mesh.smeshpyD.GetCurrentStudy():
260         ## set the study
261         studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
262         if studyID != mesh.geompyD.myStudyId:
263             mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
264         ## get a name
265         if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
266             # for all groups SubShapeName() returns "Compound_-1"
267             name = mesh.geompyD.SubShapeName(geom, mesh.geom)
268         if not name:
269             name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
270         ## publish
271         mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
272     return
273
274 ## Return the first vertex of a geomertical edge by ignoring orienation
275 def FirstVertexOnCurve(edge):
276     from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
277     vv = SubShapeAll( edge, ShapeType["VERTEX"])
278     if not vv:
279         raise TypeError, "Given object has no vertices"
280     if len( vv ) == 1: return vv[0]
281     info = KindOfShape(edge)
282     xyz = info[1:4] # coords of the first vertex
283     xyz1  = PointCoordinates( vv[0] )
284     xyz2  = PointCoordinates( vv[1] )
285     dist1, dist2 = 0,0
286     for i in range(3):
287         dist1 += abs( xyz[i] - xyz1[i] )
288         dist2 += abs( xyz[i] - xyz2[i] )
289     if dist1 < dist2:
290         return vv[0]
291     else:
292         return vv[1]
293
294 # end of l1_auxiliary
295 ## @}
296
297 # All methods of this class are accessible directly from the smesh.py package.
298 class smeshDC(SMESH._objref_SMESH_Gen):
299
300     ## Dump component to the Python script
301     #  This method overrides IDL function to allow default values for the parameters.
302     def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
303         return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
304
305     ## Set mode of DumpPython(), \a historical or \a snapshot.
306     # In the \a historical mode, the Python Dump script includes all commands
307     # performed by SMESH engine. In the \a snapshot mode, commands
308     # relating to objects removed from the Study are excluded from the script
309     # as well as commands not influencing the current state of meshes
310     def SetDumpPythonHistorical(self, isHistorical):
311         if isHistorical: val = "true"
312         else:            val = "false"
313         SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
314
315     ## Sets the current study and Geometry component
316     #  @ingroup l1_auxiliary
317     def init_smesh(self,theStudy,geompyD):
318         self.SetCurrentStudy(theStudy,geompyD)
319
320     ## Creates an empty Mesh. This mesh can have an underlying geometry.
321     #  @param obj the Geometrical object on which the mesh is built. If not defined,
322     #             the mesh will have no underlying geometry.
323     #  @param name the name for the new mesh.
324     #  @return an instance of Mesh class.
325     #  @ingroup l2_construct
326     def Mesh(self, obj=0, name=0):
327         if isinstance(obj,str):
328             obj,name = name,obj
329         return Mesh(self,self.geompyD,obj,name)
330
331     ## Returns a long value from enumeration
332     #  @ingroup l1_controls
333     def EnumToLong(self,theItem):
334         return theItem._v
335
336     ## Returns a string representation of the color.
337     #  To be used with filters.
338     #  @param c color value (SALOMEDS.Color)
339     #  @ingroup l1_controls
340     def ColorToString(self,c):
341         val = ""
342         if isinstance(c, SALOMEDS.Color):
343             val = "%s;%s;%s" % (c.R, c.G, c.B)
344         elif isinstance(c, str):
345             val = c
346         else:
347             raise ValueError, "Color value should be of string or SALOMEDS.Color type"
348         return val
349
350     ## Gets PointStruct from vertex
351     #  @param theVertex a GEOM object(vertex)
352     #  @return SMESH.PointStruct
353     #  @ingroup l1_auxiliary
354     def GetPointStruct(self,theVertex):
355         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
356         return PointStruct(x,y,z)
357
358     ## Gets DirStruct from vector
359     #  @param theVector a GEOM object(vector)
360     #  @return SMESH.DirStruct
361     #  @ingroup l1_auxiliary
362     def GetDirStruct(self,theVector):
363         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
364         if(len(vertices) != 2):
365             print "Error: vector object is incorrect."
366             return None
367         p1 = self.geompyD.PointCoordinates(vertices[0])
368         p2 = self.geompyD.PointCoordinates(vertices[1])
369         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
370         dirst = DirStruct(pnt)
371         return dirst
372
373     ## Makes DirStruct from a triplet
374     #  @param x,y,z vector components
375     #  @return SMESH.DirStruct
376     #  @ingroup l1_auxiliary
377     def MakeDirStruct(self,x,y,z):
378         pnt = PointStruct(x,y,z)
379         return DirStruct(pnt)
380
381     ## Get AxisStruct from object
382     #  @param theObj a GEOM object (line or plane)
383     #  @return SMESH.AxisStruct
384     #  @ingroup l1_auxiliary
385     def GetAxisStruct(self,theObj):
386         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
387         if len(edges) > 1:
388             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
389             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
390             vertex1 = self.geompyD.PointCoordinates(vertex1)
391             vertex2 = self.geompyD.PointCoordinates(vertex2)
392             vertex3 = self.geompyD.PointCoordinates(vertex3)
393             vertex4 = self.geompyD.PointCoordinates(vertex4)
394             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
395             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
396             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] ]
397             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
398             return axis
399         elif len(edges) == 1:
400             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
401             p1 = self.geompyD.PointCoordinates( vertex1 )
402             p2 = self.geompyD.PointCoordinates( vertex2 )
403             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
404             return axis
405         return None
406
407     # From SMESH_Gen interface:
408     # ------------------------
409
410     ## Sets the given name to the object
411     #  @param obj the object to rename
412     #  @param name a new object name
413     #  @ingroup l1_auxiliary
414     def SetName(self, obj, name):
415         if isinstance( obj, Mesh ):
416             obj = obj.GetMesh()
417         elif isinstance( obj, Mesh_Algorithm ):
418             obj = obj.GetAlgorithm()
419         ior  = salome.orb.object_to_string(obj)
420         SMESH._objref_SMESH_Gen.SetName(self, ior, name)
421
422     ## Sets the current mode
423     #  @ingroup l1_auxiliary
424     def SetEmbeddedMode( self,theMode ):
425         #self.SetEmbeddedMode(theMode)
426         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
427
428     ## Gets the current mode
429     #  @ingroup l1_auxiliary
430     def IsEmbeddedMode(self):
431         #return self.IsEmbeddedMode()
432         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
433
434     ## Sets the current study
435     #  @ingroup l1_auxiliary
436     def SetCurrentStudy( self, theStudy, geompyD = None ):
437         #self.SetCurrentStudy(theStudy)
438         if not geompyD:
439             import geompy
440             geompyD = geompy.geom
441             pass
442         self.geompyD=geompyD
443         self.SetGeomEngine(geompyD)
444         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
445         global notebook
446         if theStudy:
447             notebook = salome_notebook.NoteBook( theStudy )
448         else:
449             notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
450
451     ## Gets the current study
452     #  @ingroup l1_auxiliary
453     def GetCurrentStudy(self):
454         #return self.GetCurrentStudy()
455         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
456
457     ## Creates a Mesh object importing data from the given UNV file
458     #  @return an instance of Mesh class
459     #  @ingroup l2_impexp
460     def CreateMeshesFromUNV( self,theFileName ):
461         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
462         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
463         return aMesh
464
465     ## Creates a Mesh object(s) importing data from the given MED file
466     #  @return a list of Mesh class instances
467     #  @ingroup l2_impexp
468     def CreateMeshesFromMED( self,theFileName ):
469         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
470         aMeshes = []
471         for iMesh in range(len(aSmeshMeshes)) :
472             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
473             aMeshes.append(aMesh)
474         return aMeshes, aStatus
475
476     ## Creates a Mesh object(s) importing data from the given SAUV file
477     #  @return a list of Mesh class instances
478     #  @ingroup l2_impexp
479     def CreateMeshesFromSAUV( self,theFileName ):
480         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
481         aMeshes = []
482         for iMesh in range(len(aSmeshMeshes)) :
483             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
484             aMeshes.append(aMesh)
485         return aMeshes, aStatus
486
487     ## Creates a Mesh object importing data from the given STL file
488     #  @return an instance of Mesh class
489     #  @ingroup l2_impexp
490     def CreateMeshesFromSTL( self, theFileName ):
491         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
492         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
493         return aMesh
494
495     ## Creates Mesh objects importing data from the given CGNS file
496     #  @return an instance of Mesh class
497     #  @ingroup l2_impexp
498     def CreateMeshesFromCGNS( self, theFileName ):
499         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
500         aMeshes = []
501         for iMesh in range(len(aSmeshMeshes)) :
502             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
503             aMeshes.append(aMesh)
504         return aMeshes, aStatus
505
506     ## Creates a Mesh object importing data from the given GMF file
507     #  @return [ an instance of Mesh class, SMESH::ComputeError ]
508     #  @ingroup l2_impexp
509     def CreateMeshesFromGMF( self, theFileName ):
510         aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
511                                                                         theFileName,
512                                                                         True)
513         if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
514         return Mesh(self, self.geompyD, aSmeshMesh), error
515
516     ## Concatenate the given meshes into one mesh.
517     #  @return an instance of Mesh class
518     #  @param meshes the meshes to combine into one mesh
519     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
520     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
521     #  @param mergeTolerance tolerance for merging nodes
522     #  @param allGroups forces creation of groups of all elements
523     def Concatenate( self, meshes, uniteIdenticalGroups,
524                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
525         if not meshes: return None
526         for i,m in enumerate(meshes):
527             if isinstance(m, Mesh):
528                 meshes[i] = m.GetMesh()
529         mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
530         meshes[0].SetParameters(Parameters)
531         if allGroups:
532             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
533                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
534         else:
535             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
536                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
537         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
538         return aMesh
539
540     ## Create a mesh by copying a part of another mesh.
541     #  @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
542     #                  to copy nodes or elements not contained in any mesh object,
543     #                  pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
544     #  @param meshName a name of the new mesh
545     #  @param toCopyGroups to create in the new mesh groups the copied elements belongs to
546     #  @param toKeepIDs to preserve IDs of the copied elements or not
547     #  @return an instance of Mesh class
548     def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
549         if (isinstance( meshPart, Mesh )):
550             meshPart = meshPart.GetMesh()
551         mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
552         return Mesh(self, self.geompyD, mesh)
553
554     ## From SMESH_Gen interface
555     #  @return the list of integer values
556     #  @ingroup l1_auxiliary
557     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
558         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
559
560     ## From SMESH_Gen interface. Creates a pattern
561     #  @return an instance of SMESH_Pattern
562     #
563     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
564     #  @ingroup l2_modif_patterns
565     def GetPattern(self):
566         return SMESH._objref_SMESH_Gen.GetPattern(self)
567
568     ## Sets number of segments per diagonal of boundary box of geometry by which
569     #  default segment length of appropriate 1D hypotheses is defined.
570     #  Default value is 10
571     #  @ingroup l1_auxiliary
572     def SetBoundaryBoxSegmentation(self, nbSegments):
573         SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
574
575     # Filtering. Auxiliary functions:
576     # ------------------------------
577
578     ## Creates an empty criterion
579     #  @return SMESH.Filter.Criterion
580     #  @ingroup l1_controls
581     def GetEmptyCriterion(self):
582         Type = self.EnumToLong(FT_Undefined)
583         Compare = self.EnumToLong(FT_Undefined)
584         Threshold = 0
585         ThresholdStr = ""
586         ThresholdID = ""
587         UnaryOp = self.EnumToLong(FT_Undefined)
588         BinaryOp = self.EnumToLong(FT_Undefined)
589         Tolerance = 1e-07
590         TypeOfElement = ALL
591         Precision = -1 ##@1e-07
592         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
593                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
594
595     ## Creates a criterion by the given parameters
596     #  \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
597     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
598     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
599     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
600     #  @param Threshold the threshold value (range of ids as string, shape, numeric)
601     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
602     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
603     #                  FT_Undefined (must be for the last criterion of all criteria)
604     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
605     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
606     #  @return SMESH.Filter.Criterion
607     #
608     #  <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
609     #  @ingroup l1_controls
610     def GetCriterion(self,elementType,
611                      CritType,
612                      Compare = FT_EqualTo,
613                      Threshold="",
614                      UnaryOp=FT_Undefined,
615                      BinaryOp=FT_Undefined,
616                      Tolerance=1e-07):
617         if not CritType in SMESH.FunctorType._items:
618             raise TypeError, "CritType should be of SMESH.FunctorType"
619         aCriterion = self.GetEmptyCriterion()
620         aCriterion.TypeOfElement = elementType
621         aCriterion.Type = self.EnumToLong(CritType)
622         aCriterion.Tolerance = Tolerance
623
624         aThreshold = Threshold
625
626         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
627             aCriterion.Compare = self.EnumToLong(Compare)
628         elif Compare == "=" or Compare == "==":
629             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
630         elif Compare == "<":
631             aCriterion.Compare = self.EnumToLong(FT_LessThan)
632         elif Compare == ">":
633             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
634         elif Compare != FT_Undefined:
635             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
636             aThreshold = Compare
637
638         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
639                         FT_BelongToCylinder, FT_LyingOnGeom]:
640             # Checks that Threshold is GEOM object
641             if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
642                 aCriterion.ThresholdStr = GetName(aThreshold)
643                 aCriterion.ThresholdID = aThreshold.GetStudyEntry()
644                 if not aCriterion.ThresholdID:
645                     raise RuntimeError, "Threshold shape must be published"
646             else:
647                 print "Error: The Threshold should be a shape."
648                 return None
649             if isinstance(UnaryOp,float):
650                 aCriterion.Tolerance = UnaryOp
651                 UnaryOp = FT_Undefined
652                 pass
653         elif CritType == FT_RangeOfIds:
654             # Checks that Threshold is string
655             if isinstance(aThreshold, str):
656                 aCriterion.ThresholdStr = aThreshold
657             else:
658                 print "Error: The Threshold should be a string."
659                 return None
660         elif CritType == FT_CoplanarFaces:
661             # Checks the Threshold
662             if isinstance(aThreshold, int):
663                 aCriterion.ThresholdID = str(aThreshold)
664             elif isinstance(aThreshold, str):
665                 ID = int(aThreshold)
666                 if ID < 1:
667                     raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
668                 aCriterion.ThresholdID = aThreshold
669             else:
670                 raise ValueError,\
671                       "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
672         elif CritType == FT_ElemGeomType:
673             # Checks the Threshold
674             try:
675                 aCriterion.Threshold = self.EnumToLong(aThreshold)
676                 assert( aThreshold in SMESH.GeometryType._items )
677             except:
678                 if isinstance(aThreshold, int):
679                     aCriterion.Threshold = aThreshold
680                 else:
681                     print "Error: The Threshold should be an integer or SMESH.GeometryType."
682                     return None
683                 pass
684             pass
685         elif CritType == FT_GroupColor:
686             # Checks the Threshold
687             try:
688                 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
689             except:
690                 print "Error: The threshold value should be of SALOMEDS.Color type"
691                 return None
692             pass
693         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
694                           FT_LinearOrQuadratic, FT_BadOrientedVolume,
695                           FT_BareBorderFace, FT_BareBorderVolume,
696                           FT_OverConstrainedFace, FT_OverConstrainedVolume,
697                           FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
698             # At this point the Threshold is unnecessary
699             if aThreshold ==  FT_LogicalNOT:
700                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
701             elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
702                 aCriterion.BinaryOp = aThreshold
703         else:
704             # Check Threshold
705             try:
706                 aThreshold = float(aThreshold)
707                 aCriterion.Threshold = aThreshold
708             except:
709                 print "Error: The Threshold should be a number."
710                 return None
711
712         if Threshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
713             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
714
715         if Threshold in [FT_LogicalAND, FT_LogicalOR]:
716             aCriterion.BinaryOp = self.EnumToLong(Threshold)
717
718         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
719             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
720
721         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
722             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
723
724         return aCriterion
725
726     ## Creates a filter with the given parameters
727     #  @param elementType the type of elements in the group
728     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
729     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
730     #  @param Threshold the threshold value (range of id ids as string, shape, numeric)
731     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
732     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
733     #         FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
734     #  @return SMESH_Filter
735     #
736     #  <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
737     #  @ingroup l1_controls
738     def GetFilter(self,elementType,
739                   CritType=FT_Undefined,
740                   Compare=FT_EqualTo,
741                   Threshold="",
742                   UnaryOp=FT_Undefined,
743                   Tolerance=1e-07):
744         aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
745         aFilterMgr = self.CreateFilterManager()
746         aFilter = aFilterMgr.CreateFilter()
747         aCriteria = []
748         aCriteria.append(aCriterion)
749         aFilter.SetCriteria(aCriteria)
750         aFilterMgr.UnRegister()
751         return aFilter
752
753     ## Creates a filter from criteria
754     #  @param criteria a list of criteria
755     #  @return SMESH_Filter
756     #
757     #  <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
758     #  @ingroup l1_controls
759     def GetFilterFromCriteria(self,criteria):
760         aFilterMgr = self.CreateFilterManager()
761         aFilter = aFilterMgr.CreateFilter()
762         aFilter.SetCriteria(criteria)
763         aFilterMgr.UnRegister()
764         return aFilter
765
766     ## Creates a numerical functor by its type
767     #  @param theCriterion FT_...; functor type
768     #  @return SMESH_NumericalFunctor
769     #  @ingroup l1_controls
770     def GetFunctor(self,theCriterion):
771         if isinstance( theCriterion, SMESH._objref_NumericalFunctor ):
772             return theCriterion
773         aFilterMgr = self.CreateFilterManager()
774         if theCriterion == FT_AspectRatio:
775             return aFilterMgr.CreateAspectRatio()
776         elif theCriterion == FT_AspectRatio3D:
777             return aFilterMgr.CreateAspectRatio3D()
778         elif theCriterion == FT_Warping:
779             return aFilterMgr.CreateWarping()
780         elif theCriterion == FT_MinimumAngle:
781             return aFilterMgr.CreateMinimumAngle()
782         elif theCriterion == FT_Taper:
783             return aFilterMgr.CreateTaper()
784         elif theCriterion == FT_Skew:
785             return aFilterMgr.CreateSkew()
786         elif theCriterion == FT_Area:
787             return aFilterMgr.CreateArea()
788         elif theCriterion == FT_Volume3D:
789             return aFilterMgr.CreateVolume3D()
790         elif theCriterion == FT_MaxElementLength2D:
791             return aFilterMgr.CreateMaxElementLength2D()
792         elif theCriterion == FT_MaxElementLength3D:
793             return aFilterMgr.CreateMaxElementLength3D()
794         elif theCriterion == FT_MultiConnection:
795             return aFilterMgr.CreateMultiConnection()
796         elif theCriterion == FT_MultiConnection2D:
797             return aFilterMgr.CreateMultiConnection2D()
798         elif theCriterion == FT_Length:
799             return aFilterMgr.CreateLength()
800         elif theCriterion == FT_Length2D:
801             return aFilterMgr.CreateLength2D()
802         else:
803             print "Error: given parameter is not numerical functor type."
804
805     ## Creates hypothesis
806     #  @param theHType mesh hypothesis type (string)
807     #  @param theLibName mesh plug-in library name
808     #  @return created hypothesis instance
809     def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
810         hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
811
812         if isinstance( hyp, SMESH._objref_SMESH_Algo ):
813             return hyp
814
815         # wrap hypothesis methods
816         #print "HYPOTHESIS", theHType
817         for meth_name in dir( hyp.__class__ ):
818             if not meth_name.startswith("Get") and \
819                not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ):
820                 method = getattr ( hyp.__class__, meth_name )
821                 if callable(method):
822                     setattr( hyp, meth_name, hypMethodWrapper( hyp, method ))
823
824         return hyp
825
826     ## Gets the mesh statistic
827     #  @return dictionary "element type" - "count of elements"
828     #  @ingroup l1_meshinfo
829     def GetMeshInfo(self, obj):
830         if isinstance( obj, Mesh ):
831             obj = obj.GetMesh()
832         d = {}
833         if hasattr(obj, "GetMeshInfo"):
834             values = obj.GetMeshInfo()
835             for i in range(SMESH.Entity_Last._v):
836                 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
837             pass
838         return d
839
840     ## Get minimum distance between two objects
841     #
842     #  If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
843     #  If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
844     #
845     #  @param src1 first source object
846     #  @param src2 second source object
847     #  @param id1 node/element id from the first source
848     #  @param id2 node/element id from the second (or first) source
849     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
850     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
851     #  @return minimum distance value
852     #  @sa GetMinDistance()
853     #  @ingroup l1_measurements
854     def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
855         result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
856         if result is None:
857             result = 0.0
858         else:
859             result = result.value
860         return result
861
862     ## Get measure structure specifying minimum distance data between two objects
863     #
864     #  If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
865     #  If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
866     #
867     #  @param src1 first source object
868     #  @param src2 second source object
869     #  @param id1 node/element id from the first source
870     #  @param id2 node/element id from the second (or first) source
871     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
872     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
873     #  @return Measure structure or None if input data is invalid
874     #  @sa MinDistance()
875     #  @ingroup l1_measurements
876     def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
877         if isinstance(src1, Mesh): src1 = src1.mesh
878         if isinstance(src2, Mesh): src2 = src2.mesh
879         if src2 is None and id2 != 0: src2 = src1
880         if not hasattr(src1, "_narrow"): return None
881         src1 = src1._narrow(SMESH.SMESH_IDSource)
882         if not src1: return None
883         if id1 != 0:
884             m = src1.GetMesh()
885             e = m.GetMeshEditor()
886             if isElem1:
887                 src1 = e.MakeIDSource([id1], SMESH.FACE)
888             else:
889                 src1 = e.MakeIDSource([id1], SMESH.NODE)
890             pass
891         if hasattr(src2, "_narrow"):
892             src2 = src2._narrow(SMESH.SMESH_IDSource)
893             if src2 and id2 != 0:
894                 m = src2.GetMesh()
895                 e = m.GetMeshEditor()
896                 if isElem2:
897                     src2 = e.MakeIDSource([id2], SMESH.FACE)
898                 else:
899                     src2 = e.MakeIDSource([id2], SMESH.NODE)
900                 pass
901             pass
902         aMeasurements = self.CreateMeasurements()
903         result = aMeasurements.MinDistance(src1, src2)
904         aMeasurements.UnRegister()
905         return result
906
907     ## Get bounding box of the specified object(s)
908     #  @param objects single source object or list of source objects
909     #  @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
910     #  @sa GetBoundingBox()
911     #  @ingroup l1_measurements
912     def BoundingBox(self, objects):
913         result = self.GetBoundingBox(objects)
914         if result is None:
915             result = (0.0,)*6
916         else:
917             result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
918         return result
919
920     ## Get measure structure specifying bounding box data of the specified object(s)
921     #  @param objects single source object or list of source objects
922     #  @return Measure structure
923     #  @sa BoundingBox()
924     #  @ingroup l1_measurements
925     def GetBoundingBox(self, objects):
926         if isinstance(objects, tuple):
927             objects = list(objects)
928         if not isinstance(objects, list):
929             objects = [objects]
930         srclist = []
931         for o in objects:
932             if isinstance(o, Mesh):
933                 srclist.append(o.mesh)
934             elif hasattr(o, "_narrow"):
935                 src = o._narrow(SMESH.SMESH_IDSource)
936                 if src: srclist.append(src)
937                 pass
938             pass
939         aMeasurements = self.CreateMeasurements()
940         result = aMeasurements.BoundingBox(srclist)
941         aMeasurements.UnRegister()
942         return result
943
944 import omniORB
945 #Registering the new proxy for SMESH_Gen
946 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
947
948
949 # Public class: Mesh
950 # ==================
951
952 ## This class allows defining and managing a mesh.
953 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
954 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
955 #  new nodes and elements and by changing the existing entities), to get information
956 #  about a mesh and to export a mesh into different formats.
957 class Mesh:
958
959     geom = 0
960     mesh = 0
961     editor = 0
962     functors = [None] * SMESH.FT_Undefined._v
963
964     ## Constructor
965     #
966     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
967     #  sets the GUI name of this mesh to \a name.
968     #  @param smeshpyD an instance of smeshDC class
969     #  @param geompyD an instance of geompyDC class
970     #  @param obj Shape to be meshed or SMESH_Mesh object
971     #  @param name Study name of the mesh
972     #  @ingroup l2_construct
973     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
974         self.smeshpyD=smeshpyD
975         self.geompyD=geompyD
976         if obj is None:
977             obj = 0
978         if obj != 0:
979             objHasName = True
980             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
981                 self.geom = obj
982                 # publish geom of mesh (issue 0021122)
983                 if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
984                     objHasName = False
985                     studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
986                     if studyID != geompyD.myStudyId:
987                         geompyD.init_geom( smeshpyD.GetCurrentStudy())
988                         pass
989                     if name:
990                         geo_name = name
991                     else:
992                         geo_name = "%s_%s_for_meshing"%(self.geom.GetShapeType(), id(self.geom)%100)
993                     geompyD.addToStudy( self.geom, geo_name )
994                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
995
996             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
997                 self.SetMesh(obj)
998         else:
999             self.mesh = self.smeshpyD.CreateEmptyMesh()
1000         if name != 0:
1001             self.smeshpyD.SetName(self.mesh, name)
1002         elif obj != 0 and objHasName:
1003             self.smeshpyD.SetName(self.mesh, GetName(obj))
1004
1005         if not self.geom:
1006             self.geom = self.mesh.GetShapeToMesh()
1007
1008         self.editor = self.mesh.GetMeshEditor()
1009
1010         # set self to algoCreator's
1011         for attrName in dir(self):
1012             attr = getattr( self, attrName )
1013             if isinstance( attr, algoCreator ):
1014                 setattr( self, attrName, attr.copy( self ))
1015
1016     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1017     #  @param theMesh a SMESH_Mesh object
1018     #  @ingroup l2_construct
1019     def SetMesh(self, theMesh):
1020         self.mesh = theMesh
1021         self.geom = self.mesh.GetShapeToMesh()
1022
1023     ## Returns the mesh, that is an instance of SMESH_Mesh interface
1024     #  @return a SMESH_Mesh object
1025     #  @ingroup l2_construct
1026     def GetMesh(self):
1027         return self.mesh
1028
1029     ## Gets the name of the mesh
1030     #  @return the name of the mesh as a string
1031     #  @ingroup l2_construct
1032     def GetName(self):
1033         name = GetName(self.GetMesh())
1034         return name
1035
1036     ## Sets a name to the mesh
1037     #  @param name a new name of the mesh
1038     #  @ingroup l2_construct
1039     def SetName(self, name):
1040         self.smeshpyD.SetName(self.GetMesh(), name)
1041
1042     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1043     #  The subMesh object gives access to the IDs of nodes and elements.
1044     #  @param geom a geometrical object (shape)
1045     #  @param name a name for the submesh
1046     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1047     #  @ingroup l2_submeshes
1048     def GetSubMesh(self, geom, name):
1049         AssureGeomPublished( self, geom, name )
1050         submesh = self.mesh.GetSubMesh( geom, name )
1051         return submesh
1052
1053     ## Returns the shape associated to the mesh
1054     #  @return a GEOM_Object
1055     #  @ingroup l2_construct
1056     def GetShape(self):
1057         return self.geom
1058
1059     ## Associates the given shape to the mesh (entails the recreation of the mesh)
1060     #  @param geom the shape to be meshed (GEOM_Object)
1061     #  @ingroup l2_construct
1062     def SetShape(self, geom):
1063         self.mesh = self.smeshpyD.CreateMesh(geom)
1064
1065     ## Loads mesh from the study after opening the study
1066     def Load(self):
1067         self.mesh.Load()
1068
1069     ## Returns true if the hypotheses are defined well
1070     #  @param theSubObject a sub-shape of a mesh shape
1071     #  @return True or False
1072     #  @ingroup l2_construct
1073     def IsReadyToCompute(self, theSubObject):
1074         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1075
1076     ## Returns errors of hypotheses definition.
1077     #  The list of errors is empty if everything is OK.
1078     #  @param theSubObject a sub-shape of a mesh shape
1079     #  @return a list of errors
1080     #  @ingroup l2_construct
1081     def GetAlgoState(self, theSubObject):
1082         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1083
1084     ## Returns a geometrical object on which the given element was built.
1085     #  The returned geometrical object, if not nil, is either found in the
1086     #  study or published by this method with the given name
1087     #  @param theElementID the id of the mesh element
1088     #  @param theGeomName the user-defined name of the geometrical object
1089     #  @return GEOM::GEOM_Object instance
1090     #  @ingroup l2_construct
1091     def GetGeometryByMeshElement(self, theElementID, theGeomName):
1092         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1093
1094     ## Returns the mesh dimension depending on the dimension of the underlying shape
1095     #  @return mesh dimension as an integer value [0,3]
1096     #  @ingroup l1_auxiliary
1097     def MeshDimension(self):
1098         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1099         if len( shells ) > 0 :
1100             return 3
1101         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1102             return 2
1103         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1104             return 1
1105         else:
1106             return 0;
1107         pass
1108
1109     ## Evaluates size of prospective mesh on a shape
1110     #  @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1111     #  To know predicted number of e.g. edges, inquire it this way
1112     #  Evaluate()[ EnumToLong( Entity_Edge )]
1113     def Evaluate(self, geom=0):
1114         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1115             if self.geom == 0:
1116                 geom = self.mesh.GetShapeToMesh()
1117             else:
1118                 geom = self.geom
1119         return self.smeshpyD.Evaluate(self.mesh, geom)
1120
1121
1122     ## Computes the mesh and returns the status of the computation
1123     #  @param geom geomtrical shape on which mesh data should be computed
1124     #  @param discardModifs if True and the mesh has been edited since
1125     #         a last total re-compute and that may prevent successful partial re-compute,
1126     #         then the mesh is cleaned before Compute()
1127     #  @return True or False
1128     #  @ingroup l2_construct
1129     def Compute(self, geom=0, discardModifs=False):
1130         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1131             if self.geom == 0:
1132                 geom = self.mesh.GetShapeToMesh()
1133             else:
1134                 geom = self.geom
1135         ok = False
1136         try:
1137             if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1138                 self.mesh.Clear()
1139             ok = self.smeshpyD.Compute(self.mesh, geom)
1140         except SALOME.SALOME_Exception, ex:
1141             print "Mesh computation failed, exception caught:"
1142             print "    ", ex.details.text
1143         except:
1144             import traceback
1145             print "Mesh computation failed, exception caught:"
1146             traceback.print_exc()
1147         if True:#not ok:
1148             allReasons = ""
1149
1150             # Treat compute errors
1151             computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1152             for err in computeErrors:
1153                 shapeText = ""
1154                 if self.mesh.HasShapeToMesh():
1155                     try:
1156                         mainIOR  = salome.orb.object_to_string(geom)
1157                         for sname in salome.myStudyManager.GetOpenStudies():
1158                             s = salome.myStudyManager.GetStudyByName(sname)
1159                             if not s: continue
1160                             mainSO = s.FindObjectIOR(mainIOR)
1161                             if not mainSO: continue
1162                             if err.subShapeID == 1:
1163                                 shapeText = ' on "%s"' % mainSO.GetName()
1164                             subIt = s.NewChildIterator(mainSO)
1165                             while subIt.More():
1166                                 subSO = subIt.Value()
1167                                 subIt.Next()
1168                                 obj = subSO.GetObject()
1169                                 if not obj: continue
1170                                 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1171                                 if not go: continue
1172                                 ids = go.GetSubShapeIndices()
1173                                 if len(ids) == 1 and ids[0] == err.subShapeID:
1174                                     shapeText = ' on "%s"' % subSO.GetName()
1175                                     break
1176                         if not shapeText:
1177                             shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1178                             if shape:
1179                                 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1180                             else:
1181                                 shapeText = " on subshape #%s" % (err.subShapeID)
1182                     except:
1183                         shapeText = " on subshape #%s" % (err.subShapeID)
1184                 errText = ""
1185                 stdErrors = ["OK",                   #COMPERR_OK
1186                              "Invalid input mesh",   #COMPERR_BAD_INPUT_MESH
1187                              "std::exception",       #COMPERR_STD_EXCEPTION
1188                              "OCC exception",        #COMPERR_OCC_EXCEPTION
1189                              "SALOME exception",     #COMPERR_SLM_EXCEPTION
1190                              "Unknown exception",    #COMPERR_EXCEPTION
1191                              "Memory allocation problem", #COMPERR_MEMORY_PB
1192                              "Algorithm failed",     #COMPERR_ALGO_FAILED
1193                              "Unexpected geometry",  #COMPERR_BAD_SHAPE
1194                              "Warning",              #COMPERR_WARNING
1195                              "Computation cancelled",#COMPERR_CANCELED
1196                              "No mesh on sub-shape"] #COMPERR_NO_MESH_ON_SHAPE
1197                 if err.code > 0:
1198                     if err.code < len(stdErrors): errText = stdErrors[err.code]
1199                 else:
1200                     errText = "code %s" % -err.code
1201                 if errText: errText += ". "
1202                 errText += err.comment
1203                 if allReasons != "":allReasons += "\n"
1204                 allReasons += '-  "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1205                 pass
1206
1207             # Treat hyp errors
1208             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1209             for err in errors:
1210                 if err.isGlobalAlgo:
1211                     glob = "global"
1212                 else:
1213                     glob = "local"
1214                     pass
1215                 dim = err.algoDim
1216                 name = err.algoName
1217                 if len(name) == 0:
1218                     reason = '%s %sD algorithm is missing' % (glob, dim)
1219                 elif err.state == HYP_MISSING:
1220                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1221                               % (glob, dim, name, dim))
1222                 elif err.state == HYP_NOTCONFORM:
1223                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1224                 elif err.state == HYP_BAD_PARAMETER:
1225                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1226                               % ( glob, dim, name ))
1227                 elif err.state == HYP_BAD_GEOMETRY:
1228                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1229                               'geometry' % ( glob, dim, name ))
1230                 elif err.state == HYP_HIDDEN_ALGO:
1231                     reason = ('%s %sD algorithm "%s" is ignored due to presence of a %s '
1232                               'algorithm of upper dimension generating %sD mesh'
1233                               % ( glob, dim, name, glob, dim ))
1234                 else:
1235                     reason = ("For unknown reason. "
1236                               "Developer, revise Mesh.Compute() implementation in smeshDC.py!")
1237                     pass
1238                 if allReasons != "":allReasons += "\n"
1239                 allReasons += "-  " + reason
1240                 pass
1241             if not ok or allReasons != "":
1242                 msg = '"' + GetName(self.mesh) + '"'
1243                 if ok: msg += " has been computed with warnings"
1244                 else:  msg += " has not been computed"
1245                 if allReasons != "": msg += ":"
1246                 else:                msg += "."
1247                 print msg
1248                 print allReasons
1249             pass
1250         if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
1251             smeshgui = salome.ImportComponentGUI("SMESH")
1252             smeshgui.Init(self.mesh.GetStudyId())
1253             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1254             salome.sg.updateObjBrowser(1)
1255             pass
1256         return ok
1257
1258     ## Return submesh objects list in meshing order
1259     #  @return list of list of submesh objects
1260     #  @ingroup l2_construct
1261     def GetMeshOrder(self):
1262         return self.mesh.GetMeshOrder()
1263
1264     ## Return submesh objects list in meshing order
1265     #  @return list of list of submesh objects
1266     #  @ingroup l2_construct
1267     def SetMeshOrder(self, submeshes):
1268         return self.mesh.SetMeshOrder(submeshes)
1269
1270     ## Removes all nodes and elements
1271     #  @ingroup l2_construct
1272     def Clear(self):
1273         self.mesh.Clear()
1274         if salome.sg.hasDesktop():
1275             smeshgui = salome.ImportComponentGUI("SMESH")
1276             smeshgui.Init(self.mesh.GetStudyId())
1277             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1278             salome.sg.updateObjBrowser(1)
1279
1280     ## Removes all nodes and elements of indicated shape
1281     #  @ingroup l2_construct
1282     def ClearSubMesh(self, geomId):
1283         self.mesh.ClearSubMesh(geomId)
1284         if salome.sg.hasDesktop():
1285             smeshgui = salome.ImportComponentGUI("SMESH")
1286             smeshgui.Init(self.mesh.GetStudyId())
1287             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1288             salome.sg.updateObjBrowser(1)
1289
1290     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1291     #  @param fineness [0.0,1.0] defines mesh fineness
1292     #  @return True or False
1293     #  @ingroup l3_algos_basic
1294     def AutomaticTetrahedralization(self, fineness=0):
1295         dim = self.MeshDimension()
1296         # assign hypotheses
1297         self.RemoveGlobalHypotheses()
1298         self.Segment().AutomaticLength(fineness)
1299         if dim > 1 :
1300             self.Triangle().LengthFromEdges()
1301             pass
1302         if dim > 2 :
1303             from NETGENPluginDC import NETGEN
1304             self.Tetrahedron(NETGEN)
1305             pass
1306         return self.Compute()
1307
1308     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1309     #  @param fineness [0.0, 1.0] defines mesh fineness
1310     #  @return True or False
1311     #  @ingroup l3_algos_basic
1312     def AutomaticHexahedralization(self, fineness=0):
1313         dim = self.MeshDimension()
1314         # assign the hypotheses
1315         self.RemoveGlobalHypotheses()
1316         self.Segment().AutomaticLength(fineness)
1317         if dim > 1 :
1318             self.Quadrangle()
1319             pass
1320         if dim > 2 :
1321             self.Hexahedron()
1322             pass
1323         return self.Compute()
1324
1325     ## Assigns a hypothesis
1326     #  @param hyp a hypothesis to assign
1327     #  @param geom a subhape of mesh geometry
1328     #  @return SMESH.Hypothesis_Status
1329     #  @ingroup l2_hypotheses
1330     def AddHypothesis(self, hyp, geom=0):
1331         if isinstance( hyp, Mesh_Algorithm ):
1332             hyp = hyp.GetAlgorithm()
1333             pass
1334         if not geom:
1335             geom = self.geom
1336             if not geom:
1337                 geom = self.mesh.GetShapeToMesh()
1338             pass
1339         AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
1340         status = self.mesh.AddHypothesis(geom, hyp)
1341         isAlgo = hyp._narrow( SMESH_Algo )
1342         hyp_name = GetName( hyp )
1343         geom_name = ""
1344         if geom:
1345             geom_name = GetName( geom )
1346         TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1347         return status
1348
1349     ## Return True if an algorithm of hypothesis is assigned to a given shape
1350     #  @param hyp a hypothesis to check
1351     #  @param geom a subhape of mesh geometry
1352     #  @return True of False
1353     #  @ingroup l2_hypotheses
1354     def IsUsedHypothesis(self, hyp, geom):
1355         if not hyp or not geom:
1356             return False
1357         if isinstance( hyp, Mesh_Algorithm ):
1358             hyp = hyp.GetAlgorithm()
1359             pass
1360         hyps = self.GetHypothesisList(geom)
1361         for h in hyps:
1362             if h.GetId() == hyp.GetId():
1363                 return True
1364         return False
1365
1366     ## Unassigns a hypothesis
1367     #  @param hyp a hypothesis to unassign
1368     #  @param geom a sub-shape of mesh geometry
1369     #  @return SMESH.Hypothesis_Status
1370     #  @ingroup l2_hypotheses
1371     def RemoveHypothesis(self, hyp, geom=0):
1372         if isinstance( hyp, Mesh_Algorithm ):
1373             hyp = hyp.GetAlgorithm()
1374             pass
1375         if not geom:
1376             geom = self.geom
1377             pass
1378         status = self.mesh.RemoveHypothesis(geom, hyp)
1379         return status
1380
1381     ## Gets the list of hypotheses added on a geometry
1382     #  @param geom a sub-shape of mesh geometry
1383     #  @return the sequence of SMESH_Hypothesis
1384     #  @ingroup l2_hypotheses
1385     def GetHypothesisList(self, geom):
1386         return self.mesh.GetHypothesisList( geom )
1387
1388     ## Removes all global hypotheses
1389     #  @ingroup l2_hypotheses
1390     def RemoveGlobalHypotheses(self):
1391         current_hyps = self.mesh.GetHypothesisList( self.geom )
1392         for hyp in current_hyps:
1393             self.mesh.RemoveHypothesis( self.geom, hyp )
1394             pass
1395         pass
1396
1397    ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1398     ## allowing to overwrite the file if it exists or add the exported data to its contents
1399     #  @param f is the file name
1400     #  @param auto_groups boolean parameter for creating/not creating
1401     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1402     #  the typical use is auto_groups=false.
1403     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1404     #  @param overwrite boolean parameter for overwriting/not overwriting the file
1405     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1406     #  @ingroup l2_impexp
1407     def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1408         if meshPart:
1409             if isinstance( meshPart, list ):
1410                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1411             self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1412         else:
1413             self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1414
1415     ## Exports the mesh in a file in SAUV format
1416     #  @param f is the file name
1417     #  @param auto_groups boolean parameter for creating/not creating
1418     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1419     #  the typical use is auto_groups=false.
1420     #  @ingroup l2_impexp
1421     def ExportSAUV(self, f, auto_groups=0):
1422         self.mesh.ExportSAUV(f, auto_groups)
1423
1424     ## Exports the mesh in a file in DAT format
1425     #  @param f the file name
1426     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1427     #  @ingroup l2_impexp
1428     def ExportDAT(self, f, meshPart=None):
1429         if meshPart:
1430             if isinstance( meshPart, list ):
1431                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1432             self.mesh.ExportPartToDAT( meshPart, f )
1433         else:
1434             self.mesh.ExportDAT(f)
1435
1436     ## Exports the mesh in a file in UNV format
1437     #  @param f the file name
1438     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1439     #  @ingroup l2_impexp
1440     def ExportUNV(self, f, meshPart=None):
1441         if meshPart:
1442             if isinstance( meshPart, list ):
1443                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1444             self.mesh.ExportPartToUNV( meshPart, f )
1445         else:
1446             self.mesh.ExportUNV(f)
1447
1448     ## Export the mesh in a file in STL format
1449     #  @param f the file name
1450     #  @param ascii defines the file encoding
1451     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1452     #  @ingroup l2_impexp
1453     def ExportSTL(self, f, ascii=1, meshPart=None):
1454         if meshPart:
1455             if isinstance( meshPart, list ):
1456                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1457             self.mesh.ExportPartToSTL( meshPart, f, ascii )
1458         else:
1459             self.mesh.ExportSTL(f, ascii)
1460
1461     ## Exports the mesh in a file in CGNS format
1462     #  @param f is the file name
1463     #  @param overwrite boolean parameter for overwriting/not overwriting the file
1464     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1465     #  @ingroup l2_impexp
1466     def ExportCGNS(self, f, overwrite=1, meshPart=None):
1467         if isinstance( meshPart, list ):
1468             meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1469         if isinstance( meshPart, Mesh ):
1470             meshPart = meshPart.mesh
1471         elif not meshPart:
1472             meshPart = self.mesh
1473         self.mesh.ExportCGNS(meshPart, f, overwrite)
1474
1475     ## Exports the mesh in a file in GMF format
1476     #  @param f is the file name
1477     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1478     #  @ingroup l2_impexp
1479     def ExportGMF(self, f, meshPart=None):
1480         if isinstance( meshPart, list ):
1481             meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1482         if isinstance( meshPart, Mesh ):
1483             meshPart = meshPart.mesh
1484         elif not meshPart:
1485             meshPart = self.mesh
1486         self.mesh.ExportGMF(meshPart, f, True)
1487
1488     ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1489     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
1490     ## allowing to overwrite the file if it exists or add the exported data to its contents
1491     #  @param f the file name
1492     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1493     #  @param opt boolean parameter for creating/not creating
1494     #         the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1495     #  @param overwrite boolean parameter for overwriting/not overwriting the file
1496     #  @ingroup l2_impexp
1497     def ExportToMED(self, f, version, opt=0, overwrite=1):
1498         self.mesh.ExportToMEDX(f, opt, version, overwrite)
1499
1500     # Operations with groups:
1501     # ----------------------
1502
1503     ## Creates an empty mesh group
1504     #  @param elementType the type of elements in the group
1505     #  @param name the name of the mesh group
1506     #  @return SMESH_Group
1507     #  @ingroup l2_grps_create
1508     def CreateEmptyGroup(self, elementType, name):
1509         return self.mesh.CreateGroup(elementType, name)
1510
1511     ## Creates a mesh group based on the geometric object \a grp
1512     #  and gives a \a name, \n if this parameter is not defined
1513     #  the name is the same as the geometric group name \n
1514     #  Note: Works like GroupOnGeom().
1515     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
1516     #  @param name the name of the mesh group
1517     #  @return SMESH_GroupOnGeom
1518     #  @ingroup l2_grps_create
1519     def Group(self, grp, name=""):
1520         return self.GroupOnGeom(grp, name)
1521
1522     ## Creates a mesh group based on the geometrical object \a grp
1523     #  and gives a \a name, \n if this parameter is not defined
1524     #  the name is the same as the geometrical group name
1525     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
1526     #  @param name the name of the mesh group
1527     #  @param typ  the type of elements in the group. If not set, it is
1528     #              automatically detected by the type of the geometry
1529     #  @return SMESH_GroupOnGeom
1530     #  @ingroup l2_grps_create
1531     def GroupOnGeom(self, grp, name="", typ=None):
1532         AssureGeomPublished( self, grp, name )
1533         if name == "":
1534             name = grp.GetName()
1535         if not typ:
1536             typ = self._groupTypeFromShape( grp )
1537         return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1538
1539     ## Pivate method to get a type of group on geometry
1540     def _groupTypeFromShape( self, shape ):
1541         tgeo = str(shape.GetShapeType())
1542         if tgeo == "VERTEX":
1543             typ = NODE
1544         elif tgeo == "EDGE":
1545             typ = EDGE
1546         elif tgeo == "FACE" or tgeo == "SHELL":
1547             typ = FACE
1548         elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1549             typ = VOLUME
1550         elif tgeo == "COMPOUND":
1551             sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1552             if not sub:
1553                 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1554             return self._groupTypeFromShape( sub[0] )
1555         else:
1556             raise ValueError, \
1557                   "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1558         return typ
1559
1560     ## Creates a mesh group with given \a name based on the \a filter which
1561     ## is a special type of group dynamically updating it's contents during
1562     ## mesh modification
1563     #  @param typ  the type of elements in the group
1564     #  @param name the name of the mesh group
1565     #  @param filter the filter defining group contents
1566     #  @return SMESH_GroupOnFilter
1567     #  @ingroup l2_grps_create
1568     def GroupOnFilter(self, typ, name, filter):
1569         return self.mesh.CreateGroupFromFilter(typ, name, filter)
1570
1571     ## Creates a mesh group by the given ids of elements
1572     #  @param groupName the name of the mesh group
1573     #  @param elementType the type of elements in the group
1574     #  @param elemIDs the list of ids
1575     #  @return SMESH_Group
1576     #  @ingroup l2_grps_create
1577     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1578         group = self.mesh.CreateGroup(elementType, groupName)
1579         group.Add(elemIDs)
1580         return group
1581
1582     ## Creates a mesh group by the given conditions
1583     #  @param groupName the name of the mesh group
1584     #  @param elementType the type of elements in the group
1585     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1586     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1587     #  @param Threshold the threshold value (range of id ids as string, shape, numeric)
1588     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
1589     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1590     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
1591     #  @return SMESH_Group
1592     #  @ingroup l2_grps_create
1593     def MakeGroup(self,
1594                   groupName,
1595                   elementType,
1596                   CritType=FT_Undefined,
1597                   Compare=FT_EqualTo,
1598                   Threshold="",
1599                   UnaryOp=FT_Undefined,
1600                   Tolerance=1e-07):
1601         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1602         group = self.MakeGroupByCriterion(groupName, aCriterion)
1603         return group
1604
1605     ## Creates a mesh group by the given criterion
1606     #  @param groupName the name of the mesh group
1607     #  @param Criterion the instance of Criterion class
1608     #  @return SMESH_Group
1609     #  @ingroup l2_grps_create
1610     def MakeGroupByCriterion(self, groupName, Criterion):
1611         aFilterMgr = self.smeshpyD.CreateFilterManager()
1612         aFilter = aFilterMgr.CreateFilter()
1613         aCriteria = []
1614         aCriteria.append(Criterion)
1615         aFilter.SetCriteria(aCriteria)
1616         group = self.MakeGroupByFilter(groupName, aFilter)
1617         aFilterMgr.UnRegister()
1618         return group
1619
1620     ## Creates a mesh group by the given criteria (list of criteria)
1621     #  @param groupName the name of the mesh group
1622     #  @param theCriteria the list of criteria
1623     #  @return SMESH_Group
1624     #  @ingroup l2_grps_create
1625     def MakeGroupByCriteria(self, groupName, theCriteria):
1626         aFilterMgr = self.smeshpyD.CreateFilterManager()
1627         aFilter = aFilterMgr.CreateFilter()
1628         aFilter.SetCriteria(theCriteria)
1629         group = self.MakeGroupByFilter(groupName, aFilter)
1630         aFilterMgr.UnRegister()
1631         return group
1632
1633     ## Creates a mesh group by the given filter
1634     #  @param groupName the name of the mesh group
1635     #  @param theFilter the instance of Filter class
1636     #  @return SMESH_Group
1637     #  @ingroup l2_grps_create
1638     def MakeGroupByFilter(self, groupName, theFilter):
1639         group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1640         theFilter.SetMesh( self.mesh )
1641         group.AddFrom( theFilter )
1642         return group
1643
1644     ## Removes a group
1645     #  @ingroup l2_grps_delete
1646     def RemoveGroup(self, group):
1647         self.mesh.RemoveGroup(group)
1648
1649     ## Removes a group with its contents
1650     #  @ingroup l2_grps_delete
1651     def RemoveGroupWithContents(self, group):
1652         self.mesh.RemoveGroupWithContents(group)
1653
1654     ## Gets the list of groups existing in the mesh
1655     #  @return a sequence of SMESH_GroupBase
1656     #  @ingroup l2_grps_create
1657     def GetGroups(self):
1658         return self.mesh.GetGroups()
1659
1660     ## Gets the number of groups existing in the mesh
1661     #  @return the quantity of groups as an integer value
1662     #  @ingroup l2_grps_create
1663     def NbGroups(self):
1664         return self.mesh.NbGroups()
1665
1666     ## Gets the list of names of groups existing in the mesh
1667     #  @return list of strings
1668     #  @ingroup l2_grps_create
1669     def GetGroupNames(self):
1670         groups = self.GetGroups()
1671         names = []
1672         for group in groups:
1673             names.append(group.GetName())
1674         return names
1675
1676     ## Produces a union of two groups
1677     #  A new group is created. All mesh elements that are
1678     #  present in the initial groups are added to the new one
1679     #  @return an instance of SMESH_Group
1680     #  @ingroup l2_grps_operon
1681     def UnionGroups(self, group1, group2, name):
1682         return self.mesh.UnionGroups(group1, group2, name)
1683
1684     ## Produces a union list of groups
1685     #  New group is created. All mesh elements that are present in
1686     #  initial groups are added to the new one
1687     #  @return an instance of SMESH_Group
1688     #  @ingroup l2_grps_operon
1689     def UnionListOfGroups(self, groups, name):
1690       return self.mesh.UnionListOfGroups(groups, name)
1691
1692     ## Prodices an intersection of two groups
1693     #  A new group is created. All mesh elements that are common
1694     #  for the two initial groups are added to the new one.
1695     #  @return an instance of SMESH_Group
1696     #  @ingroup l2_grps_operon
1697     def IntersectGroups(self, group1, group2, name):
1698         return self.mesh.IntersectGroups(group1, group2, name)
1699
1700     ## Produces an intersection of groups
1701     #  New group is created. All mesh elements that are present in all
1702     #  initial groups simultaneously are added to the new one
1703     #  @return an instance of SMESH_Group
1704     #  @ingroup l2_grps_operon
1705     def IntersectListOfGroups(self, groups, name):
1706       return self.mesh.IntersectListOfGroups(groups, name)
1707
1708     ## Produces a cut of two groups
1709     #  A new group is created. All mesh elements that are present in
1710     #  the main group but are not present in the tool group are added to the new one
1711     #  @return an instance of SMESH_Group
1712     #  @ingroup l2_grps_operon
1713     def CutGroups(self, main_group, tool_group, name):
1714         return self.mesh.CutGroups(main_group, tool_group, name)
1715
1716     ## Produces a cut of groups
1717     #  A new group is created. All mesh elements that are present in main groups
1718     #  but do not present in tool groups are added to the new one
1719     #  @return an instance of SMESH_Group
1720     #  @ingroup l2_grps_operon
1721     def CutListOfGroups(self, main_groups, tool_groups, name):
1722       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1723
1724     ## Produces a group of elements of specified type using list of existing groups
1725     #  A new group is created. System
1726     #  1) extracts all nodes on which groups elements are built
1727     #  2) combines all elements of specified dimension laying on these nodes
1728     #  @return an instance of SMESH_Group
1729     #  @ingroup l2_grps_operon
1730     def CreateDimGroup(self, groups, elem_type, name):
1731       return self.mesh.CreateDimGroup(groups, elem_type, name)
1732
1733
1734     ## Convert group on geom into standalone group
1735     #  @ingroup l2_grps_delete
1736     def ConvertToStandalone(self, group):
1737         return self.mesh.ConvertToStandalone(group)
1738
1739     # Get some info about mesh:
1740     # ------------------------
1741
1742     ## Returns the log of nodes and elements added or removed
1743     #  since the previous clear of the log.
1744     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1745     #  @return list of log_block structures:
1746     #                                        commandType
1747     #                                        number
1748     #                                        coords
1749     #                                        indexes
1750     #  @ingroup l1_auxiliary
1751     def GetLog(self, clearAfterGet):
1752         return self.mesh.GetLog(clearAfterGet)
1753
1754     ## Clears the log of nodes and elements added or removed since the previous
1755     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1756     #  @ingroup l1_auxiliary
1757     def ClearLog(self):
1758         self.mesh.ClearLog()
1759
1760     ## Toggles auto color mode on the object.
1761     #  @param theAutoColor the flag which toggles auto color mode.
1762     #  @ingroup l1_auxiliary
1763     def SetAutoColor(self, theAutoColor):
1764         self.mesh.SetAutoColor(theAutoColor)
1765
1766     ## Gets flag of object auto color mode.
1767     #  @return True or False
1768     #  @ingroup l1_auxiliary
1769     def GetAutoColor(self):
1770         return self.mesh.GetAutoColor()
1771
1772     ## Gets the internal ID
1773     #  @return integer value, which is the internal Id of the mesh
1774     #  @ingroup l1_auxiliary
1775     def GetId(self):
1776         return self.mesh.GetId()
1777
1778     ## Get the study Id
1779     #  @return integer value, which is the study Id of the mesh
1780     #  @ingroup l1_auxiliary
1781     def GetStudyId(self):
1782         return self.mesh.GetStudyId()
1783
1784     ## Checks the group names for duplications.
1785     #  Consider the maximum group name length stored in MED file.
1786     #  @return True or False
1787     #  @ingroup l1_auxiliary
1788     def HasDuplicatedGroupNamesMED(self):
1789         return self.mesh.HasDuplicatedGroupNamesMED()
1790
1791     ## Obtains the mesh editor tool
1792     #  @return an instance of SMESH_MeshEditor
1793     #  @ingroup l1_modifying
1794     def GetMeshEditor(self):
1795         return self.editor
1796
1797     ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1798     #  can be passed as argument to a method accepting mesh, group or sub-mesh
1799     #  @return an instance of SMESH_IDSource
1800     #  @ingroup l1_auxiliary
1801     def GetIDSource(self, ids, elemType):
1802         return self.editor.MakeIDSource(ids, elemType)
1803
1804     ## Gets MED Mesh
1805     #  @return an instance of SALOME_MED::MESH
1806     #  @ingroup l1_auxiliary
1807     def GetMEDMesh(self):
1808         return self.mesh.GetMEDMesh()
1809
1810
1811     # Get informations about mesh contents:
1812     # ------------------------------------
1813
1814     ## Gets the mesh stattistic
1815     #  @return dictionary type element - count of elements
1816     #  @ingroup l1_meshinfo
1817     def GetMeshInfo(self, obj = None):
1818         if not obj: obj = self.mesh
1819         return self.smeshpyD.GetMeshInfo(obj)
1820
1821     ## Returns the number of nodes in the mesh
1822     #  @return an integer value
1823     #  @ingroup l1_meshinfo
1824     def NbNodes(self):
1825         return self.mesh.NbNodes()
1826
1827     ## Returns the number of elements in the mesh
1828     #  @return an integer value
1829     #  @ingroup l1_meshinfo
1830     def NbElements(self):
1831         return self.mesh.NbElements()
1832
1833     ## Returns the number of 0d elements in the mesh
1834     #  @return an integer value
1835     #  @ingroup l1_meshinfo
1836     def Nb0DElements(self):
1837         return self.mesh.Nb0DElements()
1838
1839     ## Returns the number of ball discrete elements in the mesh
1840     #  @return an integer value
1841     #  @ingroup l1_meshinfo
1842     def NbBalls(self):
1843         return self.mesh.NbBalls()
1844
1845     ## Returns the number of edges in the mesh
1846     #  @return an integer value
1847     #  @ingroup l1_meshinfo
1848     def NbEdges(self):
1849         return self.mesh.NbEdges()
1850
1851     ## Returns the number of edges with the given order in the mesh
1852     #  @param elementOrder the order of elements:
1853     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1854     #  @return an integer value
1855     #  @ingroup l1_meshinfo
1856     def NbEdgesOfOrder(self, elementOrder):
1857         return self.mesh.NbEdgesOfOrder(elementOrder)
1858
1859     ## Returns the number of faces in the mesh
1860     #  @return an integer value
1861     #  @ingroup l1_meshinfo
1862     def NbFaces(self):
1863         return self.mesh.NbFaces()
1864
1865     ## Returns the number of faces with the given order in the mesh
1866     #  @param elementOrder the order of elements:
1867     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1868     #  @return an integer value
1869     #  @ingroup l1_meshinfo
1870     def NbFacesOfOrder(self, elementOrder):
1871         return self.mesh.NbFacesOfOrder(elementOrder)
1872
1873     ## Returns the number of triangles in the mesh
1874     #  @return an integer value
1875     #  @ingroup l1_meshinfo
1876     def NbTriangles(self):
1877         return self.mesh.NbTriangles()
1878
1879     ## Returns the number of triangles with the given order in the mesh
1880     #  @param elementOrder is the order of elements:
1881     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1882     #  @return an integer value
1883     #  @ingroup l1_meshinfo
1884     def NbTrianglesOfOrder(self, elementOrder):
1885         return self.mesh.NbTrianglesOfOrder(elementOrder)
1886
1887     ## Returns the number of quadrangles in the mesh
1888     #  @return an integer value
1889     #  @ingroup l1_meshinfo
1890     def NbQuadrangles(self):
1891         return self.mesh.NbQuadrangles()
1892
1893     ## Returns the number of quadrangles with the given order in the mesh
1894     #  @param elementOrder the order of elements:
1895     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1896     #  @return an integer value
1897     #  @ingroup l1_meshinfo
1898     def NbQuadranglesOfOrder(self, elementOrder):
1899         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1900
1901     ## Returns the number of biquadratic quadrangles in the mesh
1902     #  @return an integer value
1903     #  @ingroup l1_meshinfo
1904     def NbBiQuadQuadrangles(self):
1905         return self.mesh.NbBiQuadQuadrangles()
1906
1907     ## Returns the number of polygons in the mesh
1908     #  @return an integer value
1909     #  @ingroup l1_meshinfo
1910     def NbPolygons(self):
1911         return self.mesh.NbPolygons()
1912
1913     ## Returns the number of volumes in the mesh
1914     #  @return an integer value
1915     #  @ingroup l1_meshinfo
1916     def NbVolumes(self):
1917         return self.mesh.NbVolumes()
1918
1919     ## Returns the number of volumes with the given order in the mesh
1920     #  @param elementOrder  the order of elements:
1921     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1922     #  @return an integer value
1923     #  @ingroup l1_meshinfo
1924     def NbVolumesOfOrder(self, elementOrder):
1925         return self.mesh.NbVolumesOfOrder(elementOrder)
1926
1927     ## Returns the number of tetrahedrons in the mesh
1928     #  @return an integer value
1929     #  @ingroup l1_meshinfo
1930     def NbTetras(self):
1931         return self.mesh.NbTetras()
1932
1933     ## Returns the number of tetrahedrons with the given order in the mesh
1934     #  @param elementOrder  the order of elements:
1935     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1936     #  @return an integer value
1937     #  @ingroup l1_meshinfo
1938     def NbTetrasOfOrder(self, elementOrder):
1939         return self.mesh.NbTetrasOfOrder(elementOrder)
1940
1941     ## Returns the number of hexahedrons in the mesh
1942     #  @return an integer value
1943     #  @ingroup l1_meshinfo
1944     def NbHexas(self):
1945         return self.mesh.NbHexas()
1946
1947     ## Returns the number of hexahedrons with the given order in the mesh
1948     #  @param elementOrder  the order of elements:
1949     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1950     #  @return an integer value
1951     #  @ingroup l1_meshinfo
1952     def NbHexasOfOrder(self, elementOrder):
1953         return self.mesh.NbHexasOfOrder(elementOrder)
1954
1955     ## Returns the number of triquadratic hexahedrons in the mesh
1956     #  @return an integer value
1957     #  @ingroup l1_meshinfo
1958     def NbTriQuadraticHexas(self):
1959         return self.mesh.NbTriQuadraticHexas()
1960
1961     ## Returns the number of pyramids in the mesh
1962     #  @return an integer value
1963     #  @ingroup l1_meshinfo
1964     def NbPyramids(self):
1965         return self.mesh.NbPyramids()
1966
1967     ## Returns the number of pyramids with the given order in the mesh
1968     #  @param elementOrder  the order of elements:
1969     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1970     #  @return an integer value
1971     #  @ingroup l1_meshinfo
1972     def NbPyramidsOfOrder(self, elementOrder):
1973         return self.mesh.NbPyramidsOfOrder(elementOrder)
1974
1975     ## Returns the number of prisms in the mesh
1976     #  @return an integer value
1977     #  @ingroup l1_meshinfo
1978     def NbPrisms(self):
1979         return self.mesh.NbPrisms()
1980
1981     ## Returns the number of prisms with the given order in the mesh
1982     #  @param elementOrder  the order of elements:
1983     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1984     #  @return an integer value
1985     #  @ingroup l1_meshinfo
1986     def NbPrismsOfOrder(self, elementOrder):
1987         return self.mesh.NbPrismsOfOrder(elementOrder)
1988
1989     ## Returns the number of hexagonal prisms in the mesh
1990     #  @return an integer value
1991     #  @ingroup l1_meshinfo
1992     def NbHexagonalPrisms(self):
1993         return self.mesh.NbHexagonalPrisms()
1994
1995     ## Returns the number of polyhedrons in the mesh
1996     #  @return an integer value
1997     #  @ingroup l1_meshinfo
1998     def NbPolyhedrons(self):
1999         return self.mesh.NbPolyhedrons()
2000
2001     ## Returns the number of submeshes in the mesh
2002     #  @return an integer value
2003     #  @ingroup l1_meshinfo
2004     def NbSubMesh(self):
2005         return self.mesh.NbSubMesh()
2006
2007     ## Returns the list of mesh elements IDs
2008     #  @return the list of integer values
2009     #  @ingroup l1_meshinfo
2010     def GetElementsId(self):
2011         return self.mesh.GetElementsId()
2012
2013     ## Returns the list of IDs of mesh elements with the given type
2014     #  @param elementType  the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2015     #  @return list of integer values
2016     #  @ingroup l1_meshinfo
2017     def GetElementsByType(self, elementType):
2018         return self.mesh.GetElementsByType(elementType)
2019
2020     ## Returns the list of mesh nodes IDs
2021     #  @return the list of integer values
2022     #  @ingroup l1_meshinfo
2023     def GetNodesId(self):
2024         return self.mesh.GetNodesId()
2025
2026     # Get the information about mesh elements:
2027     # ------------------------------------
2028
2029     ## Returns the type of mesh element
2030     #  @return the value from SMESH::ElementType enumeration
2031     #  @ingroup l1_meshinfo
2032     def GetElementType(self, id, iselem):
2033         return self.mesh.GetElementType(id, iselem)
2034
2035     ## Returns the geometric type of mesh element
2036     #  @return the value from SMESH::EntityType enumeration
2037     #  @ingroup l1_meshinfo
2038     def GetElementGeomType(self, id):
2039         return self.mesh.GetElementGeomType(id)
2040
2041     ## Returns the list of submesh elements IDs
2042     #  @param Shape a geom object(sub-shape) IOR
2043     #         Shape must be the sub-shape of a ShapeToMesh()
2044     #  @return the list of integer values
2045     #  @ingroup l1_meshinfo
2046     def GetSubMeshElementsId(self, Shape):
2047         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2048             ShapeID = Shape.GetSubShapeIndices()[0]
2049         else:
2050             ShapeID = Shape
2051         return self.mesh.GetSubMeshElementsId(ShapeID)
2052
2053     ## Returns the list of submesh nodes IDs
2054     #  @param Shape a geom object(sub-shape) IOR
2055     #         Shape must be the sub-shape of a ShapeToMesh()
2056     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2057     #  @return the list of integer values
2058     #  @ingroup l1_meshinfo
2059     def GetSubMeshNodesId(self, Shape, all):
2060         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2061             ShapeID = self.geompyD.GetSubShapeID( self.geom, Shape )
2062         else:
2063             ShapeID = Shape
2064         return self.mesh.GetSubMeshNodesId(ShapeID, all)
2065
2066     ## Returns type of elements on given shape
2067     #  @param Shape a geom object(sub-shape) IOR
2068     #         Shape must be a sub-shape of a ShapeToMesh()
2069     #  @return element type
2070     #  @ingroup l1_meshinfo
2071     def GetSubMeshElementType(self, Shape):
2072         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2073             ShapeID = Shape.GetSubShapeIndices()[0]
2074         else:
2075             ShapeID = Shape
2076         return self.mesh.GetSubMeshElementType(ShapeID)
2077
2078     ## Gets the mesh description
2079     #  @return string value
2080     #  @ingroup l1_meshinfo
2081     def Dump(self):
2082         return self.mesh.Dump()
2083
2084
2085     # Get the information about nodes and elements of a mesh by its IDs:
2086     # -----------------------------------------------------------
2087
2088     ## Gets XYZ coordinates of a node
2089     #  \n If there is no nodes for the given ID - returns an empty list
2090     #  @return a list of double precision values
2091     #  @ingroup l1_meshinfo
2092     def GetNodeXYZ(self, id):
2093         return self.mesh.GetNodeXYZ(id)
2094
2095     ## Returns list of IDs of inverse elements for the given node
2096     #  \n If there is no node for the given ID - returns an empty list
2097     #  @return a list of integer values
2098     #  @ingroup l1_meshinfo
2099     def GetNodeInverseElements(self, id):
2100         return self.mesh.GetNodeInverseElements(id)
2101
2102     ## @brief Returns the position of a node on the shape
2103     #  @return SMESH::NodePosition
2104     #  @ingroup l1_meshinfo
2105     def GetNodePosition(self,NodeID):
2106         return self.mesh.GetNodePosition(NodeID)
2107
2108     ## If the given element is a node, returns the ID of shape
2109     #  \n If there is no node for the given ID - returns -1
2110     #  @return an integer value
2111     #  @ingroup l1_meshinfo
2112     def GetShapeID(self, id):
2113         return self.mesh.GetShapeID(id)
2114
2115     ## Returns the ID of the result shape after
2116     #  FindShape() from SMESH_MeshEditor for the given element
2117     #  \n If there is no element for the given ID - returns -1
2118     #  @return an integer value
2119     #  @ingroup l1_meshinfo
2120     def GetShapeIDForElem(self,id):
2121         return self.mesh.GetShapeIDForElem(id)
2122
2123     ## Returns the number of nodes for the given element
2124     #  \n If there is no element for the given ID - returns -1
2125     #  @return an integer value
2126     #  @ingroup l1_meshinfo
2127     def GetElemNbNodes(self, id):
2128         return self.mesh.GetElemNbNodes(id)
2129
2130     ## Returns the node ID the given index for the given element
2131     #  \n If there is no element for the given ID - returns -1
2132     #  \n If there is no node for the given index - returns -2
2133     #  @return an integer value
2134     #  @ingroup l1_meshinfo
2135     def GetElemNode(self, id, index):
2136         return self.mesh.GetElemNode(id, index)
2137
2138     ## Returns the IDs of nodes of the given element
2139     #  @return a list of integer values
2140     #  @ingroup l1_meshinfo
2141     def GetElemNodes(self, id):
2142         return self.mesh.GetElemNodes(id)
2143
2144     ## Returns true if the given node is the medium node in the given quadratic element
2145     #  @ingroup l1_meshinfo
2146     def IsMediumNode(self, elementID, nodeID):
2147         return self.mesh.IsMediumNode(elementID, nodeID)
2148
2149     ## Returns true if the given node is the medium node in one of quadratic elements
2150     #  @ingroup l1_meshinfo
2151     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2152         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2153
2154     ## Returns the number of edges for the given element
2155     #  @ingroup l1_meshinfo
2156     def ElemNbEdges(self, id):
2157         return self.mesh.ElemNbEdges(id)
2158
2159     ## Returns the number of faces for the given element
2160     #  @ingroup l1_meshinfo
2161     def ElemNbFaces(self, id):
2162         return self.mesh.ElemNbFaces(id)
2163
2164     ## Returns nodes of given face (counted from zero) for given volumic element.
2165     #  @ingroup l1_meshinfo
2166     def GetElemFaceNodes(self,elemId, faceIndex):
2167         return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2168
2169     ## Returns an element based on all given nodes.
2170     #  @ingroup l1_meshinfo
2171     def FindElementByNodes(self,nodes):
2172         return self.mesh.FindElementByNodes(nodes)
2173
2174     ## Returns true if the given element is a polygon
2175     #  @ingroup l1_meshinfo
2176     def IsPoly(self, id):
2177         return self.mesh.IsPoly(id)
2178
2179     ## Returns true if the given element is quadratic
2180     #  @ingroup l1_meshinfo
2181     def IsQuadratic(self, id):
2182         return self.mesh.IsQuadratic(id)
2183
2184     ## Returns diameter of a ball discrete element or zero in case of an invalid \a id
2185     #  @ingroup l1_meshinfo
2186     def GetBallDiameter(self, id):
2187         return self.mesh.GetBallDiameter(id)
2188
2189     ## Returns XYZ coordinates of the barycenter of the given element
2190     #  \n If there is no element for the given ID - returns an empty list
2191     #  @return a list of three double values
2192     #  @ingroup l1_meshinfo
2193     def BaryCenter(self, id):
2194         return self.mesh.BaryCenter(id)
2195
2196     ## Passes mesh elements through the given filter and return IDs of fitting elements
2197     #  @param theFilter SMESH_Filter
2198     #  @return a list of ids
2199     #  @ingroup l1_controls
2200     def GetIdsFromFilter(self, theFilter):
2201         theFilter.SetMesh( self.mesh )
2202         return theFilter.GetIDs()
2203
2204     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
2205     #  Returns a list of special structures (borders).
2206     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
2207     #  @ingroup l1_controls
2208     def GetFreeBorders(self):
2209         aFilterMgr = self.smeshpyD.CreateFilterManager()
2210         aPredicate = aFilterMgr.CreateFreeEdges()
2211         aPredicate.SetMesh(self.mesh)
2212         aBorders = aPredicate.GetBorders()
2213         aFilterMgr.UnRegister()
2214         return aBorders
2215
2216
2217     # Get mesh measurements information:
2218     # ------------------------------------
2219
2220     ## Get minimum distance between two nodes, elements or distance to the origin
2221     #  @param id1 first node/element id
2222     #  @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2223     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2224     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2225     #  @return minimum distance value
2226     #  @sa GetMinDistance()
2227     def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2228         aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2229         return aMeasure.value
2230
2231     ## Get measure structure specifying minimum distance data between two objects
2232     #  @param id1 first node/element id
2233     #  @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2234     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2235     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2236     #  @return Measure structure
2237     #  @sa MinDistance()
2238     def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2239         if isElem1:
2240             id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2241         else:
2242             id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2243         if id2 != 0:
2244             if isElem2:
2245                 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2246             else:
2247                 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2248             pass
2249         else:
2250             id2 = None
2251
2252         aMeasurements = self.smeshpyD.CreateMeasurements()
2253         aMeasure = aMeasurements.MinDistance(id1, id2)
2254         aMeasurements.UnRegister()
2255         return aMeasure
2256
2257     ## Get bounding box of the specified object(s)
2258     #  @param objects single source object or list of source objects or list of nodes/elements IDs
2259     #  @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2260     #  @c False specifies that @a objects are nodes
2261     #  @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2262     #  @sa GetBoundingBox()
2263     def BoundingBox(self, objects=None, isElem=False):
2264         result = self.GetBoundingBox(objects, isElem)
2265         if result is None:
2266             result = (0.0,)*6
2267         else:
2268             result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2269         return result
2270
2271     ## Get measure structure specifying bounding box data of the specified object(s)
2272     #  @param IDs single source object or list of source objects or list of nodes/elements IDs
2273     #  @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2274     #  @c False specifies that @a objects are nodes
2275     #  @return Measure structure
2276     #  @sa BoundingBox()
2277     def GetBoundingBox(self, IDs=None, isElem=False):
2278         if IDs is None:
2279             IDs = [self.mesh]
2280         elif isinstance(IDs, tuple):
2281             IDs = list(IDs)
2282         if not isinstance(IDs, list):
2283             IDs = [IDs]
2284         if len(IDs) > 0 and isinstance(IDs[0], int):
2285             IDs = [IDs]
2286         srclist = []
2287         for o in IDs:
2288             if isinstance(o, Mesh):
2289                 srclist.append(o.mesh)
2290             elif hasattr(o, "_narrow"):
2291                 src = o._narrow(SMESH.SMESH_IDSource)
2292                 if src: srclist.append(src)
2293                 pass
2294             elif isinstance(o, list):
2295                 if isElem:
2296                     srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2297                 else:
2298                     srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2299                 pass
2300             pass
2301         aMeasurements = self.smeshpyD.CreateMeasurements()
2302         aMeasure = aMeasurements.BoundingBox(srclist)
2303         aMeasurements.UnRegister()
2304         return aMeasure
2305
2306     # Mesh edition (SMESH_MeshEditor functionality):
2307     # ---------------------------------------------
2308
2309     ## Removes the elements from the mesh by ids
2310     #  @param IDsOfElements is a list of ids of elements to remove
2311     #  @return True or False
2312     #  @ingroup l2_modif_del
2313     def RemoveElements(self, IDsOfElements):
2314         return self.editor.RemoveElements(IDsOfElements)
2315
2316     ## Removes nodes from mesh by ids
2317     #  @param IDsOfNodes is a list of ids of nodes to remove
2318     #  @return True or False
2319     #  @ingroup l2_modif_del
2320     def RemoveNodes(self, IDsOfNodes):
2321         return self.editor.RemoveNodes(IDsOfNodes)
2322
2323     ## Removes all orphan (free) nodes from mesh
2324     #  @return number of the removed nodes
2325     #  @ingroup l2_modif_del
2326     def RemoveOrphanNodes(self):
2327         return self.editor.RemoveOrphanNodes()
2328
2329     ## Add a node to the mesh by coordinates
2330     #  @return Id of the new node
2331     #  @ingroup l2_modif_add
2332     def AddNode(self, x, y, z):
2333         x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2334         if hasVars: self.mesh.SetParameters(Parameters)
2335         return self.editor.AddNode( x, y, z)
2336
2337     ## Creates a 0D element on a node with given number.
2338     #  @param IDOfNode the ID of node for creation of the element.
2339     #  @return the Id of the new 0D element
2340     #  @ingroup l2_modif_add
2341     def Add0DElement(self, IDOfNode):
2342         return self.editor.Add0DElement(IDOfNode)
2343
2344     ## Create 0D elements on all nodes of the given elements except those 
2345     #  nodes on which a 0D element already exists.
2346     #  @param theObject an object on whose nodes 0D elements will be created.
2347     #         It can be mesh, sub-mesh, group, list of element IDs or a holder
2348     #         of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE )
2349     #  @param theGroupName optional name of a group to add 0D elements created
2350     #         and/or found on nodes of \a theObject.
2351     #  @return an object (a new group or a temporary SMESH_IDSource) holding
2352     #          IDs of new and/or found 0D elements. IDs of 0D elements 
2353     #          can be retrieved from the returned object by calling GetIDs()
2354     #  @ingroup l2_modif_add
2355     def Add0DElementsToAllNodes(self, theObject, theGroupName=""):
2356         if isinstance( theObject, Mesh ):
2357             theObject = theObject.GetMesh()
2358         if isinstance( theObject, list ):
2359             theObject = self.GetIDSource( theObject, SMESH.ALL )
2360         return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName )
2361
2362     ## Creates a ball element on a node with given ID.
2363     #  @param IDOfNode the ID of node for creation of the element.
2364     #  @param diameter the bal diameter.
2365     #  @return the Id of the new ball element
2366     #  @ingroup l2_modif_add
2367     def AddBall(self, IDOfNode, diameter):
2368         return self.editor.AddBall( IDOfNode, diameter )
2369
2370     ## Creates a linear or quadratic edge (this is determined
2371     #  by the number of given nodes).
2372     #  @param IDsOfNodes the list of node IDs for creation of the element.
2373     #  The order of nodes in this list should correspond to the description
2374     #  of MED. \n This description is located by the following link:
2375     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2376     #  @return the Id of the new edge
2377     #  @ingroup l2_modif_add
2378     def AddEdge(self, IDsOfNodes):
2379         return self.editor.AddEdge(IDsOfNodes)
2380
2381     ## Creates a linear or quadratic face (this is determined
2382     #  by the number of given nodes).
2383     #  @param IDsOfNodes the list of node IDs for creation of the element.
2384     #  The order of nodes in this list should correspond to the description
2385     #  of MED. \n This description is located by the following link:
2386     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2387     #  @return the Id of the new face
2388     #  @ingroup l2_modif_add
2389     def AddFace(self, IDsOfNodes):
2390         return self.editor.AddFace(IDsOfNodes)
2391
2392     ## Adds a polygonal face to the mesh by the list of node IDs
2393     #  @param IdsOfNodes the list of node IDs for creation of the element.
2394     #  @return the Id of the new face
2395     #  @ingroup l2_modif_add
2396     def AddPolygonalFace(self, IdsOfNodes):
2397         return self.editor.AddPolygonalFace(IdsOfNodes)
2398
2399     ## Creates both simple and quadratic volume (this is determined
2400     #  by the number of given nodes).
2401     #  @param IDsOfNodes the list of node IDs for creation of the element.
2402     #  The order of nodes in this list should correspond to the description
2403     #  of MED. \n This description is located by the following link:
2404     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2405     #  @return the Id of the new volumic element
2406     #  @ingroup l2_modif_add
2407     def AddVolume(self, IDsOfNodes):
2408         return self.editor.AddVolume(IDsOfNodes)
2409
2410     ## Creates a volume of many faces, giving nodes for each face.
2411     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
2412     #  @param Quantities the list of integer values, Quantities[i]
2413     #         gives the quantity of nodes in face number i.
2414     #  @return the Id of the new volumic element
2415     #  @ingroup l2_modif_add
2416     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2417         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2418
2419     ## Creates a volume of many faces, giving the IDs of the existing faces.
2420     #  @param IdsOfFaces the list of face IDs for volume creation.
2421     #
2422     #  Note:  The created volume will refer only to the nodes
2423     #         of the given faces, not to the faces themselves.
2424     #  @return the Id of the new volumic element
2425     #  @ingroup l2_modif_add
2426     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2427         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2428
2429
2430     ## @brief Binds a node to a vertex
2431     #  @param NodeID a node ID
2432     #  @param Vertex a vertex or vertex ID
2433     #  @return True if succeed else raises an exception
2434     #  @ingroup l2_modif_add
2435     def SetNodeOnVertex(self, NodeID, Vertex):
2436         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2437             VertexID = Vertex.GetSubShapeIndices()[0]
2438         else:
2439             VertexID = Vertex
2440         try:
2441             self.editor.SetNodeOnVertex(NodeID, VertexID)
2442         except SALOME.SALOME_Exception, inst:
2443             raise ValueError, inst.details.text
2444         return True
2445
2446
2447     ## @brief Stores the node position on an edge
2448     #  @param NodeID a node ID
2449     #  @param Edge an edge or edge ID
2450     #  @param paramOnEdge a parameter on the edge where the node is located
2451     #  @return True if succeed else raises an exception
2452     #  @ingroup l2_modif_add
2453     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2454         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2455             EdgeID = Edge.GetSubShapeIndices()[0]
2456         else:
2457             EdgeID = Edge
2458         try:
2459             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2460         except SALOME.SALOME_Exception, inst:
2461             raise ValueError, inst.details.text
2462         return True
2463
2464     ## @brief Stores node position on a face
2465     #  @param NodeID a node ID
2466     #  @param Face a face or face ID
2467     #  @param u U parameter on the face where the node is located
2468     #  @param v V parameter on the face where the node is located
2469     #  @return True if succeed else raises an exception
2470     #  @ingroup l2_modif_add
2471     def SetNodeOnFace(self, NodeID, Face, u, v):
2472         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2473             FaceID = Face.GetSubShapeIndices()[0]
2474         else:
2475             FaceID = Face
2476         try:
2477             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2478         except SALOME.SALOME_Exception, inst:
2479             raise ValueError, inst.details.text
2480         return True
2481
2482     ## @brief Binds a node to a solid
2483     #  @param NodeID a node ID
2484     #  @param Solid  a solid or solid ID
2485     #  @return True if succeed else raises an exception
2486     #  @ingroup l2_modif_add
2487     def SetNodeInVolume(self, NodeID, Solid):
2488         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2489             SolidID = Solid.GetSubShapeIndices()[0]
2490         else:
2491             SolidID = Solid
2492         try:
2493             self.editor.SetNodeInVolume(NodeID, SolidID)
2494         except SALOME.SALOME_Exception, inst:
2495             raise ValueError, inst.details.text
2496         return True
2497
2498     ## @brief Bind an element to a shape
2499     #  @param ElementID an element ID
2500     #  @param Shape a shape or shape ID
2501     #  @return True if succeed else raises an exception
2502     #  @ingroup l2_modif_add
2503     def SetMeshElementOnShape(self, ElementID, Shape):
2504         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2505             ShapeID = Shape.GetSubShapeIndices()[0]
2506         else:
2507             ShapeID = Shape
2508         try:
2509             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2510         except SALOME.SALOME_Exception, inst:
2511             raise ValueError, inst.details.text
2512         return True
2513
2514
2515     ## Moves the node with the given id
2516     #  @param NodeID the id of the node
2517     #  @param x  a new X coordinate
2518     #  @param y  a new Y coordinate
2519     #  @param z  a new Z coordinate
2520     #  @return True if succeed else False
2521     #  @ingroup l2_modif_movenode
2522     def MoveNode(self, NodeID, x, y, z):
2523         x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2524         if hasVars: self.mesh.SetParameters(Parameters)
2525         return self.editor.MoveNode(NodeID, x, y, z)
2526
2527     ## Finds the node closest to a point and moves it to a point location
2528     #  @param x  the X coordinate of a point
2529     #  @param y  the Y coordinate of a point
2530     #  @param z  the Z coordinate of a point
2531     #  @param NodeID if specified (>0), the node with this ID is moved,
2532     #  otherwise, the node closest to point (@a x,@a y,@a z) is moved
2533     #  @return the ID of a node
2534     #  @ingroup l2_modif_throughp
2535     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2536         x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2537         if hasVars: self.mesh.SetParameters(Parameters)
2538         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2539
2540     ## Finds the node closest to a point
2541     #  @param x  the X coordinate of a point
2542     #  @param y  the Y coordinate of a point
2543     #  @param z  the Z coordinate of a point
2544     #  @return the ID of a node
2545     #  @ingroup l2_modif_throughp
2546     def FindNodeClosestTo(self, x, y, z):
2547         #preview = self.mesh.GetMeshEditPreviewer()
2548         #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2549         return self.editor.FindNodeClosestTo(x, y, z)
2550
2551     ## Finds the elements where a point lays IN or ON
2552     #  @param x  the X coordinate of a point
2553     #  @param y  the Y coordinate of a point
2554     #  @param z  the Z coordinate of a point
2555     #  @param elementType type of elements to find (SMESH.ALL type
2556     #         means elements of any type excluding nodes, discrete and 0D elements)
2557     #  @param meshPart a part of mesh (group, sub-mesh) to search within
2558     #  @return list of IDs of found elements
2559     #  @ingroup l2_modif_throughp
2560     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2561         if meshPart:
2562             return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2563         else:
2564             return self.editor.FindElementsByPoint(x, y, z, elementType)
2565
2566     # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
2567     # 0-IN, 1-OUT, 2-ON, 3-UNKNOWN
2568     # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2569
2570     def GetPointState(self, x, y, z):
2571         return self.editor.GetPointState(x, y, z)
2572
2573     ## Finds the node closest to a point and moves it to a point location
2574     #  @param x  the X coordinate of a point
2575     #  @param y  the Y coordinate of a point
2576     #  @param z  the Z coordinate of a point
2577     #  @return the ID of a moved node
2578     #  @ingroup l2_modif_throughp
2579     def MeshToPassThroughAPoint(self, x, y, z):
2580         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2581
2582     ## Replaces two neighbour triangles sharing Node1-Node2 link
2583     #  with the triangles built on the same 4 nodes but having other common link.
2584     #  @param NodeID1  the ID of the first node
2585     #  @param NodeID2  the ID of the second node
2586     #  @return false if proper faces were not found
2587     #  @ingroup l2_modif_invdiag
2588     def InverseDiag(self, NodeID1, NodeID2):
2589         return self.editor.InverseDiag(NodeID1, NodeID2)
2590
2591     ## Replaces two neighbour triangles sharing Node1-Node2 link
2592     #  with a quadrangle built on the same 4 nodes.
2593     #  @param NodeID1  the ID of the first node
2594     #  @param NodeID2  the ID of the second node
2595     #  @return false if proper faces were not found
2596     #  @ingroup l2_modif_unitetri
2597     def DeleteDiag(self, NodeID1, NodeID2):
2598         return self.editor.DeleteDiag(NodeID1, NodeID2)
2599
2600     ## Reorients elements by ids
2601     #  @param IDsOfElements if undefined reorients all mesh elements
2602     #  @return True if succeed else False
2603     #  @ingroup l2_modif_changori
2604     def Reorient(self, IDsOfElements=None):
2605         if IDsOfElements == None:
2606             IDsOfElements = self.GetElementsId()
2607         return self.editor.Reorient(IDsOfElements)
2608
2609     ## Reorients all elements of the object
2610     #  @param theObject mesh, submesh or group
2611     #  @return True if succeed else False
2612     #  @ingroup l2_modif_changori
2613     def ReorientObject(self, theObject):
2614         if ( isinstance( theObject, Mesh )):
2615             theObject = theObject.GetMesh()
2616         return self.editor.ReorientObject(theObject)
2617
2618     ## Reorient faces contained in \a the2DObject.
2619     #  @param the2DObject is a mesh, sub-mesh, group or list of IDs of 2D elements
2620     #  @param theDirection is a desired direction of normal of \a theFace.
2621     #         It can be either a GEOM vector or a list of coordinates [x,y,z].
2622     #  @param theFaceOrPoint defines a face of \a the2DObject whose normal will be
2623     #         compared with theDirection. It can be either ID of face or a point
2624     #         by which the face will be found. The point can be given as either
2625     #         a GEOM vertex or a list of point coordinates.
2626     #  @return number of reoriented faces
2627     #  @ingroup l2_modif_changori
2628     def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ):
2629         # check the2DObject
2630         if isinstance( the2DObject, Mesh ):
2631             the2DObject = the2DObject.GetMesh()
2632         if isinstance( the2DObject, list ):
2633             the2DObject = self.GetIDSource( the2DObject, SMESH.FACE )
2634         # check theDirection
2635         if isinstance( theDirection, geompyDC.GEOM._objref_GEOM_Object):
2636             theDirection = self.smeshpyD.GetDirStruct( theDirection )
2637         if isinstance( theDirection, list ):
2638             theDirection = self.smeshpyD.MakeDirStruct( *theDirection  )
2639         # prepare theFace and thePoint
2640         theFace = theFaceOrPoint
2641         thePoint = PointStruct(0,0,0)
2642         if isinstance( theFaceOrPoint, geompyDC.GEOM._objref_GEOM_Object):
2643             thePoint = self.smeshpyD.GetPointStruct( theFaceOrPoint )
2644             theFace = -1
2645         if isinstance( theFaceOrPoint, list ):
2646             thePoint = PointStruct( *theFaceOrPoint )
2647             theFace = -1
2648         if isinstance( theFaceOrPoint, PointStruct ):
2649             thePoint = theFaceOrPoint
2650             theFace = -1
2651         return self.editor.Reorient2D( the2DObject, theDirection, theFace, thePoint )
2652
2653     ## Fuses the neighbouring triangles into quadrangles.
2654     #  @param IDsOfElements The triangles to be fused,
2655     #  @param theCriterion  is a numerical functor, in terms of enum SMESH.FunctorType, used to
2656     #                       choose a neighbour to fuse with.
2657     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2658     #                       is still performed; theMaxAngle is mesured in radians.
2659     #                       Also it could be a name of variable which defines angle in degrees.
2660     #  @return TRUE in case of success, FALSE otherwise.
2661     #  @ingroup l2_modif_unitetri
2662     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2663         MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2664         self.mesh.SetParameters(Parameters)
2665         if not IDsOfElements:
2666             IDsOfElements = self.GetElementsId()
2667         Functor = self.smeshpyD.GetFunctor(theCriterion)
2668         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2669
2670     ## Fuses the neighbouring triangles of the object into quadrangles
2671     #  @param theObject is mesh, submesh or group
2672     #  @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2673     #         choose a neighbour to fuse with.
2674     #  @param MaxAngle   a max angle between element normals at which the fusion
2675     #                   is still performed; theMaxAngle is mesured in radians.
2676     #  @return TRUE in case of success, FALSE otherwise.
2677     #  @ingroup l2_modif_unitetri
2678     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2679         MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2680         self.mesh.SetParameters(Parameters)
2681         if isinstance( theObject, Mesh ):
2682             theObject = theObject.GetMesh()
2683         Functor = self.smeshpyD.GetFunctor(theCriterion)
2684         return self.editor.TriToQuadObject(theObject, Functor, MaxAngle)
2685
2686     ## Splits quadrangles into triangles.
2687     #
2688     #  @param IDsOfElements the faces to be splitted.
2689     #  @param theCriterion   is a numerical functor, in terms of enum SMESH.FunctorType, used to
2690     #         choose a diagonal for splitting. If @a theCriterion is None, which is a default
2691     #         value, then quadrangles will be split by the smallest diagonal.
2692     #  @return TRUE in case of success, FALSE otherwise.
2693     #  @ingroup l2_modif_cutquadr
2694     def QuadToTri (self, IDsOfElements, theCriterion = None):
2695         if IDsOfElements == []:
2696             IDsOfElements = self.GetElementsId()
2697         if theCriterion is None:
2698             theCriterion = FT_MaxElementLength2D
2699         Functor = self.smeshpyD.GetFunctor(theCriterion)
2700         return self.editor.QuadToTri(IDsOfElements, Functor)
2701
2702     ## Splits quadrangles into triangles.
2703     #  @param theObject the object from which the list of elements is taken,
2704     #         this is mesh, submesh or group
2705     #  @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
2706     #         choose a diagonal for splitting. If @a theCriterion is None, which is a default
2707     #         value, then quadrangles will be split by the smallest diagonal.
2708     #  @return TRUE in case of success, FALSE otherwise.
2709     #  @ingroup l2_modif_cutquadr
2710     def QuadToTriObject (self, theObject, theCriterion = None):
2711         if ( isinstance( theObject, Mesh )):
2712             theObject = theObject.GetMesh()
2713         if theCriterion is None:
2714             theCriterion = FT_MaxElementLength2D
2715         Functor = self.smeshpyD.GetFunctor(theCriterion)
2716         return self.editor.QuadToTriObject(theObject, Functor)
2717
2718     ## Splits quadrangles into triangles.
2719     #  @param IDsOfElements the faces to be splitted
2720     #  @param Diag13        is used to choose a diagonal for splitting.
2721     #  @return TRUE in case of success, FALSE otherwise.
2722     #  @ingroup l2_modif_cutquadr
2723     def SplitQuad (self, IDsOfElements, Diag13):
2724         if IDsOfElements == []:
2725             IDsOfElements = self.GetElementsId()
2726         return self.editor.SplitQuad(IDsOfElements, Diag13)
2727
2728     ## Splits quadrangles into triangles.
2729     #  @param theObject the object from which the list of elements is taken,
2730     #         this is mesh, submesh or group
2731     #  @param Diag13    is used to choose a diagonal for splitting.
2732     #  @return TRUE in case of success, FALSE otherwise.
2733     #  @ingroup l2_modif_cutquadr
2734     def SplitQuadObject (self, theObject, Diag13):
2735         if ( isinstance( theObject, Mesh )):
2736             theObject = theObject.GetMesh()
2737         return self.editor.SplitQuadObject(theObject, Diag13)
2738
2739     ## Finds a better splitting of the given quadrangle.
2740     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2741     #  @param theCriterion  is a numerical functor, in terms of enum SMESH.FunctorType, used to
2742     #         choose a diagonal for splitting.
2743     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2744     #          diagonal is better, 0 if error occurs.
2745     #  @ingroup l2_modif_cutquadr
2746     def BestSplit (self, IDOfQuad, theCriterion):
2747         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2748
2749     ## Splits volumic elements into tetrahedrons
2750     #  @param elemIDs either list of elements or mesh or group or submesh
2751     #  @param method  flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2752     #         Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2753     #  @ingroup l2_modif_cutquadr
2754     def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2755         if isinstance( elemIDs, Mesh ):
2756             elemIDs = elemIDs.GetMesh()
2757         if ( isinstance( elemIDs, list )):
2758             elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2759         self.editor.SplitVolumesIntoTetra(elemIDs, method)
2760
2761     ## Splits quadrangle faces near triangular facets of volumes
2762     #
2763     #  @ingroup l1_auxiliary
2764     def SplitQuadsNearTriangularFacets(self):
2765         faces_array = self.GetElementsByType(SMESH.FACE)
2766         for face_id in faces_array:
2767             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2768                 quad_nodes = self.mesh.GetElemNodes(face_id)
2769                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2770                 isVolumeFound = False
2771                 for node1_elem in node1_elems:
2772                     if not isVolumeFound:
2773                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2774                             nb_nodes = self.GetElemNbNodes(node1_elem)
2775                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2776                                 volume_elem = node1_elem
2777                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2778                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2779                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2780                                         isVolumeFound = True
2781                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2782                                             self.SplitQuad([face_id], False) # diagonal 2-4
2783                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2784                                         isVolumeFound = True
2785                                         self.SplitQuad([face_id], True) # diagonal 1-3
2786                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2787                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2788                                         isVolumeFound = True
2789                                         self.SplitQuad([face_id], True) # diagonal 1-3
2790
2791     ## @brief Splits hexahedrons into tetrahedrons.
2792     #
2793     #  This operation uses pattern mapping functionality for splitting.
2794     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2795     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2796     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2797     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2798     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2799     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2800     #  @return TRUE in case of success, FALSE otherwise.
2801     #  @ingroup l1_auxiliary
2802     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2803         # Pattern:     5.---------.6
2804         #              /|#*      /|
2805         #             / | #*    / |
2806         #            /  |  # * /  |
2807         #           /   |   # /*  |
2808         # (0,0,1) 4.---------.7 * |
2809         #          |#*  |1   | # *|
2810         #          | # *.----|---#.2
2811         #          |  #/ *   |   /
2812         #          |  /#  *  |  /
2813         #          | /   # * | /
2814         #          |/      #*|/
2815         # (0,0,0) 0.---------.3
2816         pattern_tetra = "!!! Nb of points: \n 8 \n\
2817         !!! Points: \n\
2818         0 0 0  !- 0 \n\
2819         0 1 0  !- 1 \n\
2820         1 1 0  !- 2 \n\
2821         1 0 0  !- 3 \n\
2822         0 0 1  !- 4 \n\
2823         0 1 1  !- 5 \n\
2824         1 1 1  !- 6 \n\
2825         1 0 1  !- 7 \n\
2826         !!! Indices of points of 6 tetras: \n\
2827         0 3 4 1 \n\
2828         7 4 3 1 \n\
2829         4 7 5 1 \n\
2830         6 2 5 7 \n\
2831         1 5 2 7 \n\
2832         2 3 1 7 \n"
2833
2834         pattern = self.smeshpyD.GetPattern()
2835         isDone  = pattern.LoadFromFile(pattern_tetra)
2836         if not isDone:
2837             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2838             return isDone
2839
2840         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2841         isDone = pattern.MakeMesh(self.mesh, False, False)
2842         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2843
2844         # split quafrangle faces near triangular facets of volumes
2845         self.SplitQuadsNearTriangularFacets()
2846
2847         return isDone
2848
2849     ## @brief Split hexahedrons into prisms.
2850     #
2851     #  Uses the pattern mapping functionality for splitting.
2852     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2853     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2854     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2855     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2856     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2857     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2858     #  @return TRUE in case of success, FALSE otherwise.
2859     #  @ingroup l1_auxiliary
2860     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2861         # Pattern:     5.---------.6
2862         #              /|#       /|
2863         #             / | #     / |
2864         #            /  |  #   /  |
2865         #           /   |   # /   |
2866         # (0,0,1) 4.---------.7   |
2867         #          |    |    |    |
2868         #          |   1.----|----.2
2869         #          |   / *   |   /
2870         #          |  /   *  |  /
2871         #          | /     * | /
2872         #          |/       *|/
2873         # (0,0,0) 0.---------.3
2874         pattern_prism = "!!! Nb of points: \n 8 \n\
2875         !!! Points: \n\
2876         0 0 0  !- 0 \n\
2877         0 1 0  !- 1 \n\
2878         1 1 0  !- 2 \n\
2879         1 0 0  !- 3 \n\
2880         0 0 1  !- 4 \n\
2881         0 1 1  !- 5 \n\
2882         1 1 1  !- 6 \n\
2883         1 0 1  !- 7 \n\
2884         !!! Indices of points of 2 prisms: \n\
2885         0 1 3 4 5 7 \n\
2886         2 3 1 6 7 5 \n"
2887
2888         pattern = self.smeshpyD.GetPattern()
2889         isDone  = pattern.LoadFromFile(pattern_prism)
2890         if not isDone:
2891             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2892             return isDone
2893
2894         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2895         isDone = pattern.MakeMesh(self.mesh, False, False)
2896         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2897
2898         # Splits quafrangle faces near triangular facets of volumes
2899         self.SplitQuadsNearTriangularFacets()
2900
2901         return isDone
2902
2903     ## Smoothes elements
2904     #  @param IDsOfElements the list if ids of elements to smooth
2905     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2906     #  Note that nodes built on edges and boundary nodes are always fixed.
2907     #  @param MaxNbOfIterations the maximum number of iterations
2908     #  @param MaxAspectRatio varies in range [1.0, inf]
2909     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2910     #  @return TRUE in case of success, FALSE otherwise.
2911     #  @ingroup l2_modif_smooth
2912     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2913                MaxNbOfIterations, MaxAspectRatio, Method):
2914         if IDsOfElements == []:
2915             IDsOfElements = self.GetElementsId()
2916         MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2917         self.mesh.SetParameters(Parameters)
2918         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2919                                   MaxNbOfIterations, MaxAspectRatio, Method)
2920
2921     ## Smoothes elements which belong to the given object
2922     #  @param theObject the object to smooth
2923     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2924     #  Note that nodes built on edges and boundary nodes are always fixed.
2925     #  @param MaxNbOfIterations the maximum number of iterations
2926     #  @param MaxAspectRatio varies in range [1.0, inf]
2927     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2928     #  @return TRUE in case of success, FALSE otherwise.
2929     #  @ingroup l2_modif_smooth
2930     def SmoothObject(self, theObject, IDsOfFixedNodes,
2931                      MaxNbOfIterations, MaxAspectRatio, Method):
2932         if ( isinstance( theObject, Mesh )):
2933             theObject = theObject.GetMesh()
2934         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2935                                         MaxNbOfIterations, MaxAspectRatio, Method)
2936
2937     ## Parametrically smoothes the given elements
2938     #  @param IDsOfElements the list if ids of elements to smooth
2939     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2940     #  Note that nodes built on edges and boundary nodes are always fixed.
2941     #  @param MaxNbOfIterations the maximum number of iterations
2942     #  @param MaxAspectRatio varies in range [1.0, inf]
2943     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2944     #  @return TRUE in case of success, FALSE otherwise.
2945     #  @ingroup l2_modif_smooth
2946     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2947                          MaxNbOfIterations, MaxAspectRatio, Method):
2948         if IDsOfElements == []:
2949             IDsOfElements = self.GetElementsId()
2950         MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2951         self.mesh.SetParameters(Parameters)
2952         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2953                                             MaxNbOfIterations, MaxAspectRatio, Method)
2954
2955     ## Parametrically smoothes the elements which belong to the given object
2956     #  @param theObject the object to smooth
2957     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2958     #  Note that nodes built on edges and boundary nodes are always fixed.
2959     #  @param MaxNbOfIterations the maximum number of iterations
2960     #  @param MaxAspectRatio varies in range [1.0, inf]
2961     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2962     #  @return TRUE in case of success, FALSE otherwise.
2963     #  @ingroup l2_modif_smooth
2964     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2965                                MaxNbOfIterations, MaxAspectRatio, Method):
2966         if ( isinstance( theObject, Mesh )):
2967             theObject = theObject.GetMesh()
2968         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2969                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2970
2971     ## Converts the mesh to quadratic, deletes old elements, replacing
2972     #  them with quadratic with the same id.
2973     #  @param theForce3d new node creation method:
2974     #         0 - the medium node lies at the geometrical entity from which the mesh element is built
2975     #         1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2976     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2977     #  @ingroup l2_modif_tofromqu
2978     def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
2979         if theSubMesh:
2980             self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
2981         else:
2982             self.editor.ConvertToQuadratic(theForce3d)
2983
2984     ## Converts the mesh from quadratic to ordinary,
2985     #  deletes old quadratic elements, \n replacing
2986     #  them with ordinary mesh elements with the same id.
2987     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2988     #  @ingroup l2_modif_tofromqu
2989     def ConvertFromQuadratic(self, theSubMesh=None):
2990         if theSubMesh:
2991             self.editor.ConvertFromQuadraticObject(theSubMesh)
2992         else:
2993             return self.editor.ConvertFromQuadratic()
2994
2995     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2996     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2997     #  @ingroup l2_modif_edit
2998     def  Make2DMeshFrom3D(self):
2999         return self.editor. Make2DMeshFrom3D()
3000
3001     ## Creates missing boundary elements
3002     #  @param elements - elements whose boundary is to be checked:
3003     #                    mesh, group, sub-mesh or list of elements
3004     #   if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3005     #  @param dimension - defines type of boundary elements to create:
3006     #                     SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3007     #    SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3008     #  @param groupName - a name of group to store created boundary elements in,
3009     #                     "" means not to create the group
3010     #  @param meshName - a name of new mesh to store created boundary elements in,
3011     #                     "" means not to create the new mesh
3012     #  @param toCopyElements - if true, the checked elements will be copied into
3013     #     the new mesh else only boundary elements will be copied into the new mesh
3014     #  @param toCopyExistingBondary - if true, not only new but also pre-existing
3015     #     boundary elements will be copied into the new mesh
3016     #  @return tuple (mesh, group) where bondary elements were added to
3017     #  @ingroup l2_modif_edit
3018     def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3019                          toCopyElements=False, toCopyExistingBondary=False):
3020         if isinstance( elements, Mesh ):
3021             elements = elements.GetMesh()
3022         if ( isinstance( elements, list )):
3023             elemType = SMESH.ALL
3024             if elements: elemType = self.GetElementType( elements[0], iselem=True)
3025             elements = self.editor.MakeIDSource(elements, elemType)
3026         mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3027                                                    toCopyElements,toCopyExistingBondary)
3028         if mesh: mesh = self.smeshpyD.Mesh(mesh)
3029         return mesh, group
3030
3031     ##
3032     # @brief Creates missing boundary elements around either the whole mesh or 
3033     #    groups of 2D elements
3034     #  @param dimension - defines type of boundary elements to create
3035     #  @param groupName - a name of group to store all boundary elements in,
3036     #    "" means not to create the group
3037     #  @param meshName - a name of a new mesh, which is a copy of the initial 
3038     #    mesh + created boundary elements; "" means not to create the new mesh
3039     #  @param toCopyAll - if true, the whole initial mesh will be copied into
3040     #    the new mesh else only boundary elements will be copied into the new mesh
3041     #  @param groups - groups of 2D elements to make boundary around
3042     #  @retval tuple( long, mesh, groups )
3043     #                 long - number of added boundary elements
3044     #                 mesh - the mesh where elements were added to
3045     #                 group - the group of boundary elements or None
3046     #
3047     def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3048                              toCopyAll=False, groups=[]):
3049         nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3050                                                            toCopyAll,groups)
3051         if mesh: mesh = self.smeshpyD.Mesh(mesh)
3052         return nb, mesh, group
3053
3054     ## Renumber mesh nodes
3055     #  @ingroup l2_modif_renumber
3056     def RenumberNodes(self):
3057         self.editor.RenumberNodes()
3058
3059     ## Renumber mesh elements
3060     #  @ingroup l2_modif_renumber
3061     def RenumberElements(self):
3062         self.editor.RenumberElements()
3063
3064     ## Generates new elements by rotation of the elements around the axis
3065     #  @param IDsOfElements the list of ids of elements to sweep
3066     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3067     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3068     #  @param NbOfSteps the number of steps
3069     #  @param Tolerance tolerance
3070     #  @param MakeGroups forces the generation of new groups from existing ones
3071     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3072     #                    of all steps, else - size of each step
3073     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3074     #  @ingroup l2_modif_extrurev
3075     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3076                       MakeGroups=False, TotalAngle=False):
3077         if IDsOfElements == []:
3078             IDsOfElements = self.GetElementsId()
3079         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3080             Axis = self.smeshpyD.GetAxisStruct(Axis)
3081         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3082         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3083         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3084         self.mesh.SetParameters(Parameters)
3085         if TotalAngle and NbOfSteps:
3086             AngleInRadians /= NbOfSteps
3087         if MakeGroups:
3088             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3089                                                        AngleInRadians, NbOfSteps, Tolerance)
3090         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3091         return []
3092
3093     ## Generates new elements by rotation of the elements of object around the axis
3094     #  @param theObject object which elements should be sweeped.
3095     #                   It can be a mesh, a sub mesh or a group.
3096     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3097     #  @param AngleInRadians the angle of Rotation
3098     #  @param NbOfSteps number of steps
3099     #  @param Tolerance tolerance
3100     #  @param MakeGroups forces the generation of new groups from existing ones
3101     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3102     #                    of all steps, else - size of each step
3103     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3104     #  @ingroup l2_modif_extrurev
3105     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3106                             MakeGroups=False, TotalAngle=False):
3107         if ( isinstance( theObject, Mesh )):
3108             theObject = theObject.GetMesh()
3109         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3110             Axis = self.smeshpyD.GetAxisStruct(Axis)
3111         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3112         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3113         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3114         self.mesh.SetParameters(Parameters)
3115         if TotalAngle and NbOfSteps:
3116             AngleInRadians /= NbOfSteps
3117         if MakeGroups:
3118             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3119                                                              NbOfSteps, Tolerance)
3120         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3121         return []
3122
3123     ## Generates new elements by rotation of the elements of object around the axis
3124     #  @param theObject object which elements should be sweeped.
3125     #                   It can be a mesh, a sub mesh or a group.
3126     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3127     #  @param AngleInRadians the angle of Rotation
3128     #  @param NbOfSteps number of steps
3129     #  @param Tolerance tolerance
3130     #  @param MakeGroups forces the generation of new groups from existing ones
3131     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3132     #                    of all steps, else - size of each step
3133     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3134     #  @ingroup l2_modif_extrurev
3135     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3136                               MakeGroups=False, TotalAngle=False):
3137         if ( isinstance( theObject, Mesh )):
3138             theObject = theObject.GetMesh()
3139         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3140             Axis = self.smeshpyD.GetAxisStruct(Axis)
3141         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3142         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3143         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3144         self.mesh.SetParameters(Parameters)
3145         if TotalAngle and NbOfSteps:
3146             AngleInRadians /= NbOfSteps
3147         if MakeGroups:
3148             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3149                                                                NbOfSteps, Tolerance)
3150         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3151         return []
3152
3153     ## Generates new elements by rotation of the elements of object around the axis
3154     #  @param theObject object which elements should be sweeped.
3155     #                   It can be a mesh, a sub mesh or a group.
3156     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3157     #  @param AngleInRadians the angle of Rotation
3158     #  @param NbOfSteps number of steps
3159     #  @param Tolerance tolerance
3160     #  @param MakeGroups forces the generation of new groups from existing ones
3161     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3162     #                    of all steps, else - size of each step
3163     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3164     #  @ingroup l2_modif_extrurev
3165     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3166                               MakeGroups=False, TotalAngle=False):
3167         if ( isinstance( theObject, Mesh )):
3168             theObject = theObject.GetMesh()
3169         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3170             Axis = self.smeshpyD.GetAxisStruct(Axis)
3171         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3172         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3173         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3174         self.mesh.SetParameters(Parameters)
3175         if TotalAngle and NbOfSteps:
3176             AngleInRadians /= NbOfSteps
3177         if MakeGroups:
3178             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3179                                                              NbOfSteps, Tolerance)
3180         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3181         return []
3182
3183     ## Generates new elements by extrusion of the elements with given ids
3184     #  @param IDsOfElements the list of elements ids for extrusion
3185     #  @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3186     #  @param NbOfSteps the number of steps
3187     #  @param MakeGroups forces the generation of new groups from existing ones
3188     #  @param IsNodes is True if elements with given ids are nodes
3189     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3190     #  @ingroup l2_modif_extrurev
3191     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3192         if IDsOfElements == []:
3193             IDsOfElements = self.GetElementsId()
3194         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3195             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3196         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3197         Parameters = StepVector.PS.parameters + var_separator + Parameters
3198         self.mesh.SetParameters(Parameters)
3199         if MakeGroups:
3200             if(IsNodes):
3201                 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3202             else:
3203                 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3204         if(IsNodes):
3205             self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3206         else:
3207             self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3208         return []
3209
3210     ## Generates new elements by extrusion of the elements with given ids
3211     #  @param IDsOfElements is ids of elements
3212     #  @param StepVector vector, defining the direction and value of extrusion
3213     #  @param NbOfSteps the number of steps
3214     #  @param ExtrFlags sets flags for extrusion
3215     #  @param SewTolerance uses for comparing locations of nodes if flag
3216     #         EXTRUSION_FLAG_SEW is set
3217     #  @param MakeGroups forces the generation of new groups from existing ones
3218     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3219     #  @ingroup l2_modif_extrurev
3220     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3221                           ExtrFlags, SewTolerance, MakeGroups=False):
3222         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3223             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3224         if MakeGroups:
3225             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3226                                                            ExtrFlags, SewTolerance)
3227         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3228                                       ExtrFlags, SewTolerance)
3229         return []
3230
3231     ## Generates new elements by extrusion of the elements which belong to the object
3232     #  @param theObject the object which elements should be processed.
3233     #                   It can be a mesh, a sub mesh or a group.
3234     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3235     #  @param NbOfSteps the number of steps
3236     #  @param MakeGroups forces the generation of new groups from existing ones
3237     #  @param  IsNodes is True if elements which belong to the object are nodes
3238     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3239     #  @ingroup l2_modif_extrurev
3240     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3241         if ( isinstance( theObject, Mesh )):
3242             theObject = theObject.GetMesh()
3243         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3244             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3245         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3246         Parameters = StepVector.PS.parameters + var_separator + Parameters
3247         self.mesh.SetParameters(Parameters)
3248         if MakeGroups:
3249             if(IsNodes):
3250                 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3251             else:
3252                 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3253         if(IsNodes):
3254             self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3255         else:
3256             self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3257         return []
3258
3259     ## Generates new elements by extrusion of the elements which belong to the object
3260     #  @param theObject object which elements should be processed.
3261     #                   It can be a mesh, a sub mesh or a group.
3262     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3263     #  @param NbOfSteps the number of steps
3264     #  @param MakeGroups to generate new groups from existing ones
3265     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3266     #  @ingroup l2_modif_extrurev
3267     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3268         if ( isinstance( theObject, Mesh )):
3269             theObject = theObject.GetMesh()
3270         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3271             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3272         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3273         Parameters = StepVector.PS.parameters + var_separator + Parameters
3274         self.mesh.SetParameters(Parameters)
3275         if MakeGroups:
3276             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3277         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3278         return []
3279
3280     ## Generates new elements by extrusion of the elements which belong to the object
3281     #  @param theObject object which elements should be processed.
3282     #                   It can be a mesh, a sub mesh or a group.
3283     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3284     #  @param NbOfSteps the number of steps
3285     #  @param MakeGroups forces the generation of new groups from existing ones
3286     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3287     #  @ingroup l2_modif_extrurev
3288     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3289         if ( isinstance( theObject, Mesh )):
3290             theObject = theObject.GetMesh()
3291         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3292             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3293         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3294         Parameters = StepVector.PS.parameters + var_separator + Parameters
3295         self.mesh.SetParameters(Parameters)
3296         if MakeGroups:
3297             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3298         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3299         return []
3300
3301
3302
3303     ## Generates new elements by extrusion of the given elements
3304     #  The path of extrusion must be a meshed edge.
3305     #  @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3306     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3307     #  @param NodeStart the start node from Path. Defines the direction of extrusion
3308     #  @param HasAngles allows the shape to be rotated around the path
3309     #                   to get the resulting mesh in a helical fashion
3310     #  @param Angles list of angles in radians
3311     #  @param LinearVariation forces the computation of rotation angles as linear
3312     #                         variation of the given Angles along path steps
3313     #  @param HasRefPoint allows using the reference point
3314     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3315     #         The User can specify any point as the Reference Point.
3316     #  @param MakeGroups forces the generation of new groups from existing ones
3317     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
3318     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3319     #          only SMESH::Extrusion_Error otherwise
3320     #  @ingroup l2_modif_extrurev
3321     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3322                             HasAngles, Angles, LinearVariation,
3323                             HasRefPoint, RefPoint, MakeGroups, ElemType):
3324         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3325             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3326             pass
3327         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3328         Parameters = AnglesParameters + var_separator + RefPoint.parameters
3329         self.mesh.SetParameters(Parameters)
3330
3331         if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3332
3333         if isinstance(Base, list):
3334             IDsOfElements = []
3335             if Base == []: IDsOfElements = self.GetElementsId()
3336             else: IDsOfElements = Base
3337             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3338                                                    HasAngles, Angles, LinearVariation,
3339                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
3340         else:
3341             if isinstance(Base, Mesh): Base = Base.GetMesh()
3342             if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3343                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3344                                                           HasAngles, Angles, LinearVariation,
3345                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
3346             else:
3347                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3348
3349
3350     ## Generates new elements by extrusion of the given elements
3351     #  The path of extrusion must be a meshed edge.
3352     #  @param IDsOfElements ids of elements
3353     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3354     #  @param PathShape shape(edge) defines the sub-mesh for the path
3355     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3356     #  @param HasAngles allows the shape to be rotated around the path
3357     #                   to get the resulting mesh in a helical fashion
3358     #  @param Angles list of angles in radians
3359     #  @param HasRefPoint allows using the reference point
3360     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3361     #         The User can specify any point as the Reference Point.
3362     #  @param MakeGroups forces the generation of new groups from existing ones
3363     #  @param LinearVariation forces the computation of rotation angles as linear
3364     #                         variation of the given Angles along path steps
3365     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3366     #          only SMESH::Extrusion_Error otherwise
3367     #  @ingroup l2_modif_extrurev
3368     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3369                            HasAngles, Angles, HasRefPoint, RefPoint,
3370                            MakeGroups=False, LinearVariation=False):
3371         if IDsOfElements == []:
3372             IDsOfElements = self.GetElementsId()
3373         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3374             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3375             pass
3376         if ( isinstance( PathMesh, Mesh )):
3377             PathMesh = PathMesh.GetMesh()
3378         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3379         Parameters = AnglesParameters + var_separator + RefPoint.parameters
3380         self.mesh.SetParameters(Parameters)
3381         if HasAngles and Angles and LinearVariation:
3382             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3383             pass
3384         if MakeGroups:
3385             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3386                                                             PathShape, NodeStart, HasAngles,
3387                                                             Angles, HasRefPoint, RefPoint)
3388         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3389                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3390
3391     ## Generates new elements by extrusion of the elements which belong to the object
3392     #  The path of extrusion must be a meshed edge.
3393     #  @param theObject the object which elements should be processed.
3394     #                   It can be a mesh, a sub mesh or a group.
3395     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3396     #  @param PathShape shape(edge) defines the sub-mesh for the path
3397     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3398     #  @param HasAngles allows the shape to be rotated around the path
3399     #                   to get the resulting mesh in a helical fashion
3400     #  @param Angles list of angles
3401     #  @param HasRefPoint allows using the reference point
3402     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3403     #         The User can specify any point as the Reference Point.
3404     #  @param MakeGroups forces the generation of new groups from existing ones
3405     #  @param LinearVariation forces the computation of rotation angles as linear
3406     #                         variation of the given Angles along path steps
3407     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3408     #          only SMESH::Extrusion_Error otherwise
3409     #  @ingroup l2_modif_extrurev
3410     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3411                                  HasAngles, Angles, HasRefPoint, RefPoint,
3412                                  MakeGroups=False, LinearVariation=False):
3413         if ( isinstance( theObject, Mesh )):
3414             theObject = theObject.GetMesh()
3415         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3416             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3417         if ( isinstance( PathMesh, Mesh )):
3418             PathMesh = PathMesh.GetMesh()
3419         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3420         Parameters = AnglesParameters + var_separator + RefPoint.parameters
3421         self.mesh.SetParameters(Parameters)
3422         if HasAngles and Angles and LinearVariation:
3423             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3424             pass
3425         if MakeGroups:
3426             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3427                                                                   PathShape, NodeStart, HasAngles,
3428                                                                   Angles, HasRefPoint, RefPoint)
3429         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3430                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3431                                                     RefPoint)
3432
3433     ## Generates new elements by extrusion of the elements which belong to the object
3434     #  The path of extrusion must be a meshed edge.
3435     #  @param theObject the object which elements should be processed.
3436     #                   It can be a mesh, a sub mesh or a group.
3437     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3438     #  @param PathShape shape(edge) defines the sub-mesh for the path
3439     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3440     #  @param HasAngles allows the shape to be rotated around the path
3441     #                   to get the resulting mesh in a helical fashion
3442     #  @param Angles list of angles
3443     #  @param HasRefPoint allows using the reference point
3444     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3445     #         The User can specify any point as the Reference Point.
3446     #  @param MakeGroups forces the generation of new groups from existing ones
3447     #  @param LinearVariation forces the computation of rotation angles as linear
3448     #                         variation of the given Angles along path steps
3449     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3450     #          only SMESH::Extrusion_Error otherwise
3451     #  @ingroup l2_modif_extrurev
3452     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3453                                    HasAngles, Angles, HasRefPoint, RefPoint,
3454                                    MakeGroups=False, LinearVariation=False):
3455         if ( isinstance( theObject, Mesh )):
3456             theObject = theObject.GetMesh()
3457         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3458             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3459         if ( isinstance( PathMesh, Mesh )):
3460             PathMesh = PathMesh.GetMesh()
3461         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3462         Parameters = AnglesParameters + var_separator + RefPoint.parameters
3463         self.mesh.SetParameters(Parameters)
3464         if HasAngles and Angles and LinearVariation:
3465             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3466             pass
3467         if MakeGroups:
3468             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3469                                                                     PathShape, NodeStart, HasAngles,
3470                                                                     Angles, HasRefPoint, RefPoint)
3471         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3472                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3473                                                       RefPoint)
3474
3475     ## Generates new elements by extrusion of the elements which belong to the object
3476     #  The path of extrusion must be a meshed edge.
3477     #  @param theObject the object which elements should be processed.
3478     #                   It can be a mesh, a sub mesh or a group.
3479     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3480     #  @param PathShape shape(edge) defines the sub-mesh for the path
3481     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3482     #  @param HasAngles allows the shape to be rotated around the path
3483     #                   to get the resulting mesh in a helical fashion
3484     #  @param Angles list of angles
3485     #  @param HasRefPoint allows using the reference point
3486     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3487     #         The User can specify any point as the Reference Point.
3488     #  @param MakeGroups forces the generation of new groups from existing ones
3489     #  @param LinearVariation forces the computation of rotation angles as linear
3490     #                         variation of the given Angles along path steps
3491     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3492     #          only SMESH::Extrusion_Error otherwise
3493     #  @ingroup l2_modif_extrurev
3494     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3495                                    HasAngles, Angles, HasRefPoint, RefPoint,
3496                                    MakeGroups=False, LinearVariation=False):
3497         if ( isinstance( theObject, Mesh )):
3498             theObject = theObject.GetMesh()
3499         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3500             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3501         if ( isinstance( PathMesh, Mesh )):
3502             PathMesh = PathMesh.GetMesh()
3503         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3504         Parameters = AnglesParameters + var_separator + RefPoint.parameters
3505         self.mesh.SetParameters(Parameters)
3506         if HasAngles and Angles and LinearVariation:
3507             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3508             pass
3509         if MakeGroups:
3510             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3511                                                                     PathShape, NodeStart, HasAngles,
3512                                                                     Angles, HasRefPoint, RefPoint)
3513         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3514                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3515                                                       RefPoint)
3516
3517     ## Creates a symmetrical copy of mesh elements
3518     #  @param IDsOfElements list of elements ids
3519     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3520     #  @param theMirrorType is  POINT, AXIS or PLANE
3521     #  If the Mirror is a geom object this parameter is unnecessary
3522     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3523     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3524     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3525     #  @ingroup l2_modif_trsf
3526     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3527         if IDsOfElements == []:
3528             IDsOfElements = self.GetElementsId()
3529         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3530             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3531         self.mesh.SetParameters(Mirror.parameters)
3532         if Copy and MakeGroups:
3533             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3534         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3535         return []
3536
3537     ## Creates a new mesh by a symmetrical copy of mesh elements
3538     #  @param IDsOfElements the list of elements ids
3539     #  @param Mirror is AxisStruct or geom object (point, line, plane)
3540     #  @param theMirrorType is  POINT, AXIS or PLANE
3541     #  If the Mirror is a geom object this parameter is unnecessary
3542     #  @param MakeGroups to generate new groups from existing ones
3543     #  @param NewMeshName a name of the new mesh to create
3544     #  @return instance of Mesh class
3545     #  @ingroup l2_modif_trsf
3546     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3547         if IDsOfElements == []:
3548             IDsOfElements = self.GetElementsId()
3549         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3550             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3551         self.mesh.SetParameters(Mirror.parameters)
3552         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3553                                           MakeGroups, NewMeshName)
3554         return Mesh(self.smeshpyD,self.geompyD,mesh)
3555
3556     ## Creates a symmetrical copy of the object
3557     #  @param theObject mesh, submesh or group
3558     #  @param Mirror AxisStruct or geom object (point, line, plane)
3559     #  @param theMirrorType is  POINT, AXIS or PLANE
3560     #  If the Mirror is a geom object this parameter is unnecessary
3561     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3562     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3563     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3564     #  @ingroup l2_modif_trsf
3565     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3566         if ( isinstance( theObject, Mesh )):
3567             theObject = theObject.GetMesh()
3568         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3569             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3570         self.mesh.SetParameters(Mirror.parameters)
3571         if Copy and MakeGroups:
3572             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3573         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3574         return []
3575
3576     ## Creates a new mesh by a symmetrical copy of the object
3577     #  @param theObject mesh, submesh or group
3578     #  @param Mirror AxisStruct or geom object (point, line, plane)
3579     #  @param theMirrorType POINT, AXIS or PLANE
3580     #  If the Mirror is a geom object this parameter is unnecessary
3581     #  @param MakeGroups forces the generation of new groups from existing ones
3582     #  @param NewMeshName the name of the new mesh to create
3583     #  @return instance of Mesh class
3584     #  @ingroup l2_modif_trsf
3585     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3586         if ( isinstance( theObject, Mesh )):
3587             theObject = theObject.GetMesh()
3588         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3589             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3590         self.mesh.SetParameters(Mirror.parameters)
3591         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3592                                                 MakeGroups, NewMeshName)
3593         return Mesh( self.smeshpyD,self.geompyD,mesh )
3594
3595     ## Translates the elements
3596     #  @param IDsOfElements list of elements ids
3597     #  @param Vector the direction of translation (DirStruct or vector)
3598     #  @param Copy allows copying the translated elements
3599     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3600     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3601     #  @ingroup l2_modif_trsf
3602     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3603         if IDsOfElements == []:
3604             IDsOfElements = self.GetElementsId()
3605         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3606             Vector = self.smeshpyD.GetDirStruct(Vector)
3607         self.mesh.SetParameters(Vector.PS.parameters)
3608         if Copy and MakeGroups:
3609             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3610         self.editor.Translate(IDsOfElements, Vector, Copy)
3611         return []
3612
3613     ## Creates a new mesh of translated elements
3614     #  @param IDsOfElements list of elements ids
3615     #  @param Vector the direction of translation (DirStruct or vector)
3616     #  @param MakeGroups forces the generation of new groups from existing ones
3617     #  @param NewMeshName the name of the newly created mesh
3618     #  @return instance of Mesh class
3619     #  @ingroup l2_modif_trsf
3620     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3621         if IDsOfElements == []:
3622             IDsOfElements = self.GetElementsId()
3623         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3624             Vector = self.smeshpyD.GetDirStruct(Vector)
3625         self.mesh.SetParameters(Vector.PS.parameters)
3626         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3627         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3628
3629     ## Translates the object
3630     #  @param theObject the object to translate (mesh, submesh, or group)
3631     #  @param Vector direction of translation (DirStruct or geom vector)
3632     #  @param Copy allows copying the translated elements
3633     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3634     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3635     #  @ingroup l2_modif_trsf
3636     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3637         if ( isinstance( theObject, Mesh )):
3638             theObject = theObject.GetMesh()
3639         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3640             Vector = self.smeshpyD.GetDirStruct(Vector)
3641         self.mesh.SetParameters(Vector.PS.parameters)
3642         if Copy and MakeGroups:
3643             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3644         self.editor.TranslateObject(theObject, Vector, Copy)
3645         return []
3646
3647     ## Creates a new mesh from the translated object
3648     #  @param theObject the object to translate (mesh, submesh, or group)
3649     #  @param Vector the direction of translation (DirStruct or geom vector)
3650     #  @param MakeGroups forces the generation of new groups from existing ones
3651     #  @param NewMeshName the name of the newly created mesh
3652     #  @return instance of Mesh class
3653     #  @ingroup l2_modif_trsf
3654     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3655         if (isinstance(theObject, Mesh)):
3656             theObject = theObject.GetMesh()
3657         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3658             Vector = self.smeshpyD.GetDirStruct(Vector)
3659         self.mesh.SetParameters(Vector.PS.parameters)
3660         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3661         return Mesh( self.smeshpyD, self.geompyD, mesh )
3662
3663
3664
3665     ## Scales the object
3666     #  @param theObject - the object to translate (mesh, submesh, or group)
3667     #  @param thePoint - base point for scale
3668     #  @param theScaleFact - list of 1-3 scale factors for axises
3669     #  @param Copy - allows copying the translated elements
3670     #  @param MakeGroups - forces the generation of new groups from existing
3671     #                      ones (if Copy)
3672     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3673     #          empty list otherwise
3674     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3675         if ( isinstance( theObject, Mesh )):
3676             theObject = theObject.GetMesh()
3677         if ( isinstance( theObject, list )):
3678             theObject = self.GetIDSource(theObject, SMESH.ALL)
3679
3680         self.mesh.SetParameters(thePoint.parameters)
3681
3682         if Copy and MakeGroups:
3683             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3684         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3685         return []
3686
3687     ## Creates a new mesh from the translated object
3688     #  @param theObject - the object to translate (mesh, submesh, or group)
3689     #  @param thePoint - base point for scale
3690     #  @param theScaleFact - list of 1-3 scale factors for axises
3691     #  @param MakeGroups - forces the generation of new groups from existing ones
3692     #  @param NewMeshName - the name of the newly created mesh
3693     #  @return instance of Mesh class
3694     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3695         if (isinstance(theObject, Mesh)):
3696             theObject = theObject.GetMesh()
3697         if ( isinstance( theObject, list )):
3698             theObject = self.GetIDSource(theObject,SMESH.ALL)
3699
3700         self.mesh.SetParameters(thePoint.parameters)
3701         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3702                                          MakeGroups, NewMeshName)
3703         return Mesh( self.smeshpyD, self.geompyD, mesh )
3704
3705
3706
3707     ## Rotates the elements
3708     #  @param IDsOfElements list of elements ids
3709     #  @param Axis the axis of rotation (AxisStruct or geom line)
3710     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3711     #  @param Copy allows copying the rotated elements
3712     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3713     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3714     #  @ingroup l2_modif_trsf
3715     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3716         if IDsOfElements == []:
3717             IDsOfElements = self.GetElementsId()
3718         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3719             Axis = self.smeshpyD.GetAxisStruct(Axis)
3720         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3721         Parameters = Axis.parameters + var_separator + Parameters
3722         self.mesh.SetParameters(Parameters)
3723         if Copy and MakeGroups:
3724             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3725         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3726         return []
3727
3728     ## Creates a new mesh of rotated elements
3729     #  @param IDsOfElements list of element ids
3730     #  @param Axis the axis of rotation (AxisStruct or geom line)
3731     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3732     #  @param MakeGroups forces the generation of new groups from existing ones
3733     #  @param NewMeshName the name of the newly created mesh
3734     #  @return instance of Mesh class
3735     #  @ingroup l2_modif_trsf
3736     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3737         if IDsOfElements == []:
3738             IDsOfElements = self.GetElementsId()
3739         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3740             Axis = self.smeshpyD.GetAxisStruct(Axis)
3741         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3742         Parameters = Axis.parameters + var_separator + Parameters
3743         self.mesh.SetParameters(Parameters)
3744         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3745                                           MakeGroups, NewMeshName)
3746         return Mesh( self.smeshpyD, self.geompyD, mesh )
3747
3748     ## Rotates the object
3749     #  @param theObject the object to rotate( mesh, submesh, or group)
3750     #  @param Axis the axis of rotation (AxisStruct or geom line)
3751     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3752     #  @param Copy allows copying the rotated elements
3753     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3754     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3755     #  @ingroup l2_modif_trsf
3756     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3757         if (isinstance(theObject, Mesh)):
3758             theObject = theObject.GetMesh()
3759         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3760             Axis = self.smeshpyD.GetAxisStruct(Axis)
3761         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3762         Parameters = Axis.parameters + ":" + Parameters
3763         self.mesh.SetParameters(Parameters)
3764         if Copy and MakeGroups:
3765             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3766         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3767         return []
3768
3769     ## Creates a new mesh from the rotated object
3770     #  @param theObject the object to rotate (mesh, submesh, or group)
3771     #  @param Axis the axis of rotation (AxisStruct or geom line)
3772     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3773     #  @param MakeGroups forces the generation of new groups from existing ones
3774     #  @param NewMeshName the name of the newly created mesh
3775     #  @return instance of Mesh class
3776     #  @ingroup l2_modif_trsf
3777     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3778         if (isinstance( theObject, Mesh )):
3779             theObject = theObject.GetMesh()
3780         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3781             Axis = self.smeshpyD.GetAxisStruct(Axis)
3782         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3783         Parameters = Axis.parameters + ":" + Parameters
3784         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3785                                                        MakeGroups, NewMeshName)
3786         self.mesh.SetParameters(Parameters)
3787         return Mesh( self.smeshpyD, self.geompyD, mesh )
3788
3789     ## Finds groups of ajacent nodes within Tolerance.
3790     #  @param Tolerance the value of tolerance
3791     #  @return the list of groups of nodes
3792     #  @ingroup l2_modif_trsf
3793     def FindCoincidentNodes (self, Tolerance):
3794         return self.editor.FindCoincidentNodes(Tolerance)
3795
3796     ## Finds groups of ajacent nodes within Tolerance.
3797     #  @param Tolerance the value of tolerance
3798     #  @param SubMeshOrGroup SubMesh or Group
3799     #  @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3800     #  @return the list of groups of nodes
3801     #  @ingroup l2_modif_trsf
3802     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3803         if (isinstance( SubMeshOrGroup, Mesh )):
3804             SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3805         if not isinstance( exceptNodes, list):
3806             exceptNodes = [ exceptNodes ]
3807         if exceptNodes and isinstance( exceptNodes[0], int):
3808             exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3809         return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3810
3811     ## Merges nodes
3812     #  @param GroupsOfNodes the list of groups of nodes
3813     #  @ingroup l2_modif_trsf
3814     def MergeNodes (self, GroupsOfNodes):
3815         self.editor.MergeNodes(GroupsOfNodes)
3816
3817     ## Finds the elements built on the same nodes.
3818     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3819     #  @return a list of groups of equal elements
3820     #  @ingroup l2_modif_trsf
3821     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3822         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3823             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3824         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3825
3826     ## Merges elements in each given group.
3827     #  @param GroupsOfElementsID groups of elements for merging
3828     #  @ingroup l2_modif_trsf
3829     def MergeElements(self, GroupsOfElementsID):
3830         self.editor.MergeElements(GroupsOfElementsID)
3831
3832     ## Leaves one element and removes all other elements built on the same nodes.
3833     #  @ingroup l2_modif_trsf
3834     def MergeEqualElements(self):
3835         self.editor.MergeEqualElements()
3836
3837     ## Sews free borders
3838     #  @return SMESH::Sew_Error
3839     #  @ingroup l2_modif_trsf
3840     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3841                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3842                         CreatePolygons, CreatePolyedrs):
3843         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3844                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3845                                           CreatePolygons, CreatePolyedrs)
3846
3847     ## Sews conform free borders
3848     #  @return SMESH::Sew_Error
3849     #  @ingroup l2_modif_trsf
3850     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3851                                FirstNodeID2, SecondNodeID2):
3852         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3853                                                  FirstNodeID2, SecondNodeID2)
3854
3855     ## Sews border to side
3856     #  @return SMESH::Sew_Error
3857     #  @ingroup l2_modif_trsf
3858     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3859                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3860         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3861                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3862
3863     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3864     #  merged with the nodes of elements of Side2.
3865     #  The number of elements in theSide1 and in theSide2 must be
3866     #  equal and they should have similar nodal connectivity.
3867     #  The nodes to merge should belong to side borders and
3868     #  the first node should be linked to the second.
3869     #  @return SMESH::Sew_Error
3870     #  @ingroup l2_modif_trsf
3871     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3872                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3873                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3874         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3875                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3876                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3877
3878     ## Sets new nodes for the given element.
3879     #  @param ide the element id
3880     #  @param newIDs nodes ids
3881     #  @return If the number of nodes does not correspond to the type of element - returns false
3882     #  @ingroup l2_modif_edit
3883     def ChangeElemNodes(self, ide, newIDs):
3884         return self.editor.ChangeElemNodes(ide, newIDs)
3885
3886     ## If during the last operation of MeshEditor some nodes were
3887     #  created, this method returns the list of their IDs, \n
3888     #  if new nodes were not created - returns empty list
3889     #  @return the list of integer values (can be empty)
3890     #  @ingroup l1_auxiliary
3891     def GetLastCreatedNodes(self):
3892         return self.editor.GetLastCreatedNodes()
3893
3894     ## If during the last operation of MeshEditor some elements were
3895     #  created this method returns the list of their IDs, \n
3896     #  if new elements were not created - returns empty list
3897     #  @return the list of integer values (can be empty)
3898     #  @ingroup l1_auxiliary
3899     def GetLastCreatedElems(self):
3900         return self.editor.GetLastCreatedElems()
3901
3902      ## Creates a hole in a mesh by doubling the nodes of some particular elements
3903     #  @param theNodes identifiers of nodes to be doubled
3904     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3905     #         nodes. If list of element identifiers is empty then nodes are doubled but
3906     #         they not assigned to elements
3907     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3908     #  @ingroup l2_modif_edit
3909     def DoubleNodes(self, theNodes, theModifiedElems):
3910         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3911
3912     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3913     #  This method provided for convenience works as DoubleNodes() described above.
3914     #  @param theNodeId identifiers of node to be doubled
3915     #  @param theModifiedElems identifiers of elements to be updated
3916     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3917     #  @ingroup l2_modif_edit
3918     def DoubleNode(self, theNodeId, theModifiedElems):
3919         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3920
3921     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3922     #  This method provided for convenience works as DoubleNodes() described above.
3923     #  @param theNodes group of nodes to be doubled
3924     #  @param theModifiedElems group of elements to be updated.
3925     #  @param theMakeGroup forces the generation of a group containing new nodes.
3926     #  @return TRUE or a created group if operation has been completed successfully,
3927     #          FALSE or None otherwise
3928     #  @ingroup l2_modif_edit
3929     def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3930         if theMakeGroup:
3931             return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3932         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3933
3934     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3935     #  This method provided for convenience works as DoubleNodes() described above.
3936     #  @param theNodes list of groups of nodes to be doubled
3937     #  @param theModifiedElems list of groups of elements to be updated.
3938     #  @param theMakeGroup forces the generation of a group containing new nodes.
3939     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3940     #  @ingroup l2_modif_edit
3941     def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
3942         if theMakeGroup:
3943             return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
3944         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3945
3946     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3947     #  @param theElems - the list of elements (edges or faces) to be replicated
3948     #         The nodes for duplication could be found from these elements
3949     #  @param theNodesNot - list of nodes to NOT replicate
3950     #  @param theAffectedElems - the list of elements (cells and edges) to which the
3951     #         replicated nodes should be associated to.
3952     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3953     #  @ingroup l2_modif_edit
3954     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3955         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3956
3957     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3958     #  @param theElems - the list of elements (edges or faces) to be replicated
3959     #         The nodes for duplication could be found from these elements
3960     #  @param theNodesNot - list of nodes to NOT replicate
3961     #  @param theShape - shape to detect affected elements (element which geometric center
3962     #         located on or inside shape).
3963     #         The replicated nodes should be associated to affected elements.
3964     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3965     #  @ingroup l2_modif_edit
3966     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3967         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3968
3969     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3970     #  This method provided for convenience works as DoubleNodes() described above.
3971     #  @param theElems - group of of elements (edges or faces) to be replicated
3972     #  @param theNodesNot - group of nodes not to replicated
3973     #  @param theAffectedElems - group of elements to which the replicated nodes
3974     #         should be associated to.
3975     #  @param theMakeGroup forces the generation of a group containing new elements.
3976     #  @param theMakeNodeGroup forces the generation of a group containing new nodes.
3977     #  @return TRUE or created groups (one or two) if operation has been completed successfully,
3978     #          FALSE or None otherwise
3979     #  @ingroup l2_modif_edit
3980     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems,
3981                              theMakeGroup=False, theMakeNodeGroup=False):
3982         if theMakeGroup or theMakeNodeGroup:
3983             twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot,
3984                                                             theAffectedElems,
3985                                                             theMakeGroup, theMakeNodeGroup)
3986             if theMakeGroup and theMakeNodeGroup:
3987                 return twoGroups
3988             else:
3989                 return twoGroups[ int(theMakeNodeGroup) ]
3990         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3991
3992     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3993     #  This method provided for convenience works as DoubleNodes() described above.
3994     #  @param theElems - group of of elements (edges or faces) to be replicated
3995     #  @param theNodesNot - group of nodes not to replicated
3996     #  @param theShape - shape to detect affected elements (element which geometric center
3997     #         located on or inside shape).
3998     #         The replicated nodes should be associated to affected elements.
3999     #  @ingroup l2_modif_edit
4000     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4001         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4002
4003     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4004     #  This method provided for convenience works as DoubleNodes() described above.
4005     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4006     #  @param theNodesNot - list of groups of nodes not to replicated
4007     #  @param theAffectedElems - group of elements to which the replicated nodes
4008     #         should be associated to.
4009     #  @param theMakeGroup forces the generation of a group containing new elements.
4010     #  @param theMakeNodeGroup forces the generation of a group containing new nodes.
4011     #  @return TRUE or created groups (one or two) if operation has been completed successfully,
4012     #          FALSE or None otherwise
4013     #  @ingroup l2_modif_edit
4014     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems,
4015                              theMakeGroup=False, theMakeNodeGroup=False):
4016         if theMakeGroup or theMakeNodeGroup:
4017             twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot,
4018                                                              theAffectedElems,
4019                                                              theMakeGroup, theMakeNodeGroup)
4020             if theMakeGroup and theMakeNodeGroup:
4021                 return twoGroups
4022             else:
4023                 return twoGroups[ int(theMakeNodeGroup) ]
4024         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4025
4026     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4027     #  This method provided for convenience works as DoubleNodes() described above.
4028     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4029     #  @param theNodesNot - list of groups of nodes not to replicated
4030     #  @param theShape - shape to detect affected elements (element which geometric center
4031     #         located on or inside shape).
4032     #         The replicated nodes should be associated to affected elements.
4033     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4034     #  @ingroup l2_modif_edit
4035     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4036         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4037
4038     ## Identify the elements that will be affected by node duplication (actual duplication is not performed.
4039     #  This method is the first step of DoubleNodeElemGroupsInRegion.
4040     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4041     #  @param theNodesNot - list of groups of nodes not to replicated
4042     #  @param theShape - shape to detect affected elements (element which geometric center
4043     #         located on or inside shape).
4044     #         The replicated nodes should be associated to affected elements.
4045     #  @return groups of affected elements
4046     #  @ingroup l2_modif_edit
4047     def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4048         return self.editor.AffectedElemGroupsInRegion(theElems, theNodesNot, theShape)
4049
4050     ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4051     # The list of groups must describe a partition of the mesh volumes.
4052     # The nodes of the internal faces at the boundaries of the groups are doubled.
4053     # In option, the internal faces are replaced by flat elements.
4054     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4055     # @param theDomains - list of groups of volumes
4056     # @param createJointElems - if TRUE, create the elements
4057     # @return TRUE if operation has been completed successfully, FALSE otherwise
4058     def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4059        return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4060
4061     ## Double nodes on some external faces and create flat elements.
4062     # Flat elements are mainly used by some types of mechanic calculations.
4063     #
4064     # Each group of the list must be constituted of faces.
4065     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4066     # @param theGroupsOfFaces - list of groups of faces
4067     # @return TRUE if operation has been completed successfully, FALSE otherwise
4068     def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4069         return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4070     
4071     ## identify all the elements around a geom shape, get the faces delimiting the hole
4072     #
4073     def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
4074         return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords )
4075
4076     def _getFunctor(self, funcType ):
4077         fn = self.functors[ funcType._v ]
4078         if not fn:
4079             fn = self.smeshpyD.GetFunctor(funcType)
4080             fn.SetMesh(self.mesh)
4081             self.functors[ funcType._v ] = fn
4082         return fn
4083
4084     def _valueFromFunctor(self, funcType, elemId):
4085         fn = self._getFunctor( funcType )
4086         if fn.GetElementType() == self.GetElementType(elemId, True):
4087             val = fn.GetValue(elemId)
4088         else:
4089             val = 0
4090         return val
4091
4092     ## Get length of 1D element.
4093     #  @param elemId mesh element ID
4094     #  @return element's length value
4095     #  @ingroup l1_measurements
4096     def GetLength(self, elemId):
4097         return self._valueFromFunctor(SMESH.FT_Length, elemId)
4098
4099     ## Get area of 2D element.
4100     #  @param elemId mesh element ID
4101     #  @return element's area value
4102     #  @ingroup l1_measurements
4103     def GetArea(self, elemId):
4104         return self._valueFromFunctor(SMESH.FT_Area, elemId)
4105
4106     ## Get volume of 3D element.
4107     #  @param elemId mesh element ID
4108     #  @return element's volume value
4109     #  @ingroup l1_measurements
4110     def GetVolume(self, elemId):
4111         return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4112
4113     ## Get maximum element length.
4114     #  @param elemId mesh element ID
4115     #  @return element's maximum length value
4116     #  @ingroup l1_measurements
4117     def GetMaxElementLength(self, elemId):
4118         if self.GetElementType(elemId, True) == SMESH.VOLUME:
4119             ftype = SMESH.FT_MaxElementLength3D
4120         else:
4121             ftype = SMESH.FT_MaxElementLength2D
4122         return self._valueFromFunctor(ftype, elemId)
4123
4124     ## Get aspect ratio of 2D or 3D element.
4125     #  @param elemId mesh element ID
4126     #  @return element's aspect ratio value
4127     #  @ingroup l1_measurements
4128     def GetAspectRatio(self, elemId):
4129         if self.GetElementType(elemId, True) == SMESH.VOLUME:
4130             ftype = SMESH.FT_AspectRatio3D
4131         else:
4132             ftype = SMESH.FT_AspectRatio
4133         return self._valueFromFunctor(ftype, elemId)
4134
4135     ## Get warping angle of 2D element.
4136     #  @param elemId mesh element ID
4137     #  @return element's warping angle value
4138     #  @ingroup l1_measurements
4139     def GetWarping(self, elemId):
4140         return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4141
4142     ## Get minimum angle of 2D element.
4143     #  @param elemId mesh element ID
4144     #  @return element's minimum angle value
4145     #  @ingroup l1_measurements
4146     def GetMinimumAngle(self, elemId):
4147         return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4148
4149     ## Get taper of 2D element.
4150     #  @param elemId mesh element ID
4151     #  @return element's taper value
4152     #  @ingroup l1_measurements
4153     def GetTaper(self, elemId):
4154         return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4155
4156     ## Get skew of 2D element.
4157     #  @param elemId mesh element ID
4158     #  @return element's skew value
4159     #  @ingroup l1_measurements
4160     def GetSkew(self, elemId):
4161         return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4162
4163     pass # end of Mesh class
4164     
4165 ## Helper class for wrapping of SMESH.SMESH_Pattern CORBA class
4166 #
4167 class Pattern(SMESH._objref_SMESH_Pattern):
4168
4169     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4170         decrFun = lambda i: i-1
4171         theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
4172         theMesh.SetParameters(Parameters)
4173         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4174
4175     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4176         decrFun = lambda i: i-1
4177         theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
4178         theMesh.SetParameters(Parameters)
4179         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4180
4181 # Registering the new proxy for Pattern
4182 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
4183
4184 ## Private class used to bind methods creating algorithms to the class Mesh
4185 #
4186 class algoCreator:
4187     def __init__(self):
4188         self.mesh = None
4189         self.defaultAlgoType = ""
4190         self.algoTypeToClass = {}
4191
4192     # Stores a python class of algorithm
4193     def add(self, algoClass):
4194         if type( algoClass ).__name__ == 'classobj' and \
4195            hasattr( algoClass, "algoType"):
4196             self.algoTypeToClass[ algoClass.algoType ] = algoClass
4197             if not self.defaultAlgoType and \
4198                hasattr( algoClass, "isDefault") and algoClass.isDefault:
4199                 self.defaultAlgoType = algoClass.algoType
4200             #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
4201
4202     # creates a copy of self and assign mesh to the copy
4203     def copy(self, mesh):
4204         other = algoCreator()
4205         other.defaultAlgoType = self.defaultAlgoType
4206         other.algoTypeToClass  = self.algoTypeToClass
4207         other.mesh = mesh
4208         return other
4209
4210     # creates an instance of algorithm
4211     def __call__(self,algo="",geom=0,*args):
4212         algoType = self.defaultAlgoType
4213         for arg in args + (algo,geom):
4214             if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4215                 geom = arg
4216             if isinstance( arg, str ) and arg:
4217                 algoType = arg
4218         if not algoType and self.algoTypeToClass:
4219             algoType = self.algoTypeToClass.keys()[0]
4220         if self.algoTypeToClass.has_key( algoType ):
4221             #print "Create algo",algoType
4222             return self.algoTypeToClass[ algoType ]( self.mesh, geom )
4223         raise RuntimeError, "No class found for algo type %s" % algoType
4224         return None
4225
4226 # Private class used to substitute and store variable parameters of hypotheses.
4227 #
4228 class hypMethodWrapper:
4229     def __init__(self, hyp, method):
4230         self.hyp    = hyp
4231         self.method = method
4232         #print "REBIND:", method.__name__
4233         return
4234
4235     # call a method of hypothesis with calling SetVarParameter() before
4236     def __call__(self,*args):
4237         if not args:
4238             return self.method( self.hyp, *args ) # hypothesis method with no args
4239
4240         #print "MethWrapper.__call__",self.method.__name__, args
4241         try:
4242             parsed = ParseParameters(*args)     # replace variables with their values
4243             self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
4244             result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
4245         except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
4246             # maybe there is a replaced string arg which is not variable
4247             result = self.method( self.hyp, *args )
4248         except ValueError, detail: # raised by ParseParameters()
4249             try:
4250                 result = self.method( self.hyp, *args )
4251             except omniORB.CORBA.BAD_PARAM:
4252                 raise ValueError, detail # wrong variable name
4253
4254         return result