Salome HOME
NPAL16198: EDF462: Submeshes creation duplicate algorithms and hypotheses. Refix.
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.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 geompyDC
31
32 import SMESH # necessary for back compatibility
33 from   SMESH import *
34
35 import StdMeshers
36
37 import SALOME
38
39 # import NETGENPlugin module if possible
40 noNETGENPlugin = 0
41 try:
42     import NETGENPlugin
43 except ImportError:
44     noNETGENPlugin = 1
45     pass
46
47 # Types of algo
48 REGULAR    = 1
49 PYTHON     = 2
50 COMPOSITE  = 3
51
52 MEFISTO       = 3
53 NETGEN        = 4
54 GHS3D         = 5
55 FULL_NETGEN   = 6
56 NETGEN_2D     = 7
57 NETGEN_1D2D   = NETGEN
58 NETGEN_1D2D3D = FULL_NETGEN
59 NETGEN_FULL   = FULL_NETGEN
60 Hexa    = 8
61 Hexotic = 9
62 BLSURF  = 10
63
64 # MirrorType enumeration
65 POINT = SMESH_MeshEditor.POINT
66 AXIS =  SMESH_MeshEditor.AXIS
67 PLANE = SMESH_MeshEditor.PLANE
68
69 # Smooth_Method enumeration
70 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
71 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
72
73 # Fineness enumeration(for NETGEN)
74 VeryCoarse = 0
75 Coarse = 1
76 Moderate = 2
77 Fine = 3
78 VeryFine = 4
79 Custom = 5
80
81 PrecisionConfusion = 1e-07
82
83 def IsEqual(val1, val2, tol=PrecisionConfusion):
84     if abs(val1 - val2) < tol:
85         return True
86     return False
87
88 NO_NAME = "NoName"
89
90 ## Gets object name
91 def GetName(obj):
92     ior  = salome.orb.object_to_string(obj)
93     sobj = salome.myStudy.FindObjectIOR(ior)
94     if sobj is None:
95         return NO_NAME
96     else:
97         attr = sobj.FindAttribute("AttributeName")[1]
98         return attr.Value()
99
100     ## Sets name to object
101 def SetName(obj, name):
102     ior  = salome.orb.object_to_string(obj)
103     sobj = salome.myStudy.FindObjectIOR(ior)
104     if not sobj is None:
105         attr = sobj.FindAttribute("AttributeName")[1]
106         attr.SetValue(name)
107
108     ## Print error message if a hypothesis was not assigned.
109 def TreatHypoStatus(status, hypName, geomName, isAlgo):
110     if isAlgo:
111         hypType = "algorithm"
112     else:
113         hypType = "hypothesis"
114         pass
115     if status == HYP_UNKNOWN_FATAL :
116         reason = "for unknown reason"
117     elif status == HYP_INCOMPATIBLE :
118         reason = "this hypothesis mismatches algorithm"
119     elif status == HYP_NOTCONFORM :
120         reason = "not conform mesh would be built"
121     elif status == HYP_ALREADY_EXIST :
122         reason = hypType + " of the same dimension already assigned to this shape"
123     elif status == HYP_BAD_DIM :
124         reason = hypType + " mismatches shape"
125     elif status == HYP_CONCURENT :
126         reason = "there are concurrent hypotheses on sub-shapes"
127     elif status == HYP_BAD_SUBSHAPE :
128         reason = "shape is neither the main one, nor its subshape, nor a valid group"
129     elif status == HYP_BAD_GEOMETRY:
130         reason = "geometry mismatches algorithm's expectation"
131     elif status == HYP_HIDDEN_ALGO:
132         reason = "it is hidden by an algorithm of upper dimension generating all-dimensions elements"
133     elif status == HYP_HIDING_ALGO:
134         reason = "it hides algorithm(s) of lower dimension by generating all-dimensions elements"
135     else:
136         return
137     hypName = '"' + hypName + '"'
138     geomName= '"' + geomName+ '"'
139     if status < HYP_UNKNOWN_FATAL:
140         print hypName, "was assigned to",    geomName,"but", reason
141     else:
142         print hypName, "was not assigned to",geomName,":", reason
143         pass
144
145 class smeshDC(SMESH._objref_SMESH_Gen):
146
147     def init_smesh(self,theStudy,geompyD):
148         self.geompyD=geompyD
149         self.SetGeomEngine(geompyD)
150         self.SetCurrentStudy(theStudy)
151
152     def Mesh(self, obj=0, name=0):
153       return Mesh(self,self.geompyD,obj,name)
154
155     ## Returns long value from enumeration
156     #  Uses for SMESH.FunctorType enumeration
157     def EnumToLong(self,theItem):
158         return theItem._v
159
160     ## Get PointStruct from vertex
161     #  @param theVertex is GEOM object(vertex)
162     #  @return SMESH.PointStruct
163     def GetPointStruct(self,theVertex):
164         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
165         return PointStruct(x,y,z)
166
167     ## Get DirStruct from vector
168     #  @param theVector is GEOM object(vector)
169     #  @return SMESH.DirStruct
170     def GetDirStruct(self,theVector):
171         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
172         if(len(vertices) != 2):
173             print "Error: vector object is incorrect."
174             return None
175         p1 = self.geompyD.PointCoordinates(vertices[0])
176         p2 = self.geompyD.PointCoordinates(vertices[1])
177         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
178         dirst = DirStruct(pnt)
179         return dirst
180
181     ## Make DirStruct from a triplet
182     #  @param x,y,z are vector components
183     #  @return SMESH.DirStruct
184     def MakeDirStruct(self,x,y,z):
185         pnt = PointStruct(x,y,z)
186         return DirStruct(pnt)
187
188     ## Get AxisStruct from object
189     #  @param theObj is GEOM object(line or plane)
190     #  @return SMESH.AxisStruct
191     def GetAxisStruct(self,theObj):
192         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
193         if len(edges) > 1:
194             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
195             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
196             vertex1 = self.geompyD.PointCoordinates(vertex1)
197             vertex2 = self.geompyD.PointCoordinates(vertex2)
198             vertex3 = self.geompyD.PointCoordinates(vertex3)
199             vertex4 = self.geompyD.PointCoordinates(vertex4)
200             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
201             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
202             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] ]
203             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
204             return axis
205         elif len(edges) == 1:
206             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
207             p1 = self.geompyD.PointCoordinates( vertex1 )
208             p2 = self.geompyD.PointCoordinates( vertex2 )
209             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
210             return axis
211         return None
212
213     # From SMESH_Gen interface:
214     # ------------------------
215
216     ## Set the current mode
217     def SetEmbeddedMode( self,theMode ):
218         #self.SetEmbeddedMode(theMode)
219         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
220
221     ## Get the current mode
222     def IsEmbeddedMode(self):
223         #return self.IsEmbeddedMode()
224         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
225
226     ## Set the current study
227     def SetCurrentStudy( self, theStudy ):
228         #self.SetCurrentStudy(theStudy)
229         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
230
231     ## Get the current study
232     def GetCurrentStudy(self):
233         #return self.GetCurrentStudy()
234         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
235
236     ## Create Mesh object importing data from given UNV file
237     #  @return an instance of Mesh class
238     def CreateMeshesFromUNV( self,theFileName ):
239         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
240         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
241         return aMesh
242
243     ## Create Mesh object(s) importing data from given MED file
244     #  @return a list of Mesh class instances
245     def CreateMeshesFromMED( self,theFileName ):
246         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
247         aMeshes = []
248         for iMesh in range(len(aSmeshMeshes)) :
249             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
250             aMeshes.append(aMesh)
251         return aMeshes, aStatus
252
253     ## Create Mesh object importing data from given STL file
254     #  @return an instance of Mesh class
255     def CreateMeshesFromSTL( self, theFileName ):
256         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
257         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
258         return aMesh
259
260     ## From SMESH_Gen interface
261     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
262         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
263
264     ## From SMESH_Gen interface. Creates pattern
265     def GetPattern(self):
266         return SMESH._objref_SMESH_Gen.GetPattern(self)
267
268
269
270     # Filtering. Auxiliary functions:
271     # ------------------------------
272
273     ## Creates an empty criterion
274     #  @return SMESH.Filter.Criterion
275     def GetEmptyCriterion(self):
276         Type = self.EnumToLong(FT_Undefined)
277         Compare = self.EnumToLong(FT_Undefined)
278         Threshold = 0
279         ThresholdStr = ""
280         ThresholdID = ""
281         UnaryOp = self.EnumToLong(FT_Undefined)
282         BinaryOp = self.EnumToLong(FT_Undefined)
283         Tolerance = 1e-07
284         TypeOfElement = ALL
285         Precision = -1 ##@1e-07
286         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
287                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
288
289     ## Creates a criterion by given parameters
290     #  @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
291     #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
292     #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
293     #  @param Treshold is threshold value (range of ids as string, shape, numeric)
294     #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
295     #  @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
296     #                  FT_Undefined(must be for the last criterion in criteria)
297     #  @return SMESH.Filter.Criterion
298     def GetCriterion(self,elementType,
299                      CritType,
300                      Compare = FT_EqualTo,
301                      Treshold="",
302                      UnaryOp=FT_Undefined,
303                      BinaryOp=FT_Undefined):
304         aCriterion = self.GetEmptyCriterion()
305         aCriterion.TypeOfElement = elementType
306         aCriterion.Type = self.EnumToLong(CritType)
307
308         aTreshold = Treshold
309
310         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
311             aCriterion.Compare = self.EnumToLong(Compare)
312         elif Compare == "=" or Compare == "==":
313             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
314         elif Compare == "<":
315             aCriterion.Compare = self.EnumToLong(FT_LessThan)
316         elif Compare == ">":
317             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
318         else:
319             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
320             aTreshold = Compare
321
322         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
323                         FT_BelongToCylinder, FT_LyingOnGeom]:
324             # Check treshold
325             if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
326                 aCriterion.ThresholdStr = GetName(aTreshold)
327                 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
328             else:
329                 print "Error: Treshold should be a shape."
330                 return None
331         elif CritType == FT_RangeOfIds:
332             # Check treshold
333             if isinstance(aTreshold, str):
334                 aCriterion.ThresholdStr = aTreshold
335             else:
336                 print "Error: Treshold should be a string."
337                 return None
338         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
339             # Here we do not need treshold
340             if aTreshold ==  FT_LogicalNOT:
341                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
342             elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
343                 aCriterion.BinaryOp = aTreshold
344         else:
345             # Check treshold
346             try:
347                 aTreshold = float(aTreshold)
348                 aCriterion.Threshold = aTreshold
349             except:
350                 print "Error: Treshold should be a number."
351                 return None
352
353         if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
354             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
355
356         if Treshold in [FT_LogicalAND, FT_LogicalOR]:
357             aCriterion.BinaryOp = self.EnumToLong(Treshold)
358
359         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
360             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
361
362         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
363             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
364
365         return aCriterion
366
367     ## Creates filter by given parameters of criterion
368     #  @param elementType is the type of elements in the group
369     #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
370     #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
371     #  @param Treshold is threshold value (range of id ids as string, shape, numeric)
372     #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
373     #  @return SMESH_Filter
374     def GetFilter(self,elementType,
375                   CritType=FT_Undefined,
376                   Compare=FT_EqualTo,
377                   Treshold="",
378                   UnaryOp=FT_Undefined):
379         aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
380         aFilterMgr = self.CreateFilterManager()
381         aFilter = aFilterMgr.CreateFilter()
382         aCriteria = []
383         aCriteria.append(aCriterion)
384         aFilter.SetCriteria(aCriteria)
385         return aFilter
386
387     ## Creates numerical functor by its type
388     #  @param theCrierion is FT_...; functor type
389     #  @return SMESH_NumericalFunctor
390     def GetFunctor(self,theCriterion):
391         aFilterMgr = self.CreateFilterManager()
392         if theCriterion == FT_AspectRatio:
393             return aFilterMgr.CreateAspectRatio()
394         elif theCriterion == FT_AspectRatio3D:
395             return aFilterMgr.CreateAspectRatio3D()
396         elif theCriterion == FT_Warping:
397             return aFilterMgr.CreateWarping()
398         elif theCriterion == FT_MinimumAngle:
399             return aFilterMgr.CreateMinimumAngle()
400         elif theCriterion == FT_Taper:
401             return aFilterMgr.CreateTaper()
402         elif theCriterion == FT_Skew:
403             return aFilterMgr.CreateSkew()
404         elif theCriterion == FT_Area:
405             return aFilterMgr.CreateArea()
406         elif theCriterion == FT_Volume3D:
407             return aFilterMgr.CreateVolume3D()
408         elif theCriterion == FT_MultiConnection:
409             return aFilterMgr.CreateMultiConnection()
410         elif theCriterion == FT_MultiConnection2D:
411             return aFilterMgr.CreateMultiConnection2D()
412         elif theCriterion == FT_Length:
413             return aFilterMgr.CreateLength()
414         elif theCriterion == FT_Length2D:
415             return aFilterMgr.CreateLength2D()
416         else:
417             print "Error: given parameter is not numerucal functor type."
418
419 import omniORB
420 #Register the new proxy for SMESH_Gen
421 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
422
423
424 ## Mother class to define algorithm, recommended to do not use directly.
425 #
426 #  More details.
427 class Mesh_Algorithm:
428     #  @class Mesh_Algorithm
429     #  @brief Class Mesh_Algorithm
430
431     #def __init__(self,smesh):
432     #    self.smesh=smesh
433     def __init__(self):
434         self.mesh = None
435         self.geom = None
436         self.subm = None
437         self.algo = None
438
439     ## Find hypothesis in study by its type name and parameters.
440     #  Find only those hypothesis, which was created in smeshpyD engine.
441     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
442         study = smeshpyD.GetCurrentStudy()
443         #to do: find component by smeshpyD object, not by its data type
444         scomp = study.FindComponent(smeshpyD.ComponentDataType())
445         if scomp is not None:
446             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
447             # is hypotheses root label exists?
448             if res and hypRoot is not None:
449                 iter = study.NewChildIterator(hypRoot)
450                 # check all published hypotheses
451                 while iter.More():
452                     hypo_so_i = iter.Value()
453                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
454                     if attr is not None:
455                         anIOR = attr.Value()
456                         hypo_o_i = salome.orb.string_to_object(anIOR)
457                         if hypo_o_i is not None:
458                             # is hypothesis?
459                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
460                             if hypo_i is not None:
461                                 # belongs to this engine?
462                                 if smeshpyD.GetObjectId(hypo_i) > 0:
463                                     # is it the needed hypothesis?
464                                     if hypo_i.GetName() == hypname:
465                                         # check args
466                                         if CompareMethod(hypo_i, args):
467                                             # found!!!
468                                             return hypo_i
469                                         pass
470                                     pass
471                                 pass
472                             pass
473                         pass
474                     iter.Next()
475                     pass
476                 pass
477             pass
478         return None
479
480     ## Find algorithm in study by its type name.
481     #  Find only those algorithm, which was created in smeshpyD engine.
482     def FindAlgorithm (self, algoname, smeshpyD):
483         study = smeshpyD.GetCurrentStudy()
484         #to do: find component by smeshpyD object, not by its data type
485         scomp = study.FindComponent(smeshpyD.ComponentDataType())
486         if scomp is not None:
487             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
488             # is algorithms root label exists?
489             if res and hypRoot is not None:
490                 iter = study.NewChildIterator(hypRoot)
491                 # check all published algorithms
492                 while iter.More():
493                     algo_so_i = iter.Value()
494                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
495                     if attr is not None:
496                         anIOR = attr.Value()
497                         algo_o_i = salome.orb.string_to_object(anIOR)
498                         if algo_o_i is not None:
499                             # is algorithm?
500                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
501                             if algo_i is not None:
502                                 # belongs to this engine?
503                                 if smeshpyD.GetObjectId(algo_i) > 0:
504                                     # is it the needed algorithm?
505                                     if algo_i.GetName() == algoname:
506                                         # found!!!
507                                         return algo_i
508                                     pass
509                                 pass
510                             pass
511                         pass
512                     iter.Next()
513                     pass
514                 pass
515             pass
516         return None
517
518     ## If the algorithm is global, return 0; \n
519     #  else return the submesh associated to this algorithm.
520     def GetSubMesh(self):
521         return self.subm
522
523     ## Return the wrapped mesher.
524     def GetAlgorithm(self):
525         return self.algo
526
527     ## Get list of hypothesis that can be used with this algorithm
528     def GetCompatibleHypothesis(self):
529         mylist = []
530         if self.algo:
531             mylist = self.algo.GetCompatibleHypothesis()
532         return mylist
533
534     ## Get name of algo
535     def GetName(self):
536         GetName(self.algo)
537
538     ## Set name to algo
539     def SetName(self, name):
540         SetName(self.algo, name)
541
542     ## Get id of algo
543     def GetId(self):
544         return self.algo.GetId()
545
546     ## Private method.
547     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
548         if geom is None:
549             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
550         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
551         if algo is None:
552             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
553             pass
554         self.Assign(algo, mesh, geom)
555         return self.algo
556
557     ## Private method
558     def Assign(self, algo, mesh, geom):
559         if geom is None:
560             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
561         self.mesh = mesh
562         piece = mesh.geom
563         if not geom:
564             self.geom = piece
565         else:
566             self.geom = geom
567             name = GetName(geom)
568             if name==NO_NAME:
569                 name = mesh.geompyD.SubShapeName(geom, piece)
570                 mesh.geompyD.addToStudyInFather(piece, geom, name)
571             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
572
573         self.algo = algo
574         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
575         TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
576
577     def CompareHyp (self, hyp, args):
578         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
579         return False
580
581     def CompareEqualHyp (self, hyp, args):
582         return True
583
584     ## Private method
585     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
586                     UseExisting=0, CompareMethod=""):
587         hypo = None
588         if UseExisting:
589             if CompareMethod == "": CompareMethod = self.CompareHyp
590             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
591             pass
592         if hypo is None:
593             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
594             a = ""
595             s = "="
596             i = 0
597             n = len(args)
598             while i<n:
599                 a = a + s + str(args[i])
600                 s = ","
601                 i = i + 1
602                 pass
603             SetName(hypo, hyp + a)
604             pass
605         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
606         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
607         return hypo
608
609
610 # Public class: Mesh_Segment
611 # --------------------------
612
613 ## Class to define a segment 1D algorithm for discretization
614 #
615 #  More details.
616 class Mesh_Segment(Mesh_Algorithm):
617
618     ## Private constructor.
619     def __init__(self, mesh, geom=0):
620         Mesh_Algorithm.__init__(self)
621         self.Create(mesh, geom, "Regular_1D")
622
623     ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
624     #  @param l for the length of segments that cut an edge
625     #  @param UseExisting if ==true - search existing hypothesis created with
626     #                     same parameters, else (default) - create new
627     def LocalLength(self, l, UseExisting=0):
628         hyp = self.Hypothesis("LocalLength", [l], UseExisting=UseExisting,
629                               CompareMethod=self.CompareLocalLength)
630         hyp.SetLength(l)
631         return hyp
632
633     ## Check if the given "LocalLength" hypothesis has the same parameters as given arguments
634     def CompareLocalLength(self, hyp, args):
635         return IsEqual(hyp.GetLength(), args[0])
636
637     ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
638     #  @param n for the number of segments that cut an edge
639     #  @param s for the scale factor (optional)
640     #  @param UseExisting if ==true - search existing hypothesis created with
641     #                     same parameters, else (default) - create new
642     def NumberOfSegments(self, n, s=[], UseExisting=0):
643         if s == []:
644             hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
645                                   CompareMethod=self.CompareNumberOfSegments)
646         else:
647             hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
648                                   CompareMethod=self.CompareNumberOfSegments)
649             hyp.SetDistrType( 1 )
650             hyp.SetScaleFactor(s)
651         hyp.SetNumberOfSegments(n)
652         return hyp
653
654     ## Check if the given "NumberOfSegments" hypothesis has the same parameters as given arguments
655     def CompareNumberOfSegments(self, hyp, args):
656         if hyp.GetNumberOfSegments() == args[0]:
657             if len(args) == 1:
658                 return True
659             else:
660                 if hyp.GetDistrType() == 1:
661                     if IsEqual(hyp.GetScaleFactor(), args[1]):
662                         return True
663         return False
664
665     ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
666     #  @param start for the length of the first segment
667     #  @param end   for the length of the last  segment
668     #  @param UseExisting if ==true - search existing hypothesis created with
669     #                     same parameters, else (default) - create new
670     def Arithmetic1D(self, start, end, UseExisting=0):
671         hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
672                               CompareMethod=self.CompareArithmetic1D)
673         hyp.SetLength(start, 1)
674         hyp.SetLength(end  , 0)
675         return hyp
676
677     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as given arguments
678     def CompareArithmetic1D(self, hyp, args):
679         if IsEqual(hyp.GetLength(1), args[0]):
680             if IsEqual(hyp.GetLength(0), args[1]):
681                 return True
682         return False
683
684     ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
685     #  @param start for the length of the first segment
686     #  @param end   for the length of the last  segment
687     #  @param UseExisting if ==true - search existing hypothesis created with
688     #                     same parameters, else (default) - create new
689     def StartEndLength(self, start, end, UseExisting=0):
690         hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
691                               CompareMethod=self.CompareStartEndLength)
692         hyp.SetLength(start, 1)
693         hyp.SetLength(end  , 0)
694         return hyp
695
696     ## Check if the given "StartEndLength" hypothesis has the same parameters as given arguments
697     def CompareStartEndLength(self, hyp, args):
698         if IsEqual(hyp.GetLength(1), args[0]):
699             if IsEqual(hyp.GetLength(0), args[1]):
700                 return True
701         return False
702
703     ## Define "Deflection1D" hypothesis
704     #  @param d for the deflection
705     #  @param UseExisting if ==true - search existing hypothesis created with
706     #                     same parameters, else (default) - create new
707     def Deflection1D(self, d, UseExisting=0):
708         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
709                               CompareMethod=self.CompareDeflection1D)
710         hyp.SetDeflection(d)
711         return hyp
712
713     ## Check if the given "Deflection1D" hypothesis has the same parameters as given arguments
714     def CompareDeflection1D(self, hyp, args):
715         return IsEqual(hyp.GetDeflection(), args[0])
716
717     ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
718     #  the opposite side in the case of quadrangular faces
719     def Propagation(self):
720         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
721
722     ## Define "AutomaticLength" hypothesis
723     #  @param fineness for the fineness [0-1]
724     #  @param UseExisting if ==true - search existing hypothesis created with
725     #                     same parameters, else (default) - create new
726     def AutomaticLength(self, fineness=0, UseExisting=0):
727         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
728                               CompareMethod=self.CompareAutomaticLength)
729         hyp.SetFineness( fineness )
730         return hyp
731
732     ## Check if the given "AutomaticLength" hypothesis has the same parameters as given arguments
733     def CompareAutomaticLength(self, hyp, args):
734         return IsEqual(hyp.GetFineness(), args[0])
735
736     ## Define "SegmentLengthAroundVertex" hypothesis
737     #  @param length for the segment length
738     #  @param vertex for the length localization: vertex index [0,1] | vertex object.
739     #         Any other integer value means what hypo will be set on the
740     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
741     #  @param UseExisting if ==true - search existing hypothesis created with
742     #                     same parameters, else (default) - create new
743     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
744         import types
745         store_geom = self.geom
746         if type(vertex) is types.IntType:
747             if vertex == 0 or vertex == 1:
748                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
749                 self.geom = vertex
750                 pass
751             pass
752         else:
753             self.geom = vertex
754             pass
755         ### 0D algorithm
756         if self.geom is None:
757             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
758         name = GetName(self.geom)
759         if name == NO_NAME:
760             piece = self.mesh.geom
761             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
762             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
763         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
764         if algo is None:
765             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
766             pass
767         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
768         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
769         ###
770         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
771                               CompareMethod=self.CompareLengthNearVertex)
772         self.geom = store_geom
773         hyp.SetLength( length )
774         return hyp
775
776     ## Check if the given "LengthNearVertex" hypothesis has the same parameters as given arguments
777     def CompareLengthNearVertex(self, hyp, args):
778         return IsEqual(hyp.GetLength(), args[0])
779
780     ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
781     #  If the 2D mesher sees that all boundary edges are quadratic ones,
782     #  it generates quadratic faces, else it generates linear faces using
783     #  medium nodes as if they were vertex ones.
784     #  The 3D mesher generates quadratic volumes only if all boundary faces
785     #  are quadratic ones, else it fails.
786     def QuadraticMesh(self):
787         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
788         return hyp
789
790 # Public class: Mesh_CompositeSegment
791 # --------------------------
792
793 ## Class to define a segment 1D algorithm for discretization
794 #
795 #  More details.
796 class Mesh_CompositeSegment(Mesh_Segment):
797
798     ## Private constructor.
799     def __init__(self, mesh, geom=0):
800         self.Create(mesh, geom, "CompositeSegment_1D")
801
802
803 # Public class: Mesh_Segment_Python
804 # ---------------------------------
805
806 ## Class to define a segment 1D algorithm for discretization with python function
807 #
808 #  More details.
809 class Mesh_Segment_Python(Mesh_Segment):
810
811     ## Private constructor.
812     def __init__(self, mesh, geom=0):
813         import Python1dPlugin
814         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
815
816     ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
817     #  @param n for the number of segments that cut an edge
818     #  @param func for the python function that calculate the length of all segments
819     #  @param UseExisting if ==true - search existing hypothesis created with
820     #                     same parameters, else (default) - create new
821     def PythonSplit1D(self, n, func, UseExisting=0):
822         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
823                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
824         hyp.SetNumberOfSegments(n)
825         hyp.SetPythonLog10RatioFunction(func)
826         return hyp
827
828     ## Check if the given "PythonSplit1D" hypothesis has the same parameters as given arguments
829     def ComparePythonSplit1D(self, hyp, args):
830         #if hyp.GetNumberOfSegments() == args[0]:
831         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
832         #        return True
833         return False
834
835 # Public class: Mesh_Triangle
836 # ---------------------------
837
838 ## Class to define a triangle 2D algorithm
839 #
840 #  More details.
841 class Mesh_Triangle(Mesh_Algorithm):
842
843     # default values
844     algoType = 0
845     params = 0
846
847     _angleMeshS = 8
848     _gradation  = 1.1
849
850     ## Private constructor.
851     def __init__(self, mesh, algoType, geom=0):
852         Mesh_Algorithm.__init__(self)
853
854         self.algoType = algoType
855         if algoType == MEFISTO:
856             self.Create(mesh, geom, "MEFISTO_2D")
857             pass
858         elif algoType == BLSURF:
859             import BLSURFPlugin
860             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
861             self.SetPhysicalMesh()
862         elif algoType == NETGEN:
863             if noNETGENPlugin:
864                 print "Warning: NETGENPlugin module unavailable"
865                 pass
866             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
867             pass
868         elif algoType == NETGEN_2D:
869             if noNETGENPlugin:
870                 print "Warning: NETGENPlugin module unavailable"
871                 pass
872             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
873             pass
874
875     ## Define "MaxElementArea" hypothesis to give the maximum area of each triangle
876     #  @param area for the maximum area of each triangle
877     #  @param UseExisting if ==true - search existing hypothesis created with
878     #                     same parameters, else (default) - create new
879     #
880     #  Only for algoType == MEFISTO || NETGEN_2D
881     def MaxElementArea(self, area, UseExisting=0):
882         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
883             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
884                                   CompareMethod=self.CompareMaxElementArea)
885             hyp.SetMaxElementArea(area)
886             return hyp
887         elif self.algoType == NETGEN:
888             print "Netgen 1D-2D algo doesn't support this hypothesis"
889             return None
890
891     ## Check if the given "MaxElementArea" hypothesis has the same parameters as given arguments
892     def CompareMaxElementArea(self, hyp, args):
893         return IsEqual(hyp.GetMaxElementArea(), args[0])
894
895     ## Define "LengthFromEdges" hypothesis to build triangles
896     #  based on the length of the edges taken from the wire
897     #
898     #  Only for algoType == MEFISTO || NETGEN_2D
899     def LengthFromEdges(self):
900         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
901             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
902             return hyp
903         elif self.algoType == NETGEN:
904             print "Netgen 1D-2D algo doesn't support this hypothesis"
905             return None
906
907     ## Set PhysicalMesh
908     #  @param thePhysicalMesh is:
909     #  DefaultSize or Custom
910     def SetPhysicalMesh(self, thePhysicalMesh=1):
911         if self.params == 0:
912             self.Parameters()
913         self.params.SetPhysicalMesh(thePhysicalMesh)
914
915     ## Set PhySize flag
916     def SetPhySize(self, theVal):
917         if self.params == 0:
918             self.Parameters()
919         self.params.SetPhySize(theVal)
920
921     ## Set GeometricMesh
922     #  @param theGeometricMesh is:
923     #  DefaultGeom or Custom
924     def SetGeometricMesh(self, theGeometricMesh=0):
925         if self.params == 0:
926             self.Parameters()
927         if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
928         self.params.SetGeometricMesh(theGeometricMesh)
929
930     ## Set AngleMeshS flag
931     def SetAngleMeshS(self, theVal=_angleMeshS):
932         if self.params == 0:
933             self.Parameters()
934         if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
935         self.params.SetAngleMeshS(theVal)
936
937     ## Set Gradation flag
938     def SetGradation(self, theVal=_gradation):
939         if self.params == 0:
940             self.Parameters()
941         if self.params.GetGeometricMesh() == 0: theVal = self._gradation
942         self.params.SetGradation(theVal)
943
944     ## Set QuadAllowed flag
945     #
946     #  Only for algoType == NETGEN || NETGEN_2D
947     def SetQuadAllowed(self, toAllow=True):
948         if self.algoType == NETGEN_2D:
949             if toAllow: # add QuadranglePreference
950                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
951             else:       # remove QuadranglePreference
952                 for hyp in self.mesh.GetHypothesisList( self.geom ):
953                     if hyp.GetName() == "QuadranglePreference":
954                         self.mesh.RemoveHypothesis( self.geom, hyp )
955                         pass
956                     pass
957                 pass
958             return
959         if self.params == 0:
960             self.Parameters()
961         if self.params:
962             self.params.SetQuadAllowed(toAllow)
963             return
964
965     ## Define "Netgen 2D Parameters" hypothesis
966     #
967     #  Only for algoType == NETGEN
968     def Parameters(self):
969         if self.algoType == NETGEN:
970             self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
971                                           "libNETGENEngine.so", UseExisting=0)
972             return self.params
973         elif self.algoType == MEFISTO:
974             print "Mefisto algo doesn't support NETGEN_Parameters_2D hypothesis"
975             return None
976         elif self.algoType == NETGEN_2D:
977             print "NETGEN_2D_ONLY algo doesn't support 'NETGEN_Parameters_2D' hypothesis"
978             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
979             return None
980         elif self.algoType == BLSURF:
981             self.params = self.Hypothesis("BLSURF_Parameters", [],
982                                           "libBLSURFEngine.so", UseExisting=0)
983             return self.params
984         return None
985
986     ## Set MaxSize
987     #
988     #  Only for algoType == NETGEN
989     def SetMaxSize(self, theSize):
990         if self.params == 0:
991             self.Parameters()
992         if self.params is not None:
993             self.params.SetMaxSize(theSize)
994
995     ## Set SecondOrder flag
996     #
997     #  Only for algoType == NETGEN
998     def SetSecondOrder(self, theVal):
999         if self.params == 0:
1000             self.Parameters()
1001         if self.params is not None:
1002             self.params.SetSecondOrder(theVal)
1003
1004     ## Set Optimize flag
1005     #
1006     #  Only for algoType == NETGEN
1007     def SetOptimize(self, theVal):
1008         if self.params == 0:
1009             self.Parameters()
1010         if self.params is not None:
1011             self.params.SetOptimize(theVal)
1012
1013     ## Set Fineness
1014     #  @param theFineness is:
1015     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
1016     #
1017     #  Only for algoType == NETGEN
1018     def SetFineness(self, theFineness):
1019         if self.params == 0:
1020             self.Parameters()
1021         if self.params is not None:
1022             self.params.SetFineness(theFineness)
1023
1024     ## Set GrowthRate
1025     #
1026     #  Only for algoType == NETGEN
1027     def SetGrowthRate(self, theRate):
1028         if self.params == 0:
1029             self.Parameters()
1030         if self.params is not None:
1031             self.params.SetGrowthRate(theRate)
1032
1033     ## Set NbSegPerEdge
1034     #
1035     #  Only for algoType == NETGEN
1036     def SetNbSegPerEdge(self, theVal):
1037         if self.params == 0:
1038             self.Parameters()
1039         if self.params is not None:
1040             self.params.SetNbSegPerEdge(theVal)
1041
1042     ## Set NbSegPerRadius
1043     #
1044     #  Only for algoType == NETGEN
1045     def SetNbSegPerRadius(self, theVal):
1046         if self.params == 0:
1047             self.Parameters()
1048         if self.params is not None:
1049             self.params.SetNbSegPerRadius(theVal)
1050
1051     ## Set Decimesh flag
1052     def SetDecimesh(self, toAllow=False):
1053         if self.params == 0:
1054             self.Parameters()
1055         self.params.SetDecimesh(toAllow)
1056
1057     pass
1058
1059
1060 # Public class: Mesh_Quadrangle
1061 # -----------------------------
1062
1063 ## Class to define a quadrangle 2D algorithm
1064 #
1065 #  More details.
1066 class Mesh_Quadrangle(Mesh_Algorithm):
1067
1068     ## Private constructor.
1069     def __init__(self, mesh, geom=0):
1070         Mesh_Algorithm.__init__(self)
1071         self.Create(mesh, geom, "Quadrangle_2D")
1072
1073     ## Define "QuadranglePreference" hypothesis, forcing construction
1074     #  of quadrangles if the number of nodes on opposite edges is not the same
1075     #  in the case where the global number of nodes on edges is even
1076     def QuadranglePreference(self):
1077         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
1078                               CompareMethod=self.CompareEqualHyp)
1079         return hyp
1080
1081 # Public class: Mesh_Tetrahedron
1082 # ------------------------------
1083
1084 ## Class to define a tetrahedron 3D algorithm
1085 #
1086 #  More details.
1087 class Mesh_Tetrahedron(Mesh_Algorithm):
1088
1089     params = 0
1090     algoType = 0
1091
1092     ## Private constructor.
1093     def __init__(self, mesh, algoType, geom=0):
1094         Mesh_Algorithm.__init__(self)
1095
1096         if algoType == NETGEN:
1097             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
1098             pass
1099
1100         elif algoType == GHS3D:
1101             import GHS3DPlugin
1102             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
1103             pass
1104
1105         elif algoType == FULL_NETGEN:
1106             if noNETGENPlugin:
1107                 print "Warning: NETGENPlugin module has not been imported."
1108             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
1109             pass
1110
1111         self.algoType = algoType
1112
1113     ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
1114     #  @param vol for the maximum volume of each tetrahedral
1115     #  @param UseExisting if ==true - search existing hypothesis created with
1116     #                     same parameters, else (default) - create new
1117     def MaxElementVolume(self, vol, UseExisting=0):
1118         hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
1119                               CompareMethod=self.CompareMaxElementVolume)
1120         hyp.SetMaxElementVolume(vol)
1121         return hyp
1122
1123     ## Check if the given "MaxElementVolume" hypothesis has the same parameters as given arguments
1124     def CompareMaxElementVolume(self, hyp, args):
1125         return IsEqual(hyp.GetMaxElementVolume(), args[0])
1126
1127     ## Define "Netgen 3D Parameters" hypothesis
1128     def Parameters(self):
1129         if (self.algoType == FULL_NETGEN):
1130             self.params = self.Hypothesis("NETGEN_Parameters", [],
1131                                           "libNETGENEngine.so", UseExisting=0)
1132             return self.params
1133         else:
1134             print "Algo doesn't support this hypothesis"
1135             return None
1136
1137     ## Set MaxSize
1138     def SetMaxSize(self, theSize):
1139         if self.params == 0:
1140             self.Parameters()
1141         self.params.SetMaxSize(theSize)
1142
1143     ## Set SecondOrder flag
1144     def SetSecondOrder(self, theVal):
1145         if self.params == 0:
1146             self.Parameters()
1147         self.params.SetSecondOrder(theVal)
1148
1149     ## Set Optimize flag
1150     def SetOptimize(self, theVal):
1151         if self.params == 0:
1152             self.Parameters()
1153         self.params.SetOptimize(theVal)
1154
1155     ## Set Fineness
1156     #  @param theFineness is:
1157     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
1158     def SetFineness(self, theFineness):
1159         if self.params == 0:
1160             self.Parameters()
1161         self.params.SetFineness(theFineness)
1162
1163     ## Set GrowthRate
1164     def SetGrowthRate(self, theRate):
1165         if self.params == 0:
1166             self.Parameters()
1167         self.params.SetGrowthRate(theRate)
1168
1169     ## Set NbSegPerEdge
1170     def SetNbSegPerEdge(self, theVal):
1171         if self.params == 0:
1172             self.Parameters()
1173         self.params.SetNbSegPerEdge(theVal)
1174
1175     ## Set NbSegPerRadius
1176     def SetNbSegPerRadius(self, theVal):
1177         if self.params == 0:
1178             self.Parameters()
1179         self.params.SetNbSegPerRadius(theVal)
1180
1181 # Public class: Mesh_Hexahedron
1182 # ------------------------------
1183
1184 ## Class to define a hexahedron 3D algorithm
1185 #
1186 #  More details.
1187 class Mesh_Hexahedron(Mesh_Algorithm):
1188
1189     params = 0
1190     algoType = 0
1191
1192     ## Private constructor.
1193     def __init__(self, mesh, algoType=Hexa, geom=0):
1194         Mesh_Algorithm.__init__(self)
1195
1196         self.algoType = algoType
1197
1198         if algoType == Hexa:
1199             self.Create(mesh, geom, "Hexa_3D")
1200             pass
1201
1202         elif algoType == Hexotic:
1203             import HexoticPlugin
1204             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
1205             pass
1206
1207     ## Define "MinMaxQuad" hypothesis to give the three hexotic parameters
1208     def MinMaxQuad(self, min=3, max=8, quad=True):
1209         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
1210                                       UseExisting=0)
1211         self.params.SetHexesMinLevel(min)
1212         self.params.SetHexesMaxLevel(max)
1213         self.params.SetHexoticQuadrangles(quad)
1214         return self.params
1215
1216 # Deprecated, only for compatibility!
1217 # Public class: Mesh_Netgen
1218 # ------------------------------
1219
1220 ## Class to define a NETGEN-based 2D or 3D algorithm
1221 #  that need no discrete boundary (i.e. independent)
1222 #
1223 #  This class is deprecated, only for compatibility!
1224 #
1225 #  More details.
1226 class Mesh_Netgen(Mesh_Algorithm):
1227
1228     is3D = 0
1229
1230     ## Private constructor.
1231     def __init__(self, mesh, is3D, geom=0):
1232         Mesh_Algorithm.__init__(self)
1233
1234         if noNETGENPlugin:
1235             print "Warning: NETGENPlugin module has not been imported."
1236
1237         self.is3D = is3D
1238         if is3D:
1239             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
1240             pass
1241
1242         else:
1243             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
1244             pass
1245
1246     ## Define hypothesis containing parameters of the algorithm
1247     def Parameters(self):
1248         if self.is3D:
1249             hyp = self.Hypothesis("NETGEN_Parameters", [],
1250                                   "libNETGENEngine.so", UseExisting=0)
1251         else:
1252             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
1253                                   "libNETGENEngine.so", UseExisting=0)
1254         return hyp
1255
1256 # Public class: Mesh_Projection1D
1257 # ------------------------------
1258
1259 ## Class to define a projection 1D algorithm
1260 #
1261 #  More details.
1262 class Mesh_Projection1D(Mesh_Algorithm):
1263
1264     ## Private constructor.
1265     def __init__(self, mesh, geom=0):
1266         Mesh_Algorithm.__init__(self)
1267         self.Create(mesh, geom, "Projection_1D")
1268
1269     ## Define "Source Edge" hypothesis, specifying a meshed edge to
1270     #  take a mesh pattern from, and optionally association of vertices
1271     #  between the source edge and a target one (where a hipothesis is assigned to)
1272     #  @param edge to take nodes distribution from
1273     #  @param mesh to take nodes distribution from (optional)
1274     #  @param srcV is vertex of \a edge to associate with \a tgtV (optional)
1275     #  @param tgtV is vertex of \a the edge where the algorithm is assigned,
1276     #  to associate with \a srcV (optional)
1277     #  @param UseExisting if ==true - search existing hypothesis created with
1278     #                     same parameters, else (default) - create new
1279     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
1280         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
1281                               UseExisting=0)
1282                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
1283         hyp.SetSourceEdge( edge )
1284         if not mesh is None and isinstance(mesh, Mesh):
1285             mesh = mesh.GetMesh()
1286         hyp.SetSourceMesh( mesh )
1287         hyp.SetVertexAssociation( srcV, tgtV )
1288         return hyp
1289
1290     ## Check if the given "SourceEdge" hypothesis has the same parameters as given arguments
1291     #def CompareSourceEdge(self, hyp, args):
1292     #    # seems to be not really useful to reuse existing "SourceEdge" hypothesis
1293     #    return False
1294
1295
1296 # Public class: Mesh_Projection2D
1297 # ------------------------------
1298
1299 ## Class to define a projection 2D algorithm
1300 #
1301 #  More details.
1302 class Mesh_Projection2D(Mesh_Algorithm):
1303
1304     ## Private constructor.
1305     def __init__(self, mesh, geom=0):
1306         Mesh_Algorithm.__init__(self)
1307         self.Create(mesh, geom, "Projection_2D")
1308
1309     ## Define "Source Face" hypothesis, specifying a meshed face to
1310     #  take a mesh pattern from, and optionally association of vertices
1311     #  between the source face and a target one (where a hipothesis is assigned to)
1312     #  @param face to take mesh pattern from
1313     #  @param mesh to take mesh pattern from (optional)
1314     #  @param srcV1 is vertex of \a face to associate with \a tgtV1 (optional)
1315     #  @param tgtV1 is vertex of \a the face where the algorithm is assigned,
1316     #  to associate with \a srcV1 (optional)
1317     #  @param srcV2 is vertex of \a face to associate with \a tgtV1 (optional)
1318     #  @param tgtV2 is vertex of \a the face where the algorithm is assigned,
1319     #  to associate with \a srcV2 (optional)
1320     #  @param UseExisting if ==true - search existing hypothesis created with
1321     #                     same parameters, else (default) - create new
1322     #
1323     #  Note: association vertices must belong to one edge of a face
1324     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
1325                    srcV2=None, tgtV2=None, UseExisting=0):
1326         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
1327                               UseExisting=0)
1328                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
1329         hyp.SetSourceFace( face )
1330         if not mesh is None and isinstance(mesh, Mesh):
1331             mesh = mesh.GetMesh()
1332         hyp.SetSourceMesh( mesh )
1333         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1334         return hyp
1335
1336     ## Check if the given "SourceFace" hypothesis has the same parameters as given arguments
1337     #def CompareSourceFace(self, hyp, args):
1338     #    # seems to be not really useful to reuse existing "SourceFace" hypothesis
1339     #    return False
1340
1341 # Public class: Mesh_Projection3D
1342 # ------------------------------
1343
1344 ## Class to define a projection 3D algorithm
1345 #
1346 #  More details.
1347 class Mesh_Projection3D(Mesh_Algorithm):
1348
1349     ## Private constructor.
1350     def __init__(self, mesh, geom=0):
1351         Mesh_Algorithm.__init__(self)
1352         self.Create(mesh, geom, "Projection_3D")
1353
1354     ## Define "Source Shape 3D" hypothesis, specifying a meshed solid to
1355     #  take a mesh pattern from, and optionally association of vertices
1356     #  between the source solid and a target one (where a hipothesis is assigned to)
1357     #  @param solid to take mesh pattern from
1358     #  @param mesh to take mesh pattern from (optional)
1359     #  @param srcV1 is vertex of \a solid to associate with \a tgtV1 (optional)
1360     #  @param tgtV1 is vertex of \a the solid where the algorithm is assigned,
1361     #  to associate with \a srcV1 (optional)
1362     #  @param srcV2 is vertex of \a solid to associate with \a tgtV1 (optional)
1363     #  @param tgtV2 is vertex of \a the solid where the algorithm is assigned,
1364     #  to associate with \a srcV2 (optional)
1365     #  @param UseExisting - if ==true - search existing hypothesis created with
1366     #                       same parameters, else (default) - create new
1367     #
1368     #  Note: association vertices must belong to one edge of a solid
1369     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
1370                       srcV2=0, tgtV2=0, UseExisting=0):
1371         hyp = self.Hypothesis("ProjectionSource3D",
1372                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
1373                               UseExisting=0)
1374                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
1375         hyp.SetSource3DShape( solid )
1376         if not mesh is None and isinstance(mesh, Mesh):
1377             mesh = mesh.GetMesh()
1378         hyp.SetSourceMesh( mesh )
1379         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1380         return hyp
1381
1382     ## Check if the given "SourceShape3D" hypothesis has the same parameters as given arguments
1383     #def CompareSourceShape3D(self, hyp, args):
1384     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
1385     #    return False
1386
1387
1388 # Public class: Mesh_Prism
1389 # ------------------------
1390
1391 ## Class to define a 3D extrusion algorithm
1392 #
1393 #  More details.
1394 class Mesh_Prism3D(Mesh_Algorithm):
1395
1396     ## Private constructor.
1397     def __init__(self, mesh, geom=0):
1398         Mesh_Algorithm.__init__(self)
1399         self.Create(mesh, geom, "Prism_3D")
1400
1401 # Public class: Mesh_RadialPrism
1402 # -------------------------------
1403
1404 ## Class to define a Radial Prism 3D algorithm
1405 #
1406 #  More details.
1407 class Mesh_RadialPrism3D(Mesh_Algorithm):
1408
1409     ## Private constructor.
1410     def __init__(self, mesh, geom=0):
1411         Mesh_Algorithm.__init__(self)
1412         self.Create(mesh, geom, "RadialPrism_3D")
1413
1414         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
1415         self.nbLayers = None
1416
1417     ## Return 3D hypothesis holding the 1D one
1418     def Get3DHypothesis(self):
1419         return self.distribHyp
1420
1421     ## Private method creating 1D hypothes and storing it in the LayerDistribution
1422     #  hypothes. Returns the created hypothes
1423     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1424         print "OwnHypothesis",hypType
1425         if not self.nbLayers is None:
1426             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1427             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1428         study = self.mesh.smeshpyD.GetCurrentStudy() # prevent publishing of own 1D hypothesis
1429         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1430         self.mesh.smeshpyD.SetCurrentStudy( study ) # anable publishing
1431         self.distribHyp.SetLayerDistribution( hyp )
1432         return hyp
1433
1434     ## Define "NumberOfLayers" hypothesis, specifying a number of layers of
1435     #  prisms to build between the inner and outer shells
1436     #  @param UseExisting if ==true - search existing hypothesis created with
1437     #                     same parameters, else (default) - create new
1438     def NumberOfLayers(self, n, UseExisting=0):
1439         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1440         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
1441                                         CompareMethod=self.CompareNumberOfLayers)
1442         self.nbLayers.SetNumberOfLayers( n )
1443         return self.nbLayers
1444
1445     ## Check if the given "NumberOfLayers" hypothesis has the same parameters as given arguments
1446     def CompareNumberOfLayers(self, hyp, args):
1447         return IsEqual(hyp.GetNumberOfLayers(), args[0])
1448
1449     ## Define "LocalLength" hypothesis, specifying segment length
1450     #  to build between the inner and outer shells
1451     #  @param l for the length of segments
1452     def LocalLength(self, l):
1453         hyp = self.OwnHypothesis("LocalLength", [l])
1454         hyp.SetLength(l)
1455         return hyp
1456
1457     ## Define "NumberOfSegments" hypothesis, specifying a number of layers of
1458     #  prisms to build between the inner and outer shells
1459     #  @param n for the number of segments
1460     #  @param s for the scale factor (optional)
1461     def NumberOfSegments(self, n, s=[]):
1462         if s == []:
1463             hyp = self.OwnHypothesis("NumberOfSegments", [n])
1464         else:
1465             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1466             hyp.SetDistrType( 1 )
1467             hyp.SetScaleFactor(s)
1468         hyp.SetNumberOfSegments(n)
1469         return hyp
1470
1471     ## Define "Arithmetic1D" hypothesis, specifying distribution of segments
1472     #  to build between the inner and outer shells as arithmetic length increasing
1473     #  @param start for the length of the first segment
1474     #  @param end   for the length of the last  segment
1475     def Arithmetic1D(self, start, end ):
1476         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1477         hyp.SetLength(start, 1)
1478         hyp.SetLength(end  , 0)
1479         return hyp
1480
1481     ## Define "StartEndLength" hypothesis, specifying distribution of segments
1482     #  to build between the inner and outer shells as geometric length increasing
1483     #  @param start for the length of the first segment
1484     #  @param end   for the length of the last  segment
1485     def StartEndLength(self, start, end):
1486         hyp = self.OwnHypothesis("StartEndLength", [start, end])
1487         hyp.SetLength(start, 1)
1488         hyp.SetLength(end  , 0)
1489         return hyp
1490
1491     ## Define "AutomaticLength" hypothesis, specifying number of segments
1492     #  to build between the inner and outer shells
1493     #  @param fineness for the fineness [0-1]
1494     def AutomaticLength(self, fineness=0):
1495         hyp = self.OwnHypothesis("AutomaticLength")
1496         hyp.SetFineness( fineness )
1497         return hyp
1498
1499 # Private class: Mesh_UseExisting
1500 # -------------------------------
1501 class Mesh_UseExisting(Mesh_Algorithm):
1502
1503     def __init__(self, dim, mesh, geom=0):
1504         if dim == 1:
1505             self.Create(mesh, geom, "UseExisting_1D")
1506         else:
1507             self.Create(mesh, geom, "UseExisting_2D")
1508
1509 # Public class: Mesh
1510 # ==================
1511
1512 ## Class to define a mesh
1513 #
1514 #  The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
1515 #  More details.
1516 class Mesh:
1517
1518     geom = 0
1519     mesh = 0
1520     editor = 0
1521
1522     ## Constructor
1523     #
1524     #  Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
1525     #  sets GUI name of this mesh to \a name.
1526     #  @param obj Shape to be meshed or SMESH_Mesh object
1527     #  @param name Study name of the mesh
1528     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1529         self.smeshpyD=smeshpyD
1530         self.geompyD=geompyD
1531         if obj is None:
1532             obj = 0
1533         if obj != 0:
1534             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1535                 self.geom = obj
1536                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1537             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1538                 self.SetMesh(obj)
1539         else:
1540             self.mesh = self.smeshpyD.CreateEmptyMesh()
1541         if name != 0:
1542             SetName(self.mesh, name)
1543         elif obj != 0:
1544             SetName(self.mesh, GetName(obj))
1545
1546         self.editor = self.mesh.GetMeshEditor()
1547
1548     ## Method that inits the Mesh object from SMESH_Mesh interface
1549     #  @param theMesh is SMESH_Mesh object
1550     def SetMesh(self, theMesh):
1551         self.mesh = theMesh
1552         self.geom = self.mesh.GetShapeToMesh()
1553
1554     ## Method that returns the mesh
1555     #  @return SMESH_Mesh object
1556     def GetMesh(self):
1557         return self.mesh
1558
1559     ## Get mesh name
1560     def GetName(self):
1561         name = GetName(self.GetMesh())
1562         return name
1563
1564     ## Set name to mesh
1565     def SetName(self, name):
1566         SetName(self.GetMesh(), name)
1567
1568     ## Get the subMesh object associated to a subShape. The subMesh object
1569     #  gives access to nodes and elements IDs.
1570     #  \n SubMesh will be used instead of SubShape in a next idl version to
1571     #  adress a specific subMesh...
1572     def GetSubMesh(self, theSubObject, name):
1573         submesh = self.mesh.GetSubMesh(theSubObject, name)
1574         return submesh
1575
1576     ## Method that returns the shape associated to the mesh
1577     #  @return GEOM_Object
1578     def GetShape(self):
1579         return self.geom
1580
1581     ## Method that associates given shape to the mesh(entails the mesh recreation)
1582     #  @param geom shape to be meshed(GEOM_Object)
1583     def SetShape(self, geom):
1584         self.mesh = self.smeshpyD.CreateMesh(geom)
1585
1586     ## Return true if hypotheses are defined well
1587     #  @param theMesh is an instance of Mesh class
1588     #  @param theSubObject subshape of a mesh shape
1589     def IsReadyToCompute(self, theSubObject):
1590         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1591
1592     ## Return errors of hypotheses definintion
1593     #  error list is empty if everything is OK
1594     #  @param theMesh is an instance of Mesh class
1595     #  @param theSubObject subshape of a mesh shape
1596     #  @return a list of errors
1597     def GetAlgoState(self, theSubObject):
1598         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1599
1600     ## Return geometrical object the given element is built on.
1601     #  The returned geometrical object, if not nil, is either found in the
1602     #  study or is published by this method with the given name
1603     #  @param theMesh is an instance of Mesh class
1604     #  @param theElementID an id of the mesh element
1605     #  @param theGeomName user defined name of geometrical object
1606     #  @return GEOM::GEOM_Object instance
1607     def GetGeometryByMeshElement(self, theElementID, theGeomName):
1608         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1609
1610     ## Returns mesh dimension depending on shape one
1611     def MeshDimension(self):
1612         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1613         if len( shells ) > 0 :
1614             return 3
1615         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1616             return 2
1617         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1618             return 1
1619         else:
1620             return 0;
1621         pass
1622
1623     ## Creates a segment discretization 1D algorithm.
1624     #  If the optional \a algo parameter is not sets, this algorithm is REGULAR.
1625     #  If the optional \a geom parameter is not sets, this algorithm is global.
1626     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1627     #  @param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
1628     #  @param geom If defined, subshape to be meshed
1629     def Segment(self, algo=REGULAR, geom=0):
1630         ## if Segment(geom) is called by mistake
1631         if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1632             algo, geom = geom, algo
1633             if not algo: algo = REGULAR
1634             pass
1635         if algo == REGULAR:
1636             return Mesh_Segment(self,  geom)
1637         elif algo == PYTHON:
1638             return Mesh_Segment_Python(self, geom)
1639         elif algo == COMPOSITE:
1640             return Mesh_CompositeSegment(self, geom)
1641         else:
1642             return Mesh_Segment(self, geom)
1643
1644     ## Enable creation of nodes and segments usable by 2D algoritms.
1645     #  Added nodes and segments must be bound to edges and vertices by
1646     #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1647     #  If the optional \a geom parameter is not sets, this algorithm is global.
1648     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1649     #  @param geom subshape to be manually meshed
1650     #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
1651     def UseExistingSegments(self, geom=0):
1652         algo = Mesh_UseExisting(1,self,geom)
1653         return algo.GetAlgorithm()
1654
1655     ## Enable creation of nodes and faces usable by 3D algoritms.
1656     #  Added nodes and faces must be bound to geom faces by SetNodeOnFace()
1657     #  and SetMeshElementOnShape()
1658     #  If the optional \a geom parameter is not sets, this algorithm is global.
1659     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1660     #  @param geom subshape to be manually meshed
1661     #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
1662     def UseExistingFaces(self, geom=0):
1663         algo = Mesh_UseExisting(2,self,geom)
1664         return algo.GetAlgorithm()
1665
1666     ## Creates a triangle 2D algorithm for faces.
1667     #  If the optional \a geom parameter is not sets, this algorithm is global.
1668     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1669     #  @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D
1670     #  @param geom If defined, subshape to be meshed
1671     def Triangle(self, algo=MEFISTO, geom=0):
1672         ## if Triangle(geom) is called by mistake
1673         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1674             geom = algo
1675             algo = MEFISTO
1676
1677         return Mesh_Triangle(self,  algo, geom)
1678
1679     ## Creates a quadrangle 2D algorithm for faces.
1680     #  If the optional \a geom parameter is not sets, this algorithm is global.
1681     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1682     #  @param geom If defined, subshape to be meshed
1683     def Quadrangle(self, geom=0):
1684         return Mesh_Quadrangle(self,  geom)
1685
1686     ## Creates a tetrahedron 3D algorithm for solids.
1687     #  The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
1688     #  If the optional \a geom parameter is not sets, this algorithm is global.
1689     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1690     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
1691     #  @param geom If defined, subshape to be meshed
1692     def Tetrahedron(self, algo=NETGEN, geom=0):
1693         ## if Tetrahedron(geom) is called by mistake
1694         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1695             algo, geom = geom, algo
1696             if not algo: algo = NETGEN
1697             pass
1698         return Mesh_Tetrahedron(self,  algo, geom)
1699
1700     ## Creates a hexahedron 3D algorithm for solids.
1701     #  If the optional \a geom parameter is not sets, this algorithm is global.
1702     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
1703     #  @param geom If defined, subshape to be meshed
1704     ## def Hexahedron(self, geom=0):
1705     ##     return Mesh_Hexahedron(self,  geom)
1706     def Hexahedron(self, algo=Hexa, geom=0):
1707         ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1708         if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1709             if   geom in [Hexa, Hexotic]: algo, geom = geom, algo
1710             elif geom == 0:               algo, geom = Hexa, algo
1711         return Mesh_Hexahedron(self, algo, geom)
1712
1713     ## Deprecated, only for compatibility!
1714     def Netgen(self, is3D, geom=0):
1715         return Mesh_Netgen(self,  is3D, geom)
1716
1717     ## Creates a projection 1D algorithm for edges.
1718     #  If the optional \a geom parameter is not sets, this algorithm is global.
1719     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1720     #  @param geom If defined, subshape to be meshed
1721     def Projection1D(self, geom=0):
1722         return Mesh_Projection1D(self,  geom)
1723
1724     ## Creates a projection 2D algorithm for faces.
1725     #  If the optional \a geom parameter is not sets, this algorithm is global.
1726     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1727     #  @param geom If defined, subshape to be meshed
1728     def Projection2D(self, geom=0):
1729         return Mesh_Projection2D(self,  geom)
1730
1731     ## Creates a projection 3D algorithm for solids.
1732     #  If the optional \a geom parameter is not sets, this algorithm is global.
1733     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1734     #  @param geom If defined, subshape to be meshed
1735     def Projection3D(self, geom=0):
1736         return Mesh_Projection3D(self,  geom)
1737
1738     ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1739     #  If the optional \a geom parameter is not sets, this algorithm is global.
1740     #  Otherwise, this algorithm define a submesh based on \a geom subshape.
1741     #  @param geom If defined, subshape to be meshed
1742     def Prism(self, geom=0):
1743         shape = geom
1744         if shape==0:
1745             shape = self.geom
1746         nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1747         nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1748         if nbSolids == 0 or nbSolids == nbShells:
1749             return Mesh_Prism3D(self,  geom)
1750         return Mesh_RadialPrism3D(self,  geom)
1751
1752     ## Compute the mesh and return the status of the computation
1753     def Compute(self, geom=0):
1754         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1755             if self.geom == 0:
1756                 print "Compute impossible: mesh is not constructed on geom shape."
1757                 return 0
1758             else:
1759                 geom = self.geom
1760         ok = False
1761         try:
1762             ok = self.smeshpyD.Compute(self.mesh, geom)
1763         except SALOME.SALOME_Exception, ex:
1764             print "Mesh computation failed, exception caught:"
1765             print "    ", ex.details.text
1766         except:
1767             import traceback
1768             print "Mesh computation failed, exception caught:"
1769             traceback.print_exc()
1770         if not ok:
1771             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1772             allReasons = ""
1773             for err in errors:
1774                 if err.isGlobalAlgo:
1775                     glob = "global"
1776                 else:
1777                     glob = "local"
1778                     pass
1779                 dim = err.algoDim
1780                 name = err.algoName
1781                 if len(name) == 0:
1782                     reason = '%s %sD algorithm is missing' % (glob, dim)
1783                 elif err.state == HYP_MISSING:
1784                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1785                               % (glob, dim, name, dim))
1786                 elif err.state == HYP_NOTCONFORM:
1787                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1788                 elif err.state == HYP_BAD_PARAMETER:
1789                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1790                               % ( glob, dim, name ))
1791                 elif err.state == HYP_BAD_GEOMETRY:
1792                     reason = ('%s %sD algorithm "%s" is assigned to geometry mismatching'
1793                               'its expectation' % ( glob, dim, name ))
1794                 else:
1795                     reason = "For unknown reason."+\
1796                              " Revise Mesh.Compute() implementation in smeshDC.py!"
1797                     pass
1798                 if allReasons != "":
1799                     allReasons += "\n"
1800                     pass
1801                 allReasons += reason
1802                 pass
1803             if allReasons != "":
1804                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1805                 print allReasons
1806             else:
1807                 print '"' + GetName(self.mesh) + '"',"has not been computed."
1808                 pass
1809             pass
1810         if salome.sg.hasDesktop():
1811             smeshgui = salome.ImportComponentGUI("SMESH")
1812             smeshgui.Init(salome.myStudyId)
1813             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1814             salome.sg.updateObjBrowser(1)
1815             pass
1816         return ok
1817
1818     ## Compute tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1819     #  The parameter \a fineness [0,-1] defines mesh fineness
1820     def AutomaticTetrahedralization(self, fineness=0):
1821         dim = self.MeshDimension()
1822         # assign hypotheses
1823         self.RemoveGlobalHypotheses()
1824         self.Segment().AutomaticLength(fineness)
1825         if dim > 1 :
1826             self.Triangle().LengthFromEdges()
1827             pass
1828         if dim > 2 :
1829             self.Tetrahedron(NETGEN)
1830             pass
1831         return self.Compute()
1832
1833     ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1834     #  The parameter \a fineness [0,-1] defines mesh fineness
1835     def AutomaticHexahedralization(self, fineness=0):
1836         dim = self.MeshDimension()
1837         # assign hypotheses
1838         self.RemoveGlobalHypotheses()
1839         self.Segment().AutomaticLength(fineness)
1840         if dim > 1 :
1841             self.Quadrangle()
1842             pass
1843         if dim > 2 :
1844             self.Hexahedron()
1845             pass
1846         return self.Compute()
1847
1848     ## Assign hypothesis
1849     #  @param hyp is a hypothesis to assign
1850     #  @param geom is subhape of mesh geometry
1851     def AddHypothesis(self, hyp, geom=0):
1852         if isinstance( hyp, Mesh_Algorithm ):
1853             hyp = hyp.GetAlgorithm()
1854             pass
1855         if not geom:
1856             geom = self.geom
1857             pass
1858         status = self.mesh.AddHypothesis(geom, hyp)
1859         isAlgo = hyp._narrow( SMESH_Algo )
1860         TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1861         return status
1862
1863     ## Unassign hypothesis
1864     #  @param hyp is a hypothesis to unassign
1865     #  @param geom is subhape of mesh geometry
1866     def RemoveHypothesis(self, hyp, geom=0):
1867         if isinstance( hyp, Mesh_Algorithm ):
1868             hyp = hyp.GetAlgorithm()
1869             pass
1870         if not geom:
1871             geom = self.geom
1872             pass
1873         status = self.mesh.RemoveHypothesis(geom, hyp)
1874         return status
1875
1876     ## Get the list of hypothesis added on a geom
1877     #  @param geom is subhape of mesh geometry
1878     def GetHypothesisList(self, geom):
1879         return self.mesh.GetHypothesisList( geom )
1880
1881     ## Removes all global hypotheses
1882     def RemoveGlobalHypotheses(self):
1883         current_hyps = self.mesh.GetHypothesisList( self.geom )
1884         for hyp in current_hyps:
1885             self.mesh.RemoveHypothesis( self.geom, hyp )
1886             pass
1887         pass
1888
1889     ## Create a mesh group based on geometric object \a grp
1890     #  and give a \a name, \n if this parameter is not defined
1891     #  the name is the same as the geometric group name \n
1892     #  Note: Works like GroupOnGeom().
1893     #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
1894     #  @param name is the name of the mesh group
1895     #  @return SMESH_GroupOnGeom
1896     def Group(self, grp, name=""):
1897         return self.GroupOnGeom(grp, name)
1898
1899     ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
1900     #  Export the mesh in a file with the MED format and choice the \a version of MED format
1901     #  @param f is the file name
1902     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1903     def ExportToMED(self, f, version, opt=0):
1904         self.mesh.ExportToMED(f, opt, version)
1905
1906     ## Export the mesh in a file with the MED format
1907     #  @param f is the file name
1908     #  @param auto_groups boolean parameter for creating/not creating
1909     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1910     #  the typical use is auto_groups=false.
1911     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1912     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1913         self.mesh.ExportToMED(f, auto_groups, version)
1914
1915     ## Export the mesh in a file with the DAT format
1916     #  @param f is the file name
1917     def ExportDAT(self, f):
1918         self.mesh.ExportDAT(f)
1919
1920     ## Export the mesh in a file with the UNV format
1921     #  @param f is the file name
1922     def ExportUNV(self, f):
1923         self.mesh.ExportUNV(f)
1924
1925     ## Export the mesh in a file with the STL format
1926     #  @param f is the file name
1927     #  @param ascii defined the kind of file contents
1928     def ExportSTL(self, f, ascii=1):
1929         self.mesh.ExportSTL(f, ascii)
1930
1931
1932     # Operations with groups:
1933     # ----------------------
1934
1935     ## Creates an empty mesh group
1936     #  @param elementType is the type of elements in the group
1937     #  @param name is the name of the mesh group
1938     #  @return SMESH_Group
1939     def CreateEmptyGroup(self, elementType, name):
1940         return self.mesh.CreateGroup(elementType, name)
1941
1942     ## Creates a mesh group based on geometric object \a grp
1943     #  and give a \a name, \n if this parameter is not defined
1944     #  the name is the same as the geometric group name
1945     #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
1946     #  @param name is the name of the mesh group
1947     #  @return SMESH_GroupOnGeom
1948     def GroupOnGeom(self, grp, name="", typ=None):
1949         if name == "":
1950             name = grp.GetName()
1951
1952         if typ == None:
1953             tgeo = str(grp.GetShapeType())
1954             if tgeo == "VERTEX":
1955                 typ = NODE
1956             elif tgeo == "EDGE":
1957                 typ = EDGE
1958             elif tgeo == "FACE":
1959                 typ = FACE
1960             elif tgeo == "SOLID":
1961                 typ = VOLUME
1962             elif tgeo == "SHELL":
1963                 typ = VOLUME
1964             elif tgeo == "COMPOUND":
1965                 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1966                     print "Mesh.Group: empty geometric group", GetName( grp )
1967                     return 0
1968                 tgeo = self.geompyD.GetType(grp)
1969                 if tgeo == geompyDC.ShapeType["VERTEX"]:
1970                     typ = NODE
1971                 elif tgeo == geompyDC.ShapeType["EDGE"]:
1972                     typ = EDGE
1973                 elif tgeo == geompyDC.ShapeType["FACE"]:
1974                     typ = FACE
1975                 elif tgeo == geompyDC.ShapeType["SOLID"]:
1976                     typ = VOLUME
1977
1978         if typ == None:
1979             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1980             return 0
1981         else:
1982             return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1983
1984     ## Create a mesh group by the given ids of elements
1985     #  @param groupName is the name of the mesh group
1986     #  @param elementType is the type of elements in the group
1987     #  @param elemIDs is the list of ids
1988     #  @return SMESH_Group
1989     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1990         group = self.mesh.CreateGroup(elementType, groupName)
1991         group.Add(elemIDs)
1992         return group
1993
1994     ## Create a mesh group by the given conditions
1995     #  @param groupName is the name of the mesh group
1996     #  @param elementType is the type of elements in the group
1997     #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1998     #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1999     #  @param Treshold is threshold value (range of id ids as string, shape, numeric)
2000     #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
2001     #  @return SMESH_Group
2002     def MakeGroup(self,
2003                   groupName,
2004                   elementType,
2005                   CritType=FT_Undefined,
2006                   Compare=FT_EqualTo,
2007                   Treshold="",
2008                   UnaryOp=FT_Undefined):
2009         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
2010         group = self.MakeGroupByCriterion(groupName, aCriterion)
2011         return group
2012
2013     ## Create a mesh group by the given criterion
2014     #  @param groupName is the name of the mesh group
2015     #  @param Criterion is the instance of Criterion class
2016     #  @return SMESH_Group
2017     def MakeGroupByCriterion(self, groupName, Criterion):
2018         aFilterMgr = self.smeshpyD.CreateFilterManager()
2019         aFilter = aFilterMgr.CreateFilter()
2020         aCriteria = []
2021         aCriteria.append(Criterion)
2022         aFilter.SetCriteria(aCriteria)
2023         group = self.MakeGroupByFilter(groupName, aFilter)
2024         return group
2025
2026     ## Create a mesh group by the given criteria(list of criterions)
2027     #  @param groupName is the name of the mesh group
2028     #  @param Criteria is the list of criterions
2029     #  @return SMESH_Group
2030     def MakeGroupByCriteria(self, groupName, theCriteria):
2031         aFilterMgr = self.smeshpyD.CreateFilterManager()
2032         aFilter = aFilterMgr.CreateFilter()
2033         aFilter.SetCriteria(theCriteria)
2034         group = self.MakeGroupByFilter(groupName, aFilter)
2035         return group
2036
2037     ## Create a mesh group by the given filter
2038     #  @param groupName is the name of the mesh group
2039     #  @param Criterion is the instance of Filter class
2040     #  @return SMESH_Group
2041     def MakeGroupByFilter(self, groupName, theFilter):
2042         anIds = theFilter.GetElementsId(self.mesh)
2043         anElemType = theFilter.GetElementType()
2044         group = self.MakeGroupByIds(groupName, anElemType, anIds)
2045         return group
2046
2047     ## Pass mesh elements through the given filter and return ids
2048     #  @param theFilter is SMESH_Filter
2049     #  @return list of ids
2050     def GetIdsFromFilter(self, theFilter):
2051         return theFilter.GetElementsId(self.mesh)
2052
2053     ## Verify whether 2D mesh element has free edges(edges connected to one face only)\n
2054     #  Returns list of special structures(borders).
2055     #  @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
2056     def GetFreeBorders(self):
2057         aFilterMgr = self.smeshpyD.CreateFilterManager()
2058         aPredicate = aFilterMgr.CreateFreeEdges()
2059         aPredicate.SetMesh(self.mesh)
2060         aBorders = aPredicate.GetBorders()
2061         return aBorders
2062
2063     ## Remove a group
2064     def RemoveGroup(self, group):
2065         self.mesh.RemoveGroup(group)
2066
2067     ## Remove group with its contents
2068     def RemoveGroupWithContents(self, group):
2069         self.mesh.RemoveGroupWithContents(group)
2070
2071     ## Get the list of groups existing in the mesh
2072     def GetGroups(self):
2073         return self.mesh.GetGroups()
2074
2075     ## Get number of groups existing in the mesh
2076     def NbGroups(self):
2077         return self.mesh.NbGroups()
2078
2079     ## Get the list of names of groups existing in the mesh
2080     def GetGroupNames(self):
2081         groups = self.GetGroups()
2082         names = []
2083         for group in groups:
2084             names.append(group.GetName())
2085         return names
2086
2087     ## Union of two groups
2088     #  New group is created. All mesh elements that are
2089     #  present in initial groups are added to the new one
2090     def UnionGroups(self, group1, group2, name):
2091         return self.mesh.UnionGroups(group1, group2, name)
2092
2093     ## Intersection of two groups
2094     #  New group is created. All mesh elements that are
2095     #  present in both initial groups are added to the new one.
2096     def IntersectGroups(self, group1, group2, name):
2097         return self.mesh.IntersectGroups(group1, group2, name)
2098
2099     ## Cut of two groups
2100     #  New group is created. All mesh elements that are present in
2101     #  main group but do not present in tool group are added to the new one
2102     def CutGroups(self, mainGroup, toolGroup, name):
2103         return self.mesh.CutGroups(mainGroup, toolGroup, name)
2104
2105
2106     # Get some info about mesh:
2107     # ------------------------
2108
2109     ## Get the log of nodes and elements added or removed since previous
2110     #  clear of the log.
2111     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
2112     #  @return list of log_block structures:
2113     #                                        commandType
2114     #                                        number
2115     #                                        coords
2116     #                                        indexes
2117     def GetLog(self, clearAfterGet):
2118         return self.mesh.GetLog(clearAfterGet)
2119
2120     ## Clear the log of nodes and elements added or removed since previous
2121     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
2122     def ClearLog(self):
2123         self.mesh.ClearLog()
2124
2125     def SetAutoColor(self, color):
2126         self.mesh.SetAutoColor(color)
2127
2128     def GetAutoColor(self):
2129         return self.mesh.GetAutoColor()
2130
2131     ## Get the internal Id
2132     def GetId(self):
2133         return self.mesh.GetId()
2134
2135     ## Get the study Id
2136     def GetStudyId(self):
2137         return self.mesh.GetStudyId()
2138
2139     ## Check group names for duplications.
2140     #  Consider maximum group name length stored in MED file.
2141     def HasDuplicatedGroupNamesMED(self):
2142         return self.mesh.HasDuplicatedGroupNamesMED()
2143
2144     ## Obtain instance of SMESH_MeshEditor
2145     def GetMeshEditor(self):
2146         return self.mesh.GetMeshEditor()
2147
2148     ## Get MED Mesh
2149     def GetMEDMesh(self):
2150         return self.mesh.GetMEDMesh()
2151
2152
2153     # Get informations about mesh contents:
2154     # ------------------------------------
2155
2156     ## Returns number of nodes in mesh
2157     def NbNodes(self):
2158         return self.mesh.NbNodes()
2159
2160     ## Returns number of elements in mesh
2161     def NbElements(self):
2162         return self.mesh.NbElements()
2163
2164     ## Returns number of edges in mesh
2165     def NbEdges(self):
2166         return self.mesh.NbEdges()
2167
2168     ## Returns number of edges with given order in mesh
2169     #  @param elementOrder is order of elements:
2170     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2171     def NbEdgesOfOrder(self, elementOrder):
2172         return self.mesh.NbEdgesOfOrder(elementOrder)
2173
2174     ## Returns number of faces in mesh
2175     def NbFaces(self):
2176         return self.mesh.NbFaces()
2177
2178     ## Returns number of faces with given order in mesh
2179     #  @param elementOrder is order of elements:
2180     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2181     def NbFacesOfOrder(self, elementOrder):
2182         return self.mesh.NbFacesOfOrder(elementOrder)
2183
2184     ## Returns number of triangles in mesh
2185     def NbTriangles(self):
2186         return self.mesh.NbTriangles()
2187
2188     ## Returns number of triangles with given order in mesh
2189     #  @param elementOrder is order of elements:
2190     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2191     def NbTrianglesOfOrder(self, elementOrder):
2192         return self.mesh.NbTrianglesOfOrder(elementOrder)
2193
2194     ## Returns number of quadrangles in mesh
2195     def NbQuadrangles(self):
2196         return self.mesh.NbQuadrangles()
2197
2198     ## Returns number of quadrangles with given order in mesh
2199     #  @param elementOrder is order of elements:
2200     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2201     def NbQuadranglesOfOrder(self, elementOrder):
2202         return self.mesh.NbQuadranglesOfOrder(elementOrder)
2203
2204     ## Returns number of polygons in mesh
2205     def NbPolygons(self):
2206         return self.mesh.NbPolygons()
2207
2208     ## Returns number of volumes in mesh
2209     def NbVolumes(self):
2210         return self.mesh.NbVolumes()
2211
2212     ## Returns number of volumes with given order in mesh
2213     #  @param elementOrder is order of elements:
2214     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2215     def NbVolumesOfOrder(self, elementOrder):
2216         return self.mesh.NbVolumesOfOrder(elementOrder)
2217
2218     ## Returns number of tetrahedrons in mesh
2219     def NbTetras(self):
2220         return self.mesh.NbTetras()
2221
2222     ## Returns number of tetrahedrons with given order in mesh
2223     #  @param elementOrder is order of elements:
2224     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2225     def NbTetrasOfOrder(self, elementOrder):
2226         return self.mesh.NbTetrasOfOrder(elementOrder)
2227
2228     ## Returns number of hexahedrons in mesh
2229     def NbHexas(self):
2230         return self.mesh.NbHexas()
2231
2232     ## Returns number of hexahedrons with given order in mesh
2233     #  @param elementOrder is order of elements:
2234     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2235     def NbHexasOfOrder(self, elementOrder):
2236         return self.mesh.NbHexasOfOrder(elementOrder)
2237
2238     ## Returns number of pyramids in mesh
2239     def NbPyramids(self):
2240         return self.mesh.NbPyramids()
2241
2242     ## Returns number of pyramids with given order in mesh
2243     #  @param elementOrder is order of elements:
2244     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2245     def NbPyramidsOfOrder(self, elementOrder):
2246         return self.mesh.NbPyramidsOfOrder(elementOrder)
2247
2248     ## Returns number of prisms in mesh
2249     def NbPrisms(self):
2250         return self.mesh.NbPrisms()
2251
2252     ## Returns number of prisms with given order in mesh
2253     #  @param elementOrder is order of elements:
2254     #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2255     def NbPrismsOfOrder(self, elementOrder):
2256         return self.mesh.NbPrismsOfOrder(elementOrder)
2257
2258     ## Returns number of polyhedrons in mesh
2259     def NbPolyhedrons(self):
2260         return self.mesh.NbPolyhedrons()
2261
2262     ## Returns number of submeshes in mesh
2263     def NbSubMesh(self):
2264         return self.mesh.NbSubMesh()
2265
2266     ## Returns list of mesh elements ids
2267     def GetElementsId(self):
2268         return self.mesh.GetElementsId()
2269
2270     ## Returns list of ids of mesh elements with given type
2271     #  @param elementType is required type of elements
2272     def GetElementsByType(self, elementType):
2273         return self.mesh.GetElementsByType(elementType)
2274
2275     ## Returns list of mesh nodes ids
2276     def GetNodesId(self):
2277         return self.mesh.GetNodesId()
2278
2279     # Get informations about mesh elements:
2280     # ------------------------------------
2281
2282     ## Returns type of mesh element
2283     def GetElementType(self, id, iselem):
2284         return self.mesh.GetElementType(id, iselem)
2285
2286     ## Returns list of submesh elements ids
2287     #  @param Shape is geom object(subshape) IOR
2288     #  Shape must be subshape of a ShapeToMesh()
2289     def GetSubMeshElementsId(self, Shape):
2290         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2291             ShapeID = Shape.GetSubShapeIndices()[0]
2292         else:
2293             ShapeID = Shape
2294         return self.mesh.GetSubMeshElementsId(ShapeID)
2295
2296     ## Returns list of submesh nodes ids
2297     #  @param Shape is geom object(subshape) IOR
2298     #  Shape must be subshape of a ShapeToMesh()
2299     def GetSubMeshNodesId(self, Shape, all):
2300         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2301             ShapeID = Shape.GetSubShapeIndices()[0]
2302         else:
2303             ShapeID = Shape
2304         return self.mesh.GetSubMeshNodesId(ShapeID, all)
2305
2306     ## Returns list of ids of submesh elements with given type
2307     #  @param Shape is geom object(subshape) IOR
2308     #  Shape must be subshape of a ShapeToMesh()
2309     def GetSubMeshElementType(self, Shape):
2310         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2311             ShapeID = Shape.GetSubShapeIndices()[0]
2312         else:
2313             ShapeID = Shape
2314         return self.mesh.GetSubMeshElementType(ShapeID)
2315
2316     ## Get mesh description
2317     def Dump(self):
2318         return self.mesh.Dump()
2319
2320
2321     # Get information about nodes and elements of mesh by its ids:
2322     # -----------------------------------------------------------
2323
2324     ## Get XYZ coordinates of node as list of double
2325     #  \n If there is not node for given ID - returns empty list
2326     def GetNodeXYZ(self, id):
2327         return self.mesh.GetNodeXYZ(id)
2328
2329     ## For given node returns list of IDs of inverse elements
2330     #  \n If there is not node for given ID - returns empty list
2331     def GetNodeInverseElements(self, id):
2332         return self.mesh.GetNodeInverseElements(id)
2333
2334     ## @brief Return position of a node on shape
2335     #  @return SMESH::NodePosition
2336     def GetNodePosition(self,NodeID):
2337         return self.mesh.GetNodePosition(NodeID)
2338
2339     ## If given element is node returns IDs of shape from position
2340     #  \n If there is not node for given ID - returns -1
2341     def GetShapeID(self, id):
2342         return self.mesh.GetShapeID(id)
2343
2344     ## For given element returns ID of result shape after
2345     #  FindShape() from SMESH_MeshEditor
2346     #  \n If there is not element for given ID - returns -1
2347     def GetShapeIDForElem(self,id):
2348         return self.mesh.GetShapeIDForElem(id)
2349
2350     ## Returns number of nodes for given element
2351     #  \n If there is not element for given ID - returns -1
2352     def GetElemNbNodes(self, id):
2353         return self.mesh.GetElemNbNodes(id)
2354
2355     ## Returns ID of node by given index for given element
2356     #  \n If there is not element for given ID - returns -1
2357     #  \n If there is not node for given index - returns -2
2358     def GetElemNode(self, id, index):
2359         return self.mesh.GetElemNode(id, index)
2360
2361     ## Returns IDs of nodes of given element
2362     def GetElemNodes(self, id):
2363         return self.mesh.GetElemNodes(id)
2364
2365     ## Returns true if given node is medium node
2366     #  in given quadratic element
2367     def IsMediumNode(self, elementID, nodeID):
2368         return self.mesh.IsMediumNode(elementID, nodeID)
2369
2370     ## Returns true if given node is medium node
2371     #  in one of quadratic elements
2372     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2373         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2374
2375     ## Returns number of edges for given element
2376     def ElemNbEdges(self, id):
2377         return self.mesh.ElemNbEdges(id)
2378
2379     ## Returns number of faces for given element
2380     def ElemNbFaces(self, id):
2381         return self.mesh.ElemNbFaces(id)
2382
2383     ## Returns true if given element is polygon
2384     def IsPoly(self, id):
2385         return self.mesh.IsPoly(id)
2386
2387     ## Returns true if given element is quadratic
2388     def IsQuadratic(self, id):
2389         return self.mesh.IsQuadratic(id)
2390
2391     ## Returns XYZ coordinates of bary center for given element
2392     #  as list of double
2393     #  \n If there is not element for given ID - returns empty list
2394     def BaryCenter(self, id):
2395         return self.mesh.BaryCenter(id)
2396
2397
2398     # Mesh edition (SMESH_MeshEditor functionality):
2399     # ---------------------------------------------
2400
2401     ## Removes elements from mesh by ids
2402     #  @param IDsOfElements is list of ids of elements to remove
2403     def RemoveElements(self, IDsOfElements):
2404         return self.editor.RemoveElements(IDsOfElements)
2405
2406     ## Removes nodes from mesh by ids
2407     #  @param IDsOfNodes is list of ids of nodes to remove
2408     def RemoveNodes(self, IDsOfNodes):
2409         return self.editor.RemoveNodes(IDsOfNodes)
2410
2411     ## Add node to mesh by coordinates
2412     def AddNode(self, x, y, z):
2413         return self.editor.AddNode( x, y, z)
2414
2415
2416     ## Create edge both similar and quadratic (this is determed
2417     #  by number of given nodes).
2418     #  @param IdsOfNodes List of node IDs for creation of element.
2419     #  Needed order of nodes in this list corresponds to description
2420     #  of MED. \n This description is located by the following link:
2421     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2422     def AddEdge(self, IDsOfNodes):
2423         return self.editor.AddEdge(IDsOfNodes)
2424
2425     ## Create face both similar and quadratic (this is determed
2426     #  by number of given nodes).
2427     #  @param IdsOfNodes List of node IDs for creation of element.
2428     #  Needed order of nodes in this list corresponds to description
2429     #  of MED. \n This description is located by the following link:
2430     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2431     def AddFace(self, IDsOfNodes):
2432         return self.editor.AddFace(IDsOfNodes)
2433
2434     ## Add polygonal face to mesh by list of nodes ids
2435     def AddPolygonalFace(self, IdsOfNodes):
2436         return self.editor.AddPolygonalFace(IdsOfNodes)
2437
2438     ## Create volume both similar and quadratic (this is determed
2439     #  by number of given nodes).
2440     #  @param IdsOfNodes List of node IDs for creation of element.
2441     #  Needed order of nodes in this list corresponds to description
2442     #  of MED. \n This description is located by the following link:
2443     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2444     def AddVolume(self, IDsOfNodes):
2445         return self.editor.AddVolume(IDsOfNodes)
2446
2447     ## Create volume of many faces, giving nodes for each face.
2448     #  @param IdsOfNodes List of node IDs for volume creation face by face.
2449     #  @param Quantities List of integer values, Quantities[i]
2450     #         gives quantity of nodes in face number i.
2451     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2452         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2453
2454     ## Create volume of many faces, giving IDs of existing faces.
2455     #  @param IdsOfFaces List of face IDs for volume creation.
2456     #
2457     #  Note:  The created volume will refer only to nodes
2458     #         of the given faces, not to the faces itself.
2459     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2460         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2461
2462
2463     ## @brief Bind a node to a vertex
2464     # @param NodeID - node ID
2465     # @param Vertex - vertex or vertex ID
2466     # @return True if succeed else raise an exception
2467     def SetNodeOnVertex(self, NodeID, Vertex):
2468         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2469             VertexID = Vertex.GetSubShapeIndices()[0]
2470         else:
2471             VertexID = Vertex
2472         try:
2473             self.editor.SetNodeOnVertex(NodeID, VertexID)
2474         except SALOME.SALOME_Exception, inst:
2475             raise ValueError, inst.details.text
2476         return True
2477
2478
2479     ## @brief Store node position on an edge
2480     # @param NodeID - node ID
2481     # @param Edge - edge or edge ID
2482     # @param paramOnEdge - parameter on edge where the node is located
2483     # @return True if succeed else raise an exception
2484     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2485         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2486             EdgeID = Edge.GetSubShapeIndices()[0]
2487         else:
2488             EdgeID = Edge
2489         try:
2490             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2491         except SALOME.SALOME_Exception, inst:
2492             raise ValueError, inst.details.text
2493         return True
2494
2495     ## @brief Store node position on a face
2496     # @param NodeID - node ID
2497     # @param Face - face or face ID
2498     # @param u - U parameter on face where the node is located
2499     # @param v - V parameter on face where the node is located
2500     # @return True if succeed else raise an exception
2501     def SetNodeOnFace(self, NodeID, Face, u, v):
2502         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2503             FaceID = Face.GetSubShapeIndices()[0]
2504         else:
2505             FaceID = Face
2506         try:
2507             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2508         except SALOME.SALOME_Exception, inst:
2509             raise ValueError, inst.details.text
2510         return True
2511
2512     ## @brief Bind a node to a solid
2513     # @param NodeID - node ID
2514     # @param Solid - solid or solid ID
2515     # @return True if succeed else raise an exception
2516     def SetNodeInVolume(self, NodeID, Solid):
2517         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2518             SolidID = Solid.GetSubShapeIndices()[0]
2519         else:
2520             SolidID = Solid
2521         try:
2522             self.editor.SetNodeInVolume(NodeID, SolidID)
2523         except SALOME.SALOME_Exception, inst:
2524             raise ValueError, inst.details.text
2525         return True
2526
2527     ## @brief Bind an element to a shape
2528     # @param ElementID - element ID
2529     # @param Shape - shape or shape ID
2530     # @return True if succeed else raise an exception
2531     def SetMeshElementOnShape(self, ElementID, Shape):
2532         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2533             ShapeID = Shape.GetSubShapeIndices()[0]
2534         else:
2535             ShapeID = Shape
2536         try:
2537             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2538         except SALOME.SALOME_Exception, inst:
2539             raise ValueError, inst.details.text
2540         return True
2541
2542
2543     ## Move node with given id
2544     #  @param NodeID id of the node
2545     #  @param x new X coordinate
2546     #  @param y new Y coordinate
2547     #  @param z new Z coordinate
2548     def MoveNode(self, NodeID, x, y, z):
2549         return self.editor.MoveNode(NodeID, x, y, z)
2550
2551     ## Find a node closest to a point
2552     #  @param x X coordinate of a point
2553     #  @param y Y coordinate of a point
2554     #  @param z Z coordinate of a point
2555     #  @return id of a node
2556     def FindNodeClosestTo(self, x, y, z):
2557         preview = self.mesh.GetMeshEditPreviewer()
2558         return preview.MoveClosestNodeToPoint(x, y, z, -1)
2559
2560     ## Find a node closest to a point and move it to a point location
2561     #  @param x X coordinate of a point
2562     #  @param y Y coordinate of a point
2563     #  @param z Z coordinate of a point
2564     #  @return id of a moved node
2565     def MeshToPassThroughAPoint(self, x, y, z):
2566         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2567
2568     ## Replace two neighbour triangles sharing Node1-Node2 link
2569     #  with ones built on the same 4 nodes but having other common link.
2570     #  @param NodeID1 first node id
2571     #  @param NodeID2 second node id
2572     #  @return false if proper faces not found
2573     def InverseDiag(self, NodeID1, NodeID2):
2574         return self.editor.InverseDiag(NodeID1, NodeID2)
2575
2576     ## Replace two neighbour triangles sharing Node1-Node2 link
2577     #  with a quadrangle built on the same 4 nodes.
2578     #  @param NodeID1 first node id
2579     #  @param NodeID2 second node id
2580     #  @return false if proper faces not found
2581     def DeleteDiag(self, NodeID1, NodeID2):
2582         return self.editor.DeleteDiag(NodeID1, NodeID2)
2583
2584     ## Reorient elements by ids
2585     #  @param IDsOfElements if undefined reorient all mesh elements
2586     def Reorient(self, IDsOfElements=None):
2587         if IDsOfElements == None:
2588             IDsOfElements = self.GetElementsId()
2589         return self.editor.Reorient(IDsOfElements)
2590
2591     ## Reorient all elements of the object
2592     #  @param theObject is mesh, submesh or group
2593     def ReorientObject(self, theObject):
2594         if ( isinstance( theObject, Mesh )):
2595             theObject = theObject.GetMesh()
2596         return self.editor.ReorientObject(theObject)
2597
2598     ## Fuse neighbour triangles into quadrangles.
2599     #  @param IDsOfElements The triangles to be fused,
2600     #  @param theCriterion     is FT_...; used to choose a neighbour to fuse with.
2601     #  @param MaxAngle      is a max angle between element normals at which fusion
2602     #                       is still performed; theMaxAngle is mesured in radians.
2603     #  @return TRUE in case of success, FALSE otherwise.
2604     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2605         if IDsOfElements == []:
2606             IDsOfElements = self.GetElementsId()
2607         return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2608
2609     ## Fuse neighbour triangles of the object into quadrangles
2610     #  @param theObject is mesh, submesh or group
2611     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2612     #  @param MaxAngle  is a max angle between element normals at which fusion
2613     #                   is still performed; theMaxAngle is mesured in radians.
2614     #  @return TRUE in case of success, FALSE otherwise.
2615     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2616         if ( isinstance( theObject, Mesh )):
2617             theObject = theObject.GetMesh()
2618         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2619
2620     ## Split quadrangles into triangles.
2621     #  @param IDsOfElements the faces to be splitted.
2622     #  @param theCriterion  is FT_...; used to choose a diagonal for splitting.
2623     #  @return TRUE in case of success, FALSE otherwise.
2624     def QuadToTri (self, IDsOfElements, theCriterion):
2625         if IDsOfElements == []:
2626             IDsOfElements = self.GetElementsId()
2627         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2628
2629     ## Split quadrangles into triangles.
2630     #  @param theObject object to taking list of elements from, is mesh, submesh or group
2631     #  @param theCriterion  is FT_...; used to choose a diagonal for splitting.
2632     def QuadToTriObject (self, theObject, theCriterion):
2633         if ( isinstance( theObject, Mesh )):
2634             theObject = theObject.GetMesh()
2635         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2636
2637     ## Split quadrangles into triangles.
2638     #  @param theElems  The faces to be splitted
2639     #  @param the13Diag is used to choose a diagonal for splitting.
2640     #  @return TRUE in case of success, FALSE otherwise.
2641     def SplitQuad (self, IDsOfElements, Diag13):
2642         if IDsOfElements == []:
2643             IDsOfElements = self.GetElementsId()
2644         return self.editor.SplitQuad(IDsOfElements, Diag13)
2645
2646     ## Split quadrangles into triangles.
2647     #  @param theObject is object to taking list of elements from, is mesh, submesh or group
2648     def SplitQuadObject (self, theObject, Diag13):
2649         if ( isinstance( theObject, Mesh )):
2650             theObject = theObject.GetMesh()
2651         return self.editor.SplitQuadObject(theObject, Diag13)
2652
2653     ## Find better splitting of the given quadrangle.
2654     #  @param IDOfQuad  ID of the quadrangle to be splitted.
2655     #  @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
2656     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2657     #          diagonal is better, 0 if error occurs.
2658     def BestSplit (self, IDOfQuad, theCriterion):
2659         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2660
2661     ## Split quafrangle faces near triangular facets of volumes
2662     #
2663     def SplitQuadsNearTriangularFacets(self):
2664         faces_array = self.GetElementsByType(SMESH.FACE)
2665         for face_id in faces_array:
2666             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2667                 quad_nodes = self.mesh.GetElemNodes(face_id)
2668                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2669                 isVolumeFound = False
2670                 for node1_elem in node1_elems:
2671                     if not isVolumeFound:
2672                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2673                             nb_nodes = self.GetElemNbNodes(node1_elem)
2674                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2675                                 volume_elem = node1_elem
2676                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2677                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2678                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2679                                         isVolumeFound = True
2680                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2681                                             self.SplitQuad([face_id], False) # diagonal 2-4
2682                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2683                                         isVolumeFound = True
2684                                         self.SplitQuad([face_id], True) # diagonal 1-3
2685                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2686                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2687                                         isVolumeFound = True
2688                                         self.SplitQuad([face_id], True) # diagonal 1-3
2689
2690     ## @brief Split hexahedrons into tetrahedrons.
2691     #
2692     #  Use pattern mapping functionality for splitting.
2693     #  @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2694     #  @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2695     #         pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2696     #         will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2697     #         key-point will be mapped into <theNode001>-th node of each volume.
2698     #         The (0,0,0) key-point of used pattern corresponds to not split corner.
2699     #  @return TRUE in case of success, FALSE otherwise.
2700     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2701         # Pattern:     5.---------.6
2702         #              /|#*      /|
2703         #             / | #*    / |
2704         #            /  |  # * /  |
2705         #           /   |   # /*  |
2706         # (0,0,1) 4.---------.7 * |
2707         #          |#*  |1   | # *|
2708         #          | # *.----|---#.2
2709         #          |  #/ *   |   /
2710         #          |  /#  *  |  /
2711         #          | /   # * | /
2712         #          |/      #*|/
2713         # (0,0,0) 0.---------.3
2714         pattern_tetra = "!!! Nb of points: \n 8 \n\
2715         !!! Points: \n\
2716         0 0 0  !- 0 \n\
2717         0 1 0  !- 1 \n\
2718         1 1 0  !- 2 \n\
2719         1 0 0  !- 3 \n\
2720         0 0 1  !- 4 \n\
2721         0 1 1  !- 5 \n\
2722         1 1 1  !- 6 \n\
2723         1 0 1  !- 7 \n\
2724         !!! Indices of points of 6 tetras: \n\
2725         0 3 4 1 \n\
2726         7 4 3 1 \n\
2727         4 7 5 1 \n\
2728         6 2 5 7 \n\
2729         1 5 2 7 \n\
2730         2 3 1 7 \n"
2731
2732         pattern = self.smeshpyD.GetPattern()
2733         isDone  = pattern.LoadFromFile(pattern_tetra)
2734         if not isDone:
2735             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2736             return isDone
2737
2738         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2739         isDone = pattern.MakeMesh(self.mesh, False, False)
2740         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2741
2742         # split quafrangle faces near triangular facets of volumes
2743         self.SplitQuadsNearTriangularFacets()
2744
2745         return isDone
2746
2747     ## @brief Split hexahedrons into prisms.
2748     #
2749     #  Use pattern mapping functionality for splitting.
2750     #  @param theObject object to take list of hexahedrons from; is mesh, submesh or group.
2751     #  @param theNode000,theNode001 is in range [0,7]; give an orientation of the
2752     #         pattern relatively each hexahedron: the (0,0,0) key-point of pattern
2753     #         will be mapped into <theNode000>-th node of each volume, the (0,0,1)
2754     #         key-point will be mapped into <theNode001>-th node of each volume.
2755     #         The edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2756     #  @return TRUE in case of success, FALSE otherwise.
2757     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2758         # Pattern:     5.---------.6
2759         #              /|#       /|
2760         #             / | #     / |
2761         #            /  |  #   /  |
2762         #           /   |   # /   |
2763         # (0,0,1) 4.---------.7   |
2764         #          |    |    |    |
2765         #          |   1.----|----.2
2766         #          |   / *   |   /
2767         #          |  /   *  |  /
2768         #          | /     * | /
2769         #          |/       *|/
2770         # (0,0,0) 0.---------.3
2771         pattern_prism = "!!! Nb of points: \n 8 \n\
2772         !!! Points: \n\
2773         0 0 0  !- 0 \n\
2774         0 1 0  !- 1 \n\
2775         1 1 0  !- 2 \n\
2776         1 0 0  !- 3 \n\
2777         0 0 1  !- 4 \n\
2778         0 1 1  !- 5 \n\
2779         1 1 1  !- 6 \n\
2780         1 0 1  !- 7 \n\
2781         !!! Indices of points of 2 prisms: \n\
2782         0 1 3 4 5 7 \n\
2783         2 3 1 6 7 5 \n"
2784
2785         pattern = self.smeshpyD.GetPattern()
2786         isDone  = pattern.LoadFromFile(pattern_prism)
2787         if not isDone:
2788             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2789             return isDone
2790
2791         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2792         isDone = pattern.MakeMesh(self.mesh, False, False)
2793         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2794
2795         # split quafrangle faces near triangular facets of volumes
2796         self.SplitQuadsNearTriangularFacets()
2797
2798         return isDone
2799
2800     ## Smooth elements
2801     #  @param IDsOfElements list if ids of elements to smooth
2802     #  @param IDsOfFixedNodes list of ids of fixed nodes.
2803     #  Note that nodes built on edges and boundary nodes are always fixed.
2804     #  @param MaxNbOfIterations maximum number of iterations
2805     #  @param MaxAspectRatio varies in range [1.0, inf]
2806     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2807     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2808                MaxNbOfIterations, MaxAspectRatio, Method):
2809         if IDsOfElements == []:
2810             IDsOfElements = self.GetElementsId()
2811         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2812                                   MaxNbOfIterations, MaxAspectRatio, Method)
2813
2814     ## Smooth elements belong to given object
2815     #  @param theObject object to smooth
2816     #  @param IDsOfFixedNodes list of ids of fixed nodes.
2817     #  Note that nodes built on edges and boundary nodes are always fixed.
2818     #  @param MaxNbOfIterations maximum number of iterations
2819     #  @param MaxAspectRatio varies in range [1.0, inf]
2820     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2821     def SmoothObject(self, theObject, IDsOfFixedNodes,
2822                      MaxNbOfIterations, MaxxAspectRatio, Method):
2823         if ( isinstance( theObject, Mesh )):
2824             theObject = theObject.GetMesh()
2825         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2826                                         MaxNbOfIterations, MaxxAspectRatio, Method)
2827
2828     ## Parametric smooth the given elements
2829     #  @param IDsOfElements list if ids of elements to smooth
2830     #  @param IDsOfFixedNodes list of ids of fixed nodes.
2831     #  Note that nodes built on edges and boundary nodes are always fixed.
2832     #  @param MaxNbOfIterations maximum number of iterations
2833     #  @param MaxAspectRatio varies in range [1.0, inf]
2834     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2835     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2836                          MaxNbOfIterations, MaxAspectRatio, Method):
2837         if IDsOfElements == []:
2838             IDsOfElements = self.GetElementsId()
2839         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2840                                             MaxNbOfIterations, MaxAspectRatio, Method)
2841
2842     ## Parametric smooth elements belong to given object
2843     #  @param theObject object to smooth
2844     #  @param IDsOfFixedNodes list of ids of fixed nodes.
2845     #  Note that nodes built on edges and boundary nodes are always fixed.
2846     #  @param MaxNbOfIterations maximum number of iterations
2847     #  @param MaxAspectRatio varies in range [1.0, inf]
2848     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2849     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2850                                MaxNbOfIterations, MaxAspectRatio, Method):
2851         if ( isinstance( theObject, Mesh )):
2852             theObject = theObject.GetMesh()
2853         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2854                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2855
2856     ## Converts all mesh to quadratic one, deletes old elements, replacing
2857     #  them with quadratic ones with the same id.
2858     def ConvertToQuadratic(self, theForce3d):
2859         self.editor.ConvertToQuadratic(theForce3d)
2860
2861     ## Converts all mesh from quadratic to ordinary ones,
2862     #  deletes old quadratic elements, \n replacing
2863     #  them with ordinary mesh elements with the same id.
2864     def ConvertFromQuadratic(self):
2865         return self.editor.ConvertFromQuadratic()
2866
2867     ## Renumber mesh nodes
2868     def RenumberNodes(self):
2869         self.editor.RenumberNodes()
2870
2871     ## Renumber mesh elements
2872     def RenumberElements(self):
2873         self.editor.RenumberElements()
2874
2875     ## Generate new elements by rotation of the elements around the axis
2876     #  @param IDsOfElements list of ids of elements to sweep
2877     #  @param Axix axis of rotation, AxisStruct or line(geom object)
2878     #  @param AngleInRadians angle of Rotation
2879     #  @param NbOfSteps number of steps
2880     #  @param Tolerance tolerance
2881     #  @param MakeGroups to generate new groups from existing ones
2882     def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
2883         if IDsOfElements == []:
2884             IDsOfElements = self.GetElementsId()
2885         if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
2886             Axix = self.smeshpyD.GetAxisStruct(Axix)
2887         if MakeGroups:
2888             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
2889                                                        AngleInRadians, NbOfSteps, Tolerance)
2890         self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
2891         return []
2892
2893     ## Generate new elements by rotation of the elements of object around the axis
2894     #  @param theObject object wich elements should be sweeped
2895     #  @param Axix axis of rotation, AxisStruct or line(geom object)
2896     #  @param AngleInRadians angle of Rotation
2897     #  @param NbOfSteps number of steps
2898     #  @param Tolerance tolerance
2899     #  @param MakeGroups to generate new groups from existing ones
2900     def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
2901         if ( isinstance( theObject, Mesh )):
2902             theObject = theObject.GetMesh()
2903         if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
2904             Axix = self.smeshpyD.GetAxisStruct(Axix)
2905         if MakeGroups:
2906             return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
2907                                                              NbOfSteps, Tolerance)
2908         self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
2909         return []
2910
2911     ## Generate new elements by extrusion of the elements with given ids
2912     #  @param IDsOfElements list of elements ids for extrusion
2913     #  @param StepVector vector, defining the direction and value of extrusion
2914     #  @param NbOfSteps the number of steps
2915     #  @param MakeGroups to generate new groups from existing ones
2916     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2917         if IDsOfElements == []:
2918             IDsOfElements = self.GetElementsId()
2919         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2920             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2921         if MakeGroups:
2922             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2923         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2924         return []
2925
2926     ## Generate new elements by extrusion of the elements with given ids
2927     #  @param IDsOfElements is ids of elements
2928     #  @param StepVector vector, defining the direction and value of extrusion
2929     #  @param NbOfSteps the number of steps
2930     #  @param ExtrFlags set flags for performing extrusion
2931     #  @param SewTolerance uses for comparing locations of nodes if flag
2932     #         EXTRUSION_FLAG_SEW is set
2933     #  @param MakeGroups to generate new groups from existing ones
2934     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance, MakeGroups=False):
2935         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2936             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2937         if MakeGroups:
2938             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2939                                                            ExtrFlags, SewTolerance)
2940         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2941                                       ExtrFlags, SewTolerance)
2942         return []
2943
2944     ## Generate new elements by extrusion of the elements belong to object
2945     #  @param theObject object wich elements should be processed
2946     #  @param StepVector vector, defining the direction and value of extrusion
2947     #  @param NbOfSteps the number of steps
2948     #  @param MakeGroups to generate new groups from existing ones
2949     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2950         if ( isinstance( theObject, Mesh )):
2951             theObject = theObject.GetMesh()
2952         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2953             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2954         if MakeGroups:
2955             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2956         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2957         return []
2958
2959     ## Generate new elements by extrusion of the elements belong to object
2960     #  @param theObject object wich elements should be processed
2961     #  @param StepVector vector, defining the direction and value of extrusion
2962     #  @param NbOfSteps the number of steps
2963     #  @param MakeGroups to generate new groups from existing ones
2964     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2965         if ( isinstance( theObject, Mesh )):
2966             theObject = theObject.GetMesh()
2967         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2968             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2969         if MakeGroups:
2970             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2971         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2972         return []
2973
2974     ## Generate new elements by extrusion of the elements belong to object
2975     #  @param theObject object wich elements should be processed
2976     #  @param StepVector vector, defining the direction and value of extrusion
2977     #  @param NbOfSteps the number of steps
2978     #  @param MakeGroups to generate new groups from existing ones
2979     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2980         if ( isinstance( theObject, Mesh )):
2981             theObject = theObject.GetMesh()
2982         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2983             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2984         if MakeGroups:
2985             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2986         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2987         return []
2988
2989     ## Generate new elements by extrusion of the given elements
2990     #  A path of extrusion must be a meshed edge.
2991     #  @param IDsOfElements is ids of elements
2992     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2993     #  @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
2994     #  @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
2995     #  @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
2996     #  @param Angles list of angles
2997     #  @param HasRefPoint allows to use base point
2998     #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
2999     #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
3000     #  @param MakeGroups to generate new groups from existing ones
3001     #  @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
3002     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3003                            HasAngles, Angles, HasRefPoint, RefPoint,
3004                            MakeGroups=False, LinearVariation=False):
3005         if IDsOfElements == []:
3006             IDsOfElements = self.GetElementsId()
3007         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3008             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3009             pass
3010         if MakeGroups:
3011             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh.GetMesh(),
3012                                                             PathShape, NodeStart, HasAngles,
3013                                                             Angles, HasRefPoint, RefPoint)
3014         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape,
3015                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3016
3017     ## Generate new elements by extrusion of the elements belong to object
3018     #  A path of extrusion must be a meshed edge.
3019     #  @param IDsOfElements is ids of elements
3020     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3021     #  @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
3022     #  @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
3023     #  @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
3024     #  @param Angles list of angles
3025     #  @param HasRefPoint allows to use base point
3026     #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
3027     #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
3028     #  @param MakeGroups to generate new groups from existing ones
3029     #  @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
3030     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3031                                  HasAngles, Angles, HasRefPoint, RefPoint,
3032                                  MakeGroups=False, LinearVariation=False):
3033         if ( isinstance( theObject, Mesh )):
3034             theObject = theObject.GetMesh()
3035         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3036             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3037         if MakeGroups:
3038             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh.GetMesh(),
3039                                                                   PathShape, NodeStart, HasAngles,
3040                                                                   Angles, HasRefPoint, RefPoint)
3041         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape,
3042                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3043                                                     RefPoint)
3044
3045     ## Symmetrical copy of mesh elements
3046     #  @param IDsOfElements list of elements ids
3047     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3048     #  @param theMirrorType is  POINT, AXIS or PLANE
3049     #  If the Mirror is geom object this parameter is unnecessary
3050     #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
3051     #  @param MakeGroups to generate new groups from existing ones (if Copy)
3052     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3053         if IDsOfElements == []:
3054             IDsOfElements = self.GetElementsId()
3055         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3056             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3057         if Copy and MakeGroups:
3058             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3059         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3060         return []
3061
3062     ## Create a new mesh by symmetrical copy of mesh elements
3063     #  @param IDsOfElements list of elements ids
3064     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3065     #  @param theMirrorType is  POINT, AXIS or PLANE
3066     #  If the Mirror is geom object this parameter is unnecessary
3067     #  @param MakeGroups to generate new groups from existing ones
3068     #  @param NewMeshName is a name of new mesh to create
3069     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3070         if IDsOfElements == []:
3071             IDsOfElements = self.GetElementsId()
3072         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3073             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3074         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3075                                           MakeGroups, NewMeshName)
3076         return Mesh(self.smeshpyD,self.geompyD,mesh)
3077
3078     ## Symmetrical copy of object
3079     #  @param theObject mesh, submesh or group
3080     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3081     #  @param theMirrorType is  POINT, AXIS or PLANE
3082     #  If the Mirror is geom object this parameter is unnecessary
3083     #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
3084     #  @param MakeGroups to generate new groups from existing ones (if Copy)
3085     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3086         if ( isinstance( theObject, Mesh )):
3087             theObject = theObject.GetMesh()
3088         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3089             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3090         if Copy and MakeGroups:
3091             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3092         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3093         return []
3094
3095     ## Create a new mesh by symmetrical copy of object
3096     #  @param theObject mesh, submesh or group
3097     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3098     #  @param theMirrorType is  POINT, AXIS or PLANE
3099     #  If the Mirror is geom object this parameter is unnecessary
3100     #  @param MakeGroups to generate new groups from existing ones
3101     #  @param NewMeshName is a name of new mesh to create
3102     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3103         if ( isinstance( theObject, Mesh )):
3104             theObject = theObject.GetMesh()
3105         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3106             Mirror = GetAxisStruct(Mirror)
3107         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3108                                                 MakeGroups, NewMeshName)
3109         return Mesh( self.smeshpyD,self.geompyD,mesh )
3110
3111     ## Translates the elements
3112     #  @param IDsOfElements list of elements ids
3113     #  @param Vector direction of translation(DirStruct or vector)
3114     #  @param Copy allows to copy the translated elements
3115     #  @param MakeGroups to generate new groups from existing ones (if Copy)
3116     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3117         if IDsOfElements == []:
3118             IDsOfElements = self.GetElementsId()
3119         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3120             Vector = self.smeshpyD.GetDirStruct(Vector)
3121         if Copy and MakeGroups:
3122             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3123         self.editor.Translate(IDsOfElements, Vector, Copy)
3124         return []
3125
3126     ## Create a new mesh of translated elements
3127     #  @param IDsOfElements list of elements ids
3128     #  @param Vector direction of translation(DirStruct or vector)
3129     #  @param MakeGroups to generate new groups from existing ones
3130     #  @param NewMeshName is a name of new mesh to create
3131     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3132         if IDsOfElements == []:
3133             IDsOfElements = self.GetElementsId()
3134         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3135             Vector = self.smeshpyD.GetDirStruct(Vector)
3136         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3137         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3138
3139     ## Translates the object
3140     #  @param theObject object to translate(mesh, submesh, or group)
3141     #  @param Vector direction of translation(DirStruct or geom vector)
3142     #  @param Copy allows to copy the translated elements
3143     #  @param MakeGroups to generate new groups from existing ones (if Copy)
3144     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3145         if ( isinstance( theObject, Mesh )):
3146             theObject = theObject.GetMesh()
3147         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3148             Vector = self.smeshpyD.GetDirStruct(Vector)
3149         if Copy and MakeGroups:
3150             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3151         self.editor.TranslateObject(theObject, Vector, Copy)
3152         return []
3153
3154     ## Create a new mesh from translated object
3155     #  @param theObject object to translate(mesh, submesh, or group)
3156     #  @param Vector direction of translation(DirStruct or geom vector)
3157     #  @param MakeGroups to generate new groups from existing ones
3158     #  @param NewMeshName is a name of new mesh to create
3159     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3160         if (isinstance(theObject, Mesh)):
3161             theObject = theObject.GetMesh()
3162         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3163             Vector = self.smeshpyD.GetDirStruct(Vector)
3164         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3165         return Mesh( self.smeshpyD, self.geompyD, mesh )
3166
3167     ## Rotates the elements
3168     #  @param IDsOfElements list of elements ids
3169     #  @param Axis axis of rotation(AxisStruct or geom line)
3170     #  @param AngleInRadians angle of rotation(in radians)
3171     #  @param Copy allows to copy the rotated elements
3172     #  @param MakeGroups to generate new groups from existing ones (if Copy)
3173     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3174         if IDsOfElements == []:
3175             IDsOfElements = self.GetElementsId()
3176         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3177             Axis = self.smeshpyD.GetAxisStruct(Axis)
3178         if Copy and MakeGroups:
3179             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3180         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3181         return []
3182
3183     ## Create a new mesh of rotated elements
3184     #  @param IDsOfElements list of element ids
3185     #  @param Axis axis of rotation(AxisStruct or geom line)
3186     #  @param AngleInRadians angle of rotation(in radians)
3187     #  @param MakeGroups to generate new groups from existing ones
3188     #  @param NewMeshName is a name of new mesh to create
3189     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3190         if IDsOfElements == []:
3191             IDsOfElements = self.GetElementsId()
3192         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3193             Axis = self.smeshpyD.GetAxisStruct(Axis)
3194         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3195                                           MakeGroups, NewMeshName)
3196         return Mesh( self.smeshpyD, self.geompyD, mesh )
3197
3198     ## Rotates the object
3199     #  @param theObject object to rotate(mesh, submesh, or group)
3200     #  @param Axis axis of rotation(AxisStruct or geom line)
3201     #  @param AngleInRadians angle of rotation(in radians)
3202     #  @param Copy allows to copy the rotated elements
3203     #  @param MakeGroups to generate new groups from existing ones (if Copy)
3204     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3205         if (isinstance(theObject, Mesh)):
3206             theObject = theObject.GetMesh()
3207         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3208             Axis = self.smeshpyD.GetAxisStruct(Axis)
3209         if Copy and MakeGroups:
3210             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3211         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3212         return []
3213
3214     ## Create a new mesh from a rotated object
3215     #  @param theObject object to rotate (mesh, submesh, or group)
3216     #  @param Axis axis of rotation(AxisStruct or geom line)
3217     #  @param AngleInRadians angle of rotation(in radians)
3218     #  @param MakeGroups to generate new groups from existing ones
3219     #  @param NewMeshName is a name of new mesh to create
3220     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3221         if (isinstance( theObject, Mesh )):
3222             theObject = theObject.GetMesh()
3223         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3224             Axis = self.smeshpyD.GetAxisStruct(Axis)
3225         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3226                                                        MakeGroups, NewMeshName)
3227         return Mesh( self.smeshpyD, self.geompyD, mesh )
3228
3229     ## Find group of nodes close to each other within Tolerance.
3230     #  @param Tolerance tolerance value
3231     #  @param list of group of nodes
3232     def FindCoincidentNodes (self, Tolerance):
3233         return self.editor.FindCoincidentNodes(Tolerance)
3234
3235     ## Find group of nodes close to each other within Tolerance.
3236     #  @param Tolerance tolerance value
3237     #  @param SubMeshOrGroup SubMesh or Group
3238     #  @param list of group of nodes
3239     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3240         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3241
3242     ## Merge nodes
3243     #  @param list of group of nodes
3244     def MergeNodes (self, GroupsOfNodes):
3245         self.editor.MergeNodes(GroupsOfNodes)
3246
3247     ## Find elements built on the same nodes.
3248     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3249     #  @return a list of groups of equal elements
3250     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3251         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3252
3253     ## Merge elements in each given group.
3254     #  @param GroupsOfElementsID groups of elements for merging
3255     def MergeElements(self, GroupsOfElementsID):
3256         self.editor.MergeElements(GroupsOfElementsID)
3257
3258     ## Remove all but one of elements built on the same nodes.
3259     def MergeEqualElements(self):
3260         self.editor.MergeEqualElements()
3261
3262     ## Sew free borders
3263     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3264                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3265                         CreatePolygons, CreatePolyedrs):
3266         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3267                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3268                                           CreatePolygons, CreatePolyedrs)
3269
3270     ## Sew conform free borders
3271     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3272                                FirstNodeID2, SecondNodeID2):
3273         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3274                                                  FirstNodeID2, SecondNodeID2)
3275
3276     ## Sew border to side
3277     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3278                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3279         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3280                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3281
3282     ## Sew two sides of a mesh. Nodes belonging to Side1 are
3283     #  merged with nodes of elements of Side2.
3284     #  Number of elements in theSide1 and in theSide2 must be
3285     #  equal and they should have similar node connectivity.
3286     #  The nodes to merge should belong to sides borders and
3287     #  the first node should be linked to the second.
3288     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3289                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3290                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3291         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3292                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3293                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3294
3295     ## Set new nodes for given element.
3296     #  @param ide the element id
3297     #  @param newIDs nodes ids
3298     #  @return If number of nodes is not corresponded to type of element - returns false
3299     def ChangeElemNodes(self, ide, newIDs):
3300         return self.editor.ChangeElemNodes(ide, newIDs)
3301
3302     ## If during last operation of MeshEditor some nodes were
3303     #  created this method returns list of its IDs, \n
3304     #  if new nodes not created - returns empty list
3305     def GetLastCreatedNodes(self):
3306         return self.editor.GetLastCreatedNodes()
3307
3308     ## If during last operation of MeshEditor some elements were
3309     #  created this method returns list of its IDs, \n
3310     #  if new elements not creared - returns empty list
3311     def GetLastCreatedElems(self):
3312         return self.editor.GetLastCreatedElems()