Salome HOME
PAL13073 (Submesh hypothesises do not work for NETGEN 1D-2D-3D)
[modules/smesh.git] / src / SMESH_SWIG / smesh.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #  File   : smesh.py
21 #  Author : Francis KLOSS, OCC
22 #  Module : SMESH
23
24 """
25  \namespace smesh
26  \brief Module smesh
27 """
28
29 import salome
30 import geompy
31
32 import SMESH
33 from   SMESH import *
34
35 import StdMeshers
36
37 # import NETGENPlugin module if possible
38 noNETGENPlugin = 0
39 try:
40     import NETGENPlugin
41 except ImportError:
42     noNETGENPlugin = 1
43     pass
44     
45 # Types of algo
46 REGULAR = 1
47 PYTHON  = 2
48
49 MEFISTO = 3
50 NETGEN  = 4
51 GHS3D   = 5
52 FULL_NETGEN = 6
53
54 # MirrorType enumeration
55 POINT = SMESH_MeshEditor.POINT
56 AXIS =  SMESH_MeshEditor.AXIS 
57 PLANE = SMESH_MeshEditor.PLANE
58
59 # Smooth_Method enumeration
60 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
61 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
62
63 # Fineness enumeration(for NETGEN)
64 VeryCoarse = 0
65 Coarse = 1
66 Moderate = 2
67 Fine = 3
68 VeryFine = 4
69 Custom = 5
70
71
72 NO_NAME = "NoName"
73
74
75 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
76 smesh.SetCurrentStudy(salome.myStudy)
77
78 # Global functions
79
80 ## Gets object name
81 def GetName(obj):
82     ior  = salome.orb.object_to_string(obj)
83     sobj = salome.myStudy.FindObjectIOR(ior)
84     if sobj is None:
85         return NO_NAME
86     else:
87         attr = sobj.FindAttribute("AttributeName")[1]
88         return attr.Value()
89
90 ## Sets name to object
91 def SetName(obj, name):
92     ior  = salome.orb.object_to_string(obj)
93     sobj = salome.myStudy.FindObjectIOR(ior)
94     if not sobj is None:
95         attr = sobj.FindAttribute("AttributeName")[1]
96         attr.SetValue(name)
97         
98 ## Returns long value from enumeration
99 #  Uses for SMESH.FunctorType enumeration
100 def EnumToLong(theItem):
101     return theItem._v
102
103 ## Get PointStruct from vertex
104 #  @param theVertex is GEOM object(vertex)
105 #  @return SMESH.PointStruct
106 def GetPointStruct(theVertex):
107     [x, y, z] = geompy.PointCoordinates(theVertex)
108     return PointStruct(x,y,z)
109
110 ## Get DirStruct from vector
111 #  @param theVector is GEOM object(vector)
112 #  @return SMESH.DirStruct
113 def GetDirStruct(theVector):
114     vertices = geompy.SubShapeAll( theVector, geompy.ShapeType["VERTEX"] )
115     if(len(vertices) != 2):
116         print "Error: vector object is incorrect."
117         return None
118     p1 = geompy.PointCoordinates(vertices[0])
119     p2 = geompy.PointCoordinates(vertices[1])
120     pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
121     dir = DirStruct(pnt)
122     return dir
123
124 ## Get AxisStruct from object
125 #  @param theObj is GEOM object(line or plane)
126 #  @return SMESH.AxisStruct
127 def GetAxisStruct(theObj):
128     edges = geompy.SubShapeAll( theObj, geompy.ShapeType["EDGE"] )
129     if len(edges) > 1:
130         vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
131         vertex3, vertex4 = geompy.SubShapeAll( edges[1], geompy.ShapeType["VERTEX"] )
132         vertex1 = geompy.PointCoordinates(vertex1)
133         vertex2 = geompy.PointCoordinates(vertex2)
134         vertex3 = geompy.PointCoordinates(vertex3)
135         vertex4 = geompy.PointCoordinates(vertex4)
136         v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
137         v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
138         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] ]
139         axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
140         return axis
141     elif len(edges) == 1:
142         vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
143         p1 = geompy.PointCoordinates( vertex1 )
144         p2 = geompy.PointCoordinates( vertex2 )
145         axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
146         return axis
147     return None
148
149 # From SMESH_Gen interface:
150 # ------------------------
151
152 ## Set the current mode
153 def SetEmbeddedMode( theMode ):
154     smesh.SetEmbeddedMode(theMode)
155
156 ## Get the current mode
157 def IsEmbeddedMode():
158     return smesh.IsEmbeddedMode()
159
160 ## Set the current study
161 def SetCurrentStudy( theStudy ):
162     smesh.SetCurrentStudy(theStudy)
163
164 ## Get the current study
165 def GetCurrentStudy():
166     return smesh.GetCurrentStudy()
167
168 ## Create Mesh object importing data from given UNV file
169 #  @return an instance of Mesh class
170 def CreateMeshesFromUNV( theFileName ):
171     aSmeshMesh = smesh.CreateMeshesFromUNV(theFileName)
172     aMesh = Mesh(aSmeshMesh)
173     return aMesh
174
175 ## Create Mesh object(s) importing data from given MED file
176 #  @return a list of Mesh class instances
177 def CreateMeshesFromMED( theFileName ):
178     aSmeshMeshes, aStatus = smesh.CreateMeshesFromMED(theFileName)
179     aMeshes = []
180     for iMesh in range(len(aSmeshMeshes)) :
181         aMesh = Mesh(aSmeshMeshes[iMesh])
182         aMeshes.append(aMesh)
183     return aMeshes, aStatus
184
185 ## Create Mesh object importing data from given STL file
186 #  @return an instance of Mesh class
187 def CreateMeshesFromSTL( theFileName ):
188     aSmeshMesh = smesh.CreateMeshesFromSTL(theFileName)
189     aMesh = Mesh(aSmeshMesh)
190     return aMesh
191
192 ## From SMESH_Gen interface
193 def GetSubShapesId( theMainObject, theListOfSubObjects ):
194     return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
195
196 ## From SMESH_Gen interface. Creates pattern
197 def GetPattern():
198     return smesh.GetPattern()
199
200
201
202 # Filtering. Auxiliary functions:
203 # ------------------------------
204
205 ## Creates an empty criterion
206 #  @return SMESH.Filter.Criterion
207 def GetEmptyCriterion():
208     Type = EnumToLong(FT_Undefined)
209     Compare = EnumToLong(FT_Undefined)
210     Threshold = 0
211     ThresholdStr = ""
212     ThresholdID = ""
213     UnaryOp = EnumToLong(FT_Undefined)
214     BinaryOp = EnumToLong(FT_Undefined)
215     Tolerance = 1e-07
216     TypeOfElement = ALL
217     Precision = -1 ##@1e-07
218     return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
219                             UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
220       
221 ## Creates a criterion by given parameters
222 #  @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
223 #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
224 #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
225 #  @param Treshold is threshold value (range of ids as string, shape, numeric)
226 #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
227 #  @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
228 #                  FT_Undefined(must be for the last criterion in criteria)
229 #  @return SMESH.Filter.Criterion
230 def GetCriterion(elementType,
231                  CritType,
232                  Compare = FT_EqualTo,
233                  Treshold="",
234                  UnaryOp=FT_Undefined,
235                  BinaryOp=FT_Undefined):
236     aCriterion = GetEmptyCriterion()
237     aCriterion.TypeOfElement = elementType
238     aCriterion.Type = EnumToLong(CritType)
239         
240     aTreshold = Treshold
241         
242     if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
243         aCriterion.Compare = EnumToLong(Compare)
244     elif Compare == "=" or Compare == "==":
245         aCriterion.Compare = EnumToLong(FT_EqualTo)
246     elif Compare == "<":
247         aCriterion.Compare = EnumToLong(FT_LessThan)
248     elif Compare == ">":
249         aCriterion.Compare = EnumToLong(FT_MoreThan)
250     else:
251         aCriterion.Compare = EnumToLong(FT_EqualTo)
252         aTreshold = Compare
253
254     if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface, 
255                     FT_BelongToCylinder, FT_LyingOnGeom]:
256         # Check treshold
257         if isinstance(aTreshold, geompy.GEOM._objref_GEOM_Object):
258             aCriterion.ThresholdStr = GetName(aTreshold)
259             aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
260         else:
261             print "Error: Treshold should be a shape."
262             return None
263     elif CritType == FT_RangeOfIds:
264         # Check treshold
265         if isinstance(aTreshold, str):
266             aCriterion.ThresholdStr = aTreshold
267         else:
268             print "Error: Treshold should be a string."
269             return None
270     elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
271         # Here we don't need treshold
272         if aTreshold ==  FT_LogicalNOT:
273             aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
274         elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
275             aCriterion.BinaryOp = aTreshold
276     else:
277         # Check treshold
278         try:
279             aTreshold = float(aTreshold)
280             aCriterion.Threshold = aTreshold
281         except:
282             print "Error: Treshold should be a number."
283             return None
284
285     if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
286         aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
287
288     if Treshold in [FT_LogicalAND, FT_LogicalOR]:
289         aCriterion.BinaryOp = EnumToLong(Treshold)
290
291     if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
292         aCriterion.BinaryOp = EnumToLong(UnaryOp)
293
294     if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
295         aCriterion.BinaryOp = EnumToLong(BinaryOp)
296
297     return aCriterion
298
299 ## Creates filter by given parameters of criterion
300 #  @param elementType is the type of elements in the group
301 #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
302 #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
303 #  @param Treshold is threshold value (range of id ids as string, shape, numeric)
304 #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
305 #  @return SMESH_Filter
306 def GetFilter(elementType,
307               CritType=FT_Undefined,
308               Compare=FT_EqualTo,
309               Treshold="",
310               UnaryOp=FT_Undefined):
311     aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
312     aFilterMgr = smesh.CreateFilterManager()
313     aFilter = aFilterMgr.CreateFilter()
314     aCriteria = []
315     aCriteria.append(aCriterion)
316     aFilter.SetCriteria(aCriteria)
317     return aFilter
318
319 ## Creates numerical functor by its type
320 #  @param theCrierion is FT_...; functor type
321 #  @return SMESH_NumericalFunctor
322 def GetFunctor(theCriterion):
323     aFilterMgr = smesh.CreateFilterManager()
324     if theCriterion == FT_AspectRatio:
325         return aFilterMgr.CreateAspectRatio()
326     elif theCriterion == FT_AspectRatio3D:
327         return aFilterMgr.CreateAspectRatio3D()
328     elif theCriterion == FT_Warping:
329         return aFilterMgr.CreateWarping()
330     elif theCriterion == FT_MinimumAngle:
331         return aFilterMgr.CreateMinimumAngle()
332     elif theCriterion == FT_Taper:
333         return aFilterMgr.CreateTaper()
334     elif theCriterion == FT_Skew:
335         return aFilterMgr.CreateSkew()
336     elif theCriterion == FT_Area:
337         return aFilterMgr.CreateArea()
338     elif theCriterion == FT_Volume3D:
339         return aFilterMgr.CreateVolume3D()
340     elif theCriterion == FT_MultiConnection:
341         return aFilterMgr.CreateMultiConnection()
342     elif theCriterion == FT_MultiConnection2D:
343         return aFilterMgr.CreateMultiConnection2D()
344     elif theCriterion == FT_Length:
345         return aFilterMgr.CreateLength()
346     elif theCriterion == FT_Length2D:
347         return aFilterMgr.CreateLength2D()
348     else:
349         print "Error: given parameter is not numerucal functor type."
350
351
352 ## Private method. Print error message if a hypothesis was not assigned.
353 def TreatHypoStatus(status, hypName, geomName, isAlgo):
354     if isAlgo:
355         hypType = "algorithm"
356     else:
357         hypType = "hypothesis"
358         pass
359     if status == HYP_UNKNOWN_FATAL :
360         reason = "for unknown reason"
361     elif status == HYP_INCOMPATIBLE :
362         reason = "this hypothesis mismatches algorithm"
363     elif status == HYP_NOTCONFORM :
364         reason = "not conform mesh would be built"
365     elif status == HYP_ALREADY_EXIST :
366         reason = hypType + " of the same dimension already assigned to this shape"
367     elif status == HYP_BAD_DIM :
368         reason = hypType + " mismatches shape"
369     elif status == HYP_CONCURENT :
370         reason = "there are concurrent hypotheses on sub-shapes"
371     elif status == HYP_BAD_SUBSHAPE :
372         reason = "shape is neither the main one, nor its subshape, nor a valid group"
373     elif status == HYP_BAD_GEOMETRY:
374         reason = "geometry mismatches algorithm's expectation"
375     elif status == HYP_HIDDEN_ALGO:
376         reason = "it is hidden by an algorithm of upper dimension generating all-dimensions elements"
377     elif status == HYP_HIDING_ALGO:
378         reason = "it hides algorithm(s) of lower dimension by generating all-dimensions elements"
379     else:
380         return
381     hypName = '"' + hypName + '"'
382     geomName= '"' + geomName+ '"'
383     if status < HYP_UNKNOWN_FATAL:
384         print hypName, "was assigned to",    geomName,"but", reason
385     else:
386         print hypName, "was not assigned to",geomName,":", reason
387         pass
388
389     
390     
391 ## Mother class to define algorithm, recommended to don't use directly.
392 #
393 #  More details.
394 class Mesh_Algorithm:
395     #  @class Mesh_Algorithm
396     #  @brief Class Mesh_Algorithm
397
398     mesh = 0
399     geom = 0
400     subm = 0
401     algo = 0
402
403     ## If the algorithm is global, return 0; \n
404     #  else return the submesh associated to this algorithm.
405     def GetSubMesh(self):
406         return self.subm
407
408     ## Return the wrapped mesher.
409     def GetAlgorithm(self):
410         return self.algo
411
412     ## Get list of hypothesis that can be used with this algorithm
413     def GetCompatibleHypothesis(self):
414         list = []
415         if self.algo:
416             list = self.algo.GetCompatibleHypothesis()
417         return list
418
419     ## Get name of algo
420     def GetName(self):
421         GetName(self.algo)
422
423     ## Set name to algo
424     def SetName(self, name):
425         SetName(self.algo, name)
426
427     ## Get id of algo
428     def GetId(self):
429         return self.algo.GetId()
430     
431     ## Private method.
432     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
433         if geom is None:
434             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
435         self.mesh = mesh
436         piece = mesh.geom
437         if geom==0:
438             self.geom = piece
439             name = GetName(piece)
440         else:
441             self.geom = geom
442             name = GetName(geom)
443             if name==NO_NAME:
444                 name = geompy.SubShapeName(geom, piece)
445                 geompy.addToStudyInFather(piece, geom, name)
446             self.subm = mesh.mesh.GetSubMesh(geom, hypo)
447
448         self.algo = smesh.CreateHypothesis(hypo, so)
449         SetName(self.algo, name + "/" + hypo)
450         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
451         TreatHypoStatus( status, hypo, name, 1 )
452         
453     ## Private method
454     def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
455         hypo = smesh.CreateHypothesis(hyp, so)
456         a = ""
457         s = "="
458         i = 0
459         n = len(args)
460         while i<n:
461             a = a + s + str(args[i])
462             s = ","
463             i = i + 1
464         name = GetName(self.geom)
465         SetName(hypo, name + "/" + hyp + a)
466         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
467         TreatHypoStatus( status, hyp, name, 0 )
468         return hypo
469
470
471 # Public class: Mesh_Segment
472 # --------------------------
473
474 ## Class to define a segment 1D algorithm for discretization
475 #
476 #  More details.
477 class Mesh_Segment(Mesh_Algorithm):
478
479     ## Private constructor.
480     def __init__(self, mesh, geom=0):
481         self.Create(mesh, geom, "Regular_1D")
482         
483     ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
484     #  @param l for the length of segments that cut an edge
485     def LocalLength(self, l):
486         hyp = self.Hypothesis("LocalLength", [l])
487         hyp.SetLength(l)
488         return hyp
489         
490     ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
491     #  @param n for the number of segments that cut an edge
492     #  @param s for the scale factor (optional)
493     def NumberOfSegments(self, n, s=[]):
494         if s == []:
495             hyp = self.Hypothesis("NumberOfSegments", [n])
496         else:
497             hyp = self.Hypothesis("NumberOfSegments", [n,s])
498             hyp.SetDistrType( 1 )
499             hyp.SetScaleFactor(s)
500         hyp.SetNumberOfSegments(n)
501         return hyp
502         
503     ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
504     #  @param start for the length of the first segment
505     #  @param end   for the length of the last  segment
506     def Arithmetic1D(self, start, end):
507         hyp = self.Hypothesis("Arithmetic1D", [start, end])
508         hyp.SetLength(start, 1)
509         hyp.SetLength(end  , 0)
510         return hyp
511         
512     ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
513     #  @param start for the length of the first segment
514     #  @param end   for the length of the last  segment
515     def StartEndLength(self, start, end):
516         hyp = self.Hypothesis("StartEndLength", [start, end])
517         hyp.SetLength(start, 1)
518         hyp.SetLength(end  , 0)
519         return hyp
520         
521     ## Define "Deflection1D" hypothesis
522     #  @param d for the deflection
523     def Deflection1D(self, d):
524         hyp = self.Hypothesis("Deflection1D", [d])
525         hyp.SetDeflection(d)
526         return hyp
527         
528     ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
529     #  the opposite side in the case of quadrangular faces
530     def Propagation(self):
531         return self.Hypothesis("Propagation")
532
533     ## Define "AutomaticLength" hypothesis
534     #  @param fineness for the fineness [0-1]
535     def AutomaticLength(self, fineness=0):
536         hyp = self.Hypothesis("AutomaticLength")
537         hyp.SetFineness( fineness )
538         return hyp
539
540     ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
541     #  If the 2D mesher sees that all boundary edges are quadratic ones,
542     #  it generates quadratic faces, else it generates linear faces using
543     #  medium nodes as if they were vertex ones.
544     #  The 3D mesher generates quadratic volumes only if all boundary faces
545     #  are quadratic ones, else it fails.
546     def QuadraticMesh(self):
547         hyp = self.Hypothesis("QuadraticMesh")
548         return hyp
549
550 # Public class: Mesh_Segment_Python
551 # ---------------------------------
552
553 ## Class to define a segment 1D algorithm for discretization with python function
554 #
555 #  More details.
556 class Mesh_Segment_Python(Mesh_Segment):
557
558     ## Private constructor.
559     def __init__(self, mesh, geom=0):
560         import Python1dPlugin
561         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
562     
563     ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
564     #  @param n for the number of segments that cut an edge
565     #  @param func for the python function that calculate the length of all segments
566     def PythonSplit1D(self, n, func):
567         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so")
568         hyp.SetNumberOfSegments(n)
569         hyp.SetPythonLog10RatioFunction(func)
570         return hyp
571         
572 # Public class: Mesh_Triangle
573 # ---------------------------
574
575 ## Class to define a triangle 2D algorithm
576 #
577 #  More details.
578 class Mesh_Triangle(Mesh_Algorithm):
579
580     algoType = 0
581     params = 0
582    
583     ## Private constructor.
584     def __init__(self, mesh, algoType, geom=0):
585         if algoType == MEFISTO:
586             self.Create(mesh, geom, "MEFISTO_2D")
587         elif algoType == NETGEN:
588             if noNETGENPlugin:
589                 print "Warning: NETGENPlugin module has not been imported."
590             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
591         self.algoType = algoType
592
593     ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
594     #  @param area for the maximum area of each triangles
595     def MaxElementArea(self, area):
596         if self.algoType == MEFISTO:
597             hyp = self.Hypothesis("MaxElementArea", [area])
598             hyp.SetMaxElementArea(area)
599             return hyp
600         elif self.algoType == NETGEN:
601             print "Netgen 1D-2D algo doesn't support this hypothesis"
602             return None
603             
604     ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
605     def LengthFromEdges(self):
606         if self.algoType == MEFISTO:
607             hyp = self.Hypothesis("LengthFromEdges")
608             return hyp
609         elif self.algoType == NETGEN:
610             print "Netgen 1D-2D algo doesn't support this hypothesis"
611             return None
612         
613     ## Define "Netgen 2D Parameters" hypothesis
614     def Parameters(self):
615         if self.algoType == NETGEN:
616             self.params = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
617             return self.params
618         elif self.algoType == MEFISTO:
619             print "Mefisto algo doesn't support this hypothesis"
620             return None
621
622     ## Set MaxSize
623     def SetMaxSize(self, theSize):
624         if self.params == 0:
625             self.Parameters()
626         self.params.SetMaxSize(theSize)
627         
628     ## Set SecondOrder flag
629     def SetSecondOrder(seld, theVal):
630         if self.params == 0:
631             self.Parameters()
632         self.params.SetSecondOrder(theVal)
633
634     ## Set Optimize flag
635     def SetOptimize(self, theVal):
636         if self.params == 0:
637             self.Parameters()
638         self.params.SetOptimize(theVal)
639
640     ## Set Fineness
641     #  @param theFineness is:
642     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
643     def SetFineness(self, theFineness):
644         if self.params == 0:
645             self.Parameters()
646         self.params.SetFineness(theFineness)
647         
648     ## Set GrowthRate  
649     def SetGrowthRate(self, theRate):
650         if self.params == 0:
651             self.Parameters()
652         self.params.SetGrowthRate(theRate)
653
654     ## Set NbSegPerEdge
655     def SetNbSegPerEdge(self, theVal):
656         if self.params == 0:
657             self.Parameters()
658         self.params.SetNbSegPerEdge(theVal)
659
660     ## Set NbSegPerRadius
661     def SetNbSegPerRadius(self, theVal):
662         if self.params == 0:
663             self.Parameters()
664         self.params.SetNbSegPerRadius(theVal)
665
666     ## Set QuadAllowed flag
667     def SetQuadAllowed(self, toAllow):
668         if self.params == 0:
669             self.Parameters()
670         self.params.SetQuadAllowed(toAllow)
671         
672     
673 # Public class: Mesh_Quadrangle
674 # -----------------------------
675
676 ## Class to define a quadrangle 2D algorithm
677 #
678 #  More details.
679 class Mesh_Quadrangle(Mesh_Algorithm):
680
681     ## Private constructor.
682     def __init__(self, mesh, geom=0):
683         self.Create(mesh, geom, "Quadrangle_2D")
684     
685     ## Define "QuadranglePreference" hypothesis, forcing construction
686     #  of quadrangles if the number of nodes on opposite edges is not the same
687     #  in the case where the global number of nodes on edges is even
688     def QuadranglePreference(self):
689         hyp = self.Hypothesis("QuadranglePreference")
690         return hyp
691     
692 # Public class: Mesh_Tetrahedron
693 # ------------------------------
694
695 ## Class to define a tetrahedron 3D algorithm
696 #
697 #  More details.
698 class Mesh_Tetrahedron(Mesh_Algorithm):
699
700     params = 0
701     algoType = 0
702
703     ## Private constructor.
704     def __init__(self, mesh, algoType, geom=0):
705         if algoType == NETGEN:
706             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
707         elif algoType == GHS3D:
708             import GHS3DPlugin
709             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
710         elif algoType == FULL_NETGEN:
711             if noNETGENPlugin:
712                 print "Warning: NETGENPlugin module has not been imported."
713             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
714         self.algoType = algoType
715
716     ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
717     #  @param vol for the maximum volume of each tetrahedral
718     def MaxElementVolume(self, vol):
719         hyp = self.Hypothesis("MaxElementVolume", [vol])
720         hyp.SetMaxElementVolume(vol)
721         return hyp
722
723     ## Define "Netgen 3D Parameters" hypothesis
724     def Parameters(self):
725         if (self.algoType == FULL_NETGEN):
726             self.params = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
727             return self.params
728         else:
729             print "Algo doesn't support this hypothesis"
730             return None 
731             
732     ## Set MaxSize
733     def SetMaxSize(self, theSize):
734         if self.params == 0:
735             self.Parameters()
736         self.params.SetMaxSize(theSize)
737         
738     ## Set SecondOrder flag
739     def SetSecondOrder(self, theVal):
740         if self.params == 0:
741             self.Parameters()
742         self.params.SetSecondOrder(theVal)
743
744     ## Set Optimize flag
745     def SetOptimize(self, theVal):
746         if self.params == 0:
747             self.Parameters()
748         self.params.SetOptimize(theVal)
749
750     ## Set Fineness
751     #  @param theFineness is:
752     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
753     def SetFineness(self, theFineness):
754         if self.params == 0:
755             self.Parameters()
756         self.params.SetFineness(theFineness)
757         
758     ## Set GrowthRate  
759     def SetGrowthRate(self, theRate):
760         if self.params == 0:
761             self.Parameters()
762         self.params.SetGrowthRate(theRate)
763
764     ## Set NbSegPerEdge
765     def SetNbSegPerEdge(self, theVal):
766         if self.params == 0:
767             self.Parameters()
768         self.params.SetNbSegPerEdge(theVal)
769
770     ## Set NbSegPerRadius
771     def SetNbSegPerRadius(self, theVal):
772         if self.params == 0:
773             self.Parameters()
774         self.params.SetNbSegPerRadius(theVal)
775
776 # Public class: Mesh_Hexahedron
777 # ------------------------------
778
779 ## Class to define a hexahedron 3D algorithm
780 #
781 #  More details.
782 class Mesh_Hexahedron(Mesh_Algorithm):
783
784     ## Private constructor.
785     def __init__(self, mesh, geom=0):
786         self.Create(mesh, geom, "Hexa_3D")
787
788 # Deprecated, only for compatibility!
789 # Public class: Mesh_Netgen
790 # ------------------------------
791
792 ## Class to define a NETGEN-based 2D or 3D algorithm
793 #  that need no discrete boundary (i.e. independent)
794 #
795 #  This class is deprecated, only for compatibility!
796 #
797 #  More details.
798 class Mesh_Netgen(Mesh_Algorithm):
799
800     is3D = 0
801
802     ## Private constructor.
803     def __init__(self, mesh, is3D, geom=0):
804         if noNETGENPlugin:
805             print "Warning: NETGENPlugin module has not been imported."
806             
807         self.is3D = is3D
808         if is3D:
809             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
810         else:
811             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
812
813     ## Define hypothesis containing parameters of the algorithm
814     def Parameters(self):
815         if self.is3D:
816             hyp = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
817         else:
818             hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
819         return hyp
820
821 # Public class: Mesh_Projection1D
822 # ------------------------------
823
824 ## Class to define a projection 1D algorithm
825 #
826 #  More details.
827 class Mesh_Projection1D(Mesh_Algorithm):
828
829     ## Private constructor.
830     def __init__(self, mesh, geom=0):
831         self.Create(mesh, geom, "Projection_1D")
832
833     ## Define "Source Edge" hypothesis, specifying a meshed edge to
834     #  take a mesh pattern from, and optionally association of vertices
835     #  between the source edge and a target one (where a hipothesis is assigned to)
836     #  @param edge to take nodes distribution from
837     #  @param mesh to take nodes distribution from (optional)
838     #  @param srcV is vertex of \a edge to associate with \a tgtV (optional)
839     #  @param tgtV is vertex of \a the edge where the algorithm is assigned,
840     #  to associate with \a srcV (optional)
841     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None):
842         hyp = self.Hypothesis("ProjectionSource1D")
843         hyp.SetSourceEdge( edge )
844         if not mesh is None and isinstance(mesh, Mesh):
845             mesh = mesh.GetMesh()
846         hyp.SetSourceMesh( mesh )
847         hyp.SetVertexAssociation( srcV, tgtV )
848         return hyp
849
850
851 # Public class: Mesh_Projection2D
852 # ------------------------------
853
854 ## Class to define a projection 2D algorithm
855 #
856 #  More details.
857 class Mesh_Projection2D(Mesh_Algorithm):
858
859     ## Private constructor.
860     def __init__(self, mesh, geom=0):
861         self.Create(mesh, geom, "Projection_2D")
862
863     ## Define "Source Face" hypothesis, specifying a meshed face to
864     #  take a mesh pattern from, and optionally association of vertices
865     #  between the source face and a target one (where a hipothesis is assigned to)
866     #  @param face to take mesh pattern from
867     #  @param mesh to take mesh pattern from (optional)
868     #  @param srcV1 is vertex of \a face to associate with \a tgtV1 (optional)
869     #  @param tgtV1 is vertex of \a the face where the algorithm is assigned,
870     #  to associate with \a srcV1 (optional)
871     #  @param srcV2 is vertex of \a face to associate with \a tgtV1 (optional)
872     #  @param tgtV2 is vertex of \a the face where the algorithm is assigned,
873     #  to associate with \a srcV2 (optional)
874     #
875     #  Note: association vertices must belong to one edge of a face
876     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None, srcV2=None, tgtV2=None):
877         hyp = self.Hypothesis("ProjectionSource2D")
878         hyp.SetSourceFace( face )
879         if not mesh is None and isinstance(mesh, Mesh):
880             mesh = mesh.GetMesh()
881         hyp.SetSourceMesh( mesh )
882         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
883         return hyp
884
885 # Public class: Mesh_Projection3D
886 # ------------------------------
887
888 ## Class to define a projection 3D algorithm
889 #
890 #  More details.
891 class Mesh_Projection3D(Mesh_Algorithm):
892
893     ## Private constructor.
894     def __init__(self, mesh, geom=0):
895         self.Create(mesh, geom, "Projection_3D")
896
897     ## Define "Source Shape 3D" hypothesis, specifying a meshed solid to
898     #  take a mesh pattern from, and optionally association of vertices
899     #  between the source solid and a target one (where a hipothesis is assigned to)
900     #  @param solid to take mesh pattern from
901     #  @param mesh to take mesh pattern from (optional)
902     #  @param srcV1 is vertex of \a solid to associate with \a tgtV1 (optional)
903     #  @param tgtV1 is vertex of \a the solid where the algorithm is assigned,
904     #  to associate with \a srcV1 (optional)
905     #  @param srcV2 is vertex of \a solid to associate with \a tgtV1 (optional)
906     #  @param tgtV2 is vertex of \a the solid where the algorithm is assigned,
907     #  to associate with \a srcV2 (optional)
908     #
909     #  Note: association vertices must belong to one edge of a solid
910     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0, srcV2=0, tgtV2=0):
911         hyp = self.Hypothesis("ProjectionSource3D")
912         hyp.SetSource3DShape( solid )
913         if not mesh is None and isinstance(mesh, Mesh):
914             mesh = mesh.GetMesh()
915         hyp.SetSourceMesh( mesh )
916         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
917         return hyp
918
919
920 # Public class: Mesh_Prism
921 # ------------------------
922
923 ## Class to define a Prism 3D algorithm
924 #
925 #  More details.
926 class Mesh_Prism3D(Mesh_Algorithm):
927
928     ## Private constructor.
929     def __init__(self, mesh, geom=0):
930         self.Create(mesh, geom, "Prism_3D")
931
932 # Public class: Mesh_RadialPrism
933 # -------------------------------
934
935 ## Class to define a Radial Prism 3D algorithm
936 #
937 #  More details.
938 class Mesh_RadialPrism3D(Mesh_Algorithm):
939
940     ## Private constructor.
941     def __init__(self, mesh, geom=0):
942         self.Create(mesh, geom, "RadialPrism_3D")
943         self.distribHyp = self.Hypothesis( "LayerDistribution" )
944         self.nbLayers = None
945
946     ## Return 3D hypothesis holding the 1D one
947     def Get3DHypothesis(self):
948         return self.distribHyp
949
950     ## Private method creating 1D hypothes and storing it in the LayerDistribution
951     #  hypothes. Returns the created hypothes
952     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
953         if not self.nbLayers is None:
954             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
955             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
956         study = GetCurrentStudy() # prevent publishing of own 1D hypothesis
957         hyp = smesh.CreateHypothesis(hypType, so)
958         SetCurrentStudy( study ) # anable publishing
959         self.distribHyp.SetLayerDistribution( hyp )
960         return hyp
961
962     ## Define "NumberOfLayers" hypothesis, specifying a number of layers of
963     #  prisms to build between the inner and outer shells
964     def NumberOfLayers(self, n ):
965         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
966         self.nbLayers = self.Hypothesis("NumberOfLayers")
967         self.nbLayers.SetNumberOfLayers( n )
968         return self.nbLayers
969
970     ## Define "LocalLength" hypothesis, specifying segment length
971     #  to build between the inner and outer shells
972     #  @param l for the length of segments
973     def LocalLength(self, l):
974         hyp = self.OwnHypothesis("LocalLength", [l])
975         hyp.SetLength(l)
976         return hyp
977         
978     ## Define "NumberOfSegments" hypothesis, specifying a number of layers of
979     #  prisms to build between the inner and outer shells
980     #  @param n for the number of segments
981     #  @param s for the scale factor (optional)
982     def NumberOfSegments(self, n, s=[]):
983         if s == []:
984             hyp = self.OwnHypothesis("NumberOfSegments", [n])
985         else:
986             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
987             hyp.SetDistrType( 1 )
988             hyp.SetScaleFactor(s)
989         hyp.SetNumberOfSegments(n)
990         return hyp
991         
992     ## Define "Arithmetic1D" hypothesis, specifying distribution of segments
993     #  to build between the inner and outer shells as arithmetic length increasing
994     #  @param start for the length of the first segment
995     #  @param end   for the length of the last  segment
996     def Arithmetic1D(self, start, end):
997         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
998         hyp.SetLength(start, 1)
999         hyp.SetLength(end  , 0)
1000         return hyp
1001         
1002     ## Define "StartEndLength" hypothesis, specifying distribution of segments
1003     #  to build between the inner and outer shells as geometric length increasing
1004     #  @param start for the length of the first segment
1005     #  @param end   for the length of the last  segment
1006     def StartEndLength(self, start, end):
1007         hyp = self.OwnHypothesis("StartEndLength", [start, end])
1008         hyp.SetLength(start, 1)
1009         hyp.SetLength(end  , 0)
1010         return hyp
1011         
1012     ## Define "AutomaticLength" hypothesis, specifying number of segments
1013     #  to build between the inner and outer shells
1014     #  @param fineness for the fineness [0-1]
1015     def AutomaticLength(self, fineness=0):
1016         hyp = self.OwnHypothesis("AutomaticLength")
1017         hyp.SetFineness( fineness )
1018         return hyp
1019
1020
1021 # Public class: Mesh
1022 # ==================
1023
1024 ## Class to define a mesh
1025 #
1026 #  The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
1027 #  More details.
1028 class Mesh:
1029
1030     geom = 0
1031     mesh = 0
1032     editor = 0
1033
1034     ## Constructor
1035     #
1036     #  Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
1037     #  sets GUI name of this mesh to \a name.
1038     #  @param obj Shape to be meshed or SMESH_Mesh object
1039     #  @param name Study name of the mesh
1040     def __init__(self, obj=0, name=0):
1041         if obj is None:
1042             obj = 0
1043         if obj != 0:
1044             if isinstance(obj, geompy.GEOM._objref_GEOM_Object):
1045                 self.geom = obj
1046                 self.mesh = smesh.CreateMesh(self.geom)
1047             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1048                 self.SetMesh(obj)
1049         else:
1050             self.mesh = smesh.CreateEmptyMesh()
1051         if name != 0:
1052             SetName(self.mesh, name)
1053         elif obj != 0:
1054             SetName(self.mesh, GetName(obj))
1055
1056         self.editor = self.mesh.GetMeshEditor()
1057
1058     ## Method that inits the Mesh object from SMESH_Mesh interface
1059     #  @param theMesh is SMESH_Mesh object
1060     def SetMesh(self, theMesh):
1061         self.mesh = theMesh
1062         self.geom = self.mesh.GetShapeToMesh()
1063             
1064     ## Method that returns the mesh
1065     #  @return SMESH_Mesh object
1066     def GetMesh(self):
1067         return self.mesh
1068
1069     ## Get mesh name
1070     def GetName(self):
1071         name = GetName(self.GetMesh())
1072         return name
1073
1074     ## Set name to mesh
1075     def SetName(self, name):
1076         SetName(self.GetMesh(), name)
1077     
1078     ## Get the subMesh object associated to a subShape. The subMesh object
1079     #  gives access to nodes and elements IDs.
1080     #  \n SubMesh will be used instead of SubShape in a next idl version to
1081     #  adress a specific subMesh...
1082     def GetSubMesh(self, theSubObject, name):
1083         submesh = self.mesh.GetSubMesh(theSubObject, name)
1084         return submesh
1085         
1086     ## Method that returns the shape associated to the mesh
1087     #  @return GEOM_Object
1088     def GetShape(self):
1089         return self.geom
1090
1091     ## Method that associates given shape to the mesh(entails the mesh recreation)
1092     #  @param geom shape to be meshed(GEOM_Object)
1093     def SetShape(self, geom):
1094         self.mesh = smesh.CreateMesh(geom)  
1095                 
1096     ## Return true if hypotheses are defined well
1097     #  @param theMesh is an instance of Mesh class
1098     #  @param theSubObject subshape of a mesh shape
1099     def IsReadyToCompute(self, theSubObject):
1100         return smesh.IsReadyToCompute(self.mesh, theSubObject)
1101
1102     ## Return errors of hypotheses definintion
1103     #  error list is empty if everything is OK
1104     #  @param theMesh is an instance of Mesh class
1105     #  @param theSubObject subshape of a mesh shape
1106     #  @return a list of errors
1107     def GetAlgoState(self, theSubObject):
1108         return smesh.GetAlgoState(self.mesh, theSubObject)
1109     
1110     ## Return geometrical object the given element is built on.
1111     #  The returned geometrical object, if not nil, is either found in the 
1112     #  study or is published by this method with the given name
1113     #  @param theMesh is an instance of Mesh class
1114     #  @param theElementID an id of the mesh element
1115     #  @param theGeomName user defined name of geometrical object
1116     #  @return GEOM::GEOM_Object instance
1117     def GetGeometryByMeshElement(self, theElementID, theGeomName):
1118         return smesh.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1119         
1120     ## Returns mesh dimension depending on shape one
1121     def MeshDimension(self):
1122         shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] )
1123         if len( shells ) > 0 :
1124             return 3
1125         elif geompy.NumberOfFaces( self.geom ) > 0 :
1126             return 2
1127         elif geompy.NumberOfEdges( self.geom ) > 0 :
1128             return 1
1129         else:
1130             return 0;
1131         pass
1132         
1133     ## Creates a segment discretization 1D algorithm.
1134     #  If the optional \a algo parameter is not sets, this algorithm is REGULAR.
1135     #  If the optional \a geom parameter is not sets, this algorithm is global.
1136     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1137     #  @param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
1138     #  @param geom If defined, subshape to be meshed
1139     def Segment(self, algo=REGULAR, geom=0):
1140         ## if Segment(geom) is called by mistake
1141         if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1142             algo, geom = geom, algo
1143             pass
1144         if algo == REGULAR:
1145             return Mesh_Segment(self, geom)
1146         elif algo == PYTHON:
1147             return Mesh_Segment_Python(self, geom)
1148         else:
1149             return Mesh_Segment(self, geom)
1150         
1151     ## Creates a triangle 2D algorithm for faces.
1152     #  If the optional \a geom parameter is not sets, this algorithm is global.
1153     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1154     #  @param algo values are: smesh.MEFISTO or smesh.NETGEN
1155     #  @param geom If defined, subshape to be meshed
1156     def Triangle(self, algo=MEFISTO, geom=0):
1157         ## if Triangle(geom) is called by mistake
1158         if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1159             geom = algo
1160             algo = MEFISTO
1161         
1162         return Mesh_Triangle(self, algo, geom)
1163         
1164     ## Creates a quadrangle 2D algorithm for faces.
1165     #  If the optional \a geom parameter is not sets, this algorithm is global.
1166     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1167     #  @param geom If defined, subshape to be meshed
1168     def Quadrangle(self, geom=0):
1169         return Mesh_Quadrangle(self, geom)
1170
1171     ## Creates a tetrahedron 3D algorithm for solids.
1172     #  The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
1173     #  If the optional \a geom parameter is not sets, this algorithm is global.
1174     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1175     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
1176     #  @param geom If defined, subshape to be meshed
1177     def Tetrahedron(self, algo=NETGEN, geom=0):
1178         ## if Tetrahedron(geom) is called by mistake
1179         if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
1180             algo, geom = geom, algo
1181             pass
1182         return Mesh_Tetrahedron(self, algo, geom)
1183         
1184     ## Creates a hexahedron 3D algorithm for solids.
1185     #  If the optional \a geom parameter is not sets, this algorithm is global.
1186     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1187     #  @param geom If defined, subshape to be meshed
1188     def Hexahedron(self, geom=0):
1189         return Mesh_Hexahedron(self, geom)
1190
1191     ## Deprecated, only for compatibility!
1192     def Netgen(self, is3D, geom=0):
1193         return Mesh_Netgen(self, is3D, geom)
1194
1195     ## Creates a projection 1D algorithm for edges.
1196     #  If the optional \a geom parameter is not sets, this algorithm is global.
1197     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1198     #  @param geom If defined, subshape to be meshed
1199     def Projection1D(self, geom=0):
1200         return Mesh_Projection1D(self, geom)
1201
1202     ## Creates a projection 2D algorithm for faces.
1203     #  If the optional \a geom parameter is not sets, this algorithm is global.
1204     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1205     #  @param geom If defined, subshape to be meshed
1206     def Projection2D(self, geom=0):
1207         return Mesh_Projection2D(self, geom)
1208
1209     ## Creates a projection 3D algorithm for solids.
1210     #  If the optional \a geom parameter is not sets, this algorithm is global.
1211     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1212     #  @param geom If defined, subshape to be meshed
1213     def Projection3D(self, geom=0):
1214         return Mesh_Projection3D(self, geom)
1215
1216     ## Creates a Prism 3D or RadialPrism 3D algorithm for solids.
1217     #  If the optional \a geom parameter is not sets, this algorithm is global.
1218     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1219     #  @param geom If defined, subshape to be meshed
1220     def Prism(self, geom=0):
1221         shape = geom
1222         if shape==0:
1223             shape = self.geom
1224         nbSolids = len( geompy.SubShapeAll( shape, geompy.ShapeType["SOLID"] ))
1225         nbShells = len( geompy.SubShapeAll( shape, geompy.ShapeType["SHELL"] ))
1226         if nbSolids == 0 or nbSolids == nbShells:
1227             return Mesh_Prism3D(self, geom)
1228         return Mesh_RadialPrism3D(self, geom)
1229
1230     ## Compute the mesh and return the status of the computation
1231     def Compute(self, geom=0):
1232         if geom == 0 or not isinstance(geom, geompy.GEOM._objref_GEOM_Object):
1233             if self.geom == 0:
1234                 print "Compute impossible: mesh is not constructed on geom shape."
1235                 return 0
1236             else:
1237                 geom = self.geom
1238         ok = smesh.Compute(self.mesh, geom)
1239         if not ok:
1240             errors = smesh.GetAlgoState( self.mesh, geom )
1241             allReasons = ""
1242             for err in errors:
1243                 if err.isGlobalAlgo:
1244                     glob = " global "
1245                 else:
1246                     glob = " local "
1247                     pass
1248                 dim = str(err.algoDim)
1249                 if err.name == MISSING_ALGO:
1250                     reason = glob + dim + "D algorithm is missing"
1251                 elif err.name == MISSING_HYPO:
1252                     name = '"' + err.algoName + '"'
1253                     reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
1254                 elif err.name == NOT_CONFORM_MESH:
1255                     reason = "Global \"Not Conform mesh allowed\" hypothesis is missing"
1256                 elif err.name == BAD_PARAM_VALUE:
1257                     name = '"' + err.algoName + '"'
1258                     reason = "Hypothesis of" + glob + dim + "D algorithm " + name +\
1259                              " has a bad parameter value"
1260                 else:
1261                     reason = "For unknown reason."+\
1262                              " Revise Mesh.Compute() implementation in smesh.py!"
1263                     pass
1264                 if allReasons != "":
1265                     allReasons += "\n"
1266                     pass
1267                 allReasons += reason
1268                 pass
1269             if allReasons != "":
1270                 print '"' + GetName(self.mesh) + '"',"not computed:"
1271                 print allReasons
1272                 pass
1273             pass
1274         if salome.sg.hasDesktop():
1275             smeshgui = salome.ImportComponentGUI("SMESH")
1276             smeshgui.Init(salome.myStudyId)
1277             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok )
1278             salome.sg.updateObjBrowser(1)
1279             pass
1280         return ok
1281
1282     ## Compute tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1283     #  The parameter \a fineness [0,-1] defines mesh fineness
1284     def AutomaticTetrahedralization(self, fineness=0):
1285         dim = self.MeshDimension()
1286         # assign hypotheses
1287         self.RemoveGlobalHypotheses()
1288         self.Segment().AutomaticLength(fineness)
1289         if dim > 1 :
1290             self.Triangle().LengthFromEdges()
1291             pass
1292         if dim > 2 :
1293             self.Tetrahedron(NETGEN)
1294             pass
1295         return self.Compute()
1296         
1297     ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1298     #  The parameter \a fineness [0,-1] defines mesh fineness
1299     def AutomaticHexahedralization(self, fineness=0):
1300         dim = self.MeshDimension()
1301         # assign hypotheses
1302         self.RemoveGlobalHypotheses()
1303         self.Segment().AutomaticLength(fineness)
1304         if dim > 1 :
1305             self.Quadrangle()
1306             pass
1307         if dim > 2 :
1308             self.Hexahedron()            
1309             pass
1310         return self.Compute()
1311     
1312     ## Get the list of hypothesis added on a geom
1313     #  @param geom is subhape of mesh geometry
1314     def GetHypothesisList(self, geom):
1315         return self.mesh.GetHypothesisList( geom )
1316                 
1317     ## Removes all global hypotheses
1318     def RemoveGlobalHypotheses(self):
1319         current_hyps = self.mesh.GetHypothesisList( self.geom )
1320         for hyp in current_hyps:
1321             self.mesh.RemoveHypothesis( self.geom, hyp )
1322             pass
1323         pass
1324         
1325     ## Create a mesh group based on geometric object \a grp
1326     #  and give a \a name, \n if this parameter is not defined
1327     #  the name is the same as the geometric group name \n
1328     #  Note: Works like GroupOnGeom(). 
1329     #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
1330     #  @param name is the name of the mesh group
1331     #  @return SMESH_GroupOnGeom
1332     def Group(self, grp, name=""):
1333         return self.GroupOnGeom(grp, name)
1334        
1335     ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
1336     #  Export the mesh in a file with the MED format and choice the \a version of MED format
1337     #  @param f is the file name
1338     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1339     def ExportToMED(self, f, version, opt=0):
1340         self.mesh.ExportToMED(f, opt, version)
1341         
1342     ## Export the mesh in a file with the MED format
1343     #  @param f is the file name
1344     #  @param auto_groups boolean parameter for creating/not creating
1345     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1346     #  the typical use is auto_groups=false.
1347     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1348     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1349         self.mesh.ExportToMED(f, auto_groups, version)
1350         
1351     ## Export the mesh in a file with the DAT format
1352     #  @param f is the file name
1353     def ExportDAT(self, f):
1354         self.mesh.ExportDAT(f)
1355         
1356     ## Export the mesh in a file with the UNV format
1357     #  @param f is the file name
1358     def ExportUNV(self, f):
1359         self.mesh.ExportUNV(f)
1360         
1361     ## Export the mesh in a file with the STL format
1362     #  @param f is the file name
1363     #  @param ascii defined the kind of file contents
1364     def ExportSTL(self, f, ascii=1):
1365         self.mesh.ExportSTL(f, ascii)
1366    
1367         
1368     # Operations with groups:
1369     # ----------------------
1370
1371     ## Creates an empty mesh group
1372     #  @param elementType is the type of elements in the group
1373     #  @param name is the name of the mesh group
1374     #  @return SMESH_Group
1375     def CreateEmptyGroup(self, elementType, name):
1376         return self.mesh.CreateGroup(elementType, name)
1377     
1378     ## Creates a mesh group based on geometric object \a grp
1379     #  and give a \a name, \n if this parameter is not defined
1380     #  the name is the same as the geometric group name
1381     #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
1382     #  @param name is the name of the mesh group
1383     #  @return SMESH_GroupOnGeom
1384     def GroupOnGeom(self, grp, name="", type=None):
1385         if name == "":
1386             name = grp.GetName()
1387
1388         if type == None:
1389             tgeo = str(grp.GetShapeType())
1390             if tgeo == "VERTEX":
1391                 type = NODE
1392             elif tgeo == "EDGE":
1393                 type = EDGE
1394             elif tgeo == "FACE":
1395                 type = FACE
1396             elif tgeo == "SOLID":
1397                 type = VOLUME
1398             elif tgeo == "SHELL":
1399                 type = VOLUME
1400             elif tgeo == "COMPOUND":
1401                 if len( geompy.GetObjectIDs( grp )) == 0:
1402                     print "Mesh.Group: empty geometric group", GetName( grp )
1403                     return 0
1404                 tgeo = geompy.GetType(grp)
1405                 if tgeo == geompy.ShapeType["VERTEX"]:
1406                     type = NODE
1407                 elif tgeo == geompy.ShapeType["EDGE"]:
1408                     type = EDGE
1409                 elif tgeo == geompy.ShapeType["FACE"]:
1410                     type = FACE
1411                 elif tgeo == geompy.ShapeType["SOLID"]:
1412                     type = VOLUME
1413
1414         if type == None:
1415             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1416             return 0
1417         else:
1418             return self.mesh.CreateGroupFromGEOM(type, name, grp)
1419
1420     ## Create a mesh group by the given ids of elements
1421     #  @param groupName is the name of the mesh group
1422     #  @param elementType is the type of elements in the group
1423     #  @param elemIDs is the list of ids
1424     #  @return SMESH_Group
1425     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1426         group = self.mesh.CreateGroup(elementType, groupName)
1427         group.Add(elemIDs)
1428         return group
1429     
1430     ## Create a mesh group by the given conditions
1431     #  @param groupName is the name of the mesh group
1432     #  @param elementType is the type of elements in the group
1433     #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1434     #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1435     #  @param Treshold is threshold value (range of id ids as string, shape, numeric)
1436     #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
1437     #  @return SMESH_Group
1438     def MakeGroup(self,
1439                   groupName,
1440                   elementType,
1441                   CritType=FT_Undefined,
1442                   Compare=FT_EqualTo,
1443                   Treshold="",
1444                   UnaryOp=FT_Undefined):
1445         aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1446         group = self.MakeGroupByCriterion(groupName, aCriterion)
1447         return group
1448
1449     ## Create a mesh group by the given criterion
1450     #  @param groupName is the name of the mesh group
1451     #  @param Criterion is the instance of Criterion class
1452     #  @return SMESH_Group
1453     def MakeGroupByCriterion(self, groupName, Criterion):
1454         aFilterMgr = smesh.CreateFilterManager()
1455         aFilter = aFilterMgr.CreateFilter()
1456         aCriteria = []
1457         aCriteria.append(Criterion)
1458         aFilter.SetCriteria(aCriteria)
1459         group = self.MakeGroupByFilter(groupName, aFilter)
1460         return group
1461     
1462     ## Create a mesh group by the given criteria(list of criterions)
1463     #  @param groupName is the name of the mesh group
1464     #  @param Criteria is the list of criterions
1465     #  @return SMESH_Group
1466     def MakeGroupByCriteria(self, groupName, theCriteria):
1467         aFilterMgr = smesh.CreateFilterManager()
1468         aFilter = aFilterMgr.CreateFilter()
1469         aFilter.SetCriteria(theCriteria)
1470         group = self.MakeGroupByFilter(groupName, aFilter)
1471         return group
1472     
1473     ## Create a mesh group by the given filter
1474     #  @param groupName is the name of the mesh group
1475     #  @param Criterion is the instance of Filter class
1476     #  @return SMESH_Group
1477     def MakeGroupByFilter(self, groupName, theFilter):
1478         anIds = theFilter.GetElementsId(self.mesh)
1479         anElemType = theFilter.GetElementType()
1480         group = self.MakeGroupByIds(groupName, anElemType, anIds)
1481         return group
1482
1483     ## Pass mesh elements through the given filter and return ids
1484     #  @param theFilter is SMESH_Filter
1485     #  @return list of ids
1486     def GetIdsFromFilter(self, theFilter):
1487         return theFilter.GetElementsId(self.mesh)
1488
1489     ## Verify whether 2D mesh element has free edges(edges connected to one face only)\n
1490     #  Returns list of special structures(borders).
1491     #  @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
1492     def GetFreeBorders(self):
1493         aFilterMgr = smesh.CreateFilterManager()
1494         aPredicate = aFilterMgr.CreateFreeEdges()
1495         aPredicate.SetMesh(self.mesh)
1496         aBorders = aPredicate.GetBorders()
1497         return aBorders
1498                 
1499     ## Remove a group
1500     def RemoveGroup(self, group):
1501         self.mesh.RemoveGroup(group)
1502
1503     ## Remove group with its contents
1504     def RemoveGroupWithContents(self, group):
1505         self.mesh.RemoveGroupWithContents(group)
1506         
1507     ## Get the list of groups existing in the mesh
1508     def GetGroups(self):
1509         return self.mesh.GetGroups()
1510
1511     ## Get the list of names of groups existing in the mesh
1512     def GetGroupNames(self):
1513         groups = self.GetGroups()
1514         names = []
1515         for group in groups:
1516             names.append(group.GetName())
1517         return names
1518
1519     ## Union of two groups
1520     #  New group is created. All mesh elements that are
1521     #  present in initial groups are added to the new one
1522     def UnionGroups(self, group1, group2, name):
1523         return self.mesh.UnionGroups(group1, group2, name)
1524
1525     ## Intersection of two groups
1526     #  New group is created. All mesh elements that are
1527     #  present in both initial groups are added to the new one.
1528     def IntersectGroups(self, group1, group2, name):
1529         return self.mesh.IntersectGroups(group1, group2, name)
1530     
1531     ## Cut of two groups
1532     #  New group is created. All mesh elements that are present in
1533     #  main group but do not present in tool group are added to the new one
1534     def CutGroups(self, mainGroup, toolGroup, name):
1535         return self.mesh.CutGroups(mainGroup, toolGroup, name)
1536          
1537     
1538     # Get some info about mesh:
1539     # ------------------------
1540
1541     ## Get the log of nodes and elements added or removed since previous
1542     #  clear of the log.
1543     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1544     #  @return list of log_block structures:
1545     #                                        commandType
1546     #                                        number
1547     #                                        coords
1548     #                                        indexes
1549     def GetLog(self, clearAfterGet):
1550         return self.mesh.GetLog(clearAfterGet)
1551
1552     ## Clear the log of nodes and elements added or removed since previous
1553     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1554     def ClearLog(self):
1555         self.mesh.ClearLog()
1556
1557     ## Get the internal Id
1558     def GetId(self):
1559         return self.mesh.GetId()
1560
1561     ## Get the study Id
1562     def GetStudyId(self):
1563         return self.mesh.GetStudyId()
1564
1565     ## Check group names for duplications.
1566     #  Consider maximum group name length stored in MED file.
1567     def HasDuplicatedGroupNamesMED(self):
1568         return self.mesh.GetStudyId()
1569         
1570     ## Obtain instance of SMESH_MeshEditor
1571     def GetMeshEditor(self):
1572         return self.mesh.GetMeshEditor()
1573
1574     ## Get MED Mesh
1575     def GetMEDMesh(self):
1576         return self.mesh.GetMEDMesh()
1577     
1578     
1579     # Get informations about mesh contents:
1580     # ------------------------------------
1581
1582     ## Returns number of nodes in mesh
1583     def NbNodes(self):
1584         return self.mesh.NbNodes()
1585
1586     ## Returns number of elements in mesh
1587     def NbElements(self):
1588         return self.mesh.NbElements()
1589
1590     ## Returns number of edges in mesh
1591     def NbEdges(self):
1592         return self.mesh.NbEdges()
1593
1594     ## Returns number of edges with given order in mesh
1595     #  @param elementOrder is order of elements:
1596     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1597     def NbEdgesOfOrder(self, elementOrder):
1598         return self.mesh.NbEdgesOfOrder(elementOrder)
1599     
1600     ## Returns number of faces in mesh
1601     def NbFaces(self):
1602         return self.mesh.NbFaces()
1603
1604     ## Returns number of faces with given order in mesh
1605     #  @param elementOrder is order of elements:
1606     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1607     def NbFacesOfOrder(self, elementOrder):
1608         return self.mesh.NbFacesOfOrder(elementOrder)
1609
1610     ## Returns number of triangles in mesh
1611     def NbTriangles(self):
1612         return self.mesh.NbTriangles()
1613
1614     ## Returns number of triangles with given order in mesh
1615     #  @param elementOrder is order of elements:
1616     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1617     def NbTrianglesOfOrder(self, elementOrder):
1618         return self.mesh.NbTrianglesOfOrder(elementOrder)
1619
1620     ## Returns number of quadrangles in mesh
1621     def NbQuadrangles(self):
1622         return self.mesh.NbQuadrangles()
1623
1624     ## Returns number of quadrangles with given order in mesh
1625     #  @param elementOrder is order of elements:
1626     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1627     def NbQuadranglesOfOrder(self, elementOrder):
1628         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1629
1630     ## Returns number of polygons in mesh
1631     def NbPolygons(self):
1632         return self.mesh.NbPolygons()
1633
1634     ## Returns number of volumes in mesh
1635     def NbVolumes(self):
1636         return self.mesh.NbVolumes()
1637
1638     ## Returns number of volumes with given order in mesh
1639     #  @param elementOrder is order of elements:
1640     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1641     def NbVolumesOfOrder(self, elementOrder):
1642         return self.mesh.NbVolumesOfOrder(elementOrder)
1643
1644     ## Returns number of tetrahedrons in mesh
1645     def NbTetras(self):
1646         return self.mesh.NbTetras()
1647
1648     ## Returns number of tetrahedrons with given order in mesh
1649     #  @param elementOrder is order of elements:
1650     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1651     def NbTetrasOfOrder(self, elementOrder):
1652         return self.mesh.NbTetrasOfOrder(elementOrder)
1653
1654     ## Returns number of hexahedrons in mesh
1655     def NbHexas(self):
1656         return self.mesh.NbHexas()
1657
1658     ## Returns number of hexahedrons with given order in mesh
1659     #  @param elementOrder is order of elements:
1660     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1661     def NbHexasOfOrder(self, elementOrder):
1662         return self.mesh.NbHexasOfOrder(elementOrder)
1663
1664     ## Returns number of pyramids in mesh
1665     def NbPyramids(self):
1666         return self.mesh.NbPyramids()
1667
1668     ## Returns number of pyramids with given order in mesh
1669     #  @param elementOrder is order of elements:
1670     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1671     def NbPyramidsOfOrder(self, elementOrder):
1672         return self.mesh.NbPyramidsOfOrder(elementOrder)
1673
1674     ## Returns number of prisms in mesh
1675     def NbPrisms(self):
1676         return self.mesh.NbPrisms()
1677
1678     ## Returns number of prisms with given order in mesh
1679     #  @param elementOrder is order of elements:
1680     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1681     def NbPrismsOfOrder(self, elementOrder):
1682         return self.mesh.NbPrismsOfOrder(elementOrder)
1683
1684     ## Returns number of polyhedrons in mesh
1685     def NbPolyhedrons(self):
1686         return self.mesh.NbPolyhedrons()
1687
1688     ## Returns number of submeshes in mesh
1689     def NbSubMesh(self):
1690         return self.mesh.NbSubMesh()
1691
1692     ## Returns list of mesh elements ids
1693     def GetElementsId(self):
1694         return self.mesh.GetElementsId()
1695
1696     ## Returns list of ids of mesh elements with given type
1697     #  @param elementType is required type of elements
1698     def GetElementsByType(self, elementType):
1699         return self.mesh.GetElementsByType(elementType)
1700
1701     ## Returns list of mesh nodes ids
1702     def GetNodesId(self):
1703         return self.mesh.GetNodesId()
1704     
1705     # Get informations about mesh elements:
1706     # ------------------------------------
1707     
1708     ## Returns type of mesh element
1709     def GetElementType(self, id, iselem):
1710         return self.mesh.GetElementType(id, iselem)
1711
1712     ## Returns list of submesh elements ids
1713     #  @param shapeID is geom object(subshape) IOR
1714     def GetSubMeshElementsId(self, shapeID):
1715         return self.mesh.GetSubMeshElementsId(shapeID)
1716
1717     ## Returns list of submesh nodes ids
1718     #  @param shapeID is geom object(subshape) IOR
1719     def GetSubMeshNodesId(self, shapeID, all):
1720         return self.mesh.GetSubMeshNodesId(shapeID, all)
1721     
1722     ## Returns list of ids of submesh elements with given type
1723     #  @param shapeID is geom object(subshape) IOR
1724     def GetSubMeshElementType(self, shapeID):
1725         return self.mesh.GetSubMeshElementType(shapeID)
1726       
1727     ## Get mesh description
1728     def Dump(self):
1729         return self.mesh.Dump()
1730
1731     
1732     # Get information about nodes and elements of mesh by its ids:
1733     # -----------------------------------------------------------
1734
1735     ## Get XYZ coordinates of node as list of double
1736     #  \n If there is not node for given ID - returns empty list
1737     def GetNodeXYZ(self, id):
1738         return self.mesh.GetNodeXYZ(id)
1739
1740     ## For given node returns list of IDs of inverse elements
1741     #  \n If there is not node for given ID - returns empty list
1742     def GetNodeInverseElements(self, id):
1743         return self.mesh.GetNodeInverseElements(id)
1744
1745     ## If given element is node returns IDs of shape from position
1746     #  \n If there is not node for given ID - returns -1
1747     def GetShapeID(self, id):
1748         return self.mesh.GetShapeID(id)
1749
1750     ## For given element returns ID of result shape after 
1751     #  FindShape() from SMESH_MeshEditor
1752     #  \n If there is not element for given ID - returns -1
1753     def GetShapeIDForElem(id):
1754         return self.mesh.GetShapeIDForElem(id)
1755     
1756     ## Returns number of nodes for given element
1757     #  \n If there is not element for given ID - returns -1
1758     def GetElemNbNodes(self, id):
1759         return self.mesh.GetElemNbNodes(id)
1760
1761     ## Returns ID of node by given index for given element
1762     #  \n If there is not element for given ID - returns -1
1763     #  \n If there is not node for given index - returns -2
1764     def GetElemNode(self, id, index):
1765         return self.mesh.GetElemNode(id, index)
1766
1767     ## Returns true if given node is medium node
1768     #  in given quadratic element
1769     def IsMediumNode(self, elementID, nodeID):
1770         return self.mesh.IsMediumNode(elementID, nodeID)
1771     
1772     ## Returns true if given node is medium node
1773     #  in one of quadratic elements
1774     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1775         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1776
1777     ## Returns number of edges for given element
1778     def ElemNbEdges(self, id):
1779         return self.mesh.ElemNbEdges(id)
1780         
1781     ## Returns number of faces for given element
1782     def ElemNbFaces(self, id):
1783         return self.mesh.ElemNbFaces(id)
1784
1785     ## Returns true if given element is polygon
1786     def IsPoly(self, id):
1787         return self.mesh.IsPoly(id)
1788
1789     ## Returns true if given element is quadratic
1790     def IsQuadratic(self, id):
1791         return self.mesh.IsQuadratic(id)
1792
1793     ## Returns XYZ coordinates of bary center for given element
1794     #  as list of double
1795     #  \n If there is not element for given ID - returns empty list
1796     def BaryCenter(self, id):
1797         return self.mesh.BaryCenter(id)
1798     
1799     
1800     # Mesh edition (SMESH_MeshEditor functionality):
1801     # ---------------------------------------------
1802
1803     ## Removes elements from mesh by ids
1804     #  @param IDsOfElements is list of ids of elements to remove
1805     def RemoveElements(self, IDsOfElements):
1806         return self.editor.RemoveElements(IDsOfElements)
1807
1808     ## Removes nodes from mesh by ids
1809     #  @param IDsOfNodes is list of ids of nodes to remove
1810     def RemoveNodes(self, IDsOfNodes):
1811         return self.editor.RemoveNodes(IDsOfNodes)
1812
1813     ## Add node to mesh by coordinates
1814     def AddNode(self, x, y, z):
1815         return self.editor.AddNode( x, y, z)
1816
1817     
1818     ## Create edge both similar and quadratic (this is determed
1819     #  by number of given nodes).
1820     #  @param IdsOfNodes List of node IDs for creation of element.
1821     #  Needed order of nodes in this list corresponds to description
1822     #  of MED. \n This description is located by the following link:
1823     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1824     def AddEdge(self, IDsOfNodes):
1825         return self.editor.AddEdge(IDsOfNodes)
1826
1827     ## Create face both similar and quadratic (this is determed
1828     #  by number of given nodes).
1829     #  @param IdsOfNodes List of node IDs for creation of element.
1830     #  Needed order of nodes in this list corresponds to description
1831     #  of MED. \n This description is located by the following link:
1832     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1833     def AddFace(self, IDsOfNodes):
1834         return self.editor.AddFace(IDsOfNodes)
1835     
1836     ## Add polygonal face to mesh by list of nodes ids
1837     def AddPolygonalFace(self, IdsOfNodes):
1838         return self.editor.AddPolygonalFace(IdsOfNodes)
1839     
1840     ## Create volume both similar and quadratic (this is determed
1841     #  by number of given nodes).
1842     #  @param IdsOfNodes List of node IDs for creation of element.
1843     #  Needed order of nodes in this list corresponds to description
1844     #  of MED. \n This description is located by the following link:
1845     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1846     def AddVolume(self, IDsOfNodes):
1847         return self.editor.AddVolume(IDsOfNodes)
1848
1849     ## Create volume of many faces, giving nodes for each face.
1850     #  @param IdsOfNodes List of node IDs for volume creation face by face.
1851     #  @param Quantities List of integer values, Quantities[i]
1852     #         gives quantity of nodes in face number i.
1853     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1854         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1855
1856     ## Create volume of many faces, giving IDs of existing faces.
1857     #  @param IdsOfFaces List of face IDs for volume creation.
1858     #
1859     #  Note:  The created volume will refer only to nodes
1860     #         of the given faces, not to the faces itself.
1861     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1862         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1863     
1864     ## Move node with given id
1865     #  @param NodeID id of the node
1866     #  @param x displacing along the X axis
1867     #  @param y displacing along the Y axis
1868     #  @param z displacing along the Z axis
1869     def MoveNode(self, NodeID, x, y, z):
1870         return self.editor.MoveNode(NodeID, x, y, z)
1871
1872     ## Replace two neighbour triangles sharing Node1-Node2 link
1873     #  with ones built on the same 4 nodes but having other common link.
1874     #  @param NodeID1 first node id
1875     #  @param NodeID2 second node id
1876     #  @return false if proper faces not found
1877     def InverseDiag(self, NodeID1, NodeID2):
1878         return self.editor.InverseDiag(NodeID1, NodeID2)
1879
1880     ## Replace two neighbour triangles sharing Node1-Node2 link
1881     #  with a quadrangle built on the same 4 nodes.
1882     #  @param NodeID1 first node id
1883     #  @param NodeID2 second node id
1884     #  @return false if proper faces not found
1885     def DeleteDiag(self, NodeID1, NodeID2):
1886         return self.editor.DeleteDiag(NodeID1, NodeID2)
1887
1888     ## Reorient elements by ids
1889     #  @param IDsOfElements if undefined reorient all mesh elements
1890     def Reorient(self, IDsOfElements=None):
1891         if IDsOfElements == None:
1892             IDsOfElements = self.GetElementsId()
1893         return self.editor.Reorient(IDsOfElements)
1894
1895     ## Reorient all elements of the object
1896     #  @param theObject is mesh, submesh or group
1897     def ReorientObject(self, theObject):
1898         return self.editor.ReorientObject(theObject)
1899
1900     ## Fuse neighbour triangles into quadrangles.
1901     #  @param IDsOfElements The triangles to be fused,
1902     #  @param theCriterion     is FT_...; used to choose a neighbour to fuse with.
1903     #  @param MaxAngle      is a max angle between element normals at which fusion
1904     #                       is still performed; theMaxAngle is mesured in radians.
1905     #  @return TRUE in case of success, FALSE otherwise.
1906     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1907         if IDsOfElements == []:
1908             IDsOfElements = self.GetElementsId()
1909         return self.editor.TriToQuad(IDsOfElements, GetFunctor(theCriterion), MaxAngle)
1910
1911     ## Fuse neighbour triangles of the object into quadrangles
1912     #  @param theObject is mesh, submesh or group
1913     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1914     #  @param MaxAngle  is a max angle between element normals at which fusion
1915     #                   is still performed; theMaxAngle is mesured in radians.
1916     #  @return TRUE in case of success, FALSE otherwise.
1917     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1918         return self.editor.TriToQuadObject(theObject, GetFunctor(theCriterion), MaxAngle)
1919
1920     ## Split quadrangles into triangles.
1921     #  @param IDsOfElements the faces to be splitted.
1922     #  @param theCriterion  is FT_...; used to choose a diagonal for splitting.
1923     #  @param @return TRUE in case of success, FALSE otherwise.
1924     def QuadToTri (self, IDsOfElements, theCriterion):
1925         if IDsOfElements == []:
1926             IDsOfElements = self.GetElementsId()
1927         return self.editor.QuadToTri(IDsOfElements, GetFunctor(theCriterion))
1928
1929     ## Split quadrangles into triangles.
1930     #  @param theObject object to taking list of elements from, is mesh, submesh or group
1931     #  @param theCriterion  is FT_...; used to choose a diagonal for splitting.
1932     def QuadToTriObject (self, theObject, theCriterion):
1933         return self.editor.QuadToTriObject(theObject, GetFunctor(theCriterion))
1934
1935     ## Split quadrangles into triangles.
1936     #  @param theElems  The faces to be splitted
1937     #  @param the13Diag is used to choose a diagonal for splitting.
1938     #  @return TRUE in case of success, FALSE otherwise.
1939     def SplitQuad (self, IDsOfElements, Diag13):
1940         if IDsOfElements == []:
1941             IDsOfElements = self.GetElementsId()
1942         return self.editor.SplitQuad(IDsOfElements, Diag13)
1943
1944     ## Split quadrangles into triangles.
1945     #  @param theObject is object to taking list of elements from, is mesh, submesh or group
1946     def SplitQuadObject (self, theObject, Diag13):
1947         return self.editor.SplitQuadObject(theObject, Diag13)
1948
1949     ## Find better splitting of the given quadrangle.
1950     #  @param IDOfQuad  ID of the quadrangle to be splitted.
1951     #  @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
1952     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
1953     #          diagonal is better, 0 if error occurs.
1954     def BestSplit (self, IDOfQuad, theCriterion):
1955         return self.editor.BestSplit(IDOfQuad, GetFunctor(theCriterion))
1956     
1957     ## Smooth elements
1958     #  @param IDsOfElements list if ids of elements to smooth
1959     #  @param IDsOfFixedNodes list of ids of fixed nodes.
1960     #  Note that nodes built on edges and boundary nodes are always fixed.
1961     #  @param MaxNbOfIterations maximum number of iterations
1962     #  @param MaxAspectRatio varies in range [1.0, inf]
1963     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1964     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
1965                MaxNbOfIterations, MaxAspectRatio, Method):
1966         if IDsOfElements == []:
1967             IDsOfElements = self.GetElementsId()
1968         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
1969                                   MaxNbOfIterations, MaxAspectRatio, Method)
1970     
1971     ## Smooth elements belong to given object
1972     #  @param theObject object to smooth
1973     #  @param IDsOfFixedNodes list of ids of fixed nodes.
1974     #  Note that nodes built on edges and boundary nodes are always fixed.
1975     #  @param MaxNbOfIterations maximum number of iterations
1976     #  @param MaxAspectRatio varies in range [1.0, inf]
1977     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1978     def SmoothObject(self, theObject, IDsOfFixedNodes, 
1979                      MaxNbOfIterations, MaxxAspectRatio, Method):
1980         return self.editor.SmoothObject(theObject, IDsOfFixedNodes, 
1981                                         MaxNbOfIterations, MaxxAspectRatio, Method)
1982
1983     ## Parametric smooth the given elements
1984     #  @param IDsOfElements list if ids of elements to smooth
1985     #  @param IDsOfFixedNodes list of ids of fixed nodes.
1986     #  Note that nodes built on edges and boundary nodes are always fixed.
1987     #  @param MaxNbOfIterations maximum number of iterations
1988     #  @param MaxAspectRatio varies in range [1.0, inf]
1989     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1990     def SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1991                          MaxNbOfIterations, MaxAspectRatio, Method):
1992         if IDsOfElements == []:
1993             IDsOfElements = self.GetElementsId()
1994         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1995                                             MaxNbOfIterations, MaxAspectRatio, Method)
1996     
1997     ## Parametric smooth elements belong to given object
1998     #  @param theObject object to smooth
1999     #  @param IDsOfFixedNodes list of ids of fixed nodes.
2000     #  Note that nodes built on edges and boundary nodes are always fixed.
2001     #  @param MaxNbOfIterations maximum number of iterations
2002     #  @param MaxAspectRatio varies in range [1.0, inf]
2003     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2004     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2005                                MaxNbOfIterations, MaxAspectRatio, Method):
2006         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2007                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2008
2009     ## Converts all mesh to quadratic one, deletes old elements, replacing 
2010     #  them with quadratic ones with the same id.
2011     def ConvertToQuadratic(self, theForce3d):
2012         self.editor.ConvertToQuadratic(theForce3d)
2013
2014     ## Converts all mesh from quadratic to ordinary ones,
2015     #  deletes old quadratic elements, \n replacing 
2016     #  them with ordinary mesh elements with the same id.
2017     def ConvertFromQuadratic(self):
2018         return self.editor.ConvertFromQuadratic()
2019
2020     ## Renumber mesh nodes
2021     def RenumberNodes(self):
2022         self.editor.RenumberNodes()
2023
2024     ## Renumber mesh elements
2025     def RenumberElements(self):
2026         self.editor.RenumberElements()
2027
2028     ## Generate new elements by rotation of the elements around the axis
2029     #  @param IDsOfElements list of ids of elements to sweep
2030     #  @param Axix axis of rotation, AxisStruct or line(geom object)
2031     #  @param AngleInRadians angle of Rotation
2032     #  @param NbOfSteps number of steps
2033     #  @param Tolerance tolerance
2034     def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance):
2035         if IDsOfElements == []:
2036             IDsOfElements = self.GetElementsId()
2037         if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
2038             Axix = GetAxisStruct(Axix)
2039         self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
2040
2041     ## Generate new elements by rotation of the elements of object around the axis
2042     #  @param theObject object wich elements should be sweeped
2043     #  @param Axix axis of rotation, AxisStruct or line(geom object)
2044     #  @param AngleInRadians angle of Rotation
2045     #  @param NbOfSteps number of steps
2046     #  @param Tolerance tolerance
2047     def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance):
2048         if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
2049             Axix = GetAxisStruct(Axix)
2050         self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
2051
2052     ## Generate new elements by extrusion of the elements with given ids
2053     #  @param IDsOfElements list of elements ids for extrusion
2054     #  @param StepVector vector, defining the direction and value of extrusion 
2055     #  @param NbOfSteps the number of steps
2056     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps):
2057         if IDsOfElements == []:
2058             IDsOfElements = self.GetElementsId()
2059         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2060             StepVector = GetDirStruct(StepVector)
2061         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2062
2063     ## Generate new elements by extrusion of the elements with given ids
2064     #  @param IDsOfElements is ids of elements
2065     #  @param StepVector vector, defining the direction and value of extrusion 
2066     #  @param NbOfSteps the number of steps
2067     #  @param ExtrFlags set flags for performing extrusion
2068     #  @param SewTolerance uses for comparing locations of nodes if flag
2069     #         EXTRUSION_FLAG_SEW is set
2070     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance):
2071         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2072             StepVector = GetDirStruct(StepVector)
2073         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance)
2074
2075     ## Generate new elements by extrusion of the elements belong to object
2076     #  @param theObject object wich elements should be processed
2077     #  @param StepVector vector, defining the direction and value of extrusion 
2078     #  @param NbOfSteps the number of steps
2079     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps):
2080         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2081             StepVector = GetDirStruct(StepVector)
2082         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2083
2084     ## Generate new elements by extrusion of the elements belong to object
2085     #  @param theObject object wich elements should be processed
2086     #  @param StepVector vector, defining the direction and value of extrusion 
2087     #  @param NbOfSteps the number of steps
2088     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps):
2089         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2090             StepVector = GetDirStruct(StepVector)
2091         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2092     
2093     ## Generate new elements by extrusion of the elements belong to object
2094     #  @param theObject object wich elements should be processed
2095     #  @param StepVector vector, defining the direction and value of extrusion 
2096     #  @param NbOfSteps the number of steps    
2097     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps):
2098         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
2099             StepVector = GetDirStruct(StepVector)
2100         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2101
2102     ## Generate new elements by extrusion of the given elements
2103     #  A path of extrusion must be a meshed edge.
2104     #  @param IDsOfElements is ids of elements
2105     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2106     #  @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2107     #  @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2108     #  @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2109     #  @param Angles list of angles
2110     #  @param HasRefPoint allows to use base point 
2111     #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2112     #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2113     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2114                            HasAngles, Angles, HasRefPoint, RefPoint):
2115         if IDsOfElements == []:
2116             IDsOfElements = self.GetElementsId()
2117         if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
2118             RefPoint = GetPointStruct(RefPoint) 
2119         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart,
2120                                               HasAngles, Angles, HasRefPoint, RefPoint)
2121
2122     ## Generate new elements by extrusion of the elements belong to object
2123     #  A path of extrusion must be a meshed edge.
2124     #  @param IDsOfElements is ids of elements
2125     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2126     #  @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2127     #  @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2128     #  @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2129     #  @param Angles list of angles
2130     #  @param HasRefPoint allows to use base point 
2131     #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2132     #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
2133     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2134                                  HasAngles, Angles, HasRefPoint, RefPoint):
2135         if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
2136             RefPoint = GetPointStruct(RefPoint) 
2137         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart,
2138                                                     HasAngles, Angles, HasRefPoint, RefPoint)
2139     
2140     ## Symmetrical copy of mesh elements
2141     #  @param IDsOfElements list of elements ids
2142     #  @param Mirror is AxisStruct or geom object(point, line, plane)
2143     #  @param theMirrorType is  POINT, AXIS or PLANE
2144     #  If the Mirror is geom object this parameter is unnecessary
2145     #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2146     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0):
2147         if IDsOfElements == []:
2148             IDsOfElements = self.GetElementsId()
2149         if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
2150             Mirror = GetAxisStruct(Mirror)
2151         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2152
2153     ## Symmetrical copy of object
2154     #  @param theObject mesh, submesh or group
2155     #  @param Mirror is AxisStruct or geom object(point, line, plane)
2156     #  @param theMirrorType is  POINT, AXIS or PLANE
2157     #  If the Mirror is geom object this parameter is unnecessary
2158     #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
2159     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0):
2160         if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
2161             Mirror = GetAxisStruct(Mirror)
2162         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2163
2164     ## Translates the elements
2165     #  @param IDsOfElements list of elements ids
2166     #  @param Vector direction of translation(DirStruct or vector)
2167     #  @param Copy allows to copy the translated elements
2168     def Translate(self, IDsOfElements, Vector, Copy):
2169         if IDsOfElements == []:
2170             IDsOfElements = self.GetElementsId()
2171         if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
2172             Vector = GetDirStruct(Vector)
2173         self.editor.Translate(IDsOfElements, Vector, Copy)
2174
2175     ## Translates the object
2176     #  @param theObject object to translate(mesh, submesh, or group)
2177     #  @param Vector direction of translation(DirStruct or geom vector)
2178     #  @param Copy allows to copy the translated elements
2179     def TranslateObject(self, theObject, Vector, Copy):
2180         if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
2181             Vector = GetDirStruct(Vector)
2182         self.editor.TranslateObject(theObject, Vector, Copy)
2183
2184     ## Rotates the elements
2185     #  @param IDsOfElements list of elements ids
2186     #  @param Axis axis of rotation(AxisStruct or geom line)
2187     #  @param AngleInRadians angle of rotation(in radians)
2188     #  @param Copy allows to copy the rotated elements   
2189     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy):
2190         if IDsOfElements == []:
2191             IDsOfElements = self.GetElementsId()
2192         if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
2193             Axis = GetAxisStruct(Axis)
2194         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2195
2196     ## Rotates the object
2197     #  @param theObject object to rotate(mesh, submesh, or group)
2198     #  @param Axis axis of rotation(AxisStruct or geom line)
2199     #  @param AngleInRadians angle of rotation(in radians)
2200     #  @param Copy allows to copy the rotated elements
2201     def RotateObject (self, theObject, Axis, AngleInRadians, Copy):
2202         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2203
2204     ## Find group of nodes close to each other within Tolerance.
2205     #  @param Tolerance tolerance value
2206     #  @param list of group of nodes
2207     def FindCoincidentNodes (self, Tolerance):
2208         return self.editor.FindCoincidentNodes(Tolerance)
2209
2210     ## Merge nodes
2211     #  @param list of group of nodes
2212     def MergeNodes (self, GroupsOfNodes):
2213         self.editor.MergeNodes(GroupsOfNodes)
2214
2215     ## Remove all but one of elements built on the same nodes.
2216     def MergeEqualElements(self):
2217         self.editor.MergeEqualElements()
2218         
2219     ## Sew free borders
2220     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2221                         FirstNodeID2, SecondNodeID2, LastNodeID2,
2222                         CreatePolygons, CreatePolyedrs):
2223         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2224                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
2225                                           CreatePolygons, CreatePolyedrs)
2226
2227     ## Sew conform free borders
2228     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2229                                FirstNodeID2, SecondNodeID2):
2230         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2231                                                  FirstNodeID2, SecondNodeID2)
2232     
2233     ## Sew border to side
2234     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2235                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2236         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2237                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2238
2239     ## Sew two sides of a mesh. Nodes belonging to Side1 are
2240     #  merged with nodes of elements of Side2.
2241     #  Number of elements in theSide1 and in theSide2 must be
2242     #  equal and they should have similar node connectivity.
2243     #  The nodes to merge should belong to sides borders and
2244     #  the first node should be linked to the second.
2245     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2246                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2247                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2248         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2249                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2250                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2251
2252     ## Set new nodes for given element.
2253     #  @param ide the element id
2254     #  @param newIDs nodes ids
2255     #  @return If number of nodes is not corresponded to type of element - returns false
2256     def ChangeElemNodes(self, ide, newIDs):
2257         return self.editor.ChangeElemNodes(ide, newIDs)
2258     
2259     ## If during last operation of MeshEditor some nodes were
2260     #  created this method returns list of it's IDs, \n
2261     #  if new nodes not created - returns empty list
2262     def GetLastCreatedNodes(self):
2263         return self.editor.GetLastCreatedNodes()
2264
2265     ## If during last operation of MeshEditor some elements were
2266     #  created this method returns list of it's IDs, \n
2267     #  if new elements not creared - returns empty list
2268     def GetLastCreatedElems(self):
2269         return self.editor.GetLastCreatedElems()