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