]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH_SWIG/smeshDC.py
Salome HOME
Imp 19925 - Mesh preview
[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 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating  Creating meshes
31 ## @{
32 ##   @defgroup l2_impexp     Importing and exporting meshes
33 ##   @defgroup l2_construct  Constructing meshes
34 ##   @defgroup l2_algorithms Defining Algorithms
35 ##   @{
36 ##     @defgroup l3_algos_basic   Basic meshing algorithms
37 ##     @defgroup l3_algos_proj    Projection Algorithms
38 ##     @defgroup l3_algos_radialp Radial Prism
39 ##     @defgroup l3_algos_segmarv Segments around Vertex
40 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
41
42 ##   @}
43 ##   @defgroup l2_hypotheses Defining hypotheses
44 ##   @{
45 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ##     @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ##     @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ##     @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ##     @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ##     @defgroup l3_hypos_additi Additional Hypotheses
53
54 ##   @}
55 ##   @defgroup l2_submeshes Constructing submeshes
56 ##   @defgroup l2_compounds Building Compounds
57 ##   @defgroup l2_editing   Editing Meshes
58
59 ## @}
60 ## @defgroup l1_meshinfo  Mesh Information
61 ## @defgroup l1_controls  Quality controls and Filtering
62 ## @defgroup l1_grouping  Grouping elements
63 ## @{
64 ##   @defgroup l2_grps_create Creating groups
65 ##   @defgroup l2_grps_edit   Editing groups
66 ##   @defgroup l2_grps_operon Using operations on groups
67 ##   @defgroup l2_grps_delete Deleting Groups
68
69 ## @}
70 ## @defgroup l1_modifying Modifying meshes
71 ## @{
72 ##   @defgroup l2_modif_add      Adding nodes and elements
73 ##   @defgroup l2_modif_del      Removing nodes and elements
74 ##   @defgroup l2_modif_edit     Modifying nodes and elements
75 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
76 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ##   @defgroup l2_modif_movenode Moving nodes
78 ##   @defgroup l2_modif_throughp Mesh through point
79 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
80 ##   @defgroup l2_modif_unitetri Uniting triangles
81 ##   @defgroup l2_modif_changori Changing orientation of elements
82 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
83 ##   @defgroup l2_modif_smooth   Smoothing
84 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
85 ##   @defgroup l2_modif_patterns Pattern mapping
86 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
87
88 ## @}
89
90 import salome
91 import geompyDC
92
93 import SMESH # This is necessary for back compatibility
94 from   SMESH import *
95
96 import StdMeshers
97
98 import SALOME
99
100 # import NETGENPlugin module if possible
101 noNETGENPlugin = 0
102 try:
103     import NETGENPlugin
104 except ImportError:
105     noNETGENPlugin = 1
106     pass
107
108 ## @addtogroup l1_auxiliary
109 ## @{
110
111 # Types of algorithms
112 REGULAR    = 1
113 PYTHON     = 2
114 COMPOSITE  = 3
115 SOLE       = 0
116 SIMPLE     = 1
117
118 MEFISTO       = 3
119 NETGEN        = 4
120 GHS3D         = 5
121 FULL_NETGEN   = 6
122 NETGEN_2D     = 7
123 NETGEN_1D2D   = NETGEN
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL   = FULL_NETGEN
126 Hexa    = 8
127 Hexotic = 9
128 BLSURF  = 10
129
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS =  SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
134
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
138
139 # Fineness enumeration (for NETGEN)
140 VeryCoarse = 0
141 Coarse     = 1
142 Moderate   = 2
143 Fine       = 3
144 VeryFine   = 4
145 Custom     = 5
146
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
149
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
152
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
155
156 PrecisionConfusion = 1e-07
157
158 def IsEqual(val1, val2, tol=PrecisionConfusion):
159     if abs(val1 - val2) < tol:
160         return True
161     return False
162
163 NO_NAME = "NoName"
164
165 ## Gets object name
166 def GetName(obj):
167     ior  = salome.orb.object_to_string(obj)
168     sobj = salome.myStudy.FindObjectIOR(ior)
169     if sobj is None:
170         return NO_NAME
171     else:
172         attr = sobj.FindAttribute("AttributeName")[1]
173         return attr.Value()
174
175 ## Sets a name to the object
176 def SetName(obj, name):
177     if isinstance( obj, Mesh ):
178         obj = obj.GetMesh()
179     elif isinstance( obj, Mesh_Algorithm ):
180         obj = obj.GetAlgorithm()
181     ior  = salome.orb.object_to_string(obj)
182     sobj = salome.myStudy.FindObjectIOR(ior)
183     if not sobj is None:
184         attr = sobj.FindAttribute("AttributeName")[1]
185         attr.SetValue(name)
186
187 ## Prints error message if a hypothesis was not assigned.
188 def TreatHypoStatus(status, hypName, geomName, isAlgo):
189     if isAlgo:
190         hypType = "algorithm"
191     else:
192         hypType = "hypothesis"
193         pass
194     if status == HYP_UNKNOWN_FATAL :
195         reason = "for unknown reason"
196     elif status == HYP_INCOMPATIBLE :
197         reason = "this hypothesis mismatches the algorithm"
198     elif status == HYP_NOTCONFORM :
199         reason = "a non-conform mesh would be built"
200     elif status == HYP_ALREADY_EXIST :
201         reason = hypType + " of the same dimension is already assigned to this shape"
202     elif status == HYP_BAD_DIM :
203         reason = hypType + " mismatches the shape"
204     elif status == HYP_CONCURENT :
205         reason = "there are concurrent hypotheses on sub-shapes"
206     elif status == HYP_BAD_SUBSHAPE :
207         reason = "the shape is neither the main one, nor its subshape, nor a valid group"
208     elif status == HYP_BAD_GEOMETRY:
209         reason = "geometry mismatches the expectation of the algorithm"
210     elif status == HYP_HIDDEN_ALGO:
211         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
212     elif status == HYP_HIDING_ALGO:
213         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
214     elif status == HYP_NEED_SHAPE:
215         reason = "Algorithm can't work without shape"
216     else:
217         return
218     hypName = '"' + hypName + '"'
219     geomName= '"' + geomName+ '"'
220     if status < HYP_UNKNOWN_FATAL:
221         print hypName, "was assigned to",    geomName,"but", reason
222     else:
223         print hypName, "was not assigned to",geomName,":", reason
224         pass
225
226 ## Converts an angle from degrees to radians
227 def DegreesToRadians(AngleInDegrees):
228     from math import pi
229     return AngleInDegrees * pi / 180.0
230
231 # end of l1_auxiliary
232 ## @}
233
234 # All methods of this class are accessible directly from the smesh.py package.
235 class smeshDC(SMESH._objref_SMESH_Gen):
236
237     ## Sets the current study and Geometry component
238     #  @ingroup l1_auxiliary
239     def init_smesh(self,theStudy,geompyD):
240         self.SetCurrentStudy(theStudy,geompyD)
241
242     ## Creates an empty Mesh. This mesh can have an underlying geometry.
243     #  @param obj the Geometrical object on which the mesh is built. If not defined,
244     #             the mesh will have no underlying geometry.
245     #  @param name the name for the new mesh.
246     #  @return an instance of Mesh class.
247     #  @ingroup l2_construct
248     def Mesh(self, obj=0, name=0):
249       return Mesh(self,self.geompyD,obj,name)
250
251     ## Returns a long value from enumeration
252     #  Should be used for SMESH.FunctorType enumeration
253     #  @ingroup l1_controls
254     def EnumToLong(self,theItem):
255         return theItem._v
256
257     ## Gets PointStruct from vertex
258     #  @param theVertex a GEOM object(vertex)
259     #  @return SMESH.PointStruct
260     #  @ingroup l1_auxiliary
261     def GetPointStruct(self,theVertex):
262         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
263         return PointStruct(x,y,z)
264
265     ## Gets DirStruct from vector
266     #  @param theVector a GEOM object(vector)
267     #  @return SMESH.DirStruct
268     #  @ingroup l1_auxiliary
269     def GetDirStruct(self,theVector):
270         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
271         if(len(vertices) != 2):
272             print "Error: vector object is incorrect."
273             return None
274         p1 = self.geompyD.PointCoordinates(vertices[0])
275         p2 = self.geompyD.PointCoordinates(vertices[1])
276         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
277         dirst = DirStruct(pnt)
278         return dirst
279
280     ## Makes DirStruct from a triplet
281     #  @param x,y,z vector components
282     #  @return SMESH.DirStruct
283     #  @ingroup l1_auxiliary
284     def MakeDirStruct(self,x,y,z):
285         pnt = PointStruct(x,y,z)
286         return DirStruct(pnt)
287
288     ## Get AxisStruct from object
289     #  @param theObj a GEOM object (line or plane)
290     #  @return SMESH.AxisStruct
291     #  @ingroup l1_auxiliary
292     def GetAxisStruct(self,theObj):
293         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
294         if len(edges) > 1:
295             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
296             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
297             vertex1 = self.geompyD.PointCoordinates(vertex1)
298             vertex2 = self.geompyD.PointCoordinates(vertex2)
299             vertex3 = self.geompyD.PointCoordinates(vertex3)
300             vertex4 = self.geompyD.PointCoordinates(vertex4)
301             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
302             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
303             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] ]
304             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
305             return axis
306         elif len(edges) == 1:
307             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
308             p1 = self.geompyD.PointCoordinates( vertex1 )
309             p2 = self.geompyD.PointCoordinates( vertex2 )
310             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
311             return axis
312         return None
313
314     # From SMESH_Gen interface:
315     # ------------------------
316
317     ## Sets the current mode
318     #  @ingroup l1_auxiliary
319     def SetEmbeddedMode( self,theMode ):
320         #self.SetEmbeddedMode(theMode)
321         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
322
323     ## Gets the current mode
324     #  @ingroup l1_auxiliary
325     def IsEmbeddedMode(self):
326         #return self.IsEmbeddedMode()
327         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
328
329     ## Sets the current study
330     #  @ingroup l1_auxiliary
331     def SetCurrentStudy( self, theStudy, geompyD = None ):
332         #self.SetCurrentStudy(theStudy)
333         if not geompyD:
334             import geompy
335             geompyD = geompy.geom
336             pass
337         self.geompyD=geompyD
338         self.SetGeomEngine(geompyD)
339         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
340
341     ## Gets the current study
342     #  @ingroup l1_auxiliary
343     def GetCurrentStudy(self):
344         #return self.GetCurrentStudy()
345         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
346
347     ## Creates a Mesh object importing data from the given UNV file
348     #  @return an instance of Mesh class
349     #  @ingroup l2_impexp
350     def CreateMeshesFromUNV( self,theFileName ):
351         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
352         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
353         return aMesh
354
355     ## Creates a Mesh object(s) importing data from the given MED file
356     #  @return a list of Mesh class instances
357     #  @ingroup l2_impexp
358     def CreateMeshesFromMED( self,theFileName ):
359         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
360         aMeshes = []
361         for iMesh in range(len(aSmeshMeshes)) :
362             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
363             aMeshes.append(aMesh)
364         return aMeshes, aStatus
365
366     ## Creates a Mesh object importing data from the given STL file
367     #  @return an instance of Mesh class
368     #  @ingroup l2_impexp
369     def CreateMeshesFromSTL( self, theFileName ):
370         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
371         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
372         return aMesh
373
374     ## Concatenate the given meshes into one mesh.
375     #  @return an instance of Mesh class
376     #  @param meshes the meshes to combine into one mesh
377     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
378     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
379     #  @param mergeTolerance tolerance for merging nodes
380     #  @param allGroups forces creation of groups of all elements
381     def Concatenate( self, meshes, uniteIdenticalGroups,
382                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
383         if allGroups:
384             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
385                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
386         else:
387             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
388                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
389         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
390         return aMesh
391
392     ## From SMESH_Gen interface
393     #  @return the list of integer values
394     #  @ingroup l1_auxiliary
395     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
396         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
397
398     ## From SMESH_Gen interface. Creates a pattern
399     #  @return an instance of SMESH_Pattern
400     #
401     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
402     #  @ingroup l2_modif_patterns
403     def GetPattern(self):
404         return SMESH._objref_SMESH_Gen.GetPattern(self)
405
406
407     # Filtering. Auxiliary functions:
408     # ------------------------------
409
410     ## Creates an empty criterion
411     #  @return SMESH.Filter.Criterion
412     #  @ingroup l1_controls
413     def GetEmptyCriterion(self):
414         Type = self.EnumToLong(FT_Undefined)
415         Compare = self.EnumToLong(FT_Undefined)
416         Threshold = 0
417         ThresholdStr = ""
418         ThresholdID = ""
419         UnaryOp = self.EnumToLong(FT_Undefined)
420         BinaryOp = self.EnumToLong(FT_Undefined)
421         Tolerance = 1e-07
422         TypeOfElement = ALL
423         Precision = -1 ##@1e-07
424         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
425                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
426
427     ## Creates a criterion by the given parameters
428     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
429     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
430     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
431     #  @param Treshold the threshold value (range of ids as string, shape, numeric)
432     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
433     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
434     #                  FT_Undefined (must be for the last criterion of all criteria)
435     #  @return SMESH.Filter.Criterion
436     #  @ingroup l1_controls
437     def GetCriterion(self,elementType,
438                      CritType,
439                      Compare = FT_EqualTo,
440                      Treshold="",
441                      UnaryOp=FT_Undefined,
442                      BinaryOp=FT_Undefined):
443         aCriterion = self.GetEmptyCriterion()
444         aCriterion.TypeOfElement = elementType
445         aCriterion.Type = self.EnumToLong(CritType)
446
447         aTreshold = Treshold
448
449         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
450             aCriterion.Compare = self.EnumToLong(Compare)
451         elif Compare == "=" or Compare == "==":
452             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
453         elif Compare == "<":
454             aCriterion.Compare = self.EnumToLong(FT_LessThan)
455         elif Compare == ">":
456             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
457         else:
458             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
459             aTreshold = Compare
460
461         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
462                         FT_BelongToCylinder, FT_LyingOnGeom]:
463             # Checks the treshold
464             if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
465                 aCriterion.ThresholdStr = GetName(aTreshold)
466                 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
467             else:
468                 print "Error: The treshold should be a shape."
469                 return None
470         elif CritType == FT_RangeOfIds:
471             # Checks the treshold
472             if isinstance(aTreshold, str):
473                 aCriterion.ThresholdStr = aTreshold
474             else:
475                 print "Error: The treshold should be a string."
476                 return None
477         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
478             # At this point the treshold is unnecessary
479             if aTreshold ==  FT_LogicalNOT:
480                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
481             elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
482                 aCriterion.BinaryOp = aTreshold
483         else:
484             # Check treshold
485             try:
486                 aTreshold = float(aTreshold)
487                 aCriterion.Threshold = aTreshold
488             except:
489                 print "Error: The treshold should be a number."
490                 return None
491
492         if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
493             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
494
495         if Treshold in [FT_LogicalAND, FT_LogicalOR]:
496             aCriterion.BinaryOp = self.EnumToLong(Treshold)
497
498         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
499             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
500
501         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
502             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
503
504         return aCriterion
505
506     ## Creates a filter with the given parameters
507     #  @param elementType the type of elements in the group
508     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
509     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
510     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
511     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
512     #  @return SMESH_Filter
513     #  @ingroup l1_controls
514     def GetFilter(self,elementType,
515                   CritType=FT_Undefined,
516                   Compare=FT_EqualTo,
517                   Treshold="",
518                   UnaryOp=FT_Undefined):
519         aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
520         aFilterMgr = self.CreateFilterManager()
521         aFilter = aFilterMgr.CreateFilter()
522         aCriteria = []
523         aCriteria.append(aCriterion)
524         aFilter.SetCriteria(aCriteria)
525         return aFilter
526
527     ## Creates a numerical functor by its type
528     #  @param theCriterion FT_...; functor type
529     #  @return SMESH_NumericalFunctor
530     #  @ingroup l1_controls
531     def GetFunctor(self,theCriterion):
532         aFilterMgr = self.CreateFilterManager()
533         if theCriterion == FT_AspectRatio:
534             return aFilterMgr.CreateAspectRatio()
535         elif theCriterion == FT_AspectRatio3D:
536             return aFilterMgr.CreateAspectRatio3D()
537         elif theCriterion == FT_Warping:
538             return aFilterMgr.CreateWarping()
539         elif theCriterion == FT_MinimumAngle:
540             return aFilterMgr.CreateMinimumAngle()
541         elif theCriterion == FT_Taper:
542             return aFilterMgr.CreateTaper()
543         elif theCriterion == FT_Skew:
544             return aFilterMgr.CreateSkew()
545         elif theCriterion == FT_Area:
546             return aFilterMgr.CreateArea()
547         elif theCriterion == FT_Volume3D:
548             return aFilterMgr.CreateVolume3D()
549         elif theCriterion == FT_MultiConnection:
550             return aFilterMgr.CreateMultiConnection()
551         elif theCriterion == FT_MultiConnection2D:
552             return aFilterMgr.CreateMultiConnection2D()
553         elif theCriterion == FT_Length:
554             return aFilterMgr.CreateLength()
555         elif theCriterion == FT_Length2D:
556             return aFilterMgr.CreateLength2D()
557         else:
558             print "Error: given parameter is not numerucal functor type."
559
560
561 import omniORB
562 #Registering the new proxy for SMESH_Gen
563 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
564
565
566 # Public class: Mesh
567 # ==================
568
569 ## This class allows defining and managing a mesh.
570 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
571 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
572 #  new nodes and elements and by changing the existing entities), to get information
573 #  about a mesh and to export a mesh into different formats.
574 class Mesh:
575
576     geom = 0
577     mesh = 0
578     editor = 0
579
580     ## Constructor
581     #
582     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
583     #  sets the GUI name of this mesh to \a name.
584     #  @param smeshpyD an instance of smeshDC class
585     #  @param geompyD an instance of geompyDC class
586     #  @param obj Shape to be meshed or SMESH_Mesh object
587     #  @param name Study name of the mesh
588     #  @ingroup l2_construct
589     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
590         self.smeshpyD=smeshpyD
591         self.geompyD=geompyD
592         if obj is None:
593             obj = 0
594         if obj != 0:
595             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
596                 self.geom = obj
597                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
598             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
599                 self.SetMesh(obj)
600         else:
601             self.mesh = self.smeshpyD.CreateEmptyMesh()
602         if name != 0:
603             SetName(self.mesh, name)
604         elif obj != 0:
605             SetName(self.mesh, GetName(obj))
606
607         if not self.geom:
608             self.geom = self.mesh.GetShapeToMesh()
609
610         self.editor = self.mesh.GetMeshEditor()
611
612     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
613     #  @param theMesh a SMESH_Mesh object
614     #  @ingroup l2_construct
615     def SetMesh(self, theMesh):
616         self.mesh = theMesh
617         self.geom = self.mesh.GetShapeToMesh()
618
619     ## Returns the mesh, that is an instance of SMESH_Mesh interface
620     #  @return a SMESH_Mesh object
621     #  @ingroup l2_construct
622     def GetMesh(self):
623         return self.mesh
624
625     ## Gets the name of the mesh
626     #  @return the name of the mesh as a string
627     #  @ingroup l2_construct
628     def GetName(self):
629         name = GetName(self.GetMesh())
630         return name
631
632     ## Sets a name to the mesh
633     #  @param name a new name of the mesh
634     #  @ingroup l2_construct
635     def SetName(self, name):
636         SetName(self.GetMesh(), name)
637
638     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
639     #  The subMesh object gives access to the IDs of nodes and elements.
640     #  @param theSubObject a geometrical object (shape)
641     #  @param theName a name for the submesh
642     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
643     #  @ingroup l2_submeshes
644     def GetSubMesh(self, theSubObject, theName):
645         submesh = self.mesh.GetSubMesh(theSubObject, theName)
646         return submesh
647
648     ## Returns the shape associated to the mesh
649     #  @return a GEOM_Object
650     #  @ingroup l2_construct
651     def GetShape(self):
652         return self.geom
653
654     ## Associates the given shape to the mesh (entails the recreation of the mesh)
655     #  @param geom the shape to be meshed (GEOM_Object)
656     #  @ingroup l2_construct
657     def SetShape(self, geom):
658         self.mesh = self.smeshpyD.CreateMesh(geom)
659
660     ## Returns true if the hypotheses are defined well
661     #  @param theSubObject a subshape of a mesh shape
662     #  @return True or False
663     #  @ingroup l2_construct
664     def IsReadyToCompute(self, theSubObject):
665         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
666
667     ## Returns errors of hypotheses definition.
668     #  The list of errors is empty if everything is OK.
669     #  @param theSubObject a subshape of a mesh shape
670     #  @return a list of errors
671     #  @ingroup l2_construct
672     def GetAlgoState(self, theSubObject):
673         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
674
675     ## Returns a geometrical object on which the given element was built.
676     #  The returned geometrical object, if not nil, is either found in the
677     #  study or published by this method with the given name
678     #  @param theElementID the id of the mesh element
679     #  @param theGeomName the user-defined name of the geometrical object
680     #  @return GEOM::GEOM_Object instance
681     #  @ingroup l2_construct
682     def GetGeometryByMeshElement(self, theElementID, theGeomName):
683         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
684
685     ## Returns the mesh dimension depending on the dimension of the underlying shape
686     #  @return mesh dimension as an integer value [0,3]
687     #  @ingroup l1_auxiliary
688     def MeshDimension(self):
689         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
690         if len( shells ) > 0 :
691             return 3
692         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
693             return 2
694         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
695             return 1
696         else:
697             return 0;
698         pass
699
700     ## Creates a segment discretization 1D algorithm.
701     #  If the optional \a algo parameter is not set, this algorithm is REGULAR.
702     #  \n If the optional \a geom parameter is not set, this algorithm is global.
703     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
704     #  @param algo the type of the required algorithm. Possible values are:
705     #     - smesh.REGULAR,
706     #     - smesh.PYTHON for discretization via a python function,
707     #     - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
708     #  @param geom If defined is the subshape to be meshed
709     #  @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
710     #  @ingroup l3_algos_basic
711     def Segment(self, algo=REGULAR, geom=0):
712         ## if Segment(geom) is called by mistake
713         if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
714             algo, geom = geom, algo
715             if not algo: algo = REGULAR
716             pass
717         if algo == REGULAR:
718             return Mesh_Segment(self,  geom)
719         elif algo == PYTHON:
720             return Mesh_Segment_Python(self, geom)
721         elif algo == COMPOSITE:
722             return Mesh_CompositeSegment(self, geom)
723         else:
724             return Mesh_Segment(self, geom)
725
726     ## Enables creation of nodes and segments usable by 2D algoritms.
727     #  The added nodes and segments must be bound to edges and vertices by
728     #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
729     #  If the optional \a geom parameter is not set, this algorithm is global.
730     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
731     #  @param geom the subshape to be manually meshed
732     #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
733     #  @ingroup l3_algos_basic
734     def UseExistingSegments(self, geom=0):
735         algo = Mesh_UseExisting(1,self,geom)
736         return algo.GetAlgorithm()
737
738     ## Enables creation of nodes and faces usable by 3D algoritms.
739     #  The added nodes and faces must be bound to geom faces by SetNodeOnFace()
740     #  and SetMeshElementOnShape()
741     #  If the optional \a geom parameter is not set, this algorithm is global.
742     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
743     #  @param geom the subshape to be manually meshed
744     #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
745     #  @ingroup l3_algos_basic
746     def UseExistingFaces(self, geom=0):
747         algo = Mesh_UseExisting(2,self,geom)
748         return algo.GetAlgorithm()
749
750     ## Creates a triangle 2D algorithm for faces.
751     #  If the optional \a geom parameter is not set, this algorithm is global.
752     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
753     #  @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
754     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
755     #  @return an instance of Mesh_Triangle algorithm
756     #  @ingroup l3_algos_basic
757     def Triangle(self, algo=MEFISTO, geom=0):
758         ## if Triangle(geom) is called by mistake
759         if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
760             geom = algo
761             algo = MEFISTO
762
763         return Mesh_Triangle(self, algo, geom)
764
765     ## Creates a quadrangle 2D algorithm for faces.
766     #  If the optional \a geom parameter is not set, this algorithm is global.
767     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
768     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
769     #  @return an instance of Mesh_Quadrangle algorithm
770     #  @ingroup l3_algos_basic
771     def Quadrangle(self, geom=0):
772         return Mesh_Quadrangle(self,  geom)
773
774     ## Creates a tetrahedron 3D algorithm for solids.
775     #  The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
776     #  If the optional \a geom parameter is not set, this algorithm is global.
777     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
778     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
779     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
780     #  @return an instance of Mesh_Tetrahedron algorithm
781     #  @ingroup l3_algos_basic
782     def Tetrahedron(self, algo=NETGEN, geom=0):
783         ## if Tetrahedron(geom) is called by mistake
784         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
785             algo, geom = geom, algo
786             if not algo: algo = NETGEN
787             pass
788         return Mesh_Tetrahedron(self,  algo, geom)
789
790     ## Creates a hexahedron 3D algorithm for solids.
791     #  If the optional \a geom parameter is not set, this algorithm is global.
792     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
793     #  @param algo possible values are: smesh.Hexa, smesh.Hexotic
794     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
795     #  @return an instance of Mesh_Hexahedron algorithm
796     #  @ingroup l3_algos_basic
797     def Hexahedron(self, algo=Hexa, geom=0):
798         ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
799         if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
800             if   geom in [Hexa, Hexotic]: algo, geom = geom, algo
801             elif geom == 0:               algo, geom = Hexa, algo
802         return Mesh_Hexahedron(self, algo, geom)
803
804     ## Deprecated, used only for compatibility!
805     #  @return an instance of Mesh_Netgen algorithm
806     #  @ingroup l3_algos_basic
807     def Netgen(self, is3D, geom=0):
808         return Mesh_Netgen(self,  is3D, geom)
809
810     ## Creates a projection 1D algorithm for edges.
811     #  If the optional \a geom parameter is not set, this algorithm is global.
812     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
813     #  @param geom If defined, the subshape to be meshed
814     #  @return an instance of Mesh_Projection1D algorithm
815     #  @ingroup l3_algos_proj
816     def Projection1D(self, geom=0):
817         return Mesh_Projection1D(self,  geom)
818
819     ## Creates a projection 2D algorithm for faces.
820     #  If the optional \a geom parameter is not set, this algorithm is global.
821     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
822     #  @param geom If defined, the subshape to be meshed
823     #  @return an instance of Mesh_Projection2D algorithm
824     #  @ingroup l3_algos_proj
825     def Projection2D(self, geom=0):
826         return Mesh_Projection2D(self,  geom)
827
828     ## Creates a projection 3D algorithm for solids.
829     #  If the optional \a geom parameter is not set, this algorithm is global.
830     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
831     #  @param geom If defined, the subshape to be meshed
832     #  @return an instance of Mesh_Projection3D algorithm
833     #  @ingroup l3_algos_proj
834     def Projection3D(self, geom=0):
835         return Mesh_Projection3D(self,  geom)
836
837     ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
838     #  If the optional \a geom parameter is not set, this algorithm is global.
839     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
840     #  @param geom If defined, the subshape to be meshed
841     #  @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
842     #  @ingroup l3_algos_radialp l3_algos_3dextr
843     def Prism(self, geom=0):
844         shape = geom
845         if shape==0:
846             shape = self.geom
847         nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
848         nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
849         if nbSolids == 0 or nbSolids == nbShells:
850             return Mesh_Prism3D(self,  geom)
851         return Mesh_RadialPrism3D(self,  geom)
852
853     ## Computes the mesh and returns the status of the computation
854     #  @return True or False
855     #  @ingroup l2_construct
856     def Compute(self, geom=0):
857         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
858             if self.geom == 0:
859                 geom = self.mesh.GetShapeToMesh()
860             else:
861                 geom = self.geom
862         ok = False
863         try:
864             ok = self.smeshpyD.Compute(self.mesh, geom)
865         except SALOME.SALOME_Exception, ex:
866             print "Mesh computation failed, exception caught:"
867             print "    ", ex.details.text
868         except:
869             import traceback
870             print "Mesh computation failed, exception caught:"
871             traceback.print_exc()
872         if True:#not ok:
873             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
874             allReasons = ""
875             for err in errors:
876                 if err.isGlobalAlgo:
877                     glob = "global"
878                 else:
879                     glob = "local"
880                     pass
881                 dim = err.algoDim
882                 name = err.algoName
883                 if len(name) == 0:
884                     reason = '%s %sD algorithm is missing' % (glob, dim)
885                 elif err.state == HYP_MISSING:
886                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
887                               % (glob, dim, name, dim))
888                 elif err.state == HYP_NOTCONFORM:
889                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
890                 elif err.state == HYP_BAD_PARAMETER:
891                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
892                               % ( glob, dim, name ))
893                 elif err.state == HYP_BAD_GEOMETRY:
894                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
895                               'geometry' % ( glob, dim, name ))
896                 else:
897                     reason = "For unknown reason."+\
898                              " Revise Mesh.Compute() implementation in smeshDC.py!"
899                     pass
900                 if allReasons != "":
901                     allReasons += "\n"
902                     pass
903                 allReasons += reason
904                 pass
905             if allReasons != "":
906                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
907                 print allReasons
908                 ok = False
909             elif not ok:
910                 print '"' + GetName(self.mesh) + '"',"has not been computed."
911                 pass
912             pass
913         if salome.sg.hasDesktop():
914             smeshgui = salome.ImportComponentGUI("SMESH")
915             smeshgui.Init(salome.myStudyId)
916             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
917             salome.sg.updateObjBrowser(1)
918             pass
919         return ok
920
921     ## Removes all nodes and elements
922     #  @ingroup l2_construct
923     def Clear(self):
924         self.mesh.Clear()
925         if salome.sg.hasDesktop():
926             smeshgui = salome.ImportComponentGUI("SMESH")
927             smeshgui.Init(salome.myStudyId)
928             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
929             salome.sg.updateObjBrowser(1)
930
931     ## Removes all nodes and elements of indicated shape
932     #  @ingroup l2_construct
933     def ClearSubMesh(self, geomId):
934         self.mesh.ClearSubMesh(geomId)
935         if salome.sg.hasDesktop():
936             smeshgui = salome.ImportComponentGUI("SMESH")
937             smeshgui.Init(salome.myStudyId)
938             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
939             salome.sg.updateObjBrowser(1)
940
941     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
942     #  @param fineness [0,-1] defines mesh fineness
943     #  @return True or False
944     #  @ingroup l3_algos_basic
945     def AutomaticTetrahedralization(self, fineness=0):
946         dim = self.MeshDimension()
947         # assign hypotheses
948         self.RemoveGlobalHypotheses()
949         self.Segment().AutomaticLength(fineness)
950         if dim > 1 :
951             self.Triangle().LengthFromEdges()
952             pass
953         if dim > 2 :
954             self.Tetrahedron(NETGEN)
955             pass
956         return self.Compute()
957
958     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
959     #  @param fineness [0,-1] defines mesh fineness
960     #  @return True or False
961     #  @ingroup l3_algos_basic
962     def AutomaticHexahedralization(self, fineness=0):
963         dim = self.MeshDimension()
964         # assign the hypotheses
965         self.RemoveGlobalHypotheses()
966         self.Segment().AutomaticLength(fineness)
967         if dim > 1 :
968             self.Quadrangle()
969             pass
970         if dim > 2 :
971             self.Hexahedron()
972             pass
973         return self.Compute()
974
975     ## Assigns a hypothesis
976     #  @param hyp a hypothesis to assign
977     #  @param geom a subhape of mesh geometry
978     #  @return SMESH.Hypothesis_Status
979     #  @ingroup l2_hypotheses
980     def AddHypothesis(self, hyp, geom=0):
981         if isinstance( hyp, Mesh_Algorithm ):
982             hyp = hyp.GetAlgorithm()
983             pass
984         if not geom:
985             geom = self.geom
986             if not geom:
987                 geom = self.mesh.GetShapeToMesh()
988             pass
989         status = self.mesh.AddHypothesis(geom, hyp)
990         isAlgo = hyp._narrow( SMESH_Algo )
991         TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
992         return status
993
994     ## Unassigns a hypothesis
995     #  @param hyp a hypothesis to unassign
996     #  @param geom a subshape of mesh geometry
997     #  @return SMESH.Hypothesis_Status
998     #  @ingroup l2_hypotheses
999     def RemoveHypothesis(self, hyp, geom=0):
1000         if isinstance( hyp, Mesh_Algorithm ):
1001             hyp = hyp.GetAlgorithm()
1002             pass
1003         if not geom:
1004             geom = self.geom
1005             pass
1006         status = self.mesh.RemoveHypothesis(geom, hyp)
1007         return status
1008
1009     ## Gets the list of hypotheses added on a geometry
1010     #  @param geom a subshape of mesh geometry
1011     #  @return the sequence of SMESH_Hypothesis
1012     #  @ingroup l2_hypotheses
1013     def GetHypothesisList(self, geom):
1014         return self.mesh.GetHypothesisList( geom )
1015
1016     ## Removes all global hypotheses
1017     #  @ingroup l2_hypotheses
1018     def RemoveGlobalHypotheses(self):
1019         current_hyps = self.mesh.GetHypothesisList( self.geom )
1020         for hyp in current_hyps:
1021             self.mesh.RemoveHypothesis( self.geom, hyp )
1022             pass
1023         pass
1024
1025     ## Creates a mesh group based on the geometric object \a grp
1026     #  and gives a \a name, \n if this parameter is not defined
1027     #  the name is the same as the geometric group name \n
1028     #  Note: Works like GroupOnGeom().
1029     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
1030     #  @param name the name of the mesh group
1031     #  @return SMESH_GroupOnGeom
1032     #  @ingroup l2_grps_create
1033     def Group(self, grp, name=""):
1034         return self.GroupOnGeom(grp, name)
1035
1036     ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1037     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
1038     #  @param f the file name
1039     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1040     #  @ingroup l2_impexp
1041     def ExportToMED(self, f, version, opt=0):
1042         self.mesh.ExportToMED(f, opt, version)
1043
1044     ## Exports the mesh in a file in MED format
1045     #  @param f is the file name
1046     #  @param auto_groups boolean parameter for creating/not creating
1047     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1048     #  the typical use is auto_groups=false.
1049     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1050     #  @ingroup l2_impexp
1051     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1052         self.mesh.ExportToMED(f, auto_groups, version)
1053
1054     ## Exports the mesh in a file in DAT format
1055     #  @param f the file name
1056     #  @ingroup l2_impexp
1057     def ExportDAT(self, f):
1058         self.mesh.ExportDAT(f)
1059
1060     ## Exports the mesh in a file in UNV format
1061     #  @param f the file name
1062     #  @ingroup l2_impexp
1063     def ExportUNV(self, f):
1064         self.mesh.ExportUNV(f)
1065
1066     ## Export the mesh in a file in STL format
1067     #  @param f the file name
1068     #  @param ascii defines the file encoding
1069     #  @ingroup l2_impexp
1070     def ExportSTL(self, f, ascii=1):
1071         self.mesh.ExportSTL(f, ascii)
1072
1073
1074     # Operations with groups:
1075     # ----------------------
1076
1077     ## Creates an empty mesh group
1078     #  @param elementType the type of elements in the group
1079     #  @param name the name of the mesh group
1080     #  @return SMESH_Group
1081     #  @ingroup l2_grps_create
1082     def CreateEmptyGroup(self, elementType, name):
1083         return self.mesh.CreateGroup(elementType, name)
1084
1085     ## Creates a mesh group based on the geometrical object \a grp
1086     #  and gives a \a name, \n if this parameter is not defined
1087     #  the name is the same as the geometrical group name
1088     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
1089     #  @param name the name of the mesh group
1090     #  @param typ  the type of elements in the group. If not set, it is
1091     #              automatically detected by the type of the geometry
1092     #  @return SMESH_GroupOnGeom
1093     #  @ingroup l2_grps_create
1094     def GroupOnGeom(self, grp, name="", typ=None):
1095         if name == "":
1096             name = grp.GetName()
1097
1098         if typ == None:
1099             tgeo = str(grp.GetShapeType())
1100             if tgeo == "VERTEX":
1101                 typ = NODE
1102             elif tgeo == "EDGE":
1103                 typ = EDGE
1104             elif tgeo == "FACE":
1105                 typ = FACE
1106             elif tgeo == "SOLID":
1107                 typ = VOLUME
1108             elif tgeo == "SHELL":
1109                 typ = VOLUME
1110             elif tgeo == "COMPOUND":
1111                 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1112                     print "Mesh.Group: empty geometric group", GetName( grp )
1113                     return 0
1114                 tgeo = self.geompyD.GetType(grp)
1115                 if tgeo == geompyDC.ShapeType["VERTEX"]:
1116                     typ = NODE
1117                 elif tgeo == geompyDC.ShapeType["EDGE"]:
1118                     typ = EDGE
1119                 elif tgeo == geompyDC.ShapeType["FACE"]:
1120                     typ = FACE
1121                 elif tgeo == geompyDC.ShapeType["SOLID"]:
1122                     typ = VOLUME
1123
1124         if typ == None:
1125             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1126             return 0
1127         else:
1128             return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1129
1130     ## Creates a mesh group by the given ids of elements
1131     #  @param groupName the name of the mesh group
1132     #  @param elementType the type of elements in the group
1133     #  @param elemIDs the list of ids
1134     #  @return SMESH_Group
1135     #  @ingroup l2_grps_create
1136     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1137         group = self.mesh.CreateGroup(elementType, groupName)
1138         group.Add(elemIDs)
1139         return group
1140
1141     ## Creates a mesh group by the given conditions
1142     #  @param groupName the name of the mesh group
1143     #  @param elementType the type of elements in the group
1144     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1145     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1146     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
1147     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
1148     #  @return SMESH_Group
1149     #  @ingroup l2_grps_create
1150     def MakeGroup(self,
1151                   groupName,
1152                   elementType,
1153                   CritType=FT_Undefined,
1154                   Compare=FT_EqualTo,
1155                   Treshold="",
1156                   UnaryOp=FT_Undefined):
1157         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1158         group = self.MakeGroupByCriterion(groupName, aCriterion)
1159         return group
1160
1161     ## Creates a mesh group by the given criterion
1162     #  @param groupName the name of the mesh group
1163     #  @param Criterion the instance of Criterion class
1164     #  @return SMESH_Group
1165     #  @ingroup l2_grps_create
1166     def MakeGroupByCriterion(self, groupName, Criterion):
1167         aFilterMgr = self.smeshpyD.CreateFilterManager()
1168         aFilter = aFilterMgr.CreateFilter()
1169         aCriteria = []
1170         aCriteria.append(Criterion)
1171         aFilter.SetCriteria(aCriteria)
1172         group = self.MakeGroupByFilter(groupName, aFilter)
1173         return group
1174
1175     ## Creates a mesh group by the given criteria (list of criteria)
1176     #  @param groupName the name of the mesh group
1177     #  @param theCriteria the list of criteria
1178     #  @return SMESH_Group
1179     #  @ingroup l2_grps_create
1180     def MakeGroupByCriteria(self, groupName, theCriteria):
1181         aFilterMgr = self.smeshpyD.CreateFilterManager()
1182         aFilter = aFilterMgr.CreateFilter()
1183         aFilter.SetCriteria(theCriteria)
1184         group = self.MakeGroupByFilter(groupName, aFilter)
1185         return group
1186
1187     ## Creates a mesh group by the given filter
1188     #  @param groupName the name of the mesh group
1189     #  @param theFilter the instance of Filter class
1190     #  @return SMESH_Group
1191     #  @ingroup l2_grps_create
1192     def MakeGroupByFilter(self, groupName, theFilter):
1193         anIds = theFilter.GetElementsId(self.mesh)
1194         anElemType = theFilter.GetElementType()
1195         group = self.MakeGroupByIds(groupName, anElemType, anIds)
1196         return group
1197
1198     ## Passes mesh elements through the given filter and return IDs of fitting elements
1199     #  @param theFilter SMESH_Filter
1200     #  @return a list of ids
1201     #  @ingroup l1_controls
1202     def GetIdsFromFilter(self, theFilter):
1203         return theFilter.GetElementsId(self.mesh)
1204
1205     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1206     #  Returns a list of special structures (borders).
1207     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1208     #  @ingroup l1_controls
1209     def GetFreeBorders(self):
1210         aFilterMgr = self.smeshpyD.CreateFilterManager()
1211         aPredicate = aFilterMgr.CreateFreeEdges()
1212         aPredicate.SetMesh(self.mesh)
1213         aBorders = aPredicate.GetBorders()
1214         return aBorders
1215
1216     ## Removes a group
1217     #  @ingroup l2_grps_delete
1218     def RemoveGroup(self, group):
1219         self.mesh.RemoveGroup(group)
1220
1221     ## Removes a group with its contents
1222     #  @ingroup l2_grps_delete
1223     def RemoveGroupWithContents(self, group):
1224         self.mesh.RemoveGroupWithContents(group)
1225
1226     ## Gets the list of groups existing in the mesh
1227     #  @return a sequence of SMESH_GroupBase
1228     #  @ingroup l2_grps_create
1229     def GetGroups(self):
1230         return self.mesh.GetGroups()
1231
1232     ## Gets the number of groups existing in the mesh
1233     #  @return the quantity of groups as an integer value
1234     #  @ingroup l2_grps_create
1235     def NbGroups(self):
1236         return self.mesh.NbGroups()
1237
1238     ## Gets the list of names of groups existing in the mesh
1239     #  @return list of strings
1240     #  @ingroup l2_grps_create
1241     def GetGroupNames(self):
1242         groups = self.GetGroups()
1243         names = []
1244         for group in groups:
1245             names.append(group.GetName())
1246         return names
1247
1248     ## Produces a union of two groups
1249     #  A new group is created. All mesh elements that are
1250     #  present in the initial groups are added to the new one
1251     #  @return an instance of SMESH_Group
1252     #  @ingroup l2_grps_operon
1253     def UnionGroups(self, group1, group2, name):
1254         return self.mesh.UnionGroups(group1, group2, name)
1255         
1256     ## Produces a union list of groups
1257     #  New group is created. All mesh elements that are present in 
1258     #  initial groups are added to the new one
1259     #  @return an instance of SMESH_Group
1260     #  @ingroup l2_grps_operon
1261     def UnionListOfGroups(self, groups, name):
1262       return self.mesh.UnionListOfGroups(groups, name)
1263       
1264     ## Prodices an intersection of two groups
1265     #  A new group is created. All mesh elements that are common
1266     #  for the two initial groups are added to the new one.
1267     #  @return an instance of SMESH_Group
1268     #  @ingroup l2_grps_operon
1269     def IntersectGroups(self, group1, group2, name):
1270         return self.mesh.IntersectGroups(group1, group2, name)
1271         
1272     ## Produces an intersection of groups
1273     #  New group is created. All mesh elements that are present in all 
1274     #  initial groups simultaneously are added to the new one
1275     #  @return an instance of SMESH_Group
1276     #  @ingroup l2_grps_operon
1277     def IntersectListOfGroups(self, groups, name):
1278       return self.mesh.IntersectListOfGroups(groups, name)
1279
1280     ## Produces a cut of two groups
1281     #  A new group is created. All mesh elements that are present in
1282     #  the main group but are not present in the tool group are added to the new one
1283     #  @return an instance of SMESH_Group
1284     #  @ingroup l2_grps_operon
1285     def CutGroups(self, main_group, tool_group, name):
1286         return self.mesh.CutGroups(main_group, tool_group, name)
1287         
1288     ## Produces a cut of groups
1289     #  A new group is created. All mesh elements that are present in main groups 
1290     #  but do not present in tool groups are added to the new one
1291     #  @return an instance of SMESH_Group
1292     #  @ingroup l2_grps_operon
1293     def CutListOfGroups(self, main_groups, tool_groups, name):
1294       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1295       
1296     ## Produces a group of elements with specified element type using list of existing groups
1297     #  A new group is created. System 
1298     #  1) extract all nodes on which groups elements are built
1299     #  2) combine all elements of specified dimension laying on these nodes
1300     #  @return an instance of SMESH_Group
1301     #  @ingroup l2_grps_operon
1302     def CreateDimGroup(self, groups, elem_type, name):
1303       return self.mesh.CreateDimGroup(groups, elem_type, name)
1304
1305
1306     # Get some info about mesh:
1307     # ------------------------
1308
1309     ## Returns the log of nodes and elements added or removed
1310     #  since the previous clear of the log.
1311     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1312     #  @return list of log_block structures:
1313     #                                        commandType
1314     #                                        number
1315     #                                        coords
1316     #                                        indexes
1317     #  @ingroup l1_auxiliary
1318     def GetLog(self, clearAfterGet):
1319         return self.mesh.GetLog(clearAfterGet)
1320
1321     ## Clears the log of nodes and elements added or removed since the previous
1322     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1323     #  @ingroup l1_auxiliary
1324     def ClearLog(self):
1325         self.mesh.ClearLog()
1326
1327     ## Toggles auto color mode on the object.
1328     #  @param theAutoColor the flag which toggles auto color mode.
1329     #  @ingroup l1_auxiliary
1330     def SetAutoColor(self, theAutoColor):
1331         self.mesh.SetAutoColor(theAutoColor)
1332
1333     ## Gets flag of object auto color mode.
1334     #  @return True or False
1335     #  @ingroup l1_auxiliary
1336     def GetAutoColor(self):
1337         return self.mesh.GetAutoColor()
1338
1339     ## Gets the internal ID
1340     #  @return integer value, which is the internal Id of the mesh
1341     #  @ingroup l1_auxiliary
1342     def GetId(self):
1343         return self.mesh.GetId()
1344
1345     ## Get the study Id
1346     #  @return integer value, which is the study Id of the mesh
1347     #  @ingroup l1_auxiliary
1348     def GetStudyId(self):
1349         return self.mesh.GetStudyId()
1350
1351     ## Checks the group names for duplications.
1352     #  Consider the maximum group name length stored in MED file.
1353     #  @return True or False
1354     #  @ingroup l1_auxiliary
1355     def HasDuplicatedGroupNamesMED(self):
1356         return self.mesh.HasDuplicatedGroupNamesMED()
1357
1358     ## Obtains the mesh editor tool
1359     #  @return an instance of SMESH_MeshEditor
1360     #  @ingroup l1_modifying
1361     def GetMeshEditor(self):
1362         return self.mesh.GetMeshEditor()
1363
1364     ## Gets MED Mesh
1365     #  @return an instance of SALOME_MED::MESH
1366     #  @ingroup l1_auxiliary
1367     def GetMEDMesh(self):
1368         return self.mesh.GetMEDMesh()
1369
1370
1371     # Get informations about mesh contents:
1372     # ------------------------------------
1373
1374     ## Returns the number of nodes in the mesh
1375     #  @return an integer value
1376     #  @ingroup l1_meshinfo
1377     def NbNodes(self):
1378         return self.mesh.NbNodes()
1379
1380     ## Returns the number of elements in the mesh
1381     #  @return an integer value
1382     #  @ingroup l1_meshinfo
1383     def NbElements(self):
1384         return self.mesh.NbElements()
1385
1386     ## Returns the number of edges in the mesh
1387     #  @return an integer value
1388     #  @ingroup l1_meshinfo
1389     def NbEdges(self):
1390         return self.mesh.NbEdges()
1391
1392     ## Returns the number of edges with the given order in the mesh
1393     #  @param elementOrder the order of elements:
1394     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1395     #  @return an integer value
1396     #  @ingroup l1_meshinfo
1397     def NbEdgesOfOrder(self, elementOrder):
1398         return self.mesh.NbEdgesOfOrder(elementOrder)
1399
1400     ## Returns the number of faces in the mesh
1401     #  @return an integer value
1402     #  @ingroup l1_meshinfo
1403     def NbFaces(self):
1404         return self.mesh.NbFaces()
1405
1406     ## Returns the number of faces with the given order in the mesh
1407     #  @param elementOrder the order of elements:
1408     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1409     #  @return an integer value
1410     #  @ingroup l1_meshinfo
1411     def NbFacesOfOrder(self, elementOrder):
1412         return self.mesh.NbFacesOfOrder(elementOrder)
1413
1414     ## Returns the number of triangles in the mesh
1415     #  @return an integer value
1416     #  @ingroup l1_meshinfo
1417     def NbTriangles(self):
1418         return self.mesh.NbTriangles()
1419
1420     ## Returns the number of triangles with the given order in the mesh
1421     #  @param elementOrder is the order of elements:
1422     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1423     #  @return an integer value
1424     #  @ingroup l1_meshinfo
1425     def NbTrianglesOfOrder(self, elementOrder):
1426         return self.mesh.NbTrianglesOfOrder(elementOrder)
1427
1428     ## Returns the number of quadrangles in the mesh
1429     #  @return an integer value
1430     #  @ingroup l1_meshinfo
1431     def NbQuadrangles(self):
1432         return self.mesh.NbQuadrangles()
1433
1434     ## Returns the number of quadrangles with the given order in the mesh
1435     #  @param elementOrder the order of elements:
1436     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1437     #  @return an integer value
1438     #  @ingroup l1_meshinfo
1439     def NbQuadranglesOfOrder(self, elementOrder):
1440         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1441
1442     ## Returns the number of polygons in the mesh
1443     #  @return an integer value
1444     #  @ingroup l1_meshinfo
1445     def NbPolygons(self):
1446         return self.mesh.NbPolygons()
1447
1448     ## Returns the number of volumes in the mesh
1449     #  @return an integer value
1450     #  @ingroup l1_meshinfo
1451     def NbVolumes(self):
1452         return self.mesh.NbVolumes()
1453
1454     ## Returns the number of volumes with the given order in the mesh
1455     #  @param elementOrder  the order of elements:
1456     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1457     #  @return an integer value
1458     #  @ingroup l1_meshinfo
1459     def NbVolumesOfOrder(self, elementOrder):
1460         return self.mesh.NbVolumesOfOrder(elementOrder)
1461
1462     ## Returns the number of tetrahedrons in the mesh
1463     #  @return an integer value
1464     #  @ingroup l1_meshinfo
1465     def NbTetras(self):
1466         return self.mesh.NbTetras()
1467
1468     ## Returns the number of tetrahedrons with the given order in the mesh
1469     #  @param elementOrder  the order of elements:
1470     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1471     #  @return an integer value
1472     #  @ingroup l1_meshinfo
1473     def NbTetrasOfOrder(self, elementOrder):
1474         return self.mesh.NbTetrasOfOrder(elementOrder)
1475
1476     ## Returns the number of hexahedrons in the mesh
1477     #  @return an integer value
1478     #  @ingroup l1_meshinfo
1479     def NbHexas(self):
1480         return self.mesh.NbHexas()
1481
1482     ## Returns the number of hexahedrons with the given order in the mesh
1483     #  @param elementOrder  the order of elements:
1484     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1485     #  @return an integer value
1486     #  @ingroup l1_meshinfo
1487     def NbHexasOfOrder(self, elementOrder):
1488         return self.mesh.NbHexasOfOrder(elementOrder)
1489
1490     ## Returns the number of pyramids in the mesh
1491     #  @return an integer value
1492     #  @ingroup l1_meshinfo
1493     def NbPyramids(self):
1494         return self.mesh.NbPyramids()
1495
1496     ## Returns the number of pyramids with the given order in the mesh
1497     #  @param elementOrder  the order of elements:
1498     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1499     #  @return an integer value
1500     #  @ingroup l1_meshinfo
1501     def NbPyramidsOfOrder(self, elementOrder):
1502         return self.mesh.NbPyramidsOfOrder(elementOrder)
1503
1504     ## Returns the number of prisms in the mesh
1505     #  @return an integer value
1506     #  @ingroup l1_meshinfo
1507     def NbPrisms(self):
1508         return self.mesh.NbPrisms()
1509
1510     ## Returns the number of prisms with the given order in the mesh
1511     #  @param elementOrder  the order of elements:
1512     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1513     #  @return an integer value
1514     #  @ingroup l1_meshinfo
1515     def NbPrismsOfOrder(self, elementOrder):
1516         return self.mesh.NbPrismsOfOrder(elementOrder)
1517
1518     ## Returns the number of polyhedrons in the mesh
1519     #  @return an integer value
1520     #  @ingroup l1_meshinfo
1521     def NbPolyhedrons(self):
1522         return self.mesh.NbPolyhedrons()
1523
1524     ## Returns the number of submeshes in the mesh
1525     #  @return an integer value
1526     #  @ingroup l1_meshinfo
1527     def NbSubMesh(self):
1528         return self.mesh.NbSubMesh()
1529
1530     ## Returns the list of mesh elements IDs
1531     #  @return the list of integer values
1532     #  @ingroup l1_meshinfo
1533     def GetElementsId(self):
1534         return self.mesh.GetElementsId()
1535
1536     ## Returns the list of IDs of mesh elements with the given type
1537     #  @param elementType  the required type of elements
1538     #  @return list of integer values
1539     #  @ingroup l1_meshinfo
1540     def GetElementsByType(self, elementType):
1541         return self.mesh.GetElementsByType(elementType)
1542
1543     ## Returns the list of mesh nodes IDs
1544     #  @return the list of integer values
1545     #  @ingroup l1_meshinfo
1546     def GetNodesId(self):
1547         return self.mesh.GetNodesId()
1548
1549     # Get the information about mesh elements:
1550     # ------------------------------------
1551
1552     ## Returns the type of mesh element
1553     #  @return the value from SMESH::ElementType enumeration
1554     #  @ingroup l1_meshinfo
1555     def GetElementType(self, id, iselem):
1556         return self.mesh.GetElementType(id, iselem)
1557
1558     ## Returns the list of submesh elements IDs
1559     #  @param Shape a geom object(subshape) IOR
1560     #         Shape must be the subshape of a ShapeToMesh()
1561     #  @return the list of integer values
1562     #  @ingroup l1_meshinfo
1563     def GetSubMeshElementsId(self, Shape):
1564         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1565             ShapeID = Shape.GetSubShapeIndices()[0]
1566         else:
1567             ShapeID = Shape
1568         return self.mesh.GetSubMeshElementsId(ShapeID)
1569
1570     ## Returns the list of submesh nodes IDs
1571     #  @param Shape a geom object(subshape) IOR
1572     #         Shape must be the subshape of a ShapeToMesh()
1573     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1574     #  @return the list of integer values
1575     #  @ingroup l1_meshinfo
1576     def GetSubMeshNodesId(self, Shape, all):
1577         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1578             ShapeID = Shape.GetSubShapeIndices()[0]
1579         else:
1580             ShapeID = Shape
1581         return self.mesh.GetSubMeshNodesId(ShapeID, all)
1582
1583     ## Returns the list of IDs of submesh elements with the given type
1584     #  @param Shape a geom object(subshape) IOR
1585     #         Shape must be a subshape of a ShapeToMesh()
1586     #  @return the list of integer values
1587     #  @ingroup l1_meshinfo
1588     def GetSubMeshElementType(self, Shape):
1589         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1590             ShapeID = Shape.GetSubShapeIndices()[0]
1591         else:
1592             ShapeID = Shape
1593         return self.mesh.GetSubMeshElementType(ShapeID)
1594
1595     ## Gets the mesh description
1596     #  @return string value
1597     #  @ingroup l1_meshinfo
1598     def Dump(self):
1599         return self.mesh.Dump()
1600
1601
1602     # Get the information about nodes and elements of a mesh by its IDs:
1603     # -----------------------------------------------------------
1604
1605     ## Gets XYZ coordinates of a node
1606     #  \n If there is no nodes for the given ID - returns an empty list
1607     #  @return a list of double precision values
1608     #  @ingroup l1_meshinfo
1609     def GetNodeXYZ(self, id):
1610         return self.mesh.GetNodeXYZ(id)
1611
1612     ## Returns list of IDs of inverse elements for the given node
1613     #  \n If there is no node for the given ID - returns an empty list
1614     #  @return a list of integer values
1615     #  @ingroup l1_meshinfo
1616     def GetNodeInverseElements(self, id):
1617         return self.mesh.GetNodeInverseElements(id)
1618
1619     ## @brief Returns the position of a node on the shape
1620     #  @return SMESH::NodePosition
1621     #  @ingroup l1_meshinfo
1622     def GetNodePosition(self,NodeID):
1623         return self.mesh.GetNodePosition(NodeID)
1624
1625     ## If the given element is a node, returns the ID of shape
1626     #  \n If there is no node for the given ID - returns -1
1627     #  @return an integer value
1628     #  @ingroup l1_meshinfo
1629     def GetShapeID(self, id):
1630         return self.mesh.GetShapeID(id)
1631
1632     ## Returns the ID of the result shape after
1633     #  FindShape() from SMESH_MeshEditor for the given element
1634     #  \n If there is no element for the given ID - returns -1
1635     #  @return an integer value
1636     #  @ingroup l1_meshinfo
1637     def GetShapeIDForElem(self,id):
1638         return self.mesh.GetShapeIDForElem(id)
1639
1640     ## Returns the number of nodes for the given element
1641     #  \n If there is no element for the given ID - returns -1
1642     #  @return an integer value
1643     #  @ingroup l1_meshinfo
1644     def GetElemNbNodes(self, id):
1645         return self.mesh.GetElemNbNodes(id)
1646
1647     ## Returns the node ID the given index for the given element
1648     #  \n If there is no element for the given ID - returns -1
1649     #  \n If there is no node for the given index - returns -2
1650     #  @return an integer value
1651     #  @ingroup l1_meshinfo
1652     def GetElemNode(self, id, index):
1653         return self.mesh.GetElemNode(id, index)
1654
1655     ## Returns the IDs of nodes of the given element
1656     #  @return a list of integer values
1657     #  @ingroup l1_meshinfo
1658     def GetElemNodes(self, id):
1659         return self.mesh.GetElemNodes(id)
1660
1661     ## Returns true if the given node is the medium node in the given quadratic element
1662     #  @ingroup l1_meshinfo
1663     def IsMediumNode(self, elementID, nodeID):
1664         return self.mesh.IsMediumNode(elementID, nodeID)
1665
1666     ## Returns true if the given node is the medium node in one of quadratic elements
1667     #  @ingroup l1_meshinfo
1668     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1669         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1670
1671     ## Returns the number of edges for the given element
1672     #  @ingroup l1_meshinfo
1673     def ElemNbEdges(self, id):
1674         return self.mesh.ElemNbEdges(id)
1675
1676     ## Returns the number of faces for the given element
1677     #  @ingroup l1_meshinfo
1678     def ElemNbFaces(self, id):
1679         return self.mesh.ElemNbFaces(id)
1680
1681     ## Returns true if the given element is a polygon
1682     #  @ingroup l1_meshinfo
1683     def IsPoly(self, id):
1684         return self.mesh.IsPoly(id)
1685
1686     ## Returns true if the given element is quadratic
1687     #  @ingroup l1_meshinfo
1688     def IsQuadratic(self, id):
1689         return self.mesh.IsQuadratic(id)
1690
1691     ## Returns XYZ coordinates of the barycenter of the given element
1692     #  \n If there is no element for the given ID - returns an empty list
1693     #  @return a list of three double values
1694     #  @ingroup l1_meshinfo
1695     def BaryCenter(self, id):
1696         return self.mesh.BaryCenter(id)
1697
1698
1699     # Mesh edition (SMESH_MeshEditor functionality):
1700     # ---------------------------------------------
1701
1702     ## Removes the elements from the mesh by ids
1703     #  @param IDsOfElements is a list of ids of elements to remove
1704     #  @return True or False
1705     #  @ingroup l2_modif_del
1706     def RemoveElements(self, IDsOfElements):
1707         return self.editor.RemoveElements(IDsOfElements)
1708
1709     ## Removes nodes from mesh by ids
1710     #  @param IDsOfNodes is a list of ids of nodes to remove
1711     #  @return True or False
1712     #  @ingroup l2_modif_del
1713     def RemoveNodes(self, IDsOfNodes):
1714         return self.editor.RemoveNodes(IDsOfNodes)
1715
1716     ## Add a node to the mesh by coordinates
1717     #  @return Id of the new node
1718     #  @ingroup l2_modif_add
1719     def AddNode(self, x, y, z):
1720         return self.editor.AddNode( x, y, z)
1721
1722     ## Creates a linear or quadratic edge (this is determined
1723     #  by the number of given nodes).
1724     #  @param IDsOfNodes the list of node IDs for creation of the element.
1725     #  The order of nodes in this list should correspond to the description
1726     #  of MED. \n This description is located by the following link:
1727     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1728     #  @return the Id of the new edge
1729     #  @ingroup l2_modif_add
1730     def AddEdge(self, IDsOfNodes):
1731         return self.editor.AddEdge(IDsOfNodes)
1732
1733     ## Creates a linear or quadratic face (this is determined
1734     #  by the number of given nodes).
1735     #  @param IDsOfNodes the list of node IDs for creation of the element.
1736     #  The order of nodes in this list should correspond to the description
1737     #  of MED. \n This description is located by the following link:
1738     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1739     #  @return the Id of the new face
1740     #  @ingroup l2_modif_add
1741     def AddFace(self, IDsOfNodes):
1742         return self.editor.AddFace(IDsOfNodes)
1743
1744     ## Adds a polygonal face to the mesh by the list of node IDs
1745     #  @param IdsOfNodes the list of node IDs for creation of the element.
1746     #  @return the Id of the new face
1747     #  @ingroup l2_modif_add
1748     def AddPolygonalFace(self, IdsOfNodes):
1749         return self.editor.AddPolygonalFace(IdsOfNodes)
1750
1751     ## Creates both simple and quadratic volume (this is determined
1752     #  by the number of given nodes).
1753     #  @param IDsOfNodes the list of node IDs for creation of the element.
1754     #  The order of nodes in this list should correspond to the description
1755     #  of MED. \n This description is located by the following link:
1756     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1757     #  @return the Id of the new volumic element
1758     #  @ingroup l2_modif_add
1759     def AddVolume(self, IDsOfNodes):
1760         return self.editor.AddVolume(IDsOfNodes)
1761
1762     ## Creates a volume of many faces, giving nodes for each face.
1763     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
1764     #  @param Quantities the list of integer values, Quantities[i]
1765     #         gives the quantity of nodes in face number i.
1766     #  @return the Id of the new volumic element
1767     #  @ingroup l2_modif_add
1768     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1769         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1770
1771     ## Creates a volume of many faces, giving the IDs of the existing faces.
1772     #  @param IdsOfFaces the list of face IDs for volume creation.
1773     #
1774     #  Note:  The created volume will refer only to the nodes
1775     #         of the given faces, not to the faces themselves.
1776     #  @return the Id of the new volumic element
1777     #  @ingroup l2_modif_add
1778     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1779         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1780
1781
1782     ## @brief Binds a node to a vertex
1783     #  @param NodeID a node ID
1784     #  @param Vertex a vertex or vertex ID
1785     #  @return True if succeed else raises an exception
1786     #  @ingroup l2_modif_add
1787     def SetNodeOnVertex(self, NodeID, Vertex):
1788         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1789             VertexID = Vertex.GetSubShapeIndices()[0]
1790         else:
1791             VertexID = Vertex
1792         try:
1793             self.editor.SetNodeOnVertex(NodeID, VertexID)
1794         except SALOME.SALOME_Exception, inst:
1795             raise ValueError, inst.details.text
1796         return True
1797
1798
1799     ## @brief Stores the node position on an edge
1800     #  @param NodeID a node ID
1801     #  @param Edge an edge or edge ID
1802     #  @param paramOnEdge a parameter on the edge where the node is located
1803     #  @return True if succeed else raises an exception
1804     #  @ingroup l2_modif_add
1805     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1806         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1807             EdgeID = Edge.GetSubShapeIndices()[0]
1808         else:
1809             EdgeID = Edge
1810         try:
1811             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1812         except SALOME.SALOME_Exception, inst:
1813             raise ValueError, inst.details.text
1814         return True
1815
1816     ## @brief Stores node position on a face
1817     #  @param NodeID a node ID
1818     #  @param Face a face or face ID
1819     #  @param u U parameter on the face where the node is located
1820     #  @param v V parameter on the face where the node is located
1821     #  @return True if succeed else raises an exception
1822     #  @ingroup l2_modif_add
1823     def SetNodeOnFace(self, NodeID, Face, u, v):
1824         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1825             FaceID = Face.GetSubShapeIndices()[0]
1826         else:
1827             FaceID = Face
1828         try:
1829             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1830         except SALOME.SALOME_Exception, inst:
1831             raise ValueError, inst.details.text
1832         return True
1833
1834     ## @brief Binds a node to a solid
1835     #  @param NodeID a node ID
1836     #  @param Solid  a solid or solid ID
1837     #  @return True if succeed else raises an exception
1838     #  @ingroup l2_modif_add
1839     def SetNodeInVolume(self, NodeID, Solid):
1840         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1841             SolidID = Solid.GetSubShapeIndices()[0]
1842         else:
1843             SolidID = Solid
1844         try:
1845             self.editor.SetNodeInVolume(NodeID, SolidID)
1846         except SALOME.SALOME_Exception, inst:
1847             raise ValueError, inst.details.text
1848         return True
1849
1850     ## @brief Bind an element to a shape
1851     #  @param ElementID an element ID
1852     #  @param Shape a shape or shape ID
1853     #  @return True if succeed else raises an exception
1854     #  @ingroup l2_modif_add
1855     def SetMeshElementOnShape(self, ElementID, Shape):
1856         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1857             ShapeID = Shape.GetSubShapeIndices()[0]
1858         else:
1859             ShapeID = Shape
1860         try:
1861             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1862         except SALOME.SALOME_Exception, inst:
1863             raise ValueError, inst.details.text
1864         return True
1865
1866
1867     ## Moves the node with the given id
1868     #  @param NodeID the id of the node
1869     #  @param x  a new X coordinate
1870     #  @param y  a new Y coordinate
1871     #  @param z  a new Z coordinate
1872     #  @return True if succeed else False
1873     #  @ingroup l2_modif_movenode
1874     def MoveNode(self, NodeID, x, y, z):
1875         return self.editor.MoveNode(NodeID, x, y, z)
1876
1877     ## Finds the node closest to a point
1878     #  @param x  the X coordinate of a point
1879     #  @param y  the Y coordinate of a point
1880     #  @param z  the Z coordinate of a point
1881     #  @return the ID of a node
1882     #  @ingroup l2_modif_throughp
1883     def FindNodeClosestTo(self, x, y, z):
1884         preview = self.mesh.GetMeshEditPreviewer()
1885         return preview.MoveClosestNodeToPoint(x, y, z, -1)
1886
1887     ## Finds the node closest to a point and moves it to a point location
1888     #  @param x  the X coordinate of a point
1889     #  @param y  the Y coordinate of a point
1890     #  @param z  the Z coordinate of a point
1891     #  @return the ID of a moved node
1892     #  @ingroup l2_modif_throughp
1893     def MeshToPassThroughAPoint(self, x, y, z):
1894         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1895
1896     ## Replaces two neighbour triangles sharing Node1-Node2 link
1897     #  with the triangles built on the same 4 nodes but having other common link.
1898     #  @param NodeID1  the ID of the first node
1899     #  @param NodeID2  the ID of the second node
1900     #  @return false if proper faces were not found
1901     #  @ingroup l2_modif_invdiag
1902     def InverseDiag(self, NodeID1, NodeID2):
1903         return self.editor.InverseDiag(NodeID1, NodeID2)
1904
1905     ## Replaces two neighbour triangles sharing Node1-Node2 link
1906     #  with a quadrangle built on the same 4 nodes.
1907     #  @param NodeID1  the ID of the first node
1908     #  @param NodeID2  the ID of the second node
1909     #  @return false if proper faces were not found
1910     #  @ingroup l2_modif_unitetri
1911     def DeleteDiag(self, NodeID1, NodeID2):
1912         return self.editor.DeleteDiag(NodeID1, NodeID2)
1913
1914     ## Reorients elements by ids
1915     #  @param IDsOfElements if undefined reorients all mesh elements
1916     #  @return True if succeed else False
1917     #  @ingroup l2_modif_changori
1918     def Reorient(self, IDsOfElements=None):
1919         if IDsOfElements == None:
1920             IDsOfElements = self.GetElementsId()
1921         return self.editor.Reorient(IDsOfElements)
1922
1923     ## Reorients all elements of the object
1924     #  @param theObject mesh, submesh or group
1925     #  @return True if succeed else False
1926     #  @ingroup l2_modif_changori
1927     def ReorientObject(self, theObject):
1928         if ( isinstance( theObject, Mesh )):
1929             theObject = theObject.GetMesh()
1930         return self.editor.ReorientObject(theObject)
1931
1932     ## Fuses the neighbouring triangles into quadrangles.
1933     #  @param IDsOfElements The triangles to be fused,
1934     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
1935     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
1936     #                       is still performed; theMaxAngle is mesured in radians.
1937     #  @return TRUE in case of success, FALSE otherwise.
1938     #  @ingroup l2_modif_unitetri
1939     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1940         if IDsOfElements == []:
1941             IDsOfElements = self.GetElementsId()
1942         return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1943
1944     ## Fuses the neighbouring triangles of the object into quadrangles
1945     #  @param theObject is mesh, submesh or group
1946     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1947     #  @param MaxAngle   a max angle between element normals at which the fusion
1948     #                   is still performed; theMaxAngle is mesured in radians.
1949     #  @return TRUE in case of success, FALSE otherwise.
1950     #  @ingroup l2_modif_unitetri
1951     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1952         if ( isinstance( theObject, Mesh )):
1953             theObject = theObject.GetMesh()
1954         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1955
1956     ## Splits quadrangles into triangles.
1957     #  @param IDsOfElements the faces to be splitted.
1958     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
1959     #  @return TRUE in case of success, FALSE otherwise.
1960     #  @ingroup l2_modif_cutquadr
1961     def QuadToTri (self, IDsOfElements, theCriterion):
1962         if IDsOfElements == []:
1963             IDsOfElements = self.GetElementsId()
1964         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1965
1966     ## Splits quadrangles into triangles.
1967     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
1968     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
1969     #  @return TRUE in case of success, FALSE otherwise.
1970     #  @ingroup l2_modif_cutquadr
1971     def QuadToTriObject (self, theObject, theCriterion):
1972         if ( isinstance( theObject, Mesh )):
1973             theObject = theObject.GetMesh()
1974         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1975
1976     ## Splits quadrangles into triangles.
1977     #  @param IDsOfElements the faces to be splitted
1978     #  @param Diag13        is used to choose a diagonal for splitting.
1979     #  @return TRUE in case of success, FALSE otherwise.
1980     #  @ingroup l2_modif_cutquadr
1981     def SplitQuad (self, IDsOfElements, Diag13):
1982         if IDsOfElements == []:
1983             IDsOfElements = self.GetElementsId()
1984         return self.editor.SplitQuad(IDsOfElements, Diag13)
1985
1986     ## Splits quadrangles into triangles.
1987     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1988     #  @param Diag13    is used to choose a diagonal for splitting.
1989     #  @return TRUE in case of success, FALSE otherwise.
1990     #  @ingroup l2_modif_cutquadr
1991     def SplitQuadObject (self, theObject, Diag13):
1992         if ( isinstance( theObject, Mesh )):
1993             theObject = theObject.GetMesh()
1994         return self.editor.SplitQuadObject(theObject, Diag13)
1995
1996     ## Finds a better splitting of the given quadrangle.
1997     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
1998     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
1999     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2000     #          diagonal is better, 0 if error occurs.
2001     #  @ingroup l2_modif_cutquadr
2002     def BestSplit (self, IDOfQuad, theCriterion):
2003         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2004
2005     ## Splits quadrangle faces near triangular facets of volumes
2006     #
2007     #  @ingroup l1_auxiliary
2008     def SplitQuadsNearTriangularFacets(self):
2009         faces_array = self.GetElementsByType(SMESH.FACE)
2010         for face_id in faces_array:
2011             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2012                 quad_nodes = self.mesh.GetElemNodes(face_id)
2013                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2014                 isVolumeFound = False
2015                 for node1_elem in node1_elems:
2016                     if not isVolumeFound:
2017                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2018                             nb_nodes = self.GetElemNbNodes(node1_elem)
2019                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2020                                 volume_elem = node1_elem
2021                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2022                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2023                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2024                                         isVolumeFound = True
2025                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2026                                             self.SplitQuad([face_id], False) # diagonal 2-4
2027                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2028                                         isVolumeFound = True
2029                                         self.SplitQuad([face_id], True) # diagonal 1-3
2030                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2031                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2032                                         isVolumeFound = True
2033                                         self.SplitQuad([face_id], True) # diagonal 1-3
2034
2035     ## @brief Splits hexahedrons into tetrahedrons.
2036     #
2037     #  This operation uses pattern mapping functionality for splitting.
2038     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2039     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2040     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2041     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2042     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2043     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2044     #  @return TRUE in case of success, FALSE otherwise.
2045     #  @ingroup l1_auxiliary
2046     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2047         # Pattern:     5.---------.6
2048         #              /|#*      /|
2049         #             / | #*    / |
2050         #            /  |  # * /  |
2051         #           /   |   # /*  |
2052         # (0,0,1) 4.---------.7 * |
2053         #          |#*  |1   | # *|
2054         #          | # *.----|---#.2
2055         #          |  #/ *   |   /
2056         #          |  /#  *  |  /
2057         #          | /   # * | /
2058         #          |/      #*|/
2059         # (0,0,0) 0.---------.3
2060         pattern_tetra = "!!! Nb of points: \n 8 \n\
2061         !!! Points: \n\
2062         0 0 0  !- 0 \n\
2063         0 1 0  !- 1 \n\
2064         1 1 0  !- 2 \n\
2065         1 0 0  !- 3 \n\
2066         0 0 1  !- 4 \n\
2067         0 1 1  !- 5 \n\
2068         1 1 1  !- 6 \n\
2069         1 0 1  !- 7 \n\
2070         !!! Indices of points of 6 tetras: \n\
2071         0 3 4 1 \n\
2072         7 4 3 1 \n\
2073         4 7 5 1 \n\
2074         6 2 5 7 \n\
2075         1 5 2 7 \n\
2076         2 3 1 7 \n"
2077
2078         pattern = self.smeshpyD.GetPattern()
2079         isDone  = pattern.LoadFromFile(pattern_tetra)
2080         if not isDone:
2081             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2082             return isDone
2083
2084         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2085         isDone = pattern.MakeMesh(self.mesh, False, False)
2086         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2087
2088         # split quafrangle faces near triangular facets of volumes
2089         self.SplitQuadsNearTriangularFacets()
2090
2091         return isDone
2092
2093     ## @brief Split hexahedrons into prisms.
2094     #
2095     #  Uses the pattern mapping functionality for splitting.
2096     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2097     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2098     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2099     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2100     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2101     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2102     #  @return TRUE in case of success, FALSE otherwise.
2103     #  @ingroup l1_auxiliary
2104     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2105         # Pattern:     5.---------.6
2106         #              /|#       /|
2107         #             / | #     / |
2108         #            /  |  #   /  |
2109         #           /   |   # /   |
2110         # (0,0,1) 4.---------.7   |
2111         #          |    |    |    |
2112         #          |   1.----|----.2
2113         #          |   / *   |   /
2114         #          |  /   *  |  /
2115         #          | /     * | /
2116         #          |/       *|/
2117         # (0,0,0) 0.---------.3
2118         pattern_prism = "!!! Nb of points: \n 8 \n\
2119         !!! Points: \n\
2120         0 0 0  !- 0 \n\
2121         0 1 0  !- 1 \n\
2122         1 1 0  !- 2 \n\
2123         1 0 0  !- 3 \n\
2124         0 0 1  !- 4 \n\
2125         0 1 1  !- 5 \n\
2126         1 1 1  !- 6 \n\
2127         1 0 1  !- 7 \n\
2128         !!! Indices of points of 2 prisms: \n\
2129         0 1 3 4 5 7 \n\
2130         2 3 1 6 7 5 \n"
2131
2132         pattern = self.smeshpyD.GetPattern()
2133         isDone  = pattern.LoadFromFile(pattern_prism)
2134         if not isDone:
2135             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2136             return isDone
2137
2138         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2139         isDone = pattern.MakeMesh(self.mesh, False, False)
2140         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2141
2142         # Splits quafrangle faces near triangular facets of volumes
2143         self.SplitQuadsNearTriangularFacets()
2144
2145         return isDone
2146
2147     ## Smoothes elements
2148     #  @param IDsOfElements the list if ids of elements to smooth
2149     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2150     #  Note that nodes built on edges and boundary nodes are always fixed.
2151     #  @param MaxNbOfIterations the maximum number of iterations
2152     #  @param MaxAspectRatio varies in range [1.0, inf]
2153     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2154     #  @return TRUE in case of success, FALSE otherwise.
2155     #  @ingroup l2_modif_smooth
2156     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2157                MaxNbOfIterations, MaxAspectRatio, Method):
2158         if IDsOfElements == []:
2159             IDsOfElements = self.GetElementsId()
2160         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2161                                   MaxNbOfIterations, MaxAspectRatio, Method)
2162
2163     ## Smoothes elements which belong to the given object
2164     #  @param theObject the object to smooth
2165     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2166     #  Note that nodes built on edges and boundary nodes are always fixed.
2167     #  @param MaxNbOfIterations the maximum number of iterations
2168     #  @param MaxAspectRatio varies in range [1.0, inf]
2169     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2170     #  @return TRUE in case of success, FALSE otherwise.
2171     #  @ingroup l2_modif_smooth
2172     def SmoothObject(self, theObject, IDsOfFixedNodes,
2173                      MaxNbOfIterations, MaxAspectRatio, Method):
2174         if ( isinstance( theObject, Mesh )):
2175             theObject = theObject.GetMesh()
2176         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2177                                         MaxNbOfIterations, MaxAspectRatio, Method)
2178
2179     ## Parametrically smoothes the given elements
2180     #  @param IDsOfElements the list if ids of elements to smooth
2181     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2182     #  Note that nodes built on edges and boundary nodes are always fixed.
2183     #  @param MaxNbOfIterations the maximum number of iterations
2184     #  @param MaxAspectRatio varies in range [1.0, inf]
2185     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2186     #  @return TRUE in case of success, FALSE otherwise.
2187     #  @ingroup l2_modif_smooth
2188     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2189                          MaxNbOfIterations, MaxAspectRatio, Method):
2190         if IDsOfElements == []:
2191             IDsOfElements = self.GetElementsId()
2192         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2193                                             MaxNbOfIterations, MaxAspectRatio, Method)
2194
2195     ## Parametrically smoothes the elements which belong to the given object
2196     #  @param theObject the object to smooth
2197     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2198     #  Note that nodes built on edges and boundary nodes are always fixed.
2199     #  @param MaxNbOfIterations the maximum number of iterations
2200     #  @param MaxAspectRatio varies in range [1.0, inf]
2201     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2202     #  @return TRUE in case of success, FALSE otherwise.
2203     #  @ingroup l2_modif_smooth
2204     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2205                                MaxNbOfIterations, MaxAspectRatio, Method):
2206         if ( isinstance( theObject, Mesh )):
2207             theObject = theObject.GetMesh()
2208         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2209                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2210
2211     ## Converts the mesh to quadratic, deletes old elements, replacing
2212     #  them with quadratic with the same id.
2213     #  @ingroup l2_modif_tofromqu
2214     def ConvertToQuadratic(self, theForce3d):
2215         self.editor.ConvertToQuadratic(theForce3d)
2216
2217     ## Converts the mesh from quadratic to ordinary,
2218     #  deletes old quadratic elements, \n replacing
2219     #  them with ordinary mesh elements with the same id.
2220     #  @return TRUE in case of success, FALSE otherwise.
2221     #  @ingroup l2_modif_tofromqu
2222     def ConvertFromQuadratic(self):
2223         return self.editor.ConvertFromQuadratic()
2224
2225     ## Renumber mesh nodes
2226     #  @ingroup l2_modif_renumber
2227     def RenumberNodes(self):
2228         self.editor.RenumberNodes()
2229
2230     ## Renumber mesh elements
2231     #  @ingroup l2_modif_renumber
2232     def RenumberElements(self):
2233         self.editor.RenumberElements()
2234
2235     ## Generates new elements by rotation of the elements around the axis
2236     #  @param IDsOfElements the list of ids of elements to sweep
2237     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2238     #  @param AngleInRadians the angle of Rotation
2239     #  @param NbOfSteps the number of steps
2240     #  @param Tolerance tolerance
2241     #  @param MakeGroups forces the generation of new groups from existing ones
2242     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2243     #                    of all steps, else - size of each step
2244     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2245     #  @ingroup l2_modif_extrurev
2246     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2247                       MakeGroups=False, TotalAngle=False):
2248         if IDsOfElements == []:
2249             IDsOfElements = self.GetElementsId()
2250         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2251             Axis = self.smeshpyD.GetAxisStruct(Axis)
2252         if TotalAngle and NbOfSteps:
2253             AngleInRadians /= NbOfSteps
2254         if MakeGroups:
2255             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2256                                                        AngleInRadians, NbOfSteps, Tolerance)
2257         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2258         return []
2259
2260     ## Generates new elements by rotation of the elements of object around the axis
2261     #  @param theObject object which elements should be sweeped
2262     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2263     #  @param AngleInRadians the angle of Rotation
2264     #  @param NbOfSteps number of steps
2265     #  @param Tolerance tolerance
2266     #  @param MakeGroups forces the generation of new groups from existing ones
2267     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2268     #                    of all steps, else - size of each step
2269     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2270     #  @ingroup l2_modif_extrurev
2271     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2272                             MakeGroups=False, TotalAngle=False):
2273         if ( isinstance( theObject, Mesh )):
2274             theObject = theObject.GetMesh()
2275         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2276             Axis = self.smeshpyD.GetAxisStruct(Axis)
2277         if TotalAngle and NbOfSteps:
2278             AngleInRadians /= NbOfSteps
2279         if MakeGroups:
2280             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2281                                                              NbOfSteps, Tolerance)
2282         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2283         return []
2284
2285     ## Generates new elements by extrusion of the elements with given ids
2286     #  @param IDsOfElements the list of elements ids for extrusion
2287     #  @param StepVector vector, defining the direction and value of extrusion
2288     #  @param NbOfSteps the number of steps
2289     #  @param MakeGroups forces the generation of new groups from existing ones
2290     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2291     #  @ingroup l2_modif_extrurev
2292     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2293         if IDsOfElements == []:
2294             IDsOfElements = self.GetElementsId()
2295         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2296             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2297         if MakeGroups:
2298             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2299         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2300         return []
2301
2302     ## Generates new elements by extrusion of the elements with given ids
2303     #  @param IDsOfElements is ids of elements
2304     #  @param StepVector vector, defining the direction and value of extrusion
2305     #  @param NbOfSteps the number of steps
2306     #  @param ExtrFlags sets flags for extrusion
2307     #  @param SewTolerance uses for comparing locations of nodes if flag
2308     #         EXTRUSION_FLAG_SEW is set
2309     #  @param MakeGroups forces the generation of new groups from existing ones
2310     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2311     #  @ingroup l2_modif_extrurev
2312     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2313                           ExtrFlags, SewTolerance, MakeGroups=False):
2314         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2315             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2316         if MakeGroups:
2317             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2318                                                            ExtrFlags, SewTolerance)
2319         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2320                                       ExtrFlags, SewTolerance)
2321         return []
2322
2323     ## Generates new elements by extrusion of the elements which belong to the object
2324     #  @param theObject the object which elements should be processed
2325     #  @param StepVector vector, defining the direction and value of extrusion
2326     #  @param NbOfSteps the number of steps
2327     #  @param MakeGroups forces the generation of new groups from existing ones
2328     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2329     #  @ingroup l2_modif_extrurev
2330     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2331         if ( isinstance( theObject, Mesh )):
2332             theObject = theObject.GetMesh()
2333         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2334             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2335         if MakeGroups:
2336             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2337         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2338         return []
2339
2340     ## Generates new elements by extrusion of the elements which belong to the object
2341     #  @param theObject object which elements should be processed
2342     #  @param StepVector vector, defining the direction and value of extrusion
2343     #  @param NbOfSteps the number of steps
2344     #  @param MakeGroups to generate new groups from existing ones
2345     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2346     #  @ingroup l2_modif_extrurev
2347     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2348         if ( isinstance( theObject, Mesh )):
2349             theObject = theObject.GetMesh()
2350         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2351             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2352         if MakeGroups:
2353             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2354         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2355         return []
2356
2357     ## Generates new elements by extrusion of the elements which belong to the object
2358     #  @param theObject object which elements should be processed
2359     #  @param StepVector vector, defining the direction and value of extrusion
2360     #  @param NbOfSteps the number of steps
2361     #  @param MakeGroups forces the generation of new groups from existing ones
2362     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2363     #  @ingroup l2_modif_extrurev
2364     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2365         if ( isinstance( theObject, Mesh )):
2366             theObject = theObject.GetMesh()
2367         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2368             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2369         if MakeGroups:
2370             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2371         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2372         return []
2373
2374     ## Generates new elements by extrusion of the given elements
2375     #  The path of extrusion must be a meshed edge.
2376     #  @param IDsOfElements ids of elements
2377     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2378     #  @param PathShape shape(edge) defines the sub-mesh for the path
2379     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2380     #  @param HasAngles allows the shape to be rotated around the path
2381     #                   to get the resulting mesh in a helical fashion
2382     #  @param Angles list of angles
2383     #  @param HasRefPoint allows using the reference point
2384     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2385     #         The User can specify any point as the Reference Point.
2386     #  @param MakeGroups forces the generation of new groups from existing ones
2387     #  @param LinearVariation forces the computation of rotation angles as linear
2388     #                         variation of the given Angles along path steps
2389     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2390     #          only SMESH::Extrusion_Error otherwise
2391     #  @ingroup l2_modif_extrurev
2392     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2393                            HasAngles, Angles, HasRefPoint, RefPoint,
2394                            MakeGroups=False, LinearVariation=False):
2395         if IDsOfElements == []:
2396             IDsOfElements = self.GetElementsId()
2397         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2398             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2399             pass
2400         if ( isinstance( PathMesh, Mesh )):
2401             PathMesh = PathMesh.GetMesh()
2402         if HasAngles and Angles and LinearVariation:
2403             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2404             pass
2405         if MakeGroups:
2406             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2407                                                             PathShape, NodeStart, HasAngles,
2408                                                             Angles, HasRefPoint, RefPoint)
2409         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2410                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2411
2412     ## Generates new elements by extrusion of the elements which belong to the object
2413     #  The path of extrusion must be a meshed edge.
2414     #  @param theObject the object which elements should be processed
2415     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2416     #  @param PathShape shape(edge) defines the sub-mesh for the path
2417     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2418     #  @param HasAngles allows the shape to be rotated around the path
2419     #                   to get the resulting mesh in a helical fashion
2420     #  @param Angles list of angles
2421     #  @param HasRefPoint allows using the reference point
2422     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2423     #         The User can specify any point as the Reference Point.
2424     #  @param MakeGroups forces the generation of new groups from existing ones
2425     #  @param LinearVariation forces the computation of rotation angles as linear
2426     #                         variation of the given Angles along path steps
2427     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2428     #          only SMESH::Extrusion_Error otherwise
2429     #  @ingroup l2_modif_extrurev
2430     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2431                                  HasAngles, Angles, HasRefPoint, RefPoint,
2432                                  MakeGroups=False, LinearVariation=False):
2433         if ( isinstance( theObject, Mesh )):
2434             theObject = theObject.GetMesh()
2435         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2436             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2437         if ( isinstance( PathMesh, Mesh )):
2438             PathMesh = PathMesh.GetMesh()
2439         if HasAngles and Angles and LinearVariation:
2440             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2441             pass
2442         if MakeGroups:
2443             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2444                                                                   PathShape, NodeStart, HasAngles,
2445                                                                   Angles, HasRefPoint, RefPoint)
2446         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2447                                                     NodeStart, HasAngles, Angles, HasRefPoint,
2448                                                     RefPoint)
2449
2450     ## Creates a symmetrical copy of mesh elements
2451     #  @param IDsOfElements list of elements ids
2452     #  @param Mirror is AxisStruct or geom object(point, line, plane)
2453     #  @param theMirrorType is  POINT, AXIS or PLANE
2454     #  If the Mirror is a geom object this parameter is unnecessary
2455     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2456     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2457     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2458     #  @ingroup l2_modif_trsf
2459     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2460         if IDsOfElements == []:
2461             IDsOfElements = self.GetElementsId()
2462         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2463             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2464         if Copy and MakeGroups:
2465             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2466         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2467         return []
2468
2469     ## Creates a new mesh by a symmetrical copy of mesh elements
2470     #  @param IDsOfElements the list of elements ids
2471     #  @param Mirror is AxisStruct or geom object (point, line, plane)
2472     #  @param theMirrorType is  POINT, AXIS or PLANE
2473     #  If the Mirror is a geom object this parameter is unnecessary
2474     #  @param MakeGroups to generate new groups from existing ones
2475     #  @param NewMeshName a name of the new mesh to create
2476     #  @return instance of Mesh class
2477     #  @ingroup l2_modif_trsf
2478     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2479         if IDsOfElements == []:
2480             IDsOfElements = self.GetElementsId()
2481         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2482             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2483         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2484                                           MakeGroups, NewMeshName)
2485         return Mesh(self.smeshpyD,self.geompyD,mesh)
2486
2487     ## Creates a symmetrical copy of the object
2488     #  @param theObject mesh, submesh or group
2489     #  @param Mirror AxisStruct or geom object (point, line, plane)
2490     #  @param theMirrorType is  POINT, AXIS or PLANE
2491     #  If the Mirror is a geom object this parameter is unnecessary
2492     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2493     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2494     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2495     #  @ingroup l2_modif_trsf
2496     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2497         if ( isinstance( theObject, Mesh )):
2498             theObject = theObject.GetMesh()
2499         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2500             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2501         if Copy and MakeGroups:
2502             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2503         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2504         return []
2505
2506     ## Creates a new mesh by a symmetrical copy of the object
2507     #  @param theObject mesh, submesh or group
2508     #  @param Mirror AxisStruct or geom object (point, line, plane)
2509     #  @param theMirrorType POINT, AXIS or PLANE
2510     #  If the Mirror is a geom object this parameter is unnecessary
2511     #  @param MakeGroups forces the generation of new groups from existing ones
2512     #  @param NewMeshName the name of the new mesh to create
2513     #  @return instance of Mesh class
2514     #  @ingroup l2_modif_trsf
2515     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2516         if ( isinstance( theObject, Mesh )):
2517             theObject = theObject.GetMesh()
2518         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2519             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2520         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2521                                                 MakeGroups, NewMeshName)
2522         return Mesh( self.smeshpyD,self.geompyD,mesh )
2523
2524     ## Translates the elements
2525     #  @param IDsOfElements list of elements ids
2526     #  @param Vector the direction of translation (DirStruct or vector)
2527     #  @param Copy allows copying the translated elements
2528     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2529     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2530     #  @ingroup l2_modif_trsf
2531     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2532         if IDsOfElements == []:
2533             IDsOfElements = self.GetElementsId()
2534         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2535             Vector = self.smeshpyD.GetDirStruct(Vector)
2536         if Copy and MakeGroups:
2537             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2538         self.editor.Translate(IDsOfElements, Vector, Copy)
2539         return []
2540
2541     ## Creates a new mesh of translated elements
2542     #  @param IDsOfElements list of elements ids
2543     #  @param Vector the direction of translation (DirStruct or vector)
2544     #  @param MakeGroups forces the generation of new groups from existing ones
2545     #  @param NewMeshName the name of the newly created mesh
2546     #  @return instance of Mesh class
2547     #  @ingroup l2_modif_trsf
2548     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2549         if IDsOfElements == []:
2550             IDsOfElements = self.GetElementsId()
2551         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2552             Vector = self.smeshpyD.GetDirStruct(Vector)
2553         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2554         return Mesh ( self.smeshpyD, self.geompyD, mesh )
2555
2556     ## Translates the object
2557     #  @param theObject the object to translate (mesh, submesh, or group)
2558     #  @param Vector direction of translation (DirStruct or geom vector)
2559     #  @param Copy allows copying the translated elements
2560     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2561     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2562     #  @ingroup l2_modif_trsf
2563     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2564         if ( isinstance( theObject, Mesh )):
2565             theObject = theObject.GetMesh()
2566         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2567             Vector = self.smeshpyD.GetDirStruct(Vector)
2568         if Copy and MakeGroups:
2569             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2570         self.editor.TranslateObject(theObject, Vector, Copy)
2571         return []
2572
2573     ## Creates a new mesh from the translated object
2574     #  @param theObject the object to translate (mesh, submesh, or group)
2575     #  @param Vector the direction of translation (DirStruct or geom vector)
2576     #  @param MakeGroups forces the generation of new groups from existing ones
2577     #  @param NewMeshName the name of the newly created mesh
2578     #  @return instance of Mesh class
2579     #  @ingroup l2_modif_trsf
2580     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2581         if (isinstance(theObject, Mesh)):
2582             theObject = theObject.GetMesh()
2583         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2584             Vector = self.smeshpyD.GetDirStruct(Vector)
2585         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2586         return Mesh( self.smeshpyD, self.geompyD, mesh )
2587
2588     ## Rotates the elements
2589     #  @param IDsOfElements list of elements ids
2590     #  @param Axis the axis of rotation (AxisStruct or geom line)
2591     #  @param AngleInRadians the angle of rotation (in radians)
2592     #  @param Copy allows copying the rotated elements
2593     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2594     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2595     #  @ingroup l2_modif_trsf
2596     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2597         if IDsOfElements == []:
2598             IDsOfElements = self.GetElementsId()
2599         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2600             Axis = self.smeshpyD.GetAxisStruct(Axis)
2601         if Copy and MakeGroups:
2602             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2603         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2604         return []
2605
2606     ## Creates a new mesh of rotated elements
2607     #  @param IDsOfElements list of element ids
2608     #  @param Axis the axis of rotation (AxisStruct or geom line)
2609     #  @param AngleInRadians the angle of rotation (in radians)
2610     #  @param MakeGroups forces the generation of new groups from existing ones
2611     #  @param NewMeshName the name of the newly created mesh
2612     #  @return instance of Mesh class
2613     #  @ingroup l2_modif_trsf
2614     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2615         if IDsOfElements == []:
2616             IDsOfElements = self.GetElementsId()
2617         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2618             Axis = self.smeshpyD.GetAxisStruct(Axis)
2619         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2620                                           MakeGroups, NewMeshName)
2621         return Mesh( self.smeshpyD, self.geompyD, mesh )
2622
2623     ## Rotates the object
2624     #  @param theObject the object to rotate( mesh, submesh, or group)
2625     #  @param Axis the axis of rotation (AxisStruct or geom line)
2626     #  @param AngleInRadians the angle of rotation (in radians)
2627     #  @param Copy allows copying the rotated elements
2628     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2629     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2630     #  @ingroup l2_modif_trsf
2631     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2632         if (isinstance(theObject, Mesh)):
2633             theObject = theObject.GetMesh()
2634         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2635             Axis = self.smeshpyD.GetAxisStruct(Axis)
2636         if Copy and MakeGroups:
2637             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2638         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2639         return []
2640
2641     ## Creates a new mesh from the rotated object
2642     #  @param theObject the object to rotate (mesh, submesh, or group)
2643     #  @param Axis the axis of rotation (AxisStruct or geom line)
2644     #  @param AngleInRadians the angle of rotation (in radians)
2645     #  @param MakeGroups forces the generation of new groups from existing ones
2646     #  @param NewMeshName the name of the newly created mesh
2647     #  @return instance of Mesh class
2648     #  @ingroup l2_modif_trsf
2649     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2650         if (isinstance( theObject, Mesh )):
2651             theObject = theObject.GetMesh()
2652         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2653             Axis = self.smeshpyD.GetAxisStruct(Axis)
2654         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2655                                                        MakeGroups, NewMeshName)
2656         return Mesh( self.smeshpyD, self.geompyD, mesh )
2657
2658     ## Finds groups of ajacent nodes within Tolerance.
2659     #  @param Tolerance the value of tolerance
2660     #  @return the list of groups of nodes
2661     #  @ingroup l2_modif_trsf
2662     def FindCoincidentNodes (self, Tolerance):
2663         return self.editor.FindCoincidentNodes(Tolerance)
2664
2665     ## Finds groups of ajacent nodes within Tolerance.
2666     #  @param Tolerance the value of tolerance
2667     #  @param SubMeshOrGroup SubMesh or Group
2668     #  @return the list of groups of nodes
2669     #  @ingroup l2_modif_trsf
2670     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2671         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2672
2673     ## Merges nodes
2674     #  @param GroupsOfNodes the list of groups of nodes
2675     #  @ingroup l2_modif_trsf
2676     def MergeNodes (self, GroupsOfNodes):
2677         self.editor.MergeNodes(GroupsOfNodes)
2678
2679     ## Finds the elements built on the same nodes.
2680     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2681     #  @return a list of groups of equal elements
2682     #  @ingroup l2_modif_trsf
2683     def FindEqualElements (self, MeshOrSubMeshOrGroup):
2684         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2685
2686     ## Merges elements in each given group.
2687     #  @param GroupsOfElementsID groups of elements for merging
2688     #  @ingroup l2_modif_trsf
2689     def MergeElements(self, GroupsOfElementsID):
2690         self.editor.MergeElements(GroupsOfElementsID)
2691
2692     ## Leaves one element and removes all other elements built on the same nodes.
2693     #  @ingroup l2_modif_trsf
2694     def MergeEqualElements(self):
2695         self.editor.MergeEqualElements()
2696
2697     ## Sews free borders
2698     #  @return SMESH::Sew_Error
2699     #  @ingroup l2_modif_trsf
2700     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2701                         FirstNodeID2, SecondNodeID2, LastNodeID2,
2702                         CreatePolygons, CreatePolyedrs):
2703         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2704                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
2705                                           CreatePolygons, CreatePolyedrs)
2706
2707     ## Sews conform free borders
2708     #  @return SMESH::Sew_Error
2709     #  @ingroup l2_modif_trsf
2710     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2711                                FirstNodeID2, SecondNodeID2):
2712         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2713                                                  FirstNodeID2, SecondNodeID2)
2714
2715     ## Sews border to side
2716     #  @return SMESH::Sew_Error
2717     #  @ingroup l2_modif_trsf
2718     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2719                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2720         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2721                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2722
2723     ## Sews two sides of a mesh. The nodes belonging to Side1 are
2724     #  merged with the nodes of elements of Side2.
2725     #  The number of elements in theSide1 and in theSide2 must be
2726     #  equal and they should have similar nodal connectivity.
2727     #  The nodes to merge should belong to side borders and
2728     #  the first node should be linked to the second.
2729     #  @return SMESH::Sew_Error
2730     #  @ingroup l2_modif_trsf
2731     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2732                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2733                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2734         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2735                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2736                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2737
2738     ## Sets new nodes for the given element.
2739     #  @param ide the element id
2740     #  @param newIDs nodes ids
2741     #  @return If the number of nodes does not correspond to the type of element - returns false
2742     #  @ingroup l2_modif_edit
2743     def ChangeElemNodes(self, ide, newIDs):
2744         return self.editor.ChangeElemNodes(ide, newIDs)
2745
2746     ## If during the last operation of MeshEditor some nodes were
2747     #  created, this method returns the list of their IDs, \n
2748     #  if new nodes were not created - returns empty list
2749     #  @return the list of integer values (can be empty)
2750     #  @ingroup l1_auxiliary
2751     def GetLastCreatedNodes(self):
2752         return self.editor.GetLastCreatedNodes()
2753
2754     ## If during the last operation of MeshEditor some elements were
2755     #  created this method returns the list of their IDs, \n
2756     #  if new elements were not created - returns empty list
2757     #  @return the list of integer values (can be empty)
2758     #  @ingroup l1_auxiliary
2759     def GetLastCreatedElems(self):
2760         return self.editor.GetLastCreatedElems()
2761     
2762     ## Creates a hole in a mesh by doubling the nodes of some particular elements
2763     #  @param theNodes identifiers of nodes to be doubled
2764     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
2765     #         nodes. If list of element identifiers is empty then nodes are doubled but 
2766     #         they not assigned to elements
2767     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2768     #  @ingroup l2_modif_edit
2769     def DoubleNodes(self, theNodes, theModifiedElems):
2770         return self.editor.DoubleNodes(theNodes, theModifiedElems)
2771         
2772     ## Creates a hole in a mesh by doubling the nodes of some particular elements
2773     #  This method provided for convenience works as DoubleNodes() described above.
2774     #  @param theNodes identifiers of node to be doubled
2775     #  @param theModifiedElems identifiers of elements to be updated
2776     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2777     #  @ingroup l2_modif_edit
2778     def DoubleNode(self, theNodeId, theModifiedElems):
2779         return self.editor.DoubleNode(theNodeId, theModifiedElems)
2780         
2781     ## Creates a hole in a mesh by doubling the nodes of some particular elements
2782     #  This method provided for convenience works as DoubleNodes() described above.
2783     #  @param theNodes group of nodes to be doubled
2784     #  @param theModifiedElems group of elements to be updated.
2785     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2786     #  @ingroup l2_modif_edit
2787     def DoubleNodeGroup(self, theNodes, theModifiedElems):
2788         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
2789         
2790     ## Creates a hole in a mesh by doubling the nodes of some particular elements
2791     #  This method provided for convenience works as DoubleNodes() described above.
2792     #  @param theNodes list of groups of nodes to be doubled
2793     #  @param theModifiedElems list of groups of elements to be updated.
2794     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2795     #  @ingroup l2_modif_edit
2796     def DoubleNodeGroups(self, theNodes, theModifiedElems):
2797         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
2798
2799 ## The mother class to define algorithm, it is not recommended to use it directly.
2800 #
2801 #  More details.
2802 #  @ingroup l2_algorithms
2803 class Mesh_Algorithm:
2804     #  @class Mesh_Algorithm
2805     #  @brief Class Mesh_Algorithm
2806
2807     #def __init__(self,smesh):
2808     #    self.smesh=smesh
2809     def __init__(self):
2810         self.mesh = None
2811         self.geom = None
2812         self.subm = None
2813         self.algo = None
2814
2815     ## Finds a hypothesis in the study by its type name and parameters.
2816     #  Finds only the hypotheses created in smeshpyD engine.
2817     #  @return SMESH.SMESH_Hypothesis
2818     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2819         study = smeshpyD.GetCurrentStudy()
2820         #to do: find component by smeshpyD object, not by its data type
2821         scomp = study.FindComponent(smeshpyD.ComponentDataType())
2822         if scomp is not None:
2823             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2824             # Check if the root label of the hypotheses exists
2825             if res and hypRoot is not None:
2826                 iter = study.NewChildIterator(hypRoot)
2827                 # Check all published hypotheses
2828                 while iter.More():
2829                     hypo_so_i = iter.Value()
2830                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2831                     if attr is not None:
2832                         anIOR = attr.Value()
2833                         hypo_o_i = salome.orb.string_to_object(anIOR)
2834                         if hypo_o_i is not None:
2835                             # Check if this is a hypothesis
2836                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2837                             if hypo_i is not None:
2838                                 # Check if the hypothesis belongs to current engine
2839                                 if smeshpyD.GetObjectId(hypo_i) > 0:
2840                                     # Check if this is the required hypothesis
2841                                     if hypo_i.GetName() == hypname:
2842                                         # Check arguments
2843                                         if CompareMethod(hypo_i, args):
2844                                             # found!!!
2845                                             return hypo_i
2846                                         pass
2847                                     pass
2848                                 pass
2849                             pass
2850                         pass
2851                     iter.Next()
2852                     pass
2853                 pass
2854             pass
2855         return None
2856
2857     ## Finds the algorithm in the study by its type name.
2858     #  Finds only the algorithms, which have been created in smeshpyD engine.
2859     #  @return SMESH.SMESH_Algo
2860     def FindAlgorithm (self, algoname, smeshpyD):
2861         study = smeshpyD.GetCurrentStudy()
2862         #to do: find component by smeshpyD object, not by its data type
2863         scomp = study.FindComponent(smeshpyD.ComponentDataType())
2864         if scomp is not None:
2865             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2866             # Check if the root label of the algorithms exists
2867             if res and hypRoot is not None:
2868                 iter = study.NewChildIterator(hypRoot)
2869                 # Check all published algorithms
2870                 while iter.More():
2871                     algo_so_i = iter.Value()
2872                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2873                     if attr is not None:
2874                         anIOR = attr.Value()
2875                         algo_o_i = salome.orb.string_to_object(anIOR)
2876                         if algo_o_i is not None:
2877                             # Check if this is an algorithm
2878                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2879                             if algo_i is not None:
2880                                 # Checks if the algorithm belongs to the current engine
2881                                 if smeshpyD.GetObjectId(algo_i) > 0:
2882                                     # Check if this is the required algorithm
2883                                     if algo_i.GetName() == algoname:
2884                                         # found!!!
2885                                         return algo_i
2886                                     pass
2887                                 pass
2888                             pass
2889                         pass
2890                     iter.Next()
2891                     pass
2892                 pass
2893             pass
2894         return None
2895
2896     ## If the algorithm is global, returns 0; \n
2897     #  else returns the submesh associated to this algorithm.
2898     def GetSubMesh(self):
2899         return self.subm
2900
2901     ## Returns the wrapped mesher.
2902     def GetAlgorithm(self):
2903         return self.algo
2904
2905     ## Gets the list of hypothesis that can be used with this algorithm
2906     def GetCompatibleHypothesis(self):
2907         mylist = []
2908         if self.algo:
2909             mylist = self.algo.GetCompatibleHypothesis()
2910         return mylist
2911
2912     ## Gets the name of the algorithm
2913     def GetName(self):
2914         GetName(self.algo)
2915
2916     ## Sets the name to the algorithm
2917     def SetName(self, name):
2918         SetName(self.algo, name)
2919
2920     ## Gets the id of the algorithm
2921     def GetId(self):
2922         return self.algo.GetId()
2923
2924     ## Private method.
2925     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2926         if geom is None:
2927             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2928         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2929         if algo is None:
2930             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2931             pass
2932         self.Assign(algo, mesh, geom)
2933         return self.algo
2934
2935     ## Private method
2936     def Assign(self, algo, mesh, geom):
2937         if geom is None:
2938             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2939         self.mesh = mesh
2940         piece = mesh.geom
2941         if not geom:
2942             self.geom = piece
2943         else:
2944             self.geom = geom
2945             name = GetName(geom)
2946             if name==NO_NAME:
2947                 name = mesh.geompyD.SubShapeName(geom, piece)
2948                 mesh.geompyD.addToStudyInFather(piece, geom, name)
2949             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2950
2951         self.algo = algo
2952         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2953         TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2954
2955     def CompareHyp (self, hyp, args):
2956         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2957         return False
2958
2959     def CompareEqualHyp (self, hyp, args):
2960         return True
2961
2962     ## Private method
2963     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2964                     UseExisting=0, CompareMethod=""):
2965         hypo = None
2966         if UseExisting:
2967             if CompareMethod == "": CompareMethod = self.CompareHyp
2968             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2969             pass
2970         if hypo is None:
2971             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2972             a = ""
2973             s = "="
2974             i = 0
2975             n = len(args)
2976             while i<n:
2977                 a = a + s + str(args[i])
2978                 s = ","
2979                 i = i + 1
2980                 pass
2981             SetName(hypo, hyp + a)
2982             pass
2983         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2984         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2985         return hypo
2986
2987
2988 # Public class: Mesh_Segment
2989 # --------------------------
2990
2991 ## Class to define a segment 1D algorithm for discretization
2992 #
2993 #  More details.
2994 #  @ingroup l3_algos_basic
2995 class Mesh_Segment(Mesh_Algorithm):
2996
2997     ## Private constructor.
2998     def __init__(self, mesh, geom=0):
2999         Mesh_Algorithm.__init__(self)
3000         self.Create(mesh, geom, "Regular_1D")
3001
3002     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3003     #  @param l for the length of segments that cut an edge
3004     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3005     #                    the same parameters, else (default) - creates a new one
3006     #  @param p precision, used for calculation of the number of segments.
3007     #           The precision should be a positive, meaningful value within the range [0,1].
3008     #           In general, the number of segments is calculated with the formula:
3009     #           nb = ceil((edge_length / l) - p)
3010     #           Function ceil rounds its argument to the higher integer.
3011     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3012     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3013     #               p=1 means rounding of (edge_length / l) to the lower integer.
3014     #           Default value is 1e-07.
3015     #  @return an instance of StdMeshers_LocalLength hypothesis
3016     #  @ingroup l3_hypos_1dhyps
3017     def LocalLength(self, l, UseExisting=0, p=1e-07):
3018         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3019                               CompareMethod=self.CompareLocalLength)
3020         hyp.SetLength(l)
3021         hyp.SetPrecision(p)
3022         return hyp
3023
3024     ## Private method
3025     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3026     def CompareLocalLength(self, hyp, args):
3027         if IsEqual(hyp.GetLength(), args[0]):
3028             return IsEqual(hyp.GetPrecision(), args[1])
3029         return False
3030
3031     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3032     #  @param n for the number of segments that cut an edge
3033     #  @param s for the scale factor (optional)
3034     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3035     #                     the same parameters, else (default) - create a new one
3036     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
3037     #  @ingroup l3_hypos_1dhyps
3038     def NumberOfSegments(self, n, s=[], UseExisting=0):
3039         if s == []:
3040             hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3041                                   CompareMethod=self.CompareNumberOfSegments)
3042         else:
3043             hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3044                                   CompareMethod=self.CompareNumberOfSegments)
3045             hyp.SetDistrType( 1 )
3046             hyp.SetScaleFactor(s)
3047         hyp.SetNumberOfSegments(n)
3048         return hyp
3049
3050     ## Private method
3051     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3052     def CompareNumberOfSegments(self, hyp, args):
3053         if hyp.GetNumberOfSegments() == args[0]:
3054             if len(args) == 1:
3055                 return True
3056             else:
3057                 if hyp.GetDistrType() == 1:
3058                     if IsEqual(hyp.GetScaleFactor(), args[1]):
3059                         return True
3060         return False
3061
3062     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3063     #  @param start defines the length of the first segment
3064     #  @param end   defines the length of the last  segment
3065     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3066     #                     the same parameters, else (default) - creates a new one
3067     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
3068     #  @ingroup l3_hypos_1dhyps
3069     def Arithmetic1D(self, start, end, UseExisting=0):
3070         hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3071                               CompareMethod=self.CompareArithmetic1D)
3072         hyp.SetLength(start, 1)
3073         hyp.SetLength(end  , 0)
3074         return hyp
3075
3076     ## Private method
3077     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3078     def CompareArithmetic1D(self, hyp, args):
3079         if IsEqual(hyp.GetLength(1), args[0]):
3080             if IsEqual(hyp.GetLength(0), args[1]):
3081                 return True
3082         return False
3083
3084     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3085     #  @param start defines the length of the first segment
3086     #  @param end   defines the length of the last  segment
3087     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3088     #                     the same parameters, else (default) - creates a new one
3089     #  @return an instance of StdMeshers_StartEndLength hypothesis
3090     #  @ingroup l3_hypos_1dhyps
3091     def StartEndLength(self, start, end, UseExisting=0):
3092         hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3093                               CompareMethod=self.CompareStartEndLength)
3094         hyp.SetLength(start, 1)
3095         hyp.SetLength(end  , 0)
3096         return hyp
3097
3098     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3099     def CompareStartEndLength(self, hyp, args):
3100         if IsEqual(hyp.GetLength(1), args[0]):
3101             if IsEqual(hyp.GetLength(0), args[1]):
3102                 return True
3103         return False
3104
3105     ## Defines "Deflection1D" hypothesis
3106     #  @param d for the deflection
3107     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3108     #                     the same parameters, else (default) - create a new one
3109     #  @ingroup l3_hypos_1dhyps
3110     def Deflection1D(self, d, UseExisting=0):
3111         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3112                               CompareMethod=self.CompareDeflection1D)
3113         hyp.SetDeflection(d)
3114         return hyp
3115
3116     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3117     def CompareDeflection1D(self, hyp, args):
3118         return IsEqual(hyp.GetDeflection(), args[0])
3119
3120     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3121     #  the opposite side in case of quadrangular faces
3122     #  @ingroup l3_hypos_additi
3123     def Propagation(self):
3124         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3125
3126     ## Defines "AutomaticLength" hypothesis
3127     #  @param fineness for the fineness [0-1]
3128     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
3129     #                     same parameters, else (default) - create a new one
3130     #  @ingroup l3_hypos_1dhyps
3131     def AutomaticLength(self, fineness=0, UseExisting=0):
3132         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3133                               CompareMethod=self.CompareAutomaticLength)
3134         hyp.SetFineness( fineness )
3135         return hyp
3136
3137     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3138     def CompareAutomaticLength(self, hyp, args):
3139         return IsEqual(hyp.GetFineness(), args[0])
3140
3141     ## Defines "SegmentLengthAroundVertex" hypothesis
3142     #  @param length for the segment length
3143     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
3144     #         Any other integer value means that the hypothesis will be set on the
3145     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
3146     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3147     #                   the same parameters, else (default) - creates a new one
3148     #  @ingroup l3_algos_segmarv
3149     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3150         import types
3151         store_geom = self.geom
3152         if type(vertex) is types.IntType:
3153             if vertex == 0 or vertex == 1:
3154                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3155                 self.geom = vertex
3156                 pass
3157             pass
3158         else:
3159             self.geom = vertex
3160             pass
3161         ### 0D algorithm
3162         if self.geom is None:
3163             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3164         name = GetName(self.geom)
3165         if name == NO_NAME:
3166             piece = self.mesh.geom
3167             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3168             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3169         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3170         if algo is None:
3171             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3172             pass
3173         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3174         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3175         ###
3176         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3177                               CompareMethod=self.CompareLengthNearVertex)
3178         self.geom = store_geom
3179         hyp.SetLength( length )
3180         return hyp
3181
3182     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3183     #  @ingroup l3_algos_segmarv
3184     def CompareLengthNearVertex(self, hyp, args):
3185         return IsEqual(hyp.GetLength(), args[0])
3186
3187     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3188     #  If the 2D mesher sees that all boundary edges are quadratic,
3189     #  it generates quadratic faces, else it generates linear faces using
3190     #  medium nodes as if they are vertices.
3191     #  The 3D mesher generates quadratic volumes only if all boundary faces
3192     #  are quadratic, else it fails.
3193     #
3194     #  @ingroup l3_hypos_additi
3195     def QuadraticMesh(self):
3196         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3197         return hyp
3198
3199 # Public class: Mesh_CompositeSegment
3200 # --------------------------
3201
3202 ## Defines a segment 1D algorithm for discretization
3203 #  
3204 #  @ingroup l3_algos_basic
3205 class Mesh_CompositeSegment(Mesh_Segment):
3206
3207     ## Private constructor.
3208     def __init__(self, mesh, geom=0):
3209         self.Create(mesh, geom, "CompositeSegment_1D")
3210
3211
3212 # Public class: Mesh_Segment_Python
3213 # ---------------------------------
3214
3215 ## Defines a segment 1D algorithm for discretization with python function
3216 #
3217 #  @ingroup l3_algos_basic
3218 class Mesh_Segment_Python(Mesh_Segment):
3219
3220     ## Private constructor.
3221     def __init__(self, mesh, geom=0):
3222         import Python1dPlugin
3223         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3224
3225     ## Defines "PythonSplit1D" hypothesis
3226     #  @param n for the number of segments that cut an edge
3227     #  @param func for the python function that calculates the length of all segments
3228     #  @param UseExisting if ==true - searches for the existing hypothesis created with
3229     #                     the same parameters, else (default) - creates a new one
3230     #  @ingroup l3_hypos_1dhyps
3231     def PythonSplit1D(self, n, func, UseExisting=0):
3232         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3233                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3234         hyp.SetNumberOfSegments(n)
3235         hyp.SetPythonLog10RatioFunction(func)
3236         return hyp
3237
3238     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3239     def ComparePythonSplit1D(self, hyp, args):
3240         #if hyp.GetNumberOfSegments() == args[0]:
3241         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
3242         #        return True
3243         return False
3244
3245 # Public class: Mesh_Triangle
3246 # ---------------------------
3247
3248 ## Defines a triangle 2D algorithm
3249 #
3250 #  @ingroup l3_algos_basic
3251 class Mesh_Triangle(Mesh_Algorithm):
3252
3253     # default values
3254     algoType = 0
3255     params = 0
3256
3257     _angleMeshS = 8
3258     _gradation  = 1.1
3259
3260     ## Private constructor.
3261     def __init__(self, mesh, algoType, geom=0):
3262         Mesh_Algorithm.__init__(self)
3263
3264         self.algoType = algoType
3265         if algoType == MEFISTO:
3266             self.Create(mesh, geom, "MEFISTO_2D")
3267             pass
3268         elif algoType == BLSURF:
3269             import BLSURFPlugin
3270             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3271             #self.SetPhysicalMesh() - PAL19680
3272         elif algoType == NETGEN:
3273             if noNETGENPlugin:
3274                 print "Warning: NETGENPlugin module unavailable"
3275                 pass
3276             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3277             pass
3278         elif algoType == NETGEN_2D:
3279             if noNETGENPlugin:
3280                 print "Warning: NETGENPlugin module unavailable"
3281                 pass
3282             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3283             pass
3284
3285     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3286     #  @param area for the maximum area of each triangle
3287     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
3288     #                     same parameters, else (default) - creates a new one
3289     #
3290     #  Only for algoType == MEFISTO || NETGEN_2D
3291     #  @ingroup l3_hypos_2dhyps
3292     def MaxElementArea(self, area, UseExisting=0):
3293         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3294             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3295                                   CompareMethod=self.CompareMaxElementArea)
3296         elif self.algoType == NETGEN:
3297             hyp = self.Parameters(SIMPLE)
3298         hyp.SetMaxElementArea(area)
3299         return hyp
3300
3301     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3302     def CompareMaxElementArea(self, hyp, args):
3303         return IsEqual(hyp.GetMaxElementArea(), args[0])
3304
3305     ## Defines "LengthFromEdges" hypothesis to build triangles
3306     #  based on the length of the edges taken from the wire
3307     #
3308     #  Only for algoType == MEFISTO || NETGEN_2D
3309     #  @ingroup l3_hypos_2dhyps
3310     def LengthFromEdges(self):
3311         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3312             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3313             return hyp
3314         elif self.algoType == NETGEN:
3315             hyp = self.Parameters(SIMPLE)
3316             hyp.LengthFromEdges()
3317             return hyp
3318
3319     ## Sets a way to define size of mesh elements to generate.
3320     #  @param thePhysicalMesh is: DefaultSize or Custom.
3321     #  @ingroup l3_hypos_blsurf
3322     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3323         # Parameter of BLSURF algo
3324         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3325
3326     ## Sets size of mesh elements to generate.
3327     #  @ingroup l3_hypos_blsurf
3328     def SetPhySize(self, theVal):
3329         # Parameter of BLSURF algo
3330         self.Parameters().SetPhySize(theVal)
3331
3332     ## Sets lower boundary of mesh element size (PhySize).
3333     #  @ingroup l3_hypos_blsurf
3334     def SetPhyMin(self, theVal=-1):
3335         #  Parameter of BLSURF algo
3336         self.Parameters().SetPhyMin(theVal)
3337
3338     ## Sets upper boundary of mesh element size (PhySize).
3339     #  @ingroup l3_hypos_blsurf
3340     def SetPhyMax(self, theVal=-1):
3341         #  Parameter of BLSURF algo
3342         self.Parameters().SetPhyMax(theVal)
3343
3344     ## Sets a way to define maximum angular deflection of mesh from CAD model.
3345     #  @param theGeometricMesh is: DefaultGeom or Custom
3346     #  @ingroup l3_hypos_blsurf
3347     def SetGeometricMesh(self, theGeometricMesh=0):
3348         #  Parameter of BLSURF algo
3349         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3350         self.params.SetGeometricMesh(theGeometricMesh)
3351
3352     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3353     #  @ingroup l3_hypos_blsurf
3354     def SetAngleMeshS(self, theVal=_angleMeshS):
3355         #  Parameter of BLSURF algo
3356         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3357         self.params.SetAngleMeshS(theVal)
3358
3359     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3360     #  @ingroup l3_hypos_blsurf
3361     def SetAngleMeshC(self, theVal=_angleMeshS):
3362         #  Parameter of BLSURF algo
3363         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3364         self.params.SetAngleMeshC(theVal)
3365
3366     ## Sets lower boundary of mesh element size computed to respect angular deflection.
3367     #  @ingroup l3_hypos_blsurf
3368     def SetGeoMin(self, theVal=-1):
3369         #  Parameter of BLSURF algo
3370         self.Parameters().SetGeoMin(theVal)
3371
3372     ## Sets upper boundary of mesh element size computed to respect angular deflection.
3373     #  @ingroup l3_hypos_blsurf
3374     def SetGeoMax(self, theVal=-1):
3375         #  Parameter of BLSURF algo
3376         self.Parameters().SetGeoMax(theVal)
3377
3378     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3379     #  @ingroup l3_hypos_blsurf
3380     def SetGradation(self, theVal=_gradation):
3381         #  Parameter of BLSURF algo
3382         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3383         self.params.SetGradation(theVal)
3384
3385     ## Sets topology usage way.
3386     # @param way defines how mesh conformity is assured <ul>
3387     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3388     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3389     #  @ingroup l3_hypos_blsurf
3390     def SetTopology(self, way):
3391         #  Parameter of BLSURF algo
3392         self.Parameters().SetTopology(way)
3393
3394     ## To respect geometrical edges or not.
3395     #  @ingroup l3_hypos_blsurf
3396     def SetDecimesh(self, toIgnoreEdges=False):
3397         #  Parameter of BLSURF algo
3398         self.Parameters().SetDecimesh(toIgnoreEdges)
3399
3400     ## Sets verbosity level in the range 0 to 100.
3401     #  @ingroup l3_hypos_blsurf
3402     def SetVerbosity(self, level):
3403         #  Parameter of BLSURF algo
3404         self.Parameters().SetVerbosity(level)
3405
3406     ## Sets advanced option value.
3407     #  @ingroup l3_hypos_blsurf
3408     def SetOptionValue(self, optionName, level):
3409         #  Parameter of BLSURF algo
3410         self.Parameters().SetOptionValue(optionName,level)
3411
3412     ## Sets QuadAllowed flag.
3413     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
3414     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
3415     def SetQuadAllowed(self, toAllow=True):
3416         if self.algoType == NETGEN_2D:
3417             if toAllow: # add QuadranglePreference
3418                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3419             else:       # remove QuadranglePreference
3420                 for hyp in self.mesh.GetHypothesisList( self.geom ):
3421                     if hyp.GetName() == "QuadranglePreference":
3422                         self.mesh.RemoveHypothesis( self.geom, hyp )
3423                         pass
3424                     pass
3425                 pass
3426             return
3427         if self.Parameters():
3428             self.params.SetQuadAllowed(toAllow)
3429             return
3430
3431     ## Defines hypothesis having several parameters
3432     #
3433     #  @ingroup l3_hypos_netgen
3434     def Parameters(self, which=SOLE):
3435         if self.params:
3436             return self.params
3437         if self.algoType == NETGEN:
3438             if which == SIMPLE:
3439                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3440                                               "libNETGENEngine.so", UseExisting=0)
3441             else:
3442                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3443                                               "libNETGENEngine.so", UseExisting=0)
3444             return self.params
3445         elif self.algoType == MEFISTO:
3446             print "Mefisto algo support no multi-parameter hypothesis"
3447             return None
3448         elif self.algoType == NETGEN_2D:
3449             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3450             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3451             return None
3452         elif self.algoType == BLSURF:
3453             self.params = self.Hypothesis("BLSURF_Parameters", [],
3454                                           "libBLSURFEngine.so", UseExisting=0)
3455             return self.params
3456         else:
3457             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3458         return None
3459
3460     ## Sets MaxSize
3461     #
3462     #  Only for algoType == NETGEN
3463     #  @ingroup l3_hypos_netgen
3464     def SetMaxSize(self, theSize):
3465         if self.Parameters():
3466             self.params.SetMaxSize(theSize)
3467
3468     ## Sets SecondOrder flag
3469     #
3470     #  Only for algoType == NETGEN
3471     #  @ingroup l3_hypos_netgen
3472     def SetSecondOrder(self, theVal):
3473         if self.Parameters():
3474             self.params.SetSecondOrder(theVal)
3475
3476     ## Sets Optimize flag
3477     #
3478     #  Only for algoType == NETGEN
3479     #  @ingroup l3_hypos_netgen
3480     def SetOptimize(self, theVal):
3481         if self.Parameters():
3482             self.params.SetOptimize(theVal)
3483
3484     ## Sets Fineness
3485     #  @param theFineness is:
3486     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3487     #
3488     #  Only for algoType == NETGEN
3489     #  @ingroup l3_hypos_netgen
3490     def SetFineness(self, theFineness):
3491         if self.Parameters():
3492             self.params.SetFineness(theFineness)
3493
3494     ## Sets GrowthRate
3495     #
3496     #  Only for algoType == NETGEN
3497     #  @ingroup l3_hypos_netgen
3498     def SetGrowthRate(self, theRate):
3499         if self.Parameters():
3500             self.params.SetGrowthRate(theRate)
3501
3502     ## Sets NbSegPerEdge
3503     #
3504     #  Only for algoType == NETGEN
3505     #  @ingroup l3_hypos_netgen
3506     def SetNbSegPerEdge(self, theVal):
3507         if self.Parameters():
3508             self.params.SetNbSegPerEdge(theVal)
3509
3510     ## Sets NbSegPerRadius
3511     #
3512     #  Only for algoType == NETGEN
3513     #  @ingroup l3_hypos_netgen
3514     def SetNbSegPerRadius(self, theVal):
3515         if self.Parameters():
3516             self.params.SetNbSegPerRadius(theVal)
3517
3518     ## Sets number of segments overriding value set by SetLocalLength()
3519     #
3520     #  Only for algoType == NETGEN
3521     #  @ingroup l3_hypos_netgen
3522     def SetNumberOfSegments(self, theVal):
3523         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3524
3525     ## Sets number of segments overriding value set by SetNumberOfSegments()
3526     #
3527     #  Only for algoType == NETGEN
3528     #  @ingroup l3_hypos_netgen
3529     def SetLocalLength(self, theVal):
3530         self.Parameters(SIMPLE).SetLocalLength(theVal)
3531
3532     pass
3533
3534
3535 # Public class: Mesh_Quadrangle
3536 # -----------------------------
3537
3538 ## Defines a quadrangle 2D algorithm
3539 #
3540 #  @ingroup l3_algos_basic
3541 class Mesh_Quadrangle(Mesh_Algorithm):
3542
3543     ## Private constructor.
3544     def __init__(self, mesh, geom=0):
3545         Mesh_Algorithm.__init__(self)
3546         self.Create(mesh, geom, "Quadrangle_2D")
3547
3548     ## Defines "QuadranglePreference" hypothesis, forcing construction
3549     #  of quadrangles if the number of nodes on the opposite edges is not the same
3550     #  while the total number of nodes on edges is even
3551     #
3552     #  @ingroup l3_hypos_additi
3553     def QuadranglePreference(self):
3554         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3555                               CompareMethod=self.CompareEqualHyp)
3556         return hyp
3557
3558     ## Defines "TrianglePreference" hypothesis, forcing construction
3559     #  of triangles in the refinement area if the number of nodes
3560     #  on the opposite edges is not the same
3561     #
3562     #  @ingroup l3_hypos_additi
3563     def TrianglePreference(self):
3564         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3565                               CompareMethod=self.CompareEqualHyp)
3566         return hyp
3567
3568 # Public class: Mesh_Tetrahedron
3569 # ------------------------------
3570
3571 ## Defines a tetrahedron 3D algorithm
3572 #
3573 #  @ingroup l3_algos_basic
3574 class Mesh_Tetrahedron(Mesh_Algorithm):
3575
3576     params = 0
3577     algoType = 0
3578
3579     ## Private constructor.
3580     def __init__(self, mesh, algoType, geom=0):
3581         Mesh_Algorithm.__init__(self)
3582
3583         if algoType == NETGEN:
3584             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3585             pass
3586
3587         elif algoType == FULL_NETGEN:
3588             if noNETGENPlugin:
3589                 print "Warning: NETGENPlugin module has not been imported."
3590             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3591             pass
3592
3593         elif algoType == GHS3D:
3594             import GHS3DPlugin
3595             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3596             pass
3597
3598         self.algoType = algoType
3599
3600     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3601     #  @param vol for the maximum volume of each tetrahedron
3602     #  @param UseExisting if ==true - searches for the existing hypothesis created with
3603     #                   the same parameters, else (default) - creates a new one
3604     #  @ingroup l3_hypos_maxvol
3605     def MaxElementVolume(self, vol, UseExisting=0):
3606         if self.algoType == NETGEN:
3607             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3608                                   CompareMethod=self.CompareMaxElementVolume)
3609             hyp.SetMaxElementVolume(vol)
3610             return hyp
3611         elif self.algoType == FULL_NETGEN:
3612             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3613         return None
3614
3615     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3616     def CompareMaxElementVolume(self, hyp, args):
3617         return IsEqual(hyp.GetMaxElementVolume(), args[0])
3618
3619     ## Defines hypothesis having several parameters
3620     #
3621     #  @ingroup l3_hypos_netgen
3622     def Parameters(self, which=SOLE):
3623         if self.params:
3624             return self.params
3625         if self.algoType == FULL_NETGEN:
3626             if which == SIMPLE:
3627                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3628                                               "libNETGENEngine.so", UseExisting=0)
3629             else:
3630                 self.params = self.Hypothesis("NETGEN_Parameters", [],
3631                                               "libNETGENEngine.so", UseExisting=0)
3632             return self.params
3633         if self.algoType == GHS3D:
3634             self.params = self.Hypothesis("GHS3D_Parameters", [],
3635                                           "libGHS3DEngine.so", UseExisting=0)
3636             return self.params
3637         
3638         print "Algo supports no multi-parameter hypothesis"
3639         return None
3640
3641     ## Sets MaxSize
3642     #  Parameter of FULL_NETGEN
3643     #  @ingroup l3_hypos_netgen
3644     def SetMaxSize(self, theSize):
3645         self.Parameters().SetMaxSize(theSize)
3646
3647     ## Sets SecondOrder flag
3648     #  Parameter of FULL_NETGEN
3649     #  @ingroup l3_hypos_netgen
3650     def SetSecondOrder(self, theVal):
3651         self.Parameters().SetSecondOrder(theVal)
3652
3653     ## Sets Optimize flag
3654     #  Parameter of FULL_NETGEN
3655     #  @ingroup l3_hypos_netgen
3656     def SetOptimize(self, theVal):
3657         self.Parameters().SetOptimize(theVal)
3658
3659     ## Sets Fineness
3660     #  @param theFineness is:
3661     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3662     #  Parameter of FULL_NETGEN
3663     #  @ingroup l3_hypos_netgen
3664     def SetFineness(self, theFineness):
3665         self.Parameters().SetFineness(theFineness)
3666
3667     ## Sets GrowthRate
3668     #  Parameter of FULL_NETGEN
3669     #  @ingroup l3_hypos_netgen
3670     def SetGrowthRate(self, theRate):
3671         self.Parameters().SetGrowthRate(theRate)
3672
3673     ## Sets NbSegPerEdge
3674     #  Parameter of FULL_NETGEN
3675     #  @ingroup l3_hypos_netgen
3676     def SetNbSegPerEdge(self, theVal):
3677         self.Parameters().SetNbSegPerEdge(theVal)
3678
3679     ## Sets NbSegPerRadius
3680     #  Parameter of FULL_NETGEN
3681     #  @ingroup l3_hypos_netgen
3682     def SetNbSegPerRadius(self, theVal):
3683         self.Parameters().SetNbSegPerRadius(theVal)
3684
3685     ## Sets number of segments overriding value set by SetLocalLength()
3686     #  Only for algoType == NETGEN_FULL
3687     #  @ingroup l3_hypos_netgen
3688     def SetNumberOfSegments(self, theVal):
3689         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3690
3691     ## Sets number of segments overriding value set by SetNumberOfSegments()
3692     #  Only for algoType == NETGEN_FULL
3693     #  @ingroup l3_hypos_netgen
3694     def SetLocalLength(self, theVal):
3695         self.Parameters(SIMPLE).SetLocalLength(theVal)
3696
3697     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3698     #  Overrides value set by LengthFromEdges()
3699     #  Only for algoType == NETGEN_FULL
3700     #  @ingroup l3_hypos_netgen
3701     def MaxElementArea(self, area):
3702         self.Parameters(SIMPLE).SetMaxElementArea(area)
3703
3704     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3705     #  Overrides value set by MaxElementArea()
3706     #  Only for algoType == NETGEN_FULL
3707     #  @ingroup l3_hypos_netgen
3708     def LengthFromEdges(self):
3709         self.Parameters(SIMPLE).LengthFromEdges()
3710
3711     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3712     #  Overrides value set by MaxElementVolume()
3713     #  Only for algoType == NETGEN_FULL
3714     #  @ingroup l3_hypos_netgen
3715     def LengthFromFaces(self):
3716         self.Parameters(SIMPLE).LengthFromFaces()
3717
3718     ## To mesh "holes" in a solid or not. Default is to mesh.
3719     #  @ingroup l3_hypos_ghs3dh
3720     def SetToMeshHoles(self, toMesh):
3721         #  Parameter of GHS3D
3722         self.Parameters().SetToMeshHoles(toMesh)
3723
3724     ## Set Optimization level:
3725     #   None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3726     #  Default is Medium_Optimization
3727     #  @ingroup l3_hypos_ghs3dh
3728     def SetOptimizationLevel(self, level):
3729         #  Parameter of GHS3D
3730         self.Parameters().SetOptimizationLevel(level)
3731
3732     ## Maximal size of memory to be used by the algorithm (in Megabytes).
3733     #  @ingroup l3_hypos_ghs3dh
3734     def SetMaximumMemory(self, MB):
3735         #  Advanced parameter of GHS3D
3736         self.Parameters().SetMaximumMemory(MB)
3737
3738     ## Initial size of memory to be used by the algorithm (in Megabytes) in
3739     #  automatic memory adjustment mode.
3740     #  @ingroup l3_hypos_ghs3dh
3741     def SetInitialMemory(self, MB):
3742         #  Advanced parameter of GHS3D
3743         self.Parameters().SetInitialMemory(MB)
3744
3745     ## Path to working directory.
3746     #  @ingroup l3_hypos_ghs3dh
3747     def SetWorkingDirectory(self, path):
3748         #  Advanced parameter of GHS3D
3749         self.Parameters().SetWorkingDirectory(path)
3750
3751     ## To keep working files or remove them. Log file remains in case of errors anyway.
3752     #  @ingroup l3_hypos_ghs3dh
3753     def SetKeepFiles(self, toKeep):
3754         #  Advanced parameter of GHS3D
3755         self.Parameters().SetKeepFiles(toKeep)
3756
3757     ## To set verbose level [0-10]. <ul>
3758     #<li> 0 - no standard output,
3759     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3760     #     indicates when the final mesh is being saved. In addition the software
3761     #     gives indication regarding the CPU time.
3762     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3763     #     histogram of the skin mesh, quality statistics histogram together with
3764     #     the characteristics of the final mesh.</ul>
3765     #  @ingroup l3_hypos_ghs3dh
3766     def SetVerboseLevel(self, level):
3767         #  Advanced parameter of GHS3D
3768         self.Parameters().SetVerboseLevel(level)
3769
3770     ## To create new nodes.
3771     #  @ingroup l3_hypos_ghs3dh
3772     def SetToCreateNewNodes(self, toCreate):
3773         #  Advanced parameter of GHS3D
3774         self.Parameters().SetToCreateNewNodes(toCreate)
3775
3776     ## To use boundary recovery version which tries to create mesh on a very poor
3777     #  quality surface mesh.
3778     #  @ingroup l3_hypos_ghs3dh
3779     def SetToUseBoundaryRecoveryVersion(self, toUse):
3780         #  Advanced parameter of GHS3D
3781         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3782
3783     ## Sets command line option as text. 
3784     #  @ingroup l3_hypos_ghs3dh
3785     def SetTextOption(self, option):
3786         #  Advanced parameter of GHS3D
3787         self.Parameters().SetTextOption(option)
3788
3789 # Public class: Mesh_Hexahedron
3790 # ------------------------------
3791
3792 ## Defines a hexahedron 3D algorithm
3793 #
3794 #  @ingroup l3_algos_basic
3795 class Mesh_Hexahedron(Mesh_Algorithm):
3796
3797     params = 0
3798     algoType = 0
3799
3800     ## Private constructor.
3801     def __init__(self, mesh, algoType=Hexa, geom=0):
3802         Mesh_Algorithm.__init__(self)
3803
3804         self.algoType = algoType
3805
3806         if algoType == Hexa:
3807             self.Create(mesh, geom, "Hexa_3D")
3808             pass
3809
3810         elif algoType == Hexotic:
3811             import HexoticPlugin
3812             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3813             pass
3814
3815     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3816     #  @ingroup l3_hypos_hexotic
3817     def MinMaxQuad(self, min=3, max=8, quad=True):
3818         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3819                                       UseExisting=0)
3820         self.params.SetHexesMinLevel(min)
3821         self.params.SetHexesMaxLevel(max)
3822         self.params.SetHexoticQuadrangles(quad)
3823         return self.params
3824
3825 # Deprecated, only for compatibility!
3826 # Public class: Mesh_Netgen
3827 # ------------------------------
3828
3829 ## Defines a NETGEN-based 2D or 3D algorithm
3830 #  that needs no discrete boundary (i.e. independent)
3831 #
3832 #  This class is deprecated, only for compatibility!
3833 #
3834 #  More details.
3835 #  @ingroup l3_algos_basic
3836 class Mesh_Netgen(Mesh_Algorithm):
3837
3838     is3D = 0
3839
3840     ## Private constructor.
3841     def __init__(self, mesh, is3D, geom=0):
3842         Mesh_Algorithm.__init__(self)
3843
3844         if noNETGENPlugin:
3845             print "Warning: NETGENPlugin module has not been imported."
3846
3847         self.is3D = is3D
3848         if is3D:
3849             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3850             pass
3851
3852         else:
3853             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3854             pass
3855
3856     ## Defines the hypothesis containing parameters of the algorithm
3857     def Parameters(self):
3858         if self.is3D:
3859             hyp = self.Hypothesis("NETGEN_Parameters", [],
3860                                   "libNETGENEngine.so", UseExisting=0)
3861         else:
3862             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3863                                   "libNETGENEngine.so", UseExisting=0)
3864         return hyp
3865
3866 # Public class: Mesh_Projection1D
3867 # ------------------------------
3868
3869 ## Defines a projection 1D algorithm
3870 #  @ingroup l3_algos_proj
3871 #
3872 class Mesh_Projection1D(Mesh_Algorithm):
3873
3874     ## Private constructor.
3875     def __init__(self, mesh, geom=0):
3876         Mesh_Algorithm.__init__(self)
3877         self.Create(mesh, geom, "Projection_1D")
3878
3879     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3880     #  a mesh pattern is taken, and, optionally, the association of vertices
3881     #  between the source edge and a target edge (to which a hypothesis is assigned)
3882     #  @param edge from which nodes distribution is taken
3883     #  @param mesh from which nodes distribution is taken (optional)
3884     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3885     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3886     #  to associate with \a srcV (optional)
3887     #  @param UseExisting if ==true - searches for the existing hypothesis created with
3888     #                     the same parameters, else (default) - creates a new one
3889     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3890         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3891                               UseExisting=0)
3892                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3893         hyp.SetSourceEdge( edge )
3894         if not mesh is None and isinstance(mesh, Mesh):
3895             mesh = mesh.GetMesh()
3896         hyp.SetSourceMesh( mesh )
3897         hyp.SetVertexAssociation( srcV, tgtV )
3898         return hyp
3899
3900     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3901     #def CompareSourceEdge(self, hyp, args):
3902     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3903     #    return False
3904
3905
3906 # Public class: Mesh_Projection2D
3907 # ------------------------------
3908
3909 ## Defines a projection 2D algorithm
3910 #  @ingroup l3_algos_proj
3911 #
3912 class Mesh_Projection2D(Mesh_Algorithm):
3913
3914     ## Private constructor.
3915     def __init__(self, mesh, geom=0):
3916         Mesh_Algorithm.__init__(self)
3917         self.Create(mesh, geom, "Projection_2D")
3918
3919     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3920     #  a mesh pattern is taken, and, optionally, the association of vertices
3921     #  between the source face and the target face (to which a hypothesis is assigned)
3922     #  @param face from which the mesh pattern is taken
3923     #  @param mesh from which the mesh pattern is taken (optional)
3924     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3925     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3926     #               to associate with \a srcV1 (optional)
3927     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3928     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3929     #               to associate with \a srcV2 (optional)
3930     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
3931     #                     the same parameters, else (default) - forces the creation a new one
3932     #
3933     #  Note: all association vertices must belong to one edge of a face
3934     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3935                    srcV2=None, tgtV2=None, UseExisting=0):
3936         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3937                               UseExisting=0)
3938                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3939         hyp.SetSourceFace( face )
3940         if not mesh is None and isinstance(mesh, Mesh):
3941             mesh = mesh.GetMesh()
3942         hyp.SetSourceMesh( mesh )
3943         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3944         return hyp
3945
3946     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3947     #def CompareSourceFace(self, hyp, args):
3948     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3949     #    return False
3950
3951 # Public class: Mesh_Projection3D
3952 # ------------------------------
3953
3954 ## Defines a projection 3D algorithm
3955 #  @ingroup l3_algos_proj
3956 #
3957 class Mesh_Projection3D(Mesh_Algorithm):
3958
3959     ## Private constructor.
3960     def __init__(self, mesh, geom=0):
3961         Mesh_Algorithm.__init__(self)
3962         self.Create(mesh, geom, "Projection_3D")
3963
3964     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where 
3965     #  the mesh pattern is taken, and, optionally, the  association of vertices
3966     #  between the source and the target solid  (to which a hipothesis is assigned)
3967     #  @param solid from where the mesh pattern is taken
3968     #  @param mesh from where the mesh pattern is taken (optional)
3969     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3970     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3971     #  to associate with \a srcV1 (optional)
3972     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3973     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3974     #  to associate with \a srcV2 (optional)
3975     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
3976     #                     the same parameters, else (default) - creates a new one
3977     #
3978     #  Note: association vertices must belong to one edge of a solid
3979     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3980                       srcV2=0, tgtV2=0, UseExisting=0):
3981         hyp = self.Hypothesis("ProjectionSource3D",
3982                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3983                               UseExisting=0)
3984                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3985         hyp.SetSource3DShape( solid )
3986         if not mesh is None and isinstance(mesh, Mesh):
3987             mesh = mesh.GetMesh()
3988         hyp.SetSourceMesh( mesh )
3989         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3990         return hyp
3991
3992     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3993     #def CompareSourceShape3D(self, hyp, args):
3994     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3995     #    return False
3996
3997
3998 # Public class: Mesh_Prism
3999 # ------------------------
4000
4001 ## Defines a 3D extrusion algorithm
4002 #  @ingroup l3_algos_3dextr
4003 #
4004 class Mesh_Prism3D(Mesh_Algorithm):
4005
4006     ## Private constructor.
4007     def __init__(self, mesh, geom=0):
4008         Mesh_Algorithm.__init__(self)
4009         self.Create(mesh, geom, "Prism_3D")
4010
4011 # Public class: Mesh_RadialPrism
4012 # -------------------------------
4013
4014 ## Defines a Radial Prism 3D algorithm
4015 #  @ingroup l3_algos_radialp
4016 #
4017 class Mesh_RadialPrism3D(Mesh_Algorithm):
4018
4019     ## Private constructor.
4020     def __init__(self, mesh, geom=0):
4021         Mesh_Algorithm.__init__(self)
4022         self.Create(mesh, geom, "RadialPrism_3D")
4023
4024         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4025         self.nbLayers = None
4026
4027     ## Return 3D hypothesis holding the 1D one
4028     def Get3DHypothesis(self):
4029         return self.distribHyp
4030
4031     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4032     #  hypothesis. Returns the created hypothesis
4033     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4034         #print "OwnHypothesis",hypType
4035         if not self.nbLayers is None:
4036             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4037             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4038         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4039         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4040         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4041         self.distribHyp.SetLayerDistribution( hyp )
4042         return hyp
4043
4044     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4045     #  prisms to build between the inner and outer shells
4046     #  @param n number of layers
4047     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4048     #                     the same parameters, else (default) - creates a new one
4049     def NumberOfLayers(self, n, UseExisting=0):
4050         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4051         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4052                                         CompareMethod=self.CompareNumberOfLayers)
4053         self.nbLayers.SetNumberOfLayers( n )
4054         return self.nbLayers
4055
4056     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4057     def CompareNumberOfLayers(self, hyp, args):
4058         return IsEqual(hyp.GetNumberOfLayers(), args[0])
4059
4060     ## Defines "LocalLength" hypothesis, specifying the segment length
4061     #  to build between the inner and the outer shells
4062     #  @param l the length of segments
4063     #  @param p the precision of rounding
4064     def LocalLength(self, l, p=1e-07):
4065         hyp = self.OwnHypothesis("LocalLength", [l,p])
4066         hyp.SetLength(l)
4067         hyp.SetPrecision(p)
4068         return hyp
4069
4070     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4071     #  prisms to build between the inner and the outer shells.
4072     #  @param n the number of layers
4073     #  @param s the scale factor (optional)
4074     def NumberOfSegments(self, n, s=[]):
4075         if s == []:
4076             hyp = self.OwnHypothesis("NumberOfSegments", [n])
4077         else:
4078             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4079             hyp.SetDistrType( 1 )
4080             hyp.SetScaleFactor(s)
4081         hyp.SetNumberOfSegments(n)
4082         return hyp
4083
4084     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4085     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
4086     #  @param start  the length of the first segment
4087     #  @param end    the length of the last  segment
4088     def Arithmetic1D(self, start, end ):
4089         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4090         hyp.SetLength(start, 1)
4091         hyp.SetLength(end  , 0)
4092         return hyp
4093
4094     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4095     #  to build between the inner and the outer shells as geometric length increasing
4096     #  @param start for the length of the first segment
4097     #  @param end   for the length of the last  segment
4098     def StartEndLength(self, start, end):
4099         hyp = self.OwnHypothesis("StartEndLength", [start, end])
4100         hyp.SetLength(start, 1)
4101         hyp.SetLength(end  , 0)
4102         return hyp
4103
4104     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4105     #  to build between the inner and outer shells
4106     #  @param fineness defines the quality of the mesh within the range [0-1]
4107     def AutomaticLength(self, fineness=0):
4108         hyp = self.OwnHypothesis("AutomaticLength")
4109         hyp.SetFineness( fineness )
4110         return hyp
4111
4112 # Private class: Mesh_UseExisting
4113 # -------------------------------
4114 class Mesh_UseExisting(Mesh_Algorithm):
4115
4116     def __init__(self, dim, mesh, geom=0):
4117         if dim == 1:
4118             self.Create(mesh, geom, "UseExisting_1D")
4119         else:
4120             self.Create(mesh, geom, "UseExisting_2D")