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