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