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