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