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