Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
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
21 #  File   : smesh.py
22 #  Author : Francis KLOSS, OCC
23 #  Module : SMESH
24 #
25 """
26  \namespace smesh
27  \brief Module smesh
28 """
29
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating  Creating meshes
32 ## @{
33 ##   @defgroup l2_impexp     Importing and exporting meshes
34 ##   @defgroup l2_construct  Constructing meshes
35 ##   @defgroup l2_algorithms Defining Algorithms
36 ##   @{
37 ##     @defgroup l3_algos_basic   Basic meshing algorithms
38 ##     @defgroup l3_algos_proj    Projection Algorithms
39 ##     @defgroup l3_algos_radialp Radial Prism
40 ##     @defgroup l3_algos_segmarv Segments around Vertex
41 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
42
43 ##   @}
44 ##   @defgroup l2_hypotheses Defining hypotheses
45 ##   @{
46 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ##     @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ##     @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ##     @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ##     @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ##     @defgroup l3_hypos_additi Additional Hypotheses
54
55 ##   @}
56 ##   @defgroup l2_submeshes Constructing submeshes
57 ##   @defgroup l2_compounds Building Compounds
58 ##   @defgroup l2_editing   Editing Meshes
59
60 ## @}
61 ## @defgroup l1_meshinfo  Mesh Information
62 ## @defgroup l1_controls  Quality controls and Filtering
63 ## @defgroup l1_grouping  Grouping elements
64 ## @{
65 ##   @defgroup l2_grps_create Creating groups
66 ##   @defgroup l2_grps_edit   Editing groups
67 ##   @defgroup l2_grps_operon Using operations on groups
68 ##   @defgroup l2_grps_delete Deleting Groups
69
70 ## @}
71 ## @defgroup l1_modifying Modifying meshes
72 ## @{
73 ##   @defgroup l2_modif_add      Adding nodes and elements
74 ##   @defgroup l2_modif_del      Removing nodes and elements
75 ##   @defgroup l2_modif_edit     Modifying nodes and elements
76 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
77 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ##   @defgroup l2_modif_movenode Moving nodes
79 ##   @defgroup l2_modif_throughp Mesh through point
80 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
81 ##   @defgroup l2_modif_unitetri Uniting triangles
82 ##   @defgroup l2_modif_changori Changing orientation of elements
83 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
84 ##   @defgroup l2_modif_smooth   Smoothing
85 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
86 ##   @defgroup l2_modif_patterns Pattern mapping
87 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
88
89 ## @}
90
91 import salome
92 import geompyDC
93
94 import SMESH # This is necessary for back compatibility
95 from   SMESH import *
96
97 import StdMeshers
98
99 import SALOME
100 import SALOMEDS
101
102 # import NETGENPlugin module if possible
103 noNETGENPlugin = 0
104 try:
105     import NETGENPlugin
106 except ImportError:
107     noNETGENPlugin = 1
108     pass
109
110 # import GHS3DPlugin module if possible
111 noGHS3DPlugin = 0
112 try:
113     import GHS3DPlugin
114 except ImportError:
115     noGHS3DPlugin = 1
116     pass
117
118 # import GHS3DPRLPlugin module if possible
119 noGHS3DPRLPlugin = 0
120 try:
121     import GHS3DPRLPlugin
122 except ImportError:
123     noGHS3DPRLPlugin = 1
124     pass
125
126 # import HexoticPlugin module if possible
127 noHexoticPlugin = 0
128 try:
129     import HexoticPlugin
130 except ImportError:
131     noHexoticPlugin = 1
132     pass
133
134 # import BLSURFPlugin module if possible
135 noBLSURFPlugin = 0
136 try:
137     import BLSURFPlugin
138 except ImportError:
139     noBLSURFPlugin = 1
140     pass
141
142 ## @addtogroup l1_auxiliary
143 ## @{
144
145 # Types of algorithms
146 REGULAR    = 1
147 PYTHON     = 2
148 COMPOSITE  = 3
149 SOLE       = 0
150 SIMPLE     = 1
151
152 MEFISTO       = 3
153 NETGEN        = 4
154 GHS3D         = 5
155 FULL_NETGEN   = 6
156 NETGEN_2D     = 7
157 NETGEN_1D2D   = NETGEN
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL   = FULL_NETGEN
160 Hexa    = 8
161 Hexotic = 9
162 BLSURF  = 10
163 GHS3DPRL = 11
164 QUADRANGLE = 0
165 RADIAL_QUAD = 1
166
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS =  SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
171
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
175
176 # Fineness enumeration (for NETGEN)
177 VeryCoarse = 0
178 Coarse     = 1
179 Moderate   = 2
180 Fine       = 3
181 VeryFine   = 4
182 Custom     = 5
183
184 # Optimization level of GHS3D
185 # V3.1
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
189
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
192
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
195
196 PrecisionConfusion = 1e-07
197
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
200
201
202 ## Converts an angle from degrees to radians
203 def DegreesToRadians(AngleInDegrees):
204     from math import pi
205     return AngleInDegrees * pi / 180.0
206
207 # Salome notebook variable separator
208 var_separator = ":"
209
210 # Parametrized substitute for PointStruct
211 class PointStructStr:
212
213     x = 0
214     y = 0
215     z = 0
216     xStr = ""
217     yStr = ""
218     zStr = ""
219
220     def __init__(self, xStr, yStr, zStr):
221         self.xStr = xStr
222         self.yStr = yStr
223         self.zStr = zStr
224         if isinstance(xStr, str) and notebook.isVariable(xStr):
225             self.x = notebook.get(xStr)
226         else:
227             self.x = xStr
228         if isinstance(yStr, str) and notebook.isVariable(yStr):
229             self.y = notebook.get(yStr)
230         else:
231             self.y = yStr
232         if isinstance(zStr, str) and notebook.isVariable(zStr):
233             self.z = notebook.get(zStr)
234         else:
235             self.z = zStr
236
237 # Parametrized substitute for PointStruct (with 6 parameters)
238 class PointStructStr6:
239
240     x1 = 0
241     y1 = 0
242     z1 = 0
243     x2 = 0
244     y2 = 0
245     z2 = 0
246     xStr1 = ""
247     yStr1 = ""
248     zStr1 = ""
249     xStr2 = ""
250     yStr2 = ""
251     zStr2 = ""
252
253     def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
254         self.x1Str = x1Str
255         self.x2Str = x2Str
256         self.y1Str = y1Str
257         self.y2Str = y2Str
258         self.z1Str = z1Str
259         self.z2Str = z2Str
260         if isinstance(x1Str, str) and notebook.isVariable(x1Str):
261             self.x1 = notebook.get(x1Str)
262         else:
263             self.x1 = x1Str
264         if isinstance(x2Str, str) and notebook.isVariable(x2Str):
265             self.x2 = notebook.get(x2Str)
266         else:
267             self.x2 = x2Str
268         if isinstance(y1Str, str) and notebook.isVariable(y1Str):
269             self.y1 = notebook.get(y1Str)
270         else:
271             self.y1 = y1Str
272         if isinstance(y2Str, str) and notebook.isVariable(y2Str):
273             self.y2 = notebook.get(y2Str)
274         else:
275             self.y2 = y2Str
276         if isinstance(z1Str, str) and notebook.isVariable(z1Str):
277             self.z1 = notebook.get(z1Str)
278         else:
279             self.z1 = z1Str
280         if isinstance(z2Str, str) and notebook.isVariable(z2Str):
281             self.z2 = notebook.get(z2Str)
282         else:
283             self.z2 = z2Str
284
285 # Parametrized substitute for AxisStruct
286 class AxisStructStr:
287
288     x = 0
289     y = 0
290     z = 0
291     dx = 0
292     dy = 0
293     dz = 0
294     xStr = ""
295     yStr = ""
296     zStr = ""
297     dxStr = ""
298     dyStr = ""
299     dzStr = ""
300
301     def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
302         self.xStr = xStr
303         self.yStr = yStr
304         self.zStr = zStr
305         self.dxStr = dxStr
306         self.dyStr = dyStr
307         self.dzStr = dzStr
308         if isinstance(xStr, str) and notebook.isVariable(xStr):
309             self.x = notebook.get(xStr)
310         else:
311             self.x = xStr
312         if isinstance(yStr, str) and notebook.isVariable(yStr):
313             self.y = notebook.get(yStr)
314         else:
315             self.y = yStr
316         if isinstance(zStr, str) and notebook.isVariable(zStr):
317             self.z = notebook.get(zStr)
318         else:
319             self.z = zStr
320         if isinstance(dxStr, str) and notebook.isVariable(dxStr):
321             self.dx = notebook.get(dxStr)
322         else:
323             self.dx = dxStr
324         if isinstance(dyStr, str) and notebook.isVariable(dyStr):
325             self.dy = notebook.get(dyStr)
326         else:
327             self.dy = dyStr
328         if isinstance(dzStr, str) and notebook.isVariable(dzStr):
329             self.dz = notebook.get(dzStr)
330         else:
331             self.dz = dzStr
332
333 # Parametrized substitute for DirStruct
334 class DirStructStr:
335
336     def __init__(self, pointStruct):
337         self.pointStruct = pointStruct
338
339 # Returns list of variable values from salome notebook
340 def ParsePointStruct(Point):
341     Parameters = 2*var_separator
342     if isinstance(Point, PointStructStr):
343         Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
344         Point = PointStruct(Point.x, Point.y, Point.z)
345     return Point, Parameters
346
347 # Returns list of variable values from salome notebook
348 def ParseDirStruct(Dir):
349     Parameters = 2*var_separator
350     if isinstance(Dir, DirStructStr):
351         pntStr = Dir.pointStruct
352         if isinstance(pntStr, PointStructStr6):
353             Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
354             Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator 
355             Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
356             Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
357         else:
358             Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
359             Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
360         Dir = DirStruct(Point)
361     return Dir, Parameters
362
363 # Returns list of variable values from salome notebook
364 def ParseAxisStruct(Axis):
365     Parameters = 5*var_separator
366     if isinstance(Axis, AxisStructStr):
367         Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
368         Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
369         Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
370     return Axis, Parameters
371
372 ## Return list of variable values from salome notebook
373 def ParseAngles(list):
374     Result = []
375     Parameters = ""
376     for parameter in list:
377         if isinstance(parameter,str) and notebook.isVariable(parameter):
378             Result.append(DegreesToRadians(notebook.get(parameter)))
379             pass
380         else:
381             Result.append(parameter)
382             pass
383         
384         Parameters = Parameters + str(parameter)
385         Parameters = Parameters + var_separator
386         pass
387     Parameters = Parameters[:len(Parameters)-1]
388     return Result, Parameters
389     
390 def IsEqual(val1, val2, tol=PrecisionConfusion):
391     if abs(val1 - val2) < tol:
392         return True
393     return False
394
395 NO_NAME = "NoName"
396
397 ## Gets object name
398 def GetName(obj):
399     if obj:
400         # object not null
401         if isinstance(obj, SALOMEDS._objref_SObject):
402             # study object
403             return obj.GetName()
404         ior  = salome.orb.object_to_string(obj)
405         if ior:
406             # CORBA object
407             studies = salome.myStudyManager.GetOpenStudies()
408             for sname in studies:
409                 s = salome.myStudyManager.GetStudyByName(sname)
410                 if not s: continue
411                 sobj = s.FindObjectIOR(ior)
412                 if not sobj: continue
413                 return sobj.GetName()
414             if hasattr(obj, "GetName"):
415                 # unknown CORBA object, having GetName() method
416                 return obj.GetName()
417             else:
418                 # unknown CORBA object, no GetName() method
419                 return NO_NAME
420             pass
421         if hasattr(obj, "GetName"):
422             # unknown non-CORBA object, having GetName() method
423             return obj.GetName()
424         pass
425     raise RuntimeError, "Null or invalid object"
426
427 ## Prints error message if a hypothesis was not assigned.
428 def TreatHypoStatus(status, hypName, geomName, isAlgo):
429     if isAlgo:
430         hypType = "algorithm"
431     else:
432         hypType = "hypothesis"
433         pass
434     if status == HYP_UNKNOWN_FATAL :
435         reason = "for unknown reason"
436     elif status == HYP_INCOMPATIBLE :
437         reason = "this hypothesis mismatches the algorithm"
438     elif status == HYP_NOTCONFORM :
439         reason = "a non-conform mesh would be built"
440     elif status == HYP_ALREADY_EXIST :
441         reason = hypType + " of the same dimension is already assigned to this shape"
442     elif status == HYP_BAD_DIM :
443         reason = hypType + " mismatches the shape"
444     elif status == HYP_CONCURENT :
445         reason = "there are concurrent hypotheses on sub-shapes"
446     elif status == HYP_BAD_SUBSHAPE :
447         reason = "the shape is neither the main one, nor its subshape, nor a valid group"
448     elif status == HYP_BAD_GEOMETRY:
449         reason = "geometry mismatches the expectation of the algorithm"
450     elif status == HYP_HIDDEN_ALGO:
451         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
452     elif status == HYP_HIDING_ALGO:
453         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
454     elif status == HYP_NEED_SHAPE:
455         reason = "Algorithm can't work without shape"
456     else:
457         return
458     hypName = '"' + hypName + '"'
459     geomName= '"' + geomName+ '"'
460     if status < HYP_UNKNOWN_FATAL and not geomName =='""':
461         print hypName, "was assigned to",    geomName,"but", reason
462     elif not geomName == '""':
463         print hypName, "was not assigned to",geomName,":", reason
464     else:
465         print hypName, "was not assigned:", reason
466         pass
467
468 ## Check meshing plugin availability
469 def CheckPlugin(plugin):
470     if plugin == NETGEN and noNETGENPlugin:
471         print "Warning: NETGENPlugin module unavailable"
472         return False
473     elif plugin == GHS3D and noGHS3DPlugin:
474         print "Warning: GHS3DPlugin module unavailable"
475         return False
476     elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
477         print "Warning: GHS3DPRLPlugin module unavailable"
478         return False
479     elif plugin == Hexotic and noHexoticPlugin:
480         print "Warning: HexoticPlugin module unavailable"
481         return False
482     elif plugin == BLSURF and noBLSURFPlugin:
483         print "Warning: BLSURFPlugin module unavailable"
484         return False
485     return True
486     
487 # end of l1_auxiliary
488 ## @}
489
490 # All methods of this class are accessible directly from the smesh.py package.
491 class smeshDC(SMESH._objref_SMESH_Gen):
492
493     ## Sets the current study and Geometry component
494     #  @ingroup l1_auxiliary
495     def init_smesh(self,theStudy,geompyD):
496         self.SetCurrentStudy(theStudy,geompyD)
497
498     ## Creates an empty Mesh. This mesh can have an underlying geometry.
499     #  @param obj the Geometrical object on which the mesh is built. If not defined,
500     #             the mesh will have no underlying geometry.
501     #  @param name the name for the new mesh.
502     #  @return an instance of Mesh class.
503     #  @ingroup l2_construct
504     def Mesh(self, obj=0, name=0):
505         if isinstance(obj,str):
506             obj,name = name,obj
507         return Mesh(self,self.geompyD,obj,name)
508
509     ## Returns a long value from enumeration
510     #  Should be used for SMESH.FunctorType enumeration
511     #  @ingroup l1_controls
512     def EnumToLong(self,theItem):
513         return theItem._v
514
515     ## Gets PointStruct from vertex
516     #  @param theVertex a GEOM object(vertex)
517     #  @return SMESH.PointStruct
518     #  @ingroup l1_auxiliary
519     def GetPointStruct(self,theVertex):
520         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
521         return PointStruct(x,y,z)
522
523     ## Gets DirStruct from vector
524     #  @param theVector a GEOM object(vector)
525     #  @return SMESH.DirStruct
526     #  @ingroup l1_auxiliary
527     def GetDirStruct(self,theVector):
528         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
529         if(len(vertices) != 2):
530             print "Error: vector object is incorrect."
531             return None
532         p1 = self.geompyD.PointCoordinates(vertices[0])
533         p2 = self.geompyD.PointCoordinates(vertices[1])
534         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
535         dirst = DirStruct(pnt)
536         return dirst
537
538     ## Makes DirStruct from a triplet
539     #  @param x,y,z vector components
540     #  @return SMESH.DirStruct
541     #  @ingroup l1_auxiliary
542     def MakeDirStruct(self,x,y,z):
543         pnt = PointStruct(x,y,z)
544         return DirStruct(pnt)
545
546     ## Get AxisStruct from object
547     #  @param theObj a GEOM object (line or plane)
548     #  @return SMESH.AxisStruct
549     #  @ingroup l1_auxiliary
550     def GetAxisStruct(self,theObj):
551         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
552         if len(edges) > 1:
553             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
554             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
555             vertex1 = self.geompyD.PointCoordinates(vertex1)
556             vertex2 = self.geompyD.PointCoordinates(vertex2)
557             vertex3 = self.geompyD.PointCoordinates(vertex3)
558             vertex4 = self.geompyD.PointCoordinates(vertex4)
559             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
560             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
561             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] ]
562             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
563             return axis
564         elif len(edges) == 1:
565             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
566             p1 = self.geompyD.PointCoordinates( vertex1 )
567             p2 = self.geompyD.PointCoordinates( vertex2 )
568             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
569             return axis
570         return None
571
572     # From SMESH_Gen interface:
573     # ------------------------
574
575     ## Sets the given name to the object
576     #  @param obj the object to rename
577     #  @param name a new object name
578     #  @ingroup l1_auxiliary
579     def SetName(self, obj, name):
580         if isinstance( obj, Mesh ):
581             obj = obj.GetMesh()
582         elif isinstance( obj, Mesh_Algorithm ):
583             obj = obj.GetAlgorithm()
584         ior  = salome.orb.object_to_string(obj)
585         SMESH._objref_SMESH_Gen.SetName(self, ior, name)
586
587     ## Sets the current mode
588     #  @ingroup l1_auxiliary
589     def SetEmbeddedMode( self,theMode ):
590         #self.SetEmbeddedMode(theMode)
591         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
592
593     ## Gets the current mode
594     #  @ingroup l1_auxiliary
595     def IsEmbeddedMode(self):
596         #return self.IsEmbeddedMode()
597         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
598
599     ## Sets the current study
600     #  @ingroup l1_auxiliary
601     def SetCurrentStudy( self, theStudy, geompyD = None ):
602         #self.SetCurrentStudy(theStudy)
603         if not geompyD:
604             import geompy
605             geompyD = geompy.geom
606             pass
607         self.geompyD=geompyD
608         self.SetGeomEngine(geompyD)
609         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
610
611     ## Gets the current study
612     #  @ingroup l1_auxiliary
613     def GetCurrentStudy(self):
614         #return self.GetCurrentStudy()
615         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
616
617     ## Creates a Mesh object importing data from the given UNV file
618     #  @return an instance of Mesh class
619     #  @ingroup l2_impexp
620     def CreateMeshesFromUNV( self,theFileName ):
621         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
622         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
623         return aMesh
624
625     ## Creates a Mesh object(s) importing data from the given MED file
626     #  @return a list of Mesh class instances
627     #  @ingroup l2_impexp
628     def CreateMeshesFromMED( self,theFileName ):
629         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
630         aMeshes = []
631         for iMesh in range(len(aSmeshMeshes)) :
632             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
633             aMeshes.append(aMesh)
634         return aMeshes, aStatus
635
636     ## Creates a Mesh object importing data from the given STL file
637     #  @return an instance of Mesh class
638     #  @ingroup l2_impexp
639     def CreateMeshesFromSTL( self, theFileName ):
640         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
641         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
642         return aMesh
643
644     ## From SMESH_Gen interface
645     #  @return the list of integer values
646     #  @ingroup l1_auxiliary
647     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
648         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
649
650     ## From SMESH_Gen interface. Creates a pattern
651     #  @return an instance of SMESH_Pattern
652     #
653     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
654     #  @ingroup l2_modif_patterns
655     def GetPattern(self):
656         return SMESH._objref_SMESH_Gen.GetPattern(self)
657
658     ## Sets number of segments per diagonal of boundary box of geometry by which
659     #  default segment length of appropriate 1D hypotheses is defined.
660     #  Default value is 10
661     #  @ingroup l1_auxiliary
662     def SetBoundaryBoxSegmentation(self, nbSegments):
663         SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
664
665     ## Concatenate the given meshes into one mesh.
666     #  @return an instance of Mesh class
667     #  @param meshes the meshes to combine into one mesh
668     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
669     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
670     #  @param mergeTolerance tolerance for merging nodes
671     #  @param allGroups forces creation of groups of all elements
672     def Concatenate( self, meshes, uniteIdenticalGroups,
673                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
674         mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
675         if allGroups:
676             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
677                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
678         else:
679             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
680                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
681         aSmeshMesh.SetParameters(Parameters)
682         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
683         return aMesh
684
685     # Filtering. Auxiliary functions:
686     # ------------------------------
687
688     ## Creates an empty criterion
689     #  @return SMESH.Filter.Criterion
690     #  @ingroup l1_controls
691     def GetEmptyCriterion(self):
692         Type = self.EnumToLong(FT_Undefined)
693         Compare = self.EnumToLong(FT_Undefined)
694         Threshold = 0
695         ThresholdStr = ""
696         ThresholdID = ""
697         UnaryOp = self.EnumToLong(FT_Undefined)
698         BinaryOp = self.EnumToLong(FT_Undefined)
699         Tolerance = 1e-07
700         TypeOfElement = ALL
701         Precision = -1 ##@1e-07
702         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
703                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
704
705     ## Creates a criterion by the given parameters
706     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
707     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
708     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
709     #  @param Treshold the threshold value (range of ids as string, shape, numeric)
710     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
711     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
712     #                  FT_Undefined (must be for the last criterion of all criteria)
713     #  @return SMESH.Filter.Criterion
714     #  @ingroup l1_controls
715     def GetCriterion(self,elementType,
716                      CritType,
717                      Compare = FT_EqualTo,
718                      Treshold="",
719                      UnaryOp=FT_Undefined,
720                      BinaryOp=FT_Undefined):
721         aCriterion = self.GetEmptyCriterion()
722         aCriterion.TypeOfElement = elementType
723         aCriterion.Type = self.EnumToLong(CritType)
724
725         aTreshold = Treshold
726
727         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
728             aCriterion.Compare = self.EnumToLong(Compare)
729         elif Compare == "=" or Compare == "==":
730             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
731         elif Compare == "<":
732             aCriterion.Compare = self.EnumToLong(FT_LessThan)
733         elif Compare == ">":
734             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
735         else:
736             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
737             aTreshold = Compare
738
739         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
740                         FT_BelongToCylinder, FT_LyingOnGeom]:
741             # Checks the treshold
742             if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
743                 aCriterion.ThresholdStr = GetName(aTreshold)
744                 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
745             else:
746                 print "Error: The treshold should be a shape."
747                 return None
748         elif CritType == FT_RangeOfIds:
749             # Checks the treshold
750             if isinstance(aTreshold, str):
751                 aCriterion.ThresholdStr = aTreshold
752             else:
753                 print "Error: The treshold should be a string."
754                 return None
755         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
756                           FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
757             # At this point the treshold is unnecessary
758             if aTreshold ==  FT_LogicalNOT:
759                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
760             elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
761                 aCriterion.BinaryOp = aTreshold
762         else:
763             # Check treshold
764             try:
765                 aTreshold = float(aTreshold)
766                 aCriterion.Threshold = aTreshold
767             except:
768                 print "Error: The treshold should be a number."
769                 return None
770
771         if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
772             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
773
774         if Treshold in [FT_LogicalAND, FT_LogicalOR]:
775             aCriterion.BinaryOp = self.EnumToLong(Treshold)
776
777         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
778             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
779
780         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
781             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
782
783         return aCriterion
784
785     ## Creates a filter with the given parameters
786     #  @param elementType the type of elements in the group
787     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
788     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
789     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
790     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
791     #  @return SMESH_Filter
792     #  @ingroup l1_controls
793     def GetFilter(self,elementType,
794                   CritType=FT_Undefined,
795                   Compare=FT_EqualTo,
796                   Treshold="",
797                   UnaryOp=FT_Undefined):
798         aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
799         aFilterMgr = self.CreateFilterManager()
800         aFilter = aFilterMgr.CreateFilter()
801         aCriteria = []
802         aCriteria.append(aCriterion)
803         aFilter.SetCriteria(aCriteria)
804         return aFilter
805
806     ## Creates a numerical functor by its type
807     #  @param theCriterion FT_...; functor type
808     #  @return SMESH_NumericalFunctor
809     #  @ingroup l1_controls
810     def GetFunctor(self,theCriterion):
811         aFilterMgr = self.CreateFilterManager()
812         if theCriterion == FT_AspectRatio:
813             return aFilterMgr.CreateAspectRatio()
814         elif theCriterion == FT_AspectRatio3D:
815             return aFilterMgr.CreateAspectRatio3D()
816         elif theCriterion == FT_Warping:
817             return aFilterMgr.CreateWarping()
818         elif theCriterion == FT_MinimumAngle:
819             return aFilterMgr.CreateMinimumAngle()
820         elif theCriterion == FT_Taper:
821             return aFilterMgr.CreateTaper()
822         elif theCriterion == FT_Skew:
823             return aFilterMgr.CreateSkew()
824         elif theCriterion == FT_Area:
825             return aFilterMgr.CreateArea()
826         elif theCriterion == FT_Volume3D:
827             return aFilterMgr.CreateVolume3D()
828         elif theCriterion == FT_MultiConnection:
829             return aFilterMgr.CreateMultiConnection()
830         elif theCriterion == FT_MultiConnection2D:
831             return aFilterMgr.CreateMultiConnection2D()
832         elif theCriterion == FT_Length:
833             return aFilterMgr.CreateLength()
834         elif theCriterion == FT_Length2D:
835             return aFilterMgr.CreateLength2D()
836         else:
837             print "Error: given parameter is not numerucal functor type."
838
839     ## Creates hypothesis
840     #  @param theHType mesh hypothesis type (string)
841     #  @param theLibName mesh plug-in library name
842     #  @return created hypothesis instance
843     def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
844         return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
845
846     ## Gets the mesh stattistic
847     #  @return dictionary type element - count of elements
848     #  @ingroup l1_meshinfo
849     def GetMeshInfo(self, obj):
850         if isinstance( obj, Mesh ):
851             obj = obj.GetMesh()
852         d = {}
853         if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
854             values = obj.GetMeshInfo() 
855             for i in range(SMESH.Entity_Last._v):
856                 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
857             pass
858         return d
859
860 import omniORB
861 #Registering the new proxy for SMESH_Gen
862 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
863
864
865 # Public class: Mesh
866 # ==================
867
868 ## This class allows defining and managing a mesh.
869 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
870 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
871 #  new nodes and elements and by changing the existing entities), to get information
872 #  about a mesh and to export a mesh into different formats.
873 class Mesh:
874
875     geom = 0
876     mesh = 0
877     editor = 0
878
879     ## Constructor
880     #
881     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
882     #  sets the GUI name of this mesh to \a name.
883     #  @param smeshpyD an instance of smeshDC class
884     #  @param geompyD an instance of geompyDC class
885     #  @param obj Shape to be meshed or SMESH_Mesh object
886     #  @param name Study name of the mesh
887     #  @ingroup l2_construct
888     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
889         self.smeshpyD=smeshpyD
890         self.geompyD=geompyD
891         if obj is None:
892             obj = 0
893         if obj != 0:
894             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
895                 self.geom = obj
896                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
897             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
898                 self.SetMesh(obj)
899         else:
900             self.mesh = self.smeshpyD.CreateEmptyMesh()
901         if name != 0:
902             self.smeshpyD.SetName(self.mesh, name)
903         elif obj != 0:
904             self.smeshpyD.SetName(self.mesh, GetName(obj))
905
906         if not self.geom:
907             self.geom = self.mesh.GetShapeToMesh()
908
909         self.editor = self.mesh.GetMeshEditor()
910
911     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
912     #  @param theMesh a SMESH_Mesh object
913     #  @ingroup l2_construct
914     def SetMesh(self, theMesh):
915         self.mesh = theMesh
916         self.geom = self.mesh.GetShapeToMesh()
917
918     ## Returns the mesh, that is an instance of SMESH_Mesh interface
919     #  @return a SMESH_Mesh object
920     #  @ingroup l2_construct
921     def GetMesh(self):
922         return self.mesh
923
924     ## Gets the name of the mesh
925     #  @return the name of the mesh as a string
926     #  @ingroup l2_construct
927     def GetName(self):
928         name = GetName(self.GetMesh())
929         return name
930
931     ## Sets a name to the mesh
932     #  @param name a new name of the mesh
933     #  @ingroup l2_construct
934     def SetName(self, name):
935         self.smeshpyD.SetName(self.GetMesh(), name)
936
937     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
938     #  The subMesh object gives access to the IDs of nodes and elements.
939     #  @param theSubObject a geometrical object (shape)
940     #  @param theName a name for the submesh
941     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
942     #  @ingroup l2_submeshes
943     def GetSubMesh(self, theSubObject, theName):
944         submesh = self.mesh.GetSubMesh(theSubObject, theName)
945         return submesh
946
947     ## Returns the shape associated to the mesh
948     #  @return a GEOM_Object
949     #  @ingroup l2_construct
950     def GetShape(self):
951         return self.geom
952
953     ## Associates the given shape to the mesh (entails the recreation of the mesh)
954     #  @param geom the shape to be meshed (GEOM_Object)
955     #  @ingroup l2_construct
956     def SetShape(self, geom):
957         self.mesh = self.smeshpyD.CreateMesh(geom)
958
959     ## Returns true if the hypotheses are defined well
960     #  @param theSubObject a subshape of a mesh shape
961     #  @return True or False
962     #  @ingroup l2_construct
963     def IsReadyToCompute(self, theSubObject):
964         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
965
966     ## Returns errors of hypotheses definition.
967     #  The list of errors is empty if everything is OK.
968     #  @param theSubObject a subshape of a mesh shape
969     #  @return a list of errors
970     #  @ingroup l2_construct
971     def GetAlgoState(self, theSubObject):
972         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
973
974     ## Returns a geometrical object on which the given element was built.
975     #  The returned geometrical object, if not nil, is either found in the
976     #  study or published by this method with the given name
977     #  @param theElementID the id of the mesh element
978     #  @param theGeomName the user-defined name of the geometrical object
979     #  @return GEOM::GEOM_Object instance
980     #  @ingroup l2_construct
981     def GetGeometryByMeshElement(self, theElementID, theGeomName):
982         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
983
984     ## Returns the mesh dimension depending on the dimension of the underlying shape
985     #  @return mesh dimension as an integer value [0,3]
986     #  @ingroup l1_auxiliary
987     def MeshDimension(self):
988         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
989         if len( shells ) > 0 :
990             return 3
991         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
992             return 2
993         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
994             return 1
995         else:
996             return 0;
997         pass
998
999     ## Creates a segment discretization 1D algorithm.
1000     #  If the optional \a algo parameter is not set, this algorithm is REGULAR.
1001     #  \n If the optional \a geom parameter is not set, this algorithm is global.
1002     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1003     #  @param algo the type of the required algorithm. Possible values are:
1004     #     - smesh.REGULAR,
1005     #     - smesh.PYTHON for discretization via a python function,
1006     #     - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1007     #  @param geom If defined is the subshape to be meshed
1008     #  @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1009     #  @ingroup l3_algos_basic
1010     def Segment(self, algo=REGULAR, geom=0):
1011         ## if Segment(geom) is called by mistake
1012         if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1013             algo, geom = geom, algo
1014             if not algo: algo = REGULAR
1015             pass
1016         if algo == REGULAR:
1017             return Mesh_Segment(self,  geom)
1018         elif algo == PYTHON:
1019             return Mesh_Segment_Python(self, geom)
1020         elif algo == COMPOSITE:
1021             return Mesh_CompositeSegment(self, geom)
1022         else:
1023             return Mesh_Segment(self, geom)
1024
1025     ## Enables creation of nodes and segments usable by 2D algoritms.
1026     #  The added nodes and segments must be bound to edges and vertices by
1027     #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1028     #  If the optional \a geom parameter is not set, this algorithm is global.
1029     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1030     #  @param geom the subshape to be manually meshed
1031     #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
1032     #  @ingroup l3_algos_basic
1033     def UseExistingSegments(self, geom=0):
1034         algo = Mesh_UseExisting(1,self,geom)
1035         return algo.GetAlgorithm()
1036
1037     ## Enables creation of nodes and faces usable by 3D algoritms.
1038     #  The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1039     #  and SetMeshElementOnShape()
1040     #  If the optional \a geom parameter is not set, this algorithm is global.
1041     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1042     #  @param geom the subshape to be manually meshed
1043     #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
1044     #  @ingroup l3_algos_basic
1045     def UseExistingFaces(self, geom=0):
1046         algo = Mesh_UseExisting(2,self,geom)
1047         return algo.GetAlgorithm()
1048
1049     ## Creates a triangle 2D algorithm for faces.
1050     #  If the optional \a geom parameter is not set, this algorithm is global.
1051     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1052     #  @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1053     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
1054     #  @return an instance of Mesh_Triangle algorithm
1055     #  @ingroup l3_algos_basic
1056     def Triangle(self, algo=MEFISTO, geom=0):
1057         ## if Triangle(geom) is called by mistake
1058         if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1059             geom = algo
1060             algo = MEFISTO
1061         return Mesh_Triangle(self, algo, geom)
1062
1063     ## Creates a quadrangle 2D algorithm for faces.
1064     #  If the optional \a geom parameter is not set, this algorithm is global.
1065     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1066     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
1067     #  @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1068     #  @return an instance of Mesh_Quadrangle algorithm
1069     #  @ingroup l3_algos_basic
1070     def Quadrangle(self, geom=0, algo=QUADRANGLE):
1071         if algo==RADIAL_QUAD:
1072             return Mesh_RadialQuadrangle1D2D(self,geom)
1073         else:
1074             return Mesh_Quadrangle(self, geom)
1075
1076     ## Creates a tetrahedron 3D algorithm for solids.
1077     #  The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1078     #  If the optional \a geom parameter is not set, this algorithm is global.
1079     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1080     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1081     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
1082     #  @return an instance of Mesh_Tetrahedron algorithm
1083     #  @ingroup l3_algos_basic
1084     def Tetrahedron(self, algo=NETGEN, geom=0):
1085         ## if Tetrahedron(geom) is called by mistake
1086         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1087             algo, geom = geom, algo
1088             if not algo: algo = NETGEN
1089             pass
1090         return Mesh_Tetrahedron(self,  algo, geom)
1091
1092     ## Creates a hexahedron 3D algorithm for solids.
1093     #  If the optional \a geom parameter is not set, this algorithm is global.
1094     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1095     #  @param algo possible values are: smesh.Hexa, smesh.Hexotic
1096     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
1097     #  @return an instance of Mesh_Hexahedron algorithm
1098     #  @ingroup l3_algos_basic
1099     def Hexahedron(self, algo=Hexa, geom=0):
1100         ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1101         if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1102             if   geom in [Hexa, Hexotic]: algo, geom = geom, algo
1103             elif geom == 0:               algo, geom = Hexa, algo
1104         return Mesh_Hexahedron(self, algo, geom)
1105
1106     ## Deprecated, used only for compatibility!
1107     #  @return an instance of Mesh_Netgen algorithm
1108     #  @ingroup l3_algos_basic
1109     def Netgen(self, is3D, geom=0):
1110         return Mesh_Netgen(self,  is3D, geom)
1111
1112     ## Creates a projection 1D algorithm for edges.
1113     #  If the optional \a geom parameter is not set, this algorithm is global.
1114     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1115     #  @param geom If defined, the subshape to be meshed
1116     #  @return an instance of Mesh_Projection1D algorithm
1117     #  @ingroup l3_algos_proj
1118     def Projection1D(self, geom=0):
1119         return Mesh_Projection1D(self,  geom)
1120
1121     ## Creates a projection 2D algorithm for faces.
1122     #  If the optional \a geom parameter is not set, this algorithm is global.
1123     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1124     #  @param geom If defined, the subshape to be meshed
1125     #  @return an instance of Mesh_Projection2D algorithm
1126     #  @ingroup l3_algos_proj
1127     def Projection2D(self, geom=0):
1128         return Mesh_Projection2D(self,  geom)
1129
1130     ## Creates a projection 3D algorithm for solids.
1131     #  If the optional \a geom parameter is not set, this algorithm is global.
1132     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1133     #  @param geom If defined, the subshape to be meshed
1134     #  @return an instance of Mesh_Projection3D algorithm
1135     #  @ingroup l3_algos_proj
1136     def Projection3D(self, geom=0):
1137         return Mesh_Projection3D(self,  geom)
1138
1139     ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1140     #  If the optional \a geom parameter is not set, this algorithm is global.
1141     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1142     #  @param geom If defined, the subshape to be meshed
1143     #  @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1144     #  @ingroup l3_algos_radialp l3_algos_3dextr
1145     def Prism(self, geom=0):
1146         shape = geom
1147         if shape==0:
1148             shape = self.geom
1149         nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1150         nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1151         if nbSolids == 0 or nbSolids == nbShells:
1152             return Mesh_Prism3D(self,  geom)
1153         return Mesh_RadialPrism3D(self,  geom)
1154
1155     ## Evaluates size of prospective mesh on a shape
1156     #  @return True or False
1157     def Evaluate(self, geom=0):
1158         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1159             if self.geom == 0:
1160                 geom = self.mesh.GetShapeToMesh()
1161             else:
1162                 geom = self.geom
1163         return self.smeshpyD.Evaluate(self.mesh, geom)
1164
1165
1166     ## Computes the mesh and returns the status of the computation
1167     #  @return True or False
1168     #  @ingroup l2_construct
1169     def Compute(self, geom=0):
1170         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1171             if self.geom == 0:
1172                 geom = self.mesh.GetShapeToMesh()
1173             else:
1174                 geom = self.geom
1175         ok = False
1176         try:
1177             ok = self.smeshpyD.Compute(self.mesh, geom)
1178         except SALOME.SALOME_Exception, ex:
1179             print "Mesh computation failed, exception caught:"
1180             print "    ", ex.details.text
1181         except:
1182             import traceback
1183             print "Mesh computation failed, exception caught:"
1184             traceback.print_exc()
1185         if True:#not ok:
1186             allReasons = ""
1187
1188             # Treat compute errors
1189             computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1190             for err in computeErrors:
1191                 shapeText = ""
1192                 if self.mesh.HasShapeToMesh():
1193                     try:
1194                         mainIOR  = salome.orb.object_to_string(geom)
1195                         for sname in salome.myStudyManager.GetOpenStudies():
1196                             s = salome.myStudyManager.GetStudyByName(sname)
1197                             if not s: continue
1198                             mainSO = s.FindObjectIOR(mainIOR)
1199                             if not mainSO: continue
1200                             subIt = s.NewChildIterator(mainSO)
1201                             while subIt.More():
1202                                 subSO = subIt.Value()
1203                                 subIt.Next()
1204                                 obj = subSO.GetObject()
1205                                 if not obj: continue
1206                                 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1207                                 if not go: continue
1208                                 ids = go.GetSubShapeIndices()
1209                                 if len(ids) == 1 and ids[0] == err.subShapeID:
1210                                     shapeText = ' on "%s"' % subSO.GetName()
1211                                     break
1212                         if not shapeText:
1213                             shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1214                             if shape:
1215                                 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1216                             else:
1217                                 shapeText = " on subshape #%s" % (err.subShapeID)
1218                     except:
1219                         shapeText = " on subshape #%s" % (err.subShapeID)
1220                 errText = ""
1221                 stdErrors = ["OK",                 #COMPERR_OK            
1222                              "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1223                              "std::exception",     #COMPERR_STD_EXCEPTION 
1224                              "OCC exception",      #COMPERR_OCC_EXCEPTION 
1225                              "SALOME exception",   #COMPERR_SLM_EXCEPTION 
1226                              "Unknown exception",  #COMPERR_EXCEPTION     
1227                              "Memory allocation problem", #COMPERR_MEMORY_PB     
1228                              "Algorithm failed",   #COMPERR_ALGO_FAILED   
1229                              "Unexpected geometry"]#COMPERR_BAD_SHAPE
1230                 if err.code > 0:
1231                     if err.code < len(stdErrors): errText = stdErrors[err.code]
1232                 else:
1233                     errText = "code %s" % -err.code
1234                 if errText: errText += ". "
1235                 errText += err.comment
1236                 if allReasons != "":allReasons += "\n"
1237                 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1238                 pass
1239
1240             # Treat hyp errors
1241             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1242             for err in errors:
1243                 if err.isGlobalAlgo:
1244                     glob = "global"
1245                 else:
1246                     glob = "local"
1247                     pass
1248                 dim = err.algoDim
1249                 name = err.algoName
1250                 if len(name) == 0:
1251                     reason = '%s %sD algorithm is missing' % (glob, dim)
1252                 elif err.state == HYP_MISSING:
1253                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1254                               % (glob, dim, name, dim))
1255                 elif err.state == HYP_NOTCONFORM:
1256                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1257                 elif err.state == HYP_BAD_PARAMETER:
1258                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1259                               % ( glob, dim, name ))
1260                 elif err.state == HYP_BAD_GEOMETRY:
1261                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1262                               'geometry' % ( glob, dim, name ))
1263                 else:
1264                     reason = "For unknown reason."+\
1265                              " Revise Mesh.Compute() implementation in smeshDC.py!"
1266                     pass
1267                 if allReasons != "":allReasons += "\n"
1268                 allReasons += reason
1269                 pass
1270             if allReasons != "":
1271                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1272                 print allReasons
1273                 ok = False
1274             elif not ok:
1275                 print '"' + GetName(self.mesh) + '"',"has not been computed."
1276                 pass
1277             pass
1278         if salome.sg.hasDesktop():
1279             smeshgui = salome.ImportComponentGUI("SMESH")
1280             smeshgui.Init(self.mesh.GetStudyId())
1281             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1282             salome.sg.updateObjBrowser(1)
1283             pass
1284         return ok
1285
1286     ## Return submesh objects list in meshing order
1287     #  @return list of list of submesh objects
1288     #  @ingroup l2_construct
1289     def GetMeshOrder(self):
1290         return self.mesh.GetMeshOrder()
1291
1292     ## Return submesh objects list in meshing order
1293     #  @return list of list of submesh objects
1294     #  @ingroup l2_construct
1295     def SetMeshOrder(self, submeshes):
1296         return self.mesh.SetMeshOrder(submeshes)
1297
1298     ## Removes all nodes and elements
1299     #  @ingroup l2_construct
1300     def Clear(self):
1301         self.mesh.Clear()
1302         if salome.sg.hasDesktop():
1303             smeshgui = salome.ImportComponentGUI("SMESH")
1304             smeshgui.Init(self.mesh.GetStudyId())
1305             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1306             salome.sg.updateObjBrowser(1)
1307
1308     ## Removes all nodes and elements of indicated shape
1309     #  @ingroup l2_construct
1310     def ClearSubMesh(self, geomId):
1311         self.mesh.ClearSubMesh(geomId)
1312         if salome.sg.hasDesktop():
1313             smeshgui = salome.ImportComponentGUI("SMESH")
1314             smeshgui.Init(self.mesh.GetStudyId())
1315             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1316             salome.sg.updateObjBrowser(1)
1317
1318     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1319     #  @param fineness [0,-1] defines mesh fineness
1320     #  @return True or False
1321     #  @ingroup l3_algos_basic
1322     def AutomaticTetrahedralization(self, fineness=0):
1323         dim = self.MeshDimension()
1324         # assign hypotheses
1325         self.RemoveGlobalHypotheses()
1326         self.Segment().AutomaticLength(fineness)
1327         if dim > 1 :
1328             self.Triangle().LengthFromEdges()
1329             pass
1330         if dim > 2 :
1331             self.Tetrahedron(NETGEN)
1332             pass
1333         return self.Compute()
1334
1335     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1336     #  @param fineness [0,-1] defines mesh fineness
1337     #  @return True or False
1338     #  @ingroup l3_algos_basic
1339     def AutomaticHexahedralization(self, fineness=0):
1340         dim = self.MeshDimension()
1341         # assign the hypotheses
1342         self.RemoveGlobalHypotheses()
1343         self.Segment().AutomaticLength(fineness)
1344         if dim > 1 :
1345             self.Quadrangle()
1346             pass
1347         if dim > 2 :
1348             self.Hexahedron()
1349             pass
1350         return self.Compute()
1351
1352     ## Assigns a hypothesis
1353     #  @param hyp a hypothesis to assign
1354     #  @param geom a subhape of mesh geometry
1355     #  @return SMESH.Hypothesis_Status
1356     #  @ingroup l2_hypotheses
1357     def AddHypothesis(self, hyp, geom=0):
1358         if isinstance( hyp, Mesh_Algorithm ):
1359             hyp = hyp.GetAlgorithm()
1360             pass
1361         if not geom:
1362             geom = self.geom
1363             if not geom:
1364                 geom = self.mesh.GetShapeToMesh()
1365             pass
1366         status = self.mesh.AddHypothesis(geom, hyp)
1367         isAlgo = hyp._narrow( SMESH_Algo )
1368         hyp_name = GetName( hyp )
1369         geom_name = ""
1370         if geom:
1371             geom_name = GetName( geom )
1372         TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1373         return status
1374
1375     ## Unassigns a hypothesis
1376     #  @param hyp a hypothesis to unassign
1377     #  @param geom a subshape of mesh geometry
1378     #  @return SMESH.Hypothesis_Status
1379     #  @ingroup l2_hypotheses
1380     def RemoveHypothesis(self, hyp, geom=0):
1381         if isinstance( hyp, Mesh_Algorithm ):
1382             hyp = hyp.GetAlgorithm()
1383             pass
1384         if not geom:
1385             geom = self.geom
1386             pass
1387         status = self.mesh.RemoveHypothesis(geom, hyp)
1388         return status
1389
1390     ## Gets the list of hypotheses added on a geometry
1391     #  @param geom a subshape of mesh geometry
1392     #  @return the sequence of SMESH_Hypothesis
1393     #  @ingroup l2_hypotheses
1394     def GetHypothesisList(self, geom):
1395         return self.mesh.GetHypothesisList( geom )
1396
1397     ## Removes all global hypotheses
1398     #  @ingroup l2_hypotheses
1399     def RemoveGlobalHypotheses(self):
1400         current_hyps = self.mesh.GetHypothesisList( self.geom )
1401         for hyp in current_hyps:
1402             self.mesh.RemoveHypothesis( self.geom, hyp )
1403             pass
1404         pass
1405
1406     ## Creates a mesh group based on the geometric object \a grp
1407     #  and gives a \a name, \n if this parameter is not defined
1408     #  the name is the same as the geometric group name \n
1409     #  Note: Works like GroupOnGeom().
1410     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
1411     #  @param name the name of the mesh group
1412     #  @return SMESH_GroupOnGeom
1413     #  @ingroup l2_grps_create
1414     def Group(self, grp, name=""):
1415         return self.GroupOnGeom(grp, name)
1416
1417     ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1418     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
1419     #  @param f the file name
1420     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1421     #  @param opt boolean parameter for creating/not creating
1422     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1423     #  @ingroup l2_impexp
1424     def ExportToMED(self, f, version, opt=0):
1425         self.mesh.ExportToMED(f, opt, version)
1426
1427     ## Exports the mesh in a file in MED format
1428     #  @param f is the file name
1429     #  @param auto_groups boolean parameter for creating/not creating
1430     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1431     #  the typical use is auto_groups=false.
1432     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1433     #  @ingroup l2_impexp
1434     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1435         self.mesh.ExportToMED(f, auto_groups, version)
1436
1437     ## Exports the mesh in a file in DAT format
1438     #  @param f the file name
1439     #  @ingroup l2_impexp
1440     def ExportDAT(self, f):
1441         self.mesh.ExportDAT(f)
1442
1443     ## Exports the mesh in a file in UNV format
1444     #  @param f the file name
1445     #  @ingroup l2_impexp
1446     def ExportUNV(self, f):
1447         self.mesh.ExportUNV(f)
1448
1449     ## Export the mesh in a file in STL format
1450     #  @param f the file name
1451     #  @param ascii defines the file encoding
1452     #  @ingroup l2_impexp
1453     def ExportSTL(self, f, ascii=1):
1454         self.mesh.ExportSTL(f, ascii)
1455
1456
1457     # Operations with groups:
1458     # ----------------------
1459
1460     ## Creates an empty mesh group
1461     #  @param elementType the type of elements in the group
1462     #  @param name the name of the mesh group
1463     #  @return SMESH_Group
1464     #  @ingroup l2_grps_create
1465     def CreateEmptyGroup(self, elementType, name):
1466         return self.mesh.CreateGroup(elementType, name)
1467
1468     ## Creates a mesh group based on the geometrical object \a grp
1469     #  and gives a \a name, \n if this parameter is not defined
1470     #  the name is the same as the geometrical group name
1471     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
1472     #  @param name the name of the mesh group
1473     #  @param typ  the type of elements in the group. If not set, it is
1474     #              automatically detected by the type of the geometry
1475     #  @return SMESH_GroupOnGeom
1476     #  @ingroup l2_grps_create
1477     def GroupOnGeom(self, grp, name="", typ=None):
1478         if name == "":
1479             name = grp.GetName()
1480
1481         if typ == None:
1482             tgeo = str(grp.GetShapeType())
1483             if tgeo == "VERTEX":
1484                 typ = NODE
1485             elif tgeo == "EDGE":
1486                 typ = EDGE
1487             elif tgeo == "FACE":
1488                 typ = FACE
1489             elif tgeo == "SOLID":
1490                 typ = VOLUME
1491             elif tgeo == "SHELL":
1492                 typ = VOLUME
1493             elif tgeo == "COMPOUND":
1494                 try: # it raises on a compound of compounds
1495                     if len( self.geompyD.GetObjectIDs( grp )) == 0:
1496                         print "Mesh.Group: empty geometric group", GetName( grp )
1497                         return 0
1498                     pass
1499                 except:
1500                     pass
1501                 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1502                     # group
1503                     tgeo = self.geompyD.GetType(grp)
1504                     if tgeo == geompyDC.ShapeType["VERTEX"]:
1505                         typ = NODE
1506                     elif tgeo == geompyDC.ShapeType["EDGE"]:
1507                         typ = EDGE
1508                     elif tgeo == geompyDC.ShapeType["FACE"]:
1509                         typ = FACE
1510                     elif tgeo == geompyDC.ShapeType["SOLID"]:
1511                         typ = VOLUME
1512                         pass
1513                     pass
1514                 else:
1515                     # just a compound
1516                     for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1517                                                 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1518                         if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1519                             typ = elemType
1520                             break
1521                         pass
1522                     pass
1523                 pass
1524             pass
1525         if typ == None:
1526             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1527             return 0
1528         else:
1529             return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1530
1531     ## Creates a mesh group by the given ids of elements
1532     #  @param groupName the name of the mesh group
1533     #  @param elementType the type of elements in the group
1534     #  @param elemIDs the list of ids
1535     #  @return SMESH_Group
1536     #  @ingroup l2_grps_create
1537     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1538         group = self.mesh.CreateGroup(elementType, groupName)
1539         group.Add(elemIDs)
1540         return group
1541
1542     ## Creates a mesh group by the given conditions
1543     #  @param groupName the name of the mesh group
1544     #  @param elementType the type of elements in the group
1545     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1546     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1547     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
1548     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
1549     #  @return SMESH_Group
1550     #  @ingroup l2_grps_create
1551     def MakeGroup(self,
1552                   groupName,
1553                   elementType,
1554                   CritType=FT_Undefined,
1555                   Compare=FT_EqualTo,
1556                   Treshold="",
1557                   UnaryOp=FT_Undefined):
1558         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1559         group = self.MakeGroupByCriterion(groupName, aCriterion)
1560         return group
1561
1562     ## Creates a mesh group by the given criterion
1563     #  @param groupName the name of the mesh group
1564     #  @param Criterion the instance of Criterion class
1565     #  @return SMESH_Group
1566     #  @ingroup l2_grps_create
1567     def MakeGroupByCriterion(self, groupName, Criterion):
1568         aFilterMgr = self.smeshpyD.CreateFilterManager()
1569         aFilter = aFilterMgr.CreateFilter()
1570         aCriteria = []
1571         aCriteria.append(Criterion)
1572         aFilter.SetCriteria(aCriteria)
1573         group = self.MakeGroupByFilter(groupName, aFilter)
1574         return group
1575
1576     ## Creates a mesh group by the given criteria (list of criteria)
1577     #  @param groupName the name of the mesh group
1578     #  @param theCriteria the list of criteria
1579     #  @return SMESH_Group
1580     #  @ingroup l2_grps_create
1581     def MakeGroupByCriteria(self, groupName, theCriteria):
1582         aFilterMgr = self.smeshpyD.CreateFilterManager()
1583         aFilter = aFilterMgr.CreateFilter()
1584         aFilter.SetCriteria(theCriteria)
1585         group = self.MakeGroupByFilter(groupName, aFilter)
1586         return group
1587
1588     ## Creates a mesh group by the given filter
1589     #  @param groupName the name of the mesh group
1590     #  @param theFilter the instance of Filter class
1591     #  @return SMESH_Group
1592     #  @ingroup l2_grps_create
1593     def MakeGroupByFilter(self, groupName, theFilter):
1594         anIds = theFilter.GetElementsId(self.mesh)
1595         anElemType = theFilter.GetElementType()
1596         group = self.MakeGroupByIds(groupName, anElemType, anIds)
1597         return group
1598
1599     ## Passes mesh elements through the given filter and return IDs of fitting elements
1600     #  @param theFilter SMESH_Filter
1601     #  @return a list of ids
1602     #  @ingroup l1_controls
1603     def GetIdsFromFilter(self, theFilter):
1604         return theFilter.GetElementsId(self.mesh)
1605
1606     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1607     #  Returns a list of special structures (borders).
1608     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1609     #  @ingroup l1_controls
1610     def GetFreeBorders(self):
1611         aFilterMgr = self.smeshpyD.CreateFilterManager()
1612         aPredicate = aFilterMgr.CreateFreeEdges()
1613         aPredicate.SetMesh(self.mesh)
1614         aBorders = aPredicate.GetBorders()
1615         return aBorders
1616
1617     ## Removes a group
1618     #  @ingroup l2_grps_delete
1619     def RemoveGroup(self, group):
1620         self.mesh.RemoveGroup(group)
1621
1622     ## Removes a group with its contents
1623     #  @ingroup l2_grps_delete
1624     def RemoveGroupWithContents(self, group):
1625         self.mesh.RemoveGroupWithContents(group)
1626
1627     ## Gets the list of groups existing in the mesh
1628     #  @return a sequence of SMESH_GroupBase
1629     #  @ingroup l2_grps_create
1630     def GetGroups(self):
1631         return self.mesh.GetGroups()
1632
1633     ## Gets the number of groups existing in the mesh
1634     #  @return the quantity of groups as an integer value
1635     #  @ingroup l2_grps_create
1636     def NbGroups(self):
1637         return self.mesh.NbGroups()
1638
1639     ## Gets the list of names of groups existing in the mesh
1640     #  @return list of strings
1641     #  @ingroup l2_grps_create
1642     def GetGroupNames(self):
1643         groups = self.GetGroups()
1644         names = []
1645         for group in groups:
1646             names.append(group.GetName())
1647         return names
1648
1649     ## Produces a union of two groups
1650     #  A new group is created. All mesh elements that are
1651     #  present in the initial groups are added to the new one
1652     #  @return an instance of SMESH_Group
1653     #  @ingroup l2_grps_operon
1654     def UnionGroups(self, group1, group2, name):
1655         return self.mesh.UnionGroups(group1, group2, name)
1656         
1657     ## Produces a union list of groups
1658     #  New group is created. All mesh elements that are present in 
1659     #  initial groups are added to the new one
1660     #  @return an instance of SMESH_Group
1661     #  @ingroup l2_grps_operon
1662     def UnionListOfGroups(self, groups, name):
1663       return self.mesh.UnionListOfGroups(groups, name)
1664       
1665     ## Prodices an intersection of two groups
1666     #  A new group is created. All mesh elements that are common
1667     #  for the two initial groups are added to the new one.
1668     #  @return an instance of SMESH_Group
1669     #  @ingroup l2_grps_operon
1670     def IntersectGroups(self, group1, group2, name):
1671         return self.mesh.IntersectGroups(group1, group2, name)
1672         
1673     ## Produces an intersection of groups
1674     #  New group is created. All mesh elements that are present in all 
1675     #  initial groups simultaneously are added to the new one
1676     #  @return an instance of SMESH_Group
1677     #  @ingroup l2_grps_operon
1678     def IntersectListOfGroups(self, groups, name):
1679       return self.mesh.IntersectListOfGroups(groups, name)
1680
1681     ## Produces a cut of two groups
1682     #  A new group is created. All mesh elements that are present in
1683     #  the main group but are not present in the tool group are added to the new one
1684     #  @return an instance of SMESH_Group
1685     #  @ingroup l2_grps_operon
1686     def CutGroups(self, main_group, tool_group, name):
1687         return self.mesh.CutGroups(main_group, tool_group, name)
1688         
1689     ## Produces a cut of groups
1690     #  A new group is created. All mesh elements that are present in main groups 
1691     #  but do not present in tool groups are added to the new one
1692     #  @return an instance of SMESH_Group
1693     #  @ingroup l2_grps_operon
1694     def CutListOfGroups(self, main_groups, tool_groups, name):
1695       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1696       
1697     ## Produces a group of elements with specified element type using list of existing groups
1698     #  A new group is created. System 
1699     #  1) extract all nodes on which groups elements are built
1700     #  2) combine all elements of specified dimension laying on these nodes
1701     #  @return an instance of SMESH_Group
1702     #  @ingroup l2_grps_operon
1703     def CreateDimGroup(self, groups, elem_type, name):
1704       return self.mesh.CreateDimGroup(groups, elem_type, name)
1705
1706
1707     ## Convert group on geom into standalone group
1708     #  @ingroup l2_grps_delete
1709     def ConvertToStandalone(self, group):
1710         return self.mesh.ConvertToStandalone(group)
1711
1712     # Get some info about mesh:
1713     # ------------------------
1714
1715     ## Returns the log of nodes and elements added or removed
1716     #  since the previous clear of the log.
1717     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1718     #  @return list of log_block structures:
1719     #                                        commandType
1720     #                                        number
1721     #                                        coords
1722     #                                        indexes
1723     #  @ingroup l1_auxiliary
1724     def GetLog(self, clearAfterGet):
1725         return self.mesh.GetLog(clearAfterGet)
1726
1727     ## Clears the log of nodes and elements added or removed since the previous
1728     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1729     #  @ingroup l1_auxiliary
1730     def ClearLog(self):
1731         self.mesh.ClearLog()
1732
1733     ## Toggles auto color mode on the object.
1734     #  @param theAutoColor the flag which toggles auto color mode.
1735     #  @ingroup l1_auxiliary
1736     def SetAutoColor(self, theAutoColor):
1737         self.mesh.SetAutoColor(theAutoColor)
1738
1739     ## Gets flag of object auto color mode.
1740     #  @return True or False
1741     #  @ingroup l1_auxiliary
1742     def GetAutoColor(self):
1743         return self.mesh.GetAutoColor()
1744
1745     ## Gets the internal ID
1746     #  @return integer value, which is the internal Id of the mesh
1747     #  @ingroup l1_auxiliary
1748     def GetId(self):
1749         return self.mesh.GetId()
1750
1751     ## Get the study Id
1752     #  @return integer value, which is the study Id of the mesh
1753     #  @ingroup l1_auxiliary
1754     def GetStudyId(self):
1755         return self.mesh.GetStudyId()
1756
1757     ## Checks the group names for duplications.
1758     #  Consider the maximum group name length stored in MED file.
1759     #  @return True or False
1760     #  @ingroup l1_auxiliary
1761     def HasDuplicatedGroupNamesMED(self):
1762         return self.mesh.HasDuplicatedGroupNamesMED()
1763
1764     ## Obtains the mesh editor tool
1765     #  @return an instance of SMESH_MeshEditor
1766     #  @ingroup l1_modifying
1767     def GetMeshEditor(self):
1768         return self.mesh.GetMeshEditor()
1769
1770     ## Gets MED Mesh
1771     #  @return an instance of SALOME_MED::MESH
1772     #  @ingroup l1_auxiliary
1773     def GetMEDMesh(self):
1774         return self.mesh.GetMEDMesh()
1775
1776
1777     # Get informations about mesh contents:
1778     # ------------------------------------
1779
1780     ## Gets the mesh stattistic
1781     #  @return dictionary type element - count of elements
1782     #  @ingroup l1_meshinfo
1783     def GetMeshInfo(self, obj = None):
1784         if not obj: obj = self.mesh
1785         return self.smeshpyD.GetMeshInfo(obj)
1786
1787     ## Returns the number of nodes in the mesh
1788     #  @return an integer value
1789     #  @ingroup l1_meshinfo
1790     def NbNodes(self):
1791         return self.mesh.NbNodes()
1792
1793     ## Returns the number of elements in the mesh
1794     #  @return an integer value
1795     #  @ingroup l1_meshinfo
1796     def NbElements(self):
1797         return self.mesh.NbElements()
1798
1799     ## Returns the number of 0d elements in the mesh
1800     #  @return an integer value
1801     #  @ingroup l1_meshinfo
1802     def Nb0DElements(self):
1803         return self.mesh.Nb0DElements()
1804
1805     ## Returns the number of edges in the mesh
1806     #  @return an integer value
1807     #  @ingroup l1_meshinfo
1808     def NbEdges(self):
1809         return self.mesh.NbEdges()
1810
1811     ## Returns the number of edges with the given order in the mesh
1812     #  @param elementOrder the order of elements:
1813     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1814     #  @return an integer value
1815     #  @ingroup l1_meshinfo
1816     def NbEdgesOfOrder(self, elementOrder):
1817         return self.mesh.NbEdgesOfOrder(elementOrder)
1818
1819     ## Returns the number of faces in the mesh
1820     #  @return an integer value
1821     #  @ingroup l1_meshinfo
1822     def NbFaces(self):
1823         return self.mesh.NbFaces()
1824
1825     ## Returns the number of faces with the given order in the mesh
1826     #  @param elementOrder the order of elements:
1827     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1828     #  @return an integer value
1829     #  @ingroup l1_meshinfo
1830     def NbFacesOfOrder(self, elementOrder):
1831         return self.mesh.NbFacesOfOrder(elementOrder)
1832
1833     ## Returns the number of triangles in the mesh
1834     #  @return an integer value
1835     #  @ingroup l1_meshinfo
1836     def NbTriangles(self):
1837         return self.mesh.NbTriangles()
1838
1839     ## Returns the number of triangles with the given order in the mesh
1840     #  @param elementOrder is the order of elements:
1841     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1842     #  @return an integer value
1843     #  @ingroup l1_meshinfo
1844     def NbTrianglesOfOrder(self, elementOrder):
1845         return self.mesh.NbTrianglesOfOrder(elementOrder)
1846
1847     ## Returns the number of quadrangles in the mesh
1848     #  @return an integer value
1849     #  @ingroup l1_meshinfo
1850     def NbQuadrangles(self):
1851         return self.mesh.NbQuadrangles()
1852
1853     ## Returns the number of quadrangles with the given order in the mesh
1854     #  @param elementOrder the order of elements:
1855     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1856     #  @return an integer value
1857     #  @ingroup l1_meshinfo
1858     def NbQuadranglesOfOrder(self, elementOrder):
1859         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1860
1861     ## Returns the number of polygons in the mesh
1862     #  @return an integer value
1863     #  @ingroup l1_meshinfo
1864     def NbPolygons(self):
1865         return self.mesh.NbPolygons()
1866
1867     ## Returns the number of volumes in the mesh
1868     #  @return an integer value
1869     #  @ingroup l1_meshinfo
1870     def NbVolumes(self):
1871         return self.mesh.NbVolumes()
1872
1873     ## Returns the number of volumes with the given order in the mesh
1874     #  @param elementOrder  the order of elements:
1875     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1876     #  @return an integer value
1877     #  @ingroup l1_meshinfo
1878     def NbVolumesOfOrder(self, elementOrder):
1879         return self.mesh.NbVolumesOfOrder(elementOrder)
1880
1881     ## Returns the number of tetrahedrons in the mesh
1882     #  @return an integer value
1883     #  @ingroup l1_meshinfo
1884     def NbTetras(self):
1885         return self.mesh.NbTetras()
1886
1887     ## Returns the number of tetrahedrons with the given order in the mesh
1888     #  @param elementOrder  the order of elements:
1889     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1890     #  @return an integer value
1891     #  @ingroup l1_meshinfo
1892     def NbTetrasOfOrder(self, elementOrder):
1893         return self.mesh.NbTetrasOfOrder(elementOrder)
1894
1895     ## Returns the number of hexahedrons in the mesh
1896     #  @return an integer value
1897     #  @ingroup l1_meshinfo
1898     def NbHexas(self):
1899         return self.mesh.NbHexas()
1900
1901     ## Returns the number of hexahedrons with the given order in the mesh
1902     #  @param elementOrder  the order of elements:
1903     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1904     #  @return an integer value
1905     #  @ingroup l1_meshinfo
1906     def NbHexasOfOrder(self, elementOrder):
1907         return self.mesh.NbHexasOfOrder(elementOrder)
1908
1909     ## Returns the number of pyramids in the mesh
1910     #  @return an integer value
1911     #  @ingroup l1_meshinfo
1912     def NbPyramids(self):
1913         return self.mesh.NbPyramids()
1914
1915     ## Returns the number of pyramids with the given order in the mesh
1916     #  @param elementOrder  the order of elements:
1917     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1918     #  @return an integer value
1919     #  @ingroup l1_meshinfo
1920     def NbPyramidsOfOrder(self, elementOrder):
1921         return self.mesh.NbPyramidsOfOrder(elementOrder)
1922
1923     ## Returns the number of prisms in the mesh
1924     #  @return an integer value
1925     #  @ingroup l1_meshinfo
1926     def NbPrisms(self):
1927         return self.mesh.NbPrisms()
1928
1929     ## Returns the number of prisms with the given order in the mesh
1930     #  @param elementOrder  the order of elements:
1931     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1932     #  @return an integer value
1933     #  @ingroup l1_meshinfo
1934     def NbPrismsOfOrder(self, elementOrder):
1935         return self.mesh.NbPrismsOfOrder(elementOrder)
1936
1937     ## Returns the number of polyhedrons in the mesh
1938     #  @return an integer value
1939     #  @ingroup l1_meshinfo
1940     def NbPolyhedrons(self):
1941         return self.mesh.NbPolyhedrons()
1942
1943     ## Returns the number of submeshes in the mesh
1944     #  @return an integer value
1945     #  @ingroup l1_meshinfo
1946     def NbSubMesh(self):
1947         return self.mesh.NbSubMesh()
1948
1949     ## Returns the list of mesh elements IDs
1950     #  @return the list of integer values
1951     #  @ingroup l1_meshinfo
1952     def GetElementsId(self):
1953         return self.mesh.GetElementsId()
1954
1955     ## Returns the list of IDs of mesh elements with the given type
1956     #  @param elementType  the required type of elements
1957     #  @return list of integer values
1958     #  @ingroup l1_meshinfo
1959     def GetElementsByType(self, elementType):
1960         return self.mesh.GetElementsByType(elementType)
1961
1962     ## Returns the list of mesh nodes IDs
1963     #  @return the list of integer values
1964     #  @ingroup l1_meshinfo
1965     def GetNodesId(self):
1966         return self.mesh.GetNodesId()
1967
1968     # Get the information about mesh elements:
1969     # ------------------------------------
1970
1971     ## Returns the type of mesh element
1972     #  @return the value from SMESH::ElementType enumeration
1973     #  @ingroup l1_meshinfo
1974     def GetElementType(self, id, iselem):
1975         return self.mesh.GetElementType(id, iselem)
1976
1977     ## Returns the geometric type of mesh element
1978     #  @return the value from SMESH::EntityType enumeration
1979     #  @ingroup l1_meshinfo
1980     def GetElementGeomType(self, id):
1981         return self.mesh.GetElementGeomType(id)
1982
1983     ## Returns the list of submesh elements IDs
1984     #  @param Shape a geom object(subshape) IOR
1985     #         Shape must be the subshape of a ShapeToMesh()
1986     #  @return the list of integer values
1987     #  @ingroup l1_meshinfo
1988     def GetSubMeshElementsId(self, Shape):
1989         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1990             ShapeID = Shape.GetSubShapeIndices()[0]
1991         else:
1992             ShapeID = Shape
1993         return self.mesh.GetSubMeshElementsId(ShapeID)
1994
1995     ## Returns the list of submesh nodes IDs
1996     #  @param Shape a geom object(subshape) IOR
1997     #         Shape must be the subshape of a ShapeToMesh()
1998     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1999     #  @return the list of integer values
2000     #  @ingroup l1_meshinfo
2001     def GetSubMeshNodesId(self, Shape, all):
2002         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2003             ShapeID = Shape.GetSubShapeIndices()[0]
2004         else:
2005             ShapeID = Shape
2006         return self.mesh.GetSubMeshNodesId(ShapeID, all)
2007
2008     ## Returns type of elements on given shape
2009     #  @param Shape a geom object(subshape) IOR
2010     #         Shape must be a subshape of a ShapeToMesh()
2011     #  @return element type
2012     #  @ingroup l1_meshinfo
2013     def GetSubMeshElementType(self, Shape):
2014         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2015             ShapeID = Shape.GetSubShapeIndices()[0]
2016         else:
2017             ShapeID = Shape
2018         return self.mesh.GetSubMeshElementType(ShapeID)
2019
2020     ## Gets the mesh description
2021     #  @return string value
2022     #  @ingroup l1_meshinfo
2023     def Dump(self):
2024         return self.mesh.Dump()
2025
2026
2027     # Get the information about nodes and elements of a mesh by its IDs:
2028     # -----------------------------------------------------------
2029
2030     ## Gets XYZ coordinates of a node
2031     #  \n If there is no nodes for the given ID - returns an empty list
2032     #  @return a list of double precision values
2033     #  @ingroup l1_meshinfo
2034     def GetNodeXYZ(self, id):
2035         return self.mesh.GetNodeXYZ(id)
2036
2037     ## Returns list of IDs of inverse elements for the given node
2038     #  \n If there is no node for the given ID - returns an empty list
2039     #  @return a list of integer values
2040     #  @ingroup l1_meshinfo
2041     def GetNodeInverseElements(self, id):
2042         return self.mesh.GetNodeInverseElements(id)
2043
2044     ## @brief Returns the position of a node on the shape
2045     #  @return SMESH::NodePosition
2046     #  @ingroup l1_meshinfo
2047     def GetNodePosition(self,NodeID):
2048         return self.mesh.GetNodePosition(NodeID)
2049
2050     ## If the given element is a node, returns the ID of shape
2051     #  \n If there is no node for the given ID - returns -1
2052     #  @return an integer value
2053     #  @ingroup l1_meshinfo
2054     def GetShapeID(self, id):
2055         return self.mesh.GetShapeID(id)
2056
2057     ## Returns the ID of the result shape after
2058     #  FindShape() from SMESH_MeshEditor for the given element
2059     #  \n If there is no element for the given ID - returns -1
2060     #  @return an integer value
2061     #  @ingroup l1_meshinfo
2062     def GetShapeIDForElem(self,id):
2063         return self.mesh.GetShapeIDForElem(id)
2064
2065     ## Returns the number of nodes for the given element
2066     #  \n If there is no element for the given ID - returns -1
2067     #  @return an integer value
2068     #  @ingroup l1_meshinfo
2069     def GetElemNbNodes(self, id):
2070         return self.mesh.GetElemNbNodes(id)
2071
2072     ## Returns the node ID the given index for the given element
2073     #  \n If there is no element for the given ID - returns -1
2074     #  \n If there is no node for the given index - returns -2
2075     #  @return an integer value
2076     #  @ingroup l1_meshinfo
2077     def GetElemNode(self, id, index):
2078         return self.mesh.GetElemNode(id, index)
2079
2080     ## Returns the IDs of nodes of the given element
2081     #  @return a list of integer values
2082     #  @ingroup l1_meshinfo
2083     def GetElemNodes(self, id):
2084         return self.mesh.GetElemNodes(id)
2085
2086     ## Returns true if the given node is the medium node in the given quadratic element
2087     #  @ingroup l1_meshinfo
2088     def IsMediumNode(self, elementID, nodeID):
2089         return self.mesh.IsMediumNode(elementID, nodeID)
2090
2091     ## Returns true if the given node is the medium node in one of quadratic elements
2092     #  @ingroup l1_meshinfo
2093     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2094         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2095
2096     ## Returns the number of edges for the given element
2097     #  @ingroup l1_meshinfo
2098     def ElemNbEdges(self, id):
2099         return self.mesh.ElemNbEdges(id)
2100
2101     ## Returns the number of faces for the given element
2102     #  @ingroup l1_meshinfo
2103     def ElemNbFaces(self, id):
2104         return self.mesh.ElemNbFaces(id)
2105
2106     ## Returns nodes of given face (counted from zero) for given volumic element.
2107     #  @ingroup l1_meshinfo
2108     def GetElemFaceNodes(self,elemId, faceIndex):
2109         return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2110
2111     ## Returns an element based on all given nodes.
2112     #  @ingroup l1_meshinfo
2113     def FindElementByNodes(self,nodes):
2114         return self.mesh.FindElementByNodes(nodes)
2115
2116     ## Returns true if the given element is a polygon
2117     #  @ingroup l1_meshinfo
2118     def IsPoly(self, id):
2119         return self.mesh.IsPoly(id)
2120
2121     ## Returns true if the given element is quadratic
2122     #  @ingroup l1_meshinfo
2123     def IsQuadratic(self, id):
2124         return self.mesh.IsQuadratic(id)
2125
2126     ## Returns XYZ coordinates of the barycenter of the given element
2127     #  \n If there is no element for the given ID - returns an empty list
2128     #  @return a list of three double values
2129     #  @ingroup l1_meshinfo
2130     def BaryCenter(self, id):
2131         return self.mesh.BaryCenter(id)
2132
2133
2134     # Mesh edition (SMESH_MeshEditor functionality):
2135     # ---------------------------------------------
2136
2137     ## Removes the elements from the mesh by ids
2138     #  @param IDsOfElements is a list of ids of elements to remove
2139     #  @return True or False
2140     #  @ingroup l2_modif_del
2141     def RemoveElements(self, IDsOfElements):
2142         return self.editor.RemoveElements(IDsOfElements)
2143
2144     ## Removes nodes from mesh by ids
2145     #  @param IDsOfNodes is a list of ids of nodes to remove
2146     #  @return True or False
2147     #  @ingroup l2_modif_del
2148     def RemoveNodes(self, IDsOfNodes):
2149         return self.editor.RemoveNodes(IDsOfNodes)
2150
2151     ## Add a node to the mesh by coordinates
2152     #  @return Id of the new node
2153     #  @ingroup l2_modif_add
2154     def AddNode(self, x, y, z):
2155         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2156         self.mesh.SetParameters(Parameters)
2157         return self.editor.AddNode( x, y, z)
2158
2159     ## Creates a 0D element on a node with given number.
2160     #  @param IDOfNode the ID of node for creation of the element.
2161     #  @return the Id of the new 0D element
2162     #  @ingroup l2_modif_add
2163     def Add0DElement(self, IDOfNode):
2164         return self.editor.Add0DElement(IDOfNode)
2165
2166     ## Creates a linear or quadratic edge (this is determined
2167     #  by the number of given nodes).
2168     #  @param IDsOfNodes the list of node IDs for creation of the element.
2169     #  The order of nodes in this list should correspond to the description
2170     #  of MED. \n This description is located by the following link:
2171     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2172     #  @return the Id of the new edge
2173     #  @ingroup l2_modif_add
2174     def AddEdge(self, IDsOfNodes):
2175         return self.editor.AddEdge(IDsOfNodes)
2176
2177     ## Creates a linear or quadratic face (this is determined
2178     #  by the number of given nodes).
2179     #  @param IDsOfNodes the list of node IDs for creation of the element.
2180     #  The order of nodes in this list should correspond to the description
2181     #  of MED. \n This description is located by the following link:
2182     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2183     #  @return the Id of the new face
2184     #  @ingroup l2_modif_add
2185     def AddFace(self, IDsOfNodes):
2186         return self.editor.AddFace(IDsOfNodes)
2187
2188     ## Adds a polygonal face to the mesh by the list of node IDs
2189     #  @param IdsOfNodes the list of node IDs for creation of the element.
2190     #  @return the Id of the new face
2191     #  @ingroup l2_modif_add
2192     def AddPolygonalFace(self, IdsOfNodes):
2193         return self.editor.AddPolygonalFace(IdsOfNodes)
2194
2195     ## Creates both simple and quadratic volume (this is determined
2196     #  by the number of given nodes).
2197     #  @param IDsOfNodes the list of node IDs for creation of the element.
2198     #  The order of nodes in this list should correspond to the description
2199     #  of MED. \n This description is located by the following link:
2200     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2201     #  @return the Id of the new volumic element
2202     #  @ingroup l2_modif_add
2203     def AddVolume(self, IDsOfNodes):
2204         return self.editor.AddVolume(IDsOfNodes)
2205
2206     ## Creates a volume of many faces, giving nodes for each face.
2207     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
2208     #  @param Quantities the list of integer values, Quantities[i]
2209     #         gives the quantity of nodes in face number i.
2210     #  @return the Id of the new volumic element
2211     #  @ingroup l2_modif_add
2212     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2213         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2214
2215     ## Creates a volume of many faces, giving the IDs of the existing faces.
2216     #  @param IdsOfFaces the list of face IDs for volume creation.
2217     #
2218     #  Note:  The created volume will refer only to the nodes
2219     #         of the given faces, not to the faces themselves.
2220     #  @return the Id of the new volumic element
2221     #  @ingroup l2_modif_add
2222     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2223         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2224
2225
2226     ## @brief Binds a node to a vertex
2227     #  @param NodeID a node ID
2228     #  @param Vertex a vertex or vertex ID
2229     #  @return True if succeed else raises an exception
2230     #  @ingroup l2_modif_add
2231     def SetNodeOnVertex(self, NodeID, Vertex):
2232         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2233             VertexID = Vertex.GetSubShapeIndices()[0]
2234         else:
2235             VertexID = Vertex
2236         try:
2237             self.editor.SetNodeOnVertex(NodeID, VertexID)
2238         except SALOME.SALOME_Exception, inst:
2239             raise ValueError, inst.details.text
2240         return True
2241
2242
2243     ## @brief Stores the node position on an edge
2244     #  @param NodeID a node ID
2245     #  @param Edge an edge or edge ID
2246     #  @param paramOnEdge a parameter on the edge where the node is located
2247     #  @return True if succeed else raises an exception
2248     #  @ingroup l2_modif_add
2249     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2250         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2251             EdgeID = Edge.GetSubShapeIndices()[0]
2252         else:
2253             EdgeID = Edge
2254         try:
2255             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2256         except SALOME.SALOME_Exception, inst:
2257             raise ValueError, inst.details.text
2258         return True
2259
2260     ## @brief Stores node position on a face
2261     #  @param NodeID a node ID
2262     #  @param Face a face or face ID
2263     #  @param u U parameter on the face where the node is located
2264     #  @param v V parameter on the face where the node is located
2265     #  @return True if succeed else raises an exception
2266     #  @ingroup l2_modif_add
2267     def SetNodeOnFace(self, NodeID, Face, u, v):
2268         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2269             FaceID = Face.GetSubShapeIndices()[0]
2270         else:
2271             FaceID = Face
2272         try:
2273             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2274         except SALOME.SALOME_Exception, inst:
2275             raise ValueError, inst.details.text
2276         return True
2277
2278     ## @brief Binds a node to a solid
2279     #  @param NodeID a node ID
2280     #  @param Solid  a solid or solid ID
2281     #  @return True if succeed else raises an exception
2282     #  @ingroup l2_modif_add
2283     def SetNodeInVolume(self, NodeID, Solid):
2284         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2285             SolidID = Solid.GetSubShapeIndices()[0]
2286         else:
2287             SolidID = Solid
2288         try:
2289             self.editor.SetNodeInVolume(NodeID, SolidID)
2290         except SALOME.SALOME_Exception, inst:
2291             raise ValueError, inst.details.text
2292         return True
2293
2294     ## @brief Bind an element to a shape
2295     #  @param ElementID an element ID
2296     #  @param Shape a shape or shape ID
2297     #  @return True if succeed else raises an exception
2298     #  @ingroup l2_modif_add
2299     def SetMeshElementOnShape(self, ElementID, Shape):
2300         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2301             ShapeID = Shape.GetSubShapeIndices()[0]
2302         else:
2303             ShapeID = Shape
2304         try:
2305             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2306         except SALOME.SALOME_Exception, inst:
2307             raise ValueError, inst.details.text
2308         return True
2309
2310
2311     ## Moves the node with the given id
2312     #  @param NodeID the id of the node
2313     #  @param x  a new X coordinate
2314     #  @param y  a new Y coordinate
2315     #  @param z  a new Z coordinate
2316     #  @return True if succeed else False
2317     #  @ingroup l2_modif_movenode
2318     def MoveNode(self, NodeID, x, y, z):
2319         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2320         self.mesh.SetParameters(Parameters)
2321         return self.editor.MoveNode(NodeID, x, y, z)
2322
2323     ## Finds the node closest to a point and moves it to a point location
2324     #  @param x  the X coordinate of a point
2325     #  @param y  the Y coordinate of a point
2326     #  @param z  the Z coordinate of a point
2327     #  @param NodeID if specified (>0), the node with this ID is moved,
2328     #  otherwise, the node closest to point (@a x,@a y,@a z) is moved
2329     #  @return the ID of a node
2330     #  @ingroup l2_modif_throughp
2331     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2332         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2333         self.mesh.SetParameters(Parameters)
2334         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2335
2336     ## Finds the node closest to a point
2337     #  @param x  the X coordinate of a point
2338     #  @param y  the Y coordinate of a point
2339     #  @param z  the Z coordinate of a point
2340     #  @return the ID of a node
2341     #  @ingroup l2_modif_throughp
2342     def FindNodeClosestTo(self, x, y, z):
2343         #preview = self.mesh.GetMeshEditPreviewer()
2344         #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2345         return self.editor.FindNodeClosestTo(x, y, z)
2346
2347     ## Finds the elements where a point lays IN or ON
2348     #  @param x  the X coordinate of a point
2349     #  @param y  the Y coordinate of a point
2350     #  @param z  the Z coordinate of a point
2351     #  @param elementType type of elements to find (SMESH.ALL type
2352     #         means elements of any type excluding nodes and 0D elements)
2353     #  @return list of IDs of found elements
2354     #  @ingroup l2_modif_throughp
2355     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2356         return self.editor.FindElementsByPoint(x, y, z, elementType)
2357         
2358     # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2359     # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2360      
2361     def GetPointState(self, x, y, z):
2362         return self.editor.GetPointState(x, y, z)
2363
2364     ## Finds the node closest to a point and moves it to a point location
2365     #  @param x  the X coordinate of a point
2366     #  @param y  the Y coordinate of a point
2367     #  @param z  the Z coordinate of a point
2368     #  @return the ID of a moved node
2369     #  @ingroup l2_modif_throughp
2370     def MeshToPassThroughAPoint(self, x, y, z):
2371         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2372
2373     ## Replaces two neighbour triangles sharing Node1-Node2 link
2374     #  with the triangles built on the same 4 nodes but having other common link.
2375     #  @param NodeID1  the ID of the first node
2376     #  @param NodeID2  the ID of the second node
2377     #  @return false if proper faces were not found
2378     #  @ingroup l2_modif_invdiag
2379     def InverseDiag(self, NodeID1, NodeID2):
2380         return self.editor.InverseDiag(NodeID1, NodeID2)
2381
2382     ## Replaces two neighbour triangles sharing Node1-Node2 link
2383     #  with a quadrangle built on the same 4 nodes.
2384     #  @param NodeID1  the ID of the first node
2385     #  @param NodeID2  the ID of the second node
2386     #  @return false if proper faces were not found
2387     #  @ingroup l2_modif_unitetri
2388     def DeleteDiag(self, NodeID1, NodeID2):
2389         return self.editor.DeleteDiag(NodeID1, NodeID2)
2390
2391     ## Reorients elements by ids
2392     #  @param IDsOfElements if undefined reorients all mesh elements
2393     #  @return True if succeed else False
2394     #  @ingroup l2_modif_changori
2395     def Reorient(self, IDsOfElements=None):
2396         if IDsOfElements == None:
2397             IDsOfElements = self.GetElementsId()
2398         return self.editor.Reorient(IDsOfElements)
2399
2400     ## Reorients all elements of the object
2401     #  @param theObject mesh, submesh or group
2402     #  @return True if succeed else False
2403     #  @ingroup l2_modif_changori
2404     def ReorientObject(self, theObject):
2405         if ( isinstance( theObject, Mesh )):
2406             theObject = theObject.GetMesh()
2407         return self.editor.ReorientObject(theObject)
2408
2409     ## Fuses the neighbouring triangles into quadrangles.
2410     #  @param IDsOfElements The triangles to be fused,
2411     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
2412     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2413     #                       is still performed; theMaxAngle is mesured in radians.
2414     #                       Also it could be a name of variable which defines angle in degrees.
2415     #  @return TRUE in case of success, FALSE otherwise.
2416     #  @ingroup l2_modif_unitetri
2417     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2418         flag = False
2419         if isinstance(MaxAngle,str):
2420             flag = True
2421         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2422         if flag:
2423             MaxAngle = DegreesToRadians(MaxAngle)
2424         if IDsOfElements == []:
2425             IDsOfElements = self.GetElementsId()
2426         self.mesh.SetParameters(Parameters)
2427         Functor = 0
2428         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2429             Functor = theCriterion
2430         else:
2431             Functor = self.smeshpyD.GetFunctor(theCriterion)
2432         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2433
2434     ## Fuses the neighbouring triangles of the object into quadrangles
2435     #  @param theObject is mesh, submesh or group
2436     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2437     #  @param MaxAngle   a max angle between element normals at which the fusion
2438     #                   is still performed; theMaxAngle is mesured in radians.
2439     #  @return TRUE in case of success, FALSE otherwise.
2440     #  @ingroup l2_modif_unitetri
2441     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2442         if ( isinstance( theObject, Mesh )):
2443             theObject = theObject.GetMesh()
2444         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2445
2446     ## Splits quadrangles into triangles.
2447     #  @param IDsOfElements the faces to be splitted.
2448     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2449     #  @return TRUE in case of success, FALSE otherwise.
2450     #  @ingroup l2_modif_cutquadr
2451     def QuadToTri (self, IDsOfElements, theCriterion):
2452         if IDsOfElements == []:
2453             IDsOfElements = self.GetElementsId()
2454         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2455
2456     ## Splits quadrangles into triangles.
2457     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
2458     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2459     #  @return TRUE in case of success, FALSE otherwise.
2460     #  @ingroup l2_modif_cutquadr
2461     def QuadToTriObject (self, theObject, theCriterion):
2462         if ( isinstance( theObject, Mesh )):
2463             theObject = theObject.GetMesh()
2464         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2465
2466     ## Splits quadrangles into triangles.
2467     #  @param IDsOfElements the faces to be splitted
2468     #  @param Diag13        is used to choose a diagonal for splitting.
2469     #  @return TRUE in case of success, FALSE otherwise.
2470     #  @ingroup l2_modif_cutquadr
2471     def SplitQuad (self, IDsOfElements, Diag13):
2472         if IDsOfElements == []:
2473             IDsOfElements = self.GetElementsId()
2474         return self.editor.SplitQuad(IDsOfElements, Diag13)
2475
2476     ## Splits quadrangles into triangles.
2477     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2478     #  @param Diag13    is used to choose a diagonal for splitting.
2479     #  @return TRUE in case of success, FALSE otherwise.
2480     #  @ingroup l2_modif_cutquadr
2481     def SplitQuadObject (self, theObject, Diag13):
2482         if ( isinstance( theObject, Mesh )):
2483             theObject = theObject.GetMesh()
2484         return self.editor.SplitQuadObject(theObject, Diag13)
2485
2486     ## Finds a better splitting of the given quadrangle.
2487     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2488     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
2489     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2490     #          diagonal is better, 0 if error occurs.
2491     #  @ingroup l2_modif_cutquadr
2492     def BestSplit (self, IDOfQuad, theCriterion):
2493         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2494
2495     ## Splits volumic elements into tetrahedrons
2496     #  @param elemIDs either list of elements or mesh or group or submesh
2497     #  @param method  flags passing splitting method:
2498     #         1 - split the hexahedron into 5 tetrahedrons
2499     #         2 - split the hexahedron into 6 tetrahedrons
2500     #  @ingroup l2_modif_cutquadr
2501     def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2502         if isinstance( elemIDs, Mesh ):
2503             elemIDs = elemIDs.GetMesh()
2504         self.editor.SplitVolumesIntoTetra(elemIDs, method)
2505
2506     ## Splits quadrangle faces near triangular facets of volumes
2507     #
2508     #  @ingroup l1_auxiliary
2509     def SplitQuadsNearTriangularFacets(self):
2510         faces_array = self.GetElementsByType(SMESH.FACE)
2511         for face_id in faces_array:
2512             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2513                 quad_nodes = self.mesh.GetElemNodes(face_id)
2514                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2515                 isVolumeFound = False
2516                 for node1_elem in node1_elems:
2517                     if not isVolumeFound:
2518                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2519                             nb_nodes = self.GetElemNbNodes(node1_elem)
2520                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2521                                 volume_elem = node1_elem
2522                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2523                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2524                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2525                                         isVolumeFound = True
2526                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2527                                             self.SplitQuad([face_id], False) # diagonal 2-4
2528                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2529                                         isVolumeFound = True
2530                                         self.SplitQuad([face_id], True) # diagonal 1-3
2531                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2532                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2533                                         isVolumeFound = True
2534                                         self.SplitQuad([face_id], True) # diagonal 1-3
2535
2536     ## @brief Splits hexahedrons into tetrahedrons.
2537     #
2538     #  This operation uses pattern mapping functionality for splitting.
2539     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2540     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2541     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2542     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2543     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2544     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2545     #  @return TRUE in case of success, FALSE otherwise.
2546     #  @ingroup l1_auxiliary
2547     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2548         # Pattern:     5.---------.6
2549         #              /|#*      /|
2550         #             / | #*    / |
2551         #            /  |  # * /  |
2552         #           /   |   # /*  |
2553         # (0,0,1) 4.---------.7 * |
2554         #          |#*  |1   | # *|
2555         #          | # *.----|---#.2
2556         #          |  #/ *   |   /
2557         #          |  /#  *  |  /
2558         #          | /   # * | /
2559         #          |/      #*|/
2560         # (0,0,0) 0.---------.3
2561         pattern_tetra = "!!! Nb of points: \n 8 \n\
2562         !!! Points: \n\
2563         0 0 0  !- 0 \n\
2564         0 1 0  !- 1 \n\
2565         1 1 0  !- 2 \n\
2566         1 0 0  !- 3 \n\
2567         0 0 1  !- 4 \n\
2568         0 1 1  !- 5 \n\
2569         1 1 1  !- 6 \n\
2570         1 0 1  !- 7 \n\
2571         !!! Indices of points of 6 tetras: \n\
2572         0 3 4 1 \n\
2573         7 4 3 1 \n\
2574         4 7 5 1 \n\
2575         6 2 5 7 \n\
2576         1 5 2 7 \n\
2577         2 3 1 7 \n"
2578
2579         pattern = self.smeshpyD.GetPattern()
2580         isDone  = pattern.LoadFromFile(pattern_tetra)
2581         if not isDone:
2582             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2583             return isDone
2584
2585         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2586         isDone = pattern.MakeMesh(self.mesh, False, False)
2587         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2588
2589         # split quafrangle faces near triangular facets of volumes
2590         self.SplitQuadsNearTriangularFacets()
2591
2592         return isDone
2593
2594     ## @brief Split hexahedrons into prisms.
2595     #
2596     #  Uses the pattern mapping functionality for splitting.
2597     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2598     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2599     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2600     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2601     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2602     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2603     #  @return TRUE in case of success, FALSE otherwise.
2604     #  @ingroup l1_auxiliary
2605     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2606         # Pattern:     5.---------.6
2607         #              /|#       /|
2608         #             / | #     / |
2609         #            /  |  #   /  |
2610         #           /   |   # /   |
2611         # (0,0,1) 4.---------.7   |
2612         #          |    |    |    |
2613         #          |   1.----|----.2
2614         #          |   / *   |   /
2615         #          |  /   *  |  /
2616         #          | /     * | /
2617         #          |/       *|/
2618         # (0,0,0) 0.---------.3
2619         pattern_prism = "!!! Nb of points: \n 8 \n\
2620         !!! Points: \n\
2621         0 0 0  !- 0 \n\
2622         0 1 0  !- 1 \n\
2623         1 1 0  !- 2 \n\
2624         1 0 0  !- 3 \n\
2625         0 0 1  !- 4 \n\
2626         0 1 1  !- 5 \n\
2627         1 1 1  !- 6 \n\
2628         1 0 1  !- 7 \n\
2629         !!! Indices of points of 2 prisms: \n\
2630         0 1 3 4 5 7 \n\
2631         2 3 1 6 7 5 \n"
2632
2633         pattern = self.smeshpyD.GetPattern()
2634         isDone  = pattern.LoadFromFile(pattern_prism)
2635         if not isDone:
2636             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2637             return isDone
2638
2639         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2640         isDone = pattern.MakeMesh(self.mesh, False, False)
2641         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2642
2643         # Splits quafrangle faces near triangular facets of volumes
2644         self.SplitQuadsNearTriangularFacets()
2645
2646         return isDone
2647
2648     ## Smoothes elements
2649     #  @param IDsOfElements the list if ids of elements to smooth
2650     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2651     #  Note that nodes built on edges and boundary nodes are always fixed.
2652     #  @param MaxNbOfIterations the maximum number of iterations
2653     #  @param MaxAspectRatio varies in range [1.0, inf]
2654     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2655     #  @return TRUE in case of success, FALSE otherwise.
2656     #  @ingroup l2_modif_smooth
2657     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2658                MaxNbOfIterations, MaxAspectRatio, Method):
2659         if IDsOfElements == []:
2660             IDsOfElements = self.GetElementsId()
2661         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2662         self.mesh.SetParameters(Parameters)
2663         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2664                                   MaxNbOfIterations, MaxAspectRatio, Method)
2665
2666     ## Smoothes elements which belong to the given object
2667     #  @param theObject the object to smooth
2668     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2669     #  Note that nodes built on edges and boundary nodes are always fixed.
2670     #  @param MaxNbOfIterations the maximum number of iterations
2671     #  @param MaxAspectRatio varies in range [1.0, inf]
2672     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2673     #  @return TRUE in case of success, FALSE otherwise.
2674     #  @ingroup l2_modif_smooth
2675     def SmoothObject(self, theObject, IDsOfFixedNodes,
2676                      MaxNbOfIterations, MaxAspectRatio, Method):
2677         if ( isinstance( theObject, Mesh )):
2678             theObject = theObject.GetMesh()
2679         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2680                                         MaxNbOfIterations, MaxAspectRatio, Method)
2681
2682     ## Parametrically smoothes the given elements
2683     #  @param IDsOfElements the list if ids of elements to smooth
2684     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2685     #  Note that nodes built on edges and boundary nodes are always fixed.
2686     #  @param MaxNbOfIterations the maximum number of iterations
2687     #  @param MaxAspectRatio varies in range [1.0, inf]
2688     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2689     #  @return TRUE in case of success, FALSE otherwise.
2690     #  @ingroup l2_modif_smooth
2691     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2692                          MaxNbOfIterations, MaxAspectRatio, Method):
2693         if IDsOfElements == []:
2694             IDsOfElements = self.GetElementsId()
2695         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2696         self.mesh.SetParameters(Parameters)
2697         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2698                                             MaxNbOfIterations, MaxAspectRatio, Method)
2699
2700     ## Parametrically smoothes the elements which belong to the given object
2701     #  @param theObject the object to smooth
2702     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2703     #  Note that nodes built on edges and boundary nodes are always fixed.
2704     #  @param MaxNbOfIterations the maximum number of iterations
2705     #  @param MaxAspectRatio varies in range [1.0, inf]
2706     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2707     #  @return TRUE in case of success, FALSE otherwise.
2708     #  @ingroup l2_modif_smooth
2709     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2710                                MaxNbOfIterations, MaxAspectRatio, Method):
2711         if ( isinstance( theObject, Mesh )):
2712             theObject = theObject.GetMesh()
2713         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2714                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2715
2716     ## Converts the mesh to quadratic, deletes old elements, replacing
2717     #  them with quadratic with the same id.
2718     #  @ingroup l2_modif_tofromqu
2719     def ConvertToQuadratic(self, theForce3d):
2720         self.editor.ConvertToQuadratic(theForce3d)
2721
2722     ## Converts the mesh from quadratic to ordinary,
2723     #  deletes old quadratic elements, \n replacing
2724     #  them with ordinary mesh elements with the same id.
2725     #  @return TRUE in case of success, FALSE otherwise.
2726     #  @ingroup l2_modif_tofromqu
2727     def ConvertFromQuadratic(self):
2728         return self.editor.ConvertFromQuadratic()
2729
2730     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2731     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2732     #  @ingroup l2_modif_edit
2733     def  Make2DMeshFrom3D(self):
2734         return self.editor. Make2DMeshFrom3D()
2735         
2736     ## Renumber mesh nodes
2737     #  @ingroup l2_modif_renumber
2738     def RenumberNodes(self):
2739         self.editor.RenumberNodes()
2740
2741     ## Renumber mesh elements
2742     #  @ingroup l2_modif_renumber
2743     def RenumberElements(self):
2744         self.editor.RenumberElements()
2745
2746     ## Generates new elements by rotation of the elements around the axis
2747     #  @param IDsOfElements the list of ids of elements to sweep
2748     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2749     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2750     #  @param NbOfSteps the number of steps
2751     #  @param Tolerance tolerance
2752     #  @param MakeGroups forces the generation of new groups from existing ones
2753     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2754     #                    of all steps, else - size of each step
2755     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2756     #  @ingroup l2_modif_extrurev
2757     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2758                       MakeGroups=False, TotalAngle=False):
2759         flag = False
2760         if isinstance(AngleInRadians,str):
2761             flag = True
2762         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2763         if flag:
2764             AngleInRadians = DegreesToRadians(AngleInRadians)
2765         if IDsOfElements == []:
2766             IDsOfElements = self.GetElementsId()
2767         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2768             Axis = self.smeshpyD.GetAxisStruct(Axis)
2769         Axis,AxisParameters = ParseAxisStruct(Axis)
2770         if TotalAngle and NbOfSteps:
2771             AngleInRadians /= NbOfSteps
2772         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2773         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2774         self.mesh.SetParameters(Parameters)
2775         if MakeGroups:
2776             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2777                                                        AngleInRadians, NbOfSteps, Tolerance)
2778         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2779         return []
2780
2781     ## Generates new elements by rotation of the elements of object around the axis
2782     #  @param theObject object which elements should be sweeped
2783     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2784     #  @param AngleInRadians the angle of Rotation
2785     #  @param NbOfSteps number of steps
2786     #  @param Tolerance tolerance
2787     #  @param MakeGroups forces the generation of new groups from existing ones
2788     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2789     #                    of all steps, else - size of each step
2790     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2791     #  @ingroup l2_modif_extrurev
2792     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2793                             MakeGroups=False, TotalAngle=False):
2794         flag = False
2795         if isinstance(AngleInRadians,str):
2796             flag = True
2797         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2798         if flag:
2799             AngleInRadians = DegreesToRadians(AngleInRadians)
2800         if ( isinstance( theObject, Mesh )):
2801             theObject = theObject.GetMesh()
2802         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2803             Axis = self.smeshpyD.GetAxisStruct(Axis)
2804         Axis,AxisParameters = ParseAxisStruct(Axis)
2805         if TotalAngle and NbOfSteps:
2806             AngleInRadians /= NbOfSteps
2807         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2808         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2809         self.mesh.SetParameters(Parameters)
2810         if MakeGroups:
2811             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2812                                                              NbOfSteps, Tolerance)
2813         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2814         return []
2815
2816     ## Generates new elements by rotation of the elements of object around the axis
2817     #  @param theObject object which elements should be sweeped
2818     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2819     #  @param AngleInRadians the angle of Rotation
2820     #  @param NbOfSteps number of steps
2821     #  @param Tolerance tolerance
2822     #  @param MakeGroups forces the generation of new groups from existing ones
2823     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2824     #                    of all steps, else - size of each step
2825     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2826     #  @ingroup l2_modif_extrurev
2827     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2828                               MakeGroups=False, TotalAngle=False):
2829         flag = False
2830         if isinstance(AngleInRadians,str):
2831             flag = True
2832         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2833         if flag:
2834             AngleInRadians = DegreesToRadians(AngleInRadians)
2835         if ( isinstance( theObject, Mesh )):
2836             theObject = theObject.GetMesh()
2837         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2838             Axis = self.smeshpyD.GetAxisStruct(Axis)
2839         Axis,AxisParameters = ParseAxisStruct(Axis)
2840         if TotalAngle and NbOfSteps:
2841             AngleInRadians /= NbOfSteps
2842         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2843         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2844         self.mesh.SetParameters(Parameters)
2845         if MakeGroups:
2846             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2847                                                                NbOfSteps, Tolerance)
2848         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2849         return []
2850
2851     ## Generates new elements by rotation of the elements of object around the axis
2852     #  @param theObject object which elements should be sweeped
2853     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2854     #  @param AngleInRadians the angle of Rotation
2855     #  @param NbOfSteps number of steps
2856     #  @param Tolerance tolerance
2857     #  @param MakeGroups forces the generation of new groups from existing ones
2858     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2859     #                    of all steps, else - size of each step
2860     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2861     #  @ingroup l2_modif_extrurev
2862     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2863                               MakeGroups=False, TotalAngle=False):
2864         flag = False
2865         if isinstance(AngleInRadians,str):
2866             flag = True
2867         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2868         if flag:
2869             AngleInRadians = DegreesToRadians(AngleInRadians)
2870         if ( isinstance( theObject, Mesh )):
2871             theObject = theObject.GetMesh()
2872         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2873             Axis = self.smeshpyD.GetAxisStruct(Axis)
2874         Axis,AxisParameters = ParseAxisStruct(Axis)
2875         if TotalAngle and NbOfSteps:
2876             AngleInRadians /= NbOfSteps
2877         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2878         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2879         self.mesh.SetParameters(Parameters)
2880         if MakeGroups:
2881             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2882                                                              NbOfSteps, Tolerance)
2883         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2884         return []
2885
2886     ## Generates new elements by extrusion of the elements with given ids
2887     #  @param IDsOfElements the list of elements ids for extrusion
2888     #  @param StepVector vector, defining the direction and value of extrusion
2889     #  @param NbOfSteps the number of steps
2890     #  @param MakeGroups forces the generation of new groups from existing ones
2891     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2892     #  @ingroup l2_modif_extrurev
2893     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2894         if IDsOfElements == []:
2895             IDsOfElements = self.GetElementsId()
2896         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2897             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2898         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2899         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2900         Parameters = StepVectorParameters + var_separator + Parameters
2901         self.mesh.SetParameters(Parameters)
2902         if MakeGroups:
2903             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2904         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2905         return []
2906
2907     ## Generates new elements by extrusion of the elements with given ids
2908     #  @param IDsOfElements is ids of elements
2909     #  @param StepVector vector, defining the direction and value of extrusion
2910     #  @param NbOfSteps the number of steps
2911     #  @param ExtrFlags sets flags for extrusion
2912     #  @param SewTolerance uses for comparing locations of nodes if flag
2913     #         EXTRUSION_FLAG_SEW is set
2914     #  @param MakeGroups forces the generation of new groups from existing ones
2915     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2916     #  @ingroup l2_modif_extrurev
2917     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2918                           ExtrFlags, SewTolerance, MakeGroups=False):
2919         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2920             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2921         if MakeGroups:
2922             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2923                                                            ExtrFlags, SewTolerance)
2924         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2925                                       ExtrFlags, SewTolerance)
2926         return []
2927
2928     ## Generates new elements by extrusion of the elements which belong to the object
2929     #  @param theObject the object which elements should be processed
2930     #  @param StepVector vector, defining the direction and value of extrusion
2931     #  @param NbOfSteps the number of steps
2932     #  @param MakeGroups forces the generation of new groups from existing ones
2933     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2934     #  @ingroup l2_modif_extrurev
2935     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2936         if ( isinstance( theObject, Mesh )):
2937             theObject = theObject.GetMesh()
2938         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2939             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2940         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2941         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2942         Parameters = StepVectorParameters + var_separator + Parameters
2943         self.mesh.SetParameters(Parameters)
2944         if MakeGroups:
2945             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2946         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2947         return []
2948
2949     ## Generates new elements by extrusion of the elements which belong to the object
2950     #  @param theObject object which elements should be processed
2951     #  @param StepVector vector, defining the direction and value of extrusion
2952     #  @param NbOfSteps the number of steps
2953     #  @param MakeGroups to generate new groups from existing ones
2954     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2955     #  @ingroup l2_modif_extrurev
2956     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2957         if ( isinstance( theObject, Mesh )):
2958             theObject = theObject.GetMesh()
2959         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2960             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2961         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2962         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2963         Parameters = StepVectorParameters + var_separator + Parameters
2964         self.mesh.SetParameters(Parameters)
2965         if MakeGroups:
2966             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2967         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2968         return []
2969
2970     ## Generates new elements by extrusion of the elements which belong to the object
2971     #  @param theObject object which elements should be processed
2972     #  @param StepVector vector, defining the direction and value of extrusion
2973     #  @param NbOfSteps the number of steps
2974     #  @param MakeGroups forces the generation of new groups from existing ones
2975     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2976     #  @ingroup l2_modif_extrurev
2977     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2978         if ( isinstance( theObject, Mesh )):
2979             theObject = theObject.GetMesh()
2980         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2981             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2982         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2983         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2984         Parameters = StepVectorParameters + var_separator + Parameters
2985         self.mesh.SetParameters(Parameters)
2986         if MakeGroups:
2987             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2988         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2989         return []
2990
2991
2992
2993     ## Generates new elements by extrusion of the given elements
2994     #  The path of extrusion must be a meshed edge.
2995     #  @param Base mesh or list of ids of elements for extrusion
2996     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2997     #  @param NodeStart the start node from Path. Defines the direction of extrusion
2998     #  @param HasAngles allows the shape to be rotated around the path
2999     #                   to get the resulting mesh in a helical fashion
3000     #  @param Angles list of angles in radians
3001     #  @param LinearVariation forces the computation of rotation angles as linear
3002     #                         variation of the given Angles along path steps
3003     #  @param HasRefPoint allows using the reference point
3004     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3005     #         The User can specify any point as the Reference Point.
3006     #  @param MakeGroups forces the generation of new groups from existing ones
3007     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
3008     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3009     #          only SMESH::Extrusion_Error otherwise
3010     #  @ingroup l2_modif_extrurev
3011     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3012                             HasAngles, Angles, LinearVariation,
3013                             HasRefPoint, RefPoint, MakeGroups, ElemType):
3014         Angles,AnglesParameters = ParseAngles(Angles)
3015         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3016         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3017             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3018             pass
3019         Parameters = AnglesParameters + var_separator + RefPointParameters
3020         self.mesh.SetParameters(Parameters)
3021
3022         if isinstance(Base,list):
3023             IDsOfElements = []
3024             if Base == []: IDsOfElements = self.GetElementsId()
3025             else: IDsOfElements = Base
3026             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3027                                                    HasAngles, Angles, LinearVariation,
3028                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
3029         else:
3030             if isinstance(Base,Mesh):
3031                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3032                                                           HasAngles, Angles, LinearVariation,
3033                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
3034             else:
3035                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3036
3037
3038     ## Generates new elements by extrusion of the given elements
3039     #  The path of extrusion must be a meshed edge.
3040     #  @param IDsOfElements ids of elements
3041     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3042     #  @param PathShape shape(edge) defines the sub-mesh for the path
3043     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3044     #  @param HasAngles allows the shape to be rotated around the path
3045     #                   to get the resulting mesh in a helical fashion
3046     #  @param Angles list of angles in radians
3047     #  @param HasRefPoint allows using the reference point
3048     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3049     #         The User can specify any point as the Reference Point.
3050     #  @param MakeGroups forces the generation of new groups from existing ones
3051     #  @param LinearVariation forces the computation of rotation angles as linear
3052     #                         variation of the given Angles along path steps
3053     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3054     #          only SMESH::Extrusion_Error otherwise
3055     #  @ingroup l2_modif_extrurev
3056     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3057                            HasAngles, Angles, HasRefPoint, RefPoint,
3058                            MakeGroups=False, LinearVariation=False):
3059         Angles,AnglesParameters = ParseAngles(Angles)
3060         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3061         if IDsOfElements == []:
3062             IDsOfElements = self.GetElementsId()
3063         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3064             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3065             pass
3066         if ( isinstance( PathMesh, Mesh )):
3067             PathMesh = PathMesh.GetMesh()
3068         if HasAngles and Angles and LinearVariation:
3069             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3070             pass
3071         Parameters = AnglesParameters + var_separator + RefPointParameters
3072         self.mesh.SetParameters(Parameters)
3073         if MakeGroups:
3074             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3075                                                             PathShape, NodeStart, HasAngles,
3076                                                             Angles, HasRefPoint, RefPoint)
3077         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3078                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3079
3080     ## Generates new elements by extrusion of the elements which belong to the object
3081     #  The path of extrusion must be a meshed edge.
3082     #  @param theObject the object which elements should be processed
3083     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3084     #  @param PathShape shape(edge) defines the sub-mesh for the path
3085     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3086     #  @param HasAngles allows the shape to be rotated around the path
3087     #                   to get the resulting mesh in a helical fashion
3088     #  @param Angles list of angles
3089     #  @param HasRefPoint allows using the reference point
3090     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3091     #         The User can specify any point as the Reference Point.
3092     #  @param MakeGroups forces the generation of new groups from existing ones
3093     #  @param LinearVariation forces the computation of rotation angles as linear
3094     #                         variation of the given Angles along path steps
3095     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3096     #          only SMESH::Extrusion_Error otherwise
3097     #  @ingroup l2_modif_extrurev
3098     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3099                                  HasAngles, Angles, HasRefPoint, RefPoint,
3100                                  MakeGroups=False, LinearVariation=False):
3101         Angles,AnglesParameters = ParseAngles(Angles)
3102         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3103         if ( isinstance( theObject, Mesh )):
3104             theObject = theObject.GetMesh()
3105         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3106             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3107         if ( isinstance( PathMesh, Mesh )):
3108             PathMesh = PathMesh.GetMesh()
3109         if HasAngles and Angles and LinearVariation:
3110             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3111             pass
3112         Parameters = AnglesParameters + var_separator + RefPointParameters
3113         self.mesh.SetParameters(Parameters)
3114         if MakeGroups:
3115             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3116                                                                   PathShape, NodeStart, HasAngles,
3117                                                                   Angles, HasRefPoint, RefPoint)
3118         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3119                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3120                                                     RefPoint)
3121
3122     ## Generates new elements by extrusion of the elements which belong to the object
3123     #  The path of extrusion must be a meshed edge.
3124     #  @param theObject the object which elements should be processed
3125     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3126     #  @param PathShape shape(edge) defines the sub-mesh for the path
3127     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3128     #  @param HasAngles allows the shape to be rotated around the path
3129     #                   to get the resulting mesh in a helical fashion
3130     #  @param Angles list of angles
3131     #  @param HasRefPoint allows using the reference point
3132     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3133     #         The User can specify any point as the Reference Point.
3134     #  @param MakeGroups forces the generation of new groups from existing ones
3135     #  @param LinearVariation forces the computation of rotation angles as linear
3136     #                         variation of the given Angles along path steps
3137     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3138     #          only SMESH::Extrusion_Error otherwise
3139     #  @ingroup l2_modif_extrurev
3140     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3141                                    HasAngles, Angles, HasRefPoint, RefPoint,
3142                                    MakeGroups=False, LinearVariation=False):
3143         Angles,AnglesParameters = ParseAngles(Angles)
3144         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3145         if ( isinstance( theObject, Mesh )):
3146             theObject = theObject.GetMesh()
3147         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3148             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3149         if ( isinstance( PathMesh, Mesh )):
3150             PathMesh = PathMesh.GetMesh()
3151         if HasAngles and Angles and LinearVariation:
3152             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3153             pass
3154         Parameters = AnglesParameters + var_separator + RefPointParameters
3155         self.mesh.SetParameters(Parameters)
3156         if MakeGroups:
3157             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3158                                                                     PathShape, NodeStart, HasAngles,
3159                                                                     Angles, HasRefPoint, RefPoint)
3160         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3161                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3162                                                       RefPoint)
3163
3164     ## Generates new elements by extrusion of the elements which belong to the object
3165     #  The path of extrusion must be a meshed edge.
3166     #  @param theObject the object which elements should be processed
3167     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3168     #  @param PathShape shape(edge) defines the sub-mesh for the path
3169     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3170     #  @param HasAngles allows the shape to be rotated around the path
3171     #                   to get the resulting mesh in a helical fashion
3172     #  @param Angles list of angles
3173     #  @param HasRefPoint allows using the reference point
3174     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3175     #         The User can specify any point as the Reference Point.
3176     #  @param MakeGroups forces the generation of new groups from existing ones
3177     #  @param LinearVariation forces the computation of rotation angles as linear
3178     #                         variation of the given Angles along path steps
3179     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3180     #          only SMESH::Extrusion_Error otherwise
3181     #  @ingroup l2_modif_extrurev
3182     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3183                                    HasAngles, Angles, HasRefPoint, RefPoint,
3184                                    MakeGroups=False, LinearVariation=False):
3185         Angles,AnglesParameters = ParseAngles(Angles)
3186         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3187         if ( isinstance( theObject, Mesh )):
3188             theObject = theObject.GetMesh()
3189         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3190             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3191         if ( isinstance( PathMesh, Mesh )):
3192             PathMesh = PathMesh.GetMesh()
3193         if HasAngles and Angles and LinearVariation:
3194             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3195             pass
3196         Parameters = AnglesParameters + var_separator + RefPointParameters
3197         self.mesh.SetParameters(Parameters)
3198         if MakeGroups:
3199             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3200                                                                     PathShape, NodeStart, HasAngles,
3201                                                                     Angles, HasRefPoint, RefPoint)
3202         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3203                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3204                                                       RefPoint)
3205
3206     ## Creates a symmetrical copy of mesh elements
3207     #  @param IDsOfElements list of elements ids
3208     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3209     #  @param theMirrorType is  POINT, AXIS or PLANE
3210     #  If the Mirror is a geom object this parameter is unnecessary
3211     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3212     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3213     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3214     #  @ingroup l2_modif_trsf
3215     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3216         if IDsOfElements == []:
3217             IDsOfElements = self.GetElementsId()
3218         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3219             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3220         Mirror,Parameters = ParseAxisStruct(Mirror)
3221         self.mesh.SetParameters(Parameters)
3222         if Copy and MakeGroups:
3223             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3224         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3225         return []
3226
3227     ## Creates a new mesh by a symmetrical copy of mesh elements
3228     #  @param IDsOfElements the list of elements ids
3229     #  @param Mirror is AxisStruct or geom object (point, line, plane)
3230     #  @param theMirrorType is  POINT, AXIS or PLANE
3231     #  If the Mirror is a geom object this parameter is unnecessary
3232     #  @param MakeGroups to generate new groups from existing ones
3233     #  @param NewMeshName a name of the new mesh to create
3234     #  @return instance of Mesh class
3235     #  @ingroup l2_modif_trsf
3236     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3237         if IDsOfElements == []:
3238             IDsOfElements = self.GetElementsId()
3239         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3240             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3241         Mirror,Parameters = ParseAxisStruct(Mirror)
3242         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3243                                           MakeGroups, NewMeshName)
3244         mesh.SetParameters(Parameters)
3245         return Mesh(self.smeshpyD,self.geompyD,mesh)
3246
3247     ## Creates a symmetrical copy of the object
3248     #  @param theObject mesh, submesh or group
3249     #  @param Mirror AxisStruct or geom object (point, line, plane)
3250     #  @param theMirrorType is  POINT, AXIS or PLANE
3251     #  If the Mirror is a geom object this parameter is unnecessary
3252     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3253     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3254     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3255     #  @ingroup l2_modif_trsf
3256     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3257         if ( isinstance( theObject, Mesh )):
3258             theObject = theObject.GetMesh()
3259         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3260             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3261         Mirror,Parameters = ParseAxisStruct(Mirror)
3262         self.mesh.SetParameters(Parameters)
3263         if Copy and MakeGroups:
3264             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3265         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3266         return []
3267
3268     ## Creates a new mesh by a symmetrical copy of the object
3269     #  @param theObject mesh, submesh or group
3270     #  @param Mirror AxisStruct or geom object (point, line, plane)
3271     #  @param theMirrorType POINT, AXIS or PLANE
3272     #  If the Mirror is a geom object this parameter is unnecessary
3273     #  @param MakeGroups forces the generation of new groups from existing ones
3274     #  @param NewMeshName the name of the new mesh to create
3275     #  @return instance of Mesh class
3276     #  @ingroup l2_modif_trsf
3277     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3278         if ( isinstance( theObject, Mesh )):
3279             theObject = theObject.GetMesh()
3280         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3281             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3282         Mirror,Parameters = ParseAxisStruct(Mirror)
3283         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3284                                                 MakeGroups, NewMeshName)
3285         mesh.SetParameters(Parameters)
3286         return Mesh( self.smeshpyD,self.geompyD,mesh )
3287
3288     ## Translates the elements
3289     #  @param IDsOfElements list of elements ids
3290     #  @param Vector the direction of translation (DirStruct or vector)
3291     #  @param Copy allows copying the translated elements
3292     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3293     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3294     #  @ingroup l2_modif_trsf
3295     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3296         if IDsOfElements == []:
3297             IDsOfElements = self.GetElementsId()
3298         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3299             Vector = self.smeshpyD.GetDirStruct(Vector)
3300         Vector,Parameters = ParseDirStruct(Vector)
3301         self.mesh.SetParameters(Parameters)
3302         if Copy and MakeGroups:
3303             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3304         self.editor.Translate(IDsOfElements, Vector, Copy)
3305         return []
3306
3307     ## Creates a new mesh of translated elements
3308     #  @param IDsOfElements list of elements ids
3309     #  @param Vector the direction of translation (DirStruct or vector)
3310     #  @param MakeGroups forces the generation of new groups from existing ones
3311     #  @param NewMeshName the name of the newly created mesh
3312     #  @return instance of Mesh class
3313     #  @ingroup l2_modif_trsf
3314     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3315         if IDsOfElements == []:
3316             IDsOfElements = self.GetElementsId()
3317         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3318             Vector = self.smeshpyD.GetDirStruct(Vector)
3319         Vector,Parameters = ParseDirStruct(Vector)
3320         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3321         mesh.SetParameters(Parameters)
3322         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3323
3324     ## Translates the object
3325     #  @param theObject the object to translate (mesh, submesh, or group)
3326     #  @param Vector direction of translation (DirStruct or geom vector)
3327     #  @param Copy allows copying the translated elements
3328     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3329     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3330     #  @ingroup l2_modif_trsf
3331     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3332         if ( isinstance( theObject, Mesh )):
3333             theObject = theObject.GetMesh()
3334         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3335             Vector = self.smeshpyD.GetDirStruct(Vector)
3336         Vector,Parameters = ParseDirStruct(Vector)
3337         self.mesh.SetParameters(Parameters)
3338         if Copy and MakeGroups:
3339             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3340         self.editor.TranslateObject(theObject, Vector, Copy)
3341         return []
3342
3343     ## Creates a new mesh from the translated object
3344     #  @param theObject the object to translate (mesh, submesh, or group)
3345     #  @param Vector the direction of translation (DirStruct or geom vector)
3346     #  @param MakeGroups forces the generation of new groups from existing ones
3347     #  @param NewMeshName the name of the newly created mesh
3348     #  @return instance of Mesh class
3349     #  @ingroup l2_modif_trsf
3350     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3351         if (isinstance(theObject, Mesh)):
3352             theObject = theObject.GetMesh()
3353         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3354             Vector = self.smeshpyD.GetDirStruct(Vector)
3355         Vector,Parameters = ParseDirStruct(Vector)
3356         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3357         mesh.SetParameters(Parameters)
3358         return Mesh( self.smeshpyD, self.geompyD, mesh )
3359
3360
3361
3362     ## Scales the object
3363     #  @param theObject - the object to translate (mesh, submesh, or group)
3364     #  @param thePoint - base point for scale
3365     #  @param theScaleFact - scale factors for axises
3366     #  @param Copy - allows copying the translated elements
3367     #  @param MakeGroups - forces the generation of new groups from existing
3368     #                      ones (if Copy)
3369     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3370     #          empty list otherwise
3371     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3372         if ( isinstance( theObject, Mesh )):
3373             theObject = theObject.GetMesh()
3374         if ( isinstance( theObject, list )):
3375             theObject = self.editor.MakeIDSource(theObject)
3376
3377         thePoint, Parameters = ParsePointStruct(thePoint)
3378         self.mesh.SetParameters(Parameters)
3379
3380         if Copy and MakeGroups:
3381             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3382         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3383         return []
3384
3385     ## Creates a new mesh from the translated object
3386     #  @param theObject - the object to translate (mesh, submesh, or group)
3387     #  @param thePoint - base point for scale
3388     #  @param theScaleFact - scale factors for axises
3389     #  @param MakeGroups - forces the generation of new groups from existing ones
3390     #  @param NewMeshName - the name of the newly created mesh
3391     #  @return instance of Mesh class
3392     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3393         if (isinstance(theObject, Mesh)):
3394             theObject = theObject.GetMesh()
3395         if ( isinstance( theObject, list )):
3396             theObject = self.editor.MakeIDSource(theObject)
3397
3398         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3399                                          MakeGroups, NewMeshName)
3400         #mesh.SetParameters(Parameters)
3401         return Mesh( self.smeshpyD, self.geompyD, mesh )
3402
3403
3404
3405     ## Rotates the elements
3406     #  @param IDsOfElements list of elements ids
3407     #  @param Axis the axis of rotation (AxisStruct or geom line)
3408     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3409     #  @param Copy allows copying the rotated elements
3410     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3411     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3412     #  @ingroup l2_modif_trsf
3413     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3414         flag = False
3415         if isinstance(AngleInRadians,str):
3416             flag = True
3417         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3418         if flag:
3419             AngleInRadians = DegreesToRadians(AngleInRadians)
3420         if IDsOfElements == []:
3421             IDsOfElements = self.GetElementsId()
3422         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3423             Axis = self.smeshpyD.GetAxisStruct(Axis)
3424         Axis,AxisParameters = ParseAxisStruct(Axis)
3425         Parameters = AxisParameters + var_separator + Parameters
3426         self.mesh.SetParameters(Parameters)
3427         if Copy and MakeGroups:
3428             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3429         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3430         return []
3431
3432     ## Creates a new mesh of rotated elements
3433     #  @param IDsOfElements list of element ids
3434     #  @param Axis the axis of rotation (AxisStruct or geom line)
3435     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3436     #  @param MakeGroups forces the generation of new groups from existing ones
3437     #  @param NewMeshName the name of the newly created mesh
3438     #  @return instance of Mesh class
3439     #  @ingroup l2_modif_trsf
3440     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3441         flag = False
3442         if isinstance(AngleInRadians,str):
3443             flag = True
3444         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3445         if flag:
3446             AngleInRadians = DegreesToRadians(AngleInRadians)
3447         if IDsOfElements == []:
3448             IDsOfElements = self.GetElementsId()
3449         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3450             Axis = self.smeshpyD.GetAxisStruct(Axis)
3451         Axis,AxisParameters = ParseAxisStruct(Axis)
3452         Parameters = AxisParameters + var_separator + Parameters
3453         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3454                                           MakeGroups, NewMeshName)
3455         mesh.SetParameters(Parameters)
3456         return Mesh( self.smeshpyD, self.geompyD, mesh )
3457
3458     ## Rotates the object
3459     #  @param theObject the object to rotate( mesh, submesh, or group)
3460     #  @param Axis the axis of rotation (AxisStruct or geom line)
3461     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3462     #  @param Copy allows copying the rotated elements
3463     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3464     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3465     #  @ingroup l2_modif_trsf
3466     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3467         flag = False
3468         if isinstance(AngleInRadians,str):
3469             flag = True
3470         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3471         if flag:
3472             AngleInRadians = DegreesToRadians(AngleInRadians)
3473         if (isinstance(theObject, Mesh)):
3474             theObject = theObject.GetMesh()
3475         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3476             Axis = self.smeshpyD.GetAxisStruct(Axis)
3477         Axis,AxisParameters = ParseAxisStruct(Axis)
3478         Parameters = AxisParameters + ":" + Parameters
3479         self.mesh.SetParameters(Parameters)
3480         if Copy and MakeGroups:
3481             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3482         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3483         return []
3484
3485     ## Creates a new mesh from the rotated object
3486     #  @param theObject the object to rotate (mesh, submesh, or group)
3487     #  @param Axis the axis of rotation (AxisStruct or geom line)
3488     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3489     #  @param MakeGroups forces the generation of new groups from existing ones
3490     #  @param NewMeshName the name of the newly created mesh
3491     #  @return instance of Mesh class
3492     #  @ingroup l2_modif_trsf
3493     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3494         flag = False
3495         if isinstance(AngleInRadians,str):
3496             flag = True
3497         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3498         if flag:
3499             AngleInRadians = DegreesToRadians(AngleInRadians)
3500         if (isinstance( theObject, Mesh )):
3501             theObject = theObject.GetMesh()
3502         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3503             Axis = self.smeshpyD.GetAxisStruct(Axis)
3504         Axis,AxisParameters = ParseAxisStruct(Axis)
3505         Parameters = AxisParameters + ":" + Parameters
3506         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3507                                                        MakeGroups, NewMeshName)
3508         mesh.SetParameters(Parameters)
3509         return Mesh( self.smeshpyD, self.geompyD, mesh )
3510
3511     ## Finds groups of ajacent nodes within Tolerance.
3512     #  @param Tolerance the value of tolerance
3513     #  @return the list of groups of nodes
3514     #  @ingroup l2_modif_trsf
3515     def FindCoincidentNodes (self, Tolerance):
3516         return self.editor.FindCoincidentNodes(Tolerance)
3517
3518     ## Finds groups of ajacent nodes within Tolerance.
3519     #  @param Tolerance the value of tolerance
3520     #  @param SubMeshOrGroup SubMesh or Group
3521     #  @return the list of groups of nodes
3522     #  @ingroup l2_modif_trsf
3523     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3524         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3525
3526     ## Merges nodes
3527     #  @param GroupsOfNodes the list of groups of nodes
3528     #  @ingroup l2_modif_trsf
3529     def MergeNodes (self, GroupsOfNodes):
3530         self.editor.MergeNodes(GroupsOfNodes)
3531
3532     ## Finds the elements built on the same nodes.
3533     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3534     #  @return a list of groups of equal elements
3535     #  @ingroup l2_modif_trsf
3536     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3537         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3538             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3539         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3540
3541     ## Merges elements in each given group.
3542     #  @param GroupsOfElementsID groups of elements for merging
3543     #  @ingroup l2_modif_trsf
3544     def MergeElements(self, GroupsOfElementsID):
3545         self.editor.MergeElements(GroupsOfElementsID)
3546
3547     ## Leaves one element and removes all other elements built on the same nodes.
3548     #  @ingroup l2_modif_trsf
3549     def MergeEqualElements(self):
3550         self.editor.MergeEqualElements()
3551
3552     ## Sews free borders
3553     #  @return SMESH::Sew_Error
3554     #  @ingroup l2_modif_trsf
3555     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3556                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3557                         CreatePolygons, CreatePolyedrs):
3558         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3559                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3560                                           CreatePolygons, CreatePolyedrs)
3561
3562     ## Sews conform free borders
3563     #  @return SMESH::Sew_Error
3564     #  @ingroup l2_modif_trsf
3565     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3566                                FirstNodeID2, SecondNodeID2):
3567         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3568                                                  FirstNodeID2, SecondNodeID2)
3569
3570     ## Sews border to side
3571     #  @return SMESH::Sew_Error
3572     #  @ingroup l2_modif_trsf
3573     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3574                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3575         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3576                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3577
3578     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3579     #  merged with the nodes of elements of Side2.
3580     #  The number of elements in theSide1 and in theSide2 must be
3581     #  equal and they should have similar nodal connectivity.
3582     #  The nodes to merge should belong to side borders and
3583     #  the first node should be linked to the second.
3584     #  @return SMESH::Sew_Error
3585     #  @ingroup l2_modif_trsf
3586     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3587                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3588                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3589         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3590                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3591                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3592
3593     ## Sets new nodes for the given element.
3594     #  @param ide the element id
3595     #  @param newIDs nodes ids
3596     #  @return If the number of nodes does not correspond to the type of element - returns false
3597     #  @ingroup l2_modif_edit
3598     def ChangeElemNodes(self, ide, newIDs):
3599         return self.editor.ChangeElemNodes(ide, newIDs)
3600
3601     ## If during the last operation of MeshEditor some nodes were
3602     #  created, this method returns the list of their IDs, \n
3603     #  if new nodes were not created - returns empty list
3604     #  @return the list of integer values (can be empty)
3605     #  @ingroup l1_auxiliary
3606     def GetLastCreatedNodes(self):
3607         return self.editor.GetLastCreatedNodes()
3608
3609     ## If during the last operation of MeshEditor some elements were
3610     #  created this method returns the list of their IDs, \n
3611     #  if new elements were not created - returns empty list
3612     #  @return the list of integer values (can be empty)
3613     #  @ingroup l1_auxiliary
3614     def GetLastCreatedElems(self):
3615         return self.editor.GetLastCreatedElems()
3616
3617      ## Creates a hole in a mesh by doubling the nodes of some particular elements
3618     #  @param theNodes identifiers of nodes to be doubled
3619     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
3620     #         nodes. If list of element identifiers is empty then nodes are doubled but 
3621     #         they not assigned to elements
3622     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3623     #  @ingroup l2_modif_edit
3624     def DoubleNodes(self, theNodes, theModifiedElems):
3625         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3626         
3627     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3628     #  This method provided for convenience works as DoubleNodes() described above.
3629     #  @param theNodeId identifiers of node to be doubled
3630     #  @param theModifiedElems identifiers of elements to be updated
3631     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3632     #  @ingroup l2_modif_edit
3633     def DoubleNode(self, theNodeId, theModifiedElems):
3634         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3635         
3636     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3637     #  This method provided for convenience works as DoubleNodes() described above.
3638     #  @param theNodes group of nodes to be doubled
3639     #  @param theModifiedElems group of elements to be updated.
3640     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3641     #  @ingroup l2_modif_edit
3642     def DoubleNodeGroup(self, theNodes, theModifiedElems):
3643         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3644         
3645     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3646     #  This method provided for convenience works as DoubleNodes() described above.
3647     #  @param theNodes list of groups of nodes to be doubled
3648     #  @param theModifiedElems list of groups of elements to be updated.
3649     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3650     #  @ingroup l2_modif_edit
3651     def DoubleNodeGroups(self, theNodes, theModifiedElems):
3652         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3653     
3654     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3655     #  @param theElems - the list of elements (edges or faces) to be replicated
3656     #         The nodes for duplication could be found from these elements
3657     #  @param theNodesNot - list of nodes to NOT replicate
3658     #  @param theAffectedElems - the list of elements (cells and edges) to which the 
3659     #         replicated nodes should be associated to.
3660     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3661     #  @ingroup l2_modif_edit
3662     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3663         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3664         
3665     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3666     #  @param theElems - the list of elements (edges or faces) to be replicated
3667     #         The nodes for duplication could be found from these elements
3668     #  @param theNodesNot - list of nodes to NOT replicate
3669     #  @param theShape - shape to detect affected elements (element which geometric center
3670     #         located on or inside shape).
3671     #         The replicated nodes should be associated to affected elements.
3672     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3673     #  @ingroup l2_modif_edit
3674     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3675         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3676     
3677     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3678     #  This method provided for convenience works as DoubleNodes() described above.
3679     #  @param theElems - group of of elements (edges or faces) to be replicated
3680     #  @param theNodesNot - group of nodes not to replicated
3681     #  @param theAffectedElems - group of elements to which the replicated nodes
3682     #         should be associated to.
3683     #  @ingroup l2_modif_edit
3684     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3685         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3686         
3687     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3688     #  This method provided for convenience works as DoubleNodes() described above.
3689     #  @param theElems - group of of elements (edges or faces) to be replicated
3690     #  @param theNodesNot - group of nodes not to replicated
3691     #  @param theShape - shape to detect affected elements (element which geometric center
3692     #         located on or inside shape).
3693     #         The replicated nodes should be associated to affected elements.
3694     #  @ingroup l2_modif_edit
3695     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3696         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3697         
3698     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3699     #  This method provided for convenience works as DoubleNodes() described above.
3700     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3701     #  @param theNodesNot - list of groups of nodes not to replicated
3702     #  @param theAffectedElems - group of elements to which the replicated nodes
3703     #         should be associated to.
3704     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3705     #  @ingroup l2_modif_edit
3706     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3707         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3708
3709     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3710     #  This method provided for convenience works as DoubleNodes() described above.
3711     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3712     #  @param theNodesNot - list of groups of nodes not to replicated
3713     #  @param theShape - shape to detect affected elements (element which geometric center
3714     #         located on or inside shape).
3715     #         The replicated nodes should be associated to affected elements.
3716     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3717     #  @ingroup l2_modif_edit
3718     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3719         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3720
3721 ## The mother class to define algorithm, it is not recommended to use it directly.
3722 #
3723 #  More details.
3724 #  @ingroup l2_algorithms
3725 class Mesh_Algorithm:
3726     #  @class Mesh_Algorithm
3727     #  @brief Class Mesh_Algorithm
3728
3729     #def __init__(self,smesh):
3730     #    self.smesh=smesh
3731     def __init__(self):
3732         self.mesh = None
3733         self.geom = None
3734         self.subm = None
3735         self.algo = None
3736
3737     ## Finds a hypothesis in the study by its type name and parameters.
3738     #  Finds only the hypotheses created in smeshpyD engine.
3739     #  @return SMESH.SMESH_Hypothesis
3740     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3741         study = smeshpyD.GetCurrentStudy()
3742         #to do: find component by smeshpyD object, not by its data type
3743         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3744         if scomp is not None:
3745             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3746             # Check if the root label of the hypotheses exists
3747             if res and hypRoot is not None:
3748                 iter = study.NewChildIterator(hypRoot)
3749                 # Check all published hypotheses
3750                 while iter.More():
3751                     hypo_so_i = iter.Value()
3752                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3753                     if attr is not None:
3754                         anIOR = attr.Value()
3755                         hypo_o_i = salome.orb.string_to_object(anIOR)
3756                         if hypo_o_i is not None:
3757                             # Check if this is a hypothesis
3758                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3759                             if hypo_i is not None:
3760                                 # Check if the hypothesis belongs to current engine
3761                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3762                                     # Check if this is the required hypothesis
3763                                     if hypo_i.GetName() == hypname:
3764                                         # Check arguments
3765                                         if CompareMethod(hypo_i, args):
3766                                             # found!!!
3767                                             return hypo_i
3768                                         pass
3769                                     pass
3770                                 pass
3771                             pass
3772                         pass
3773                     iter.Next()
3774                     pass
3775                 pass
3776             pass
3777         return None
3778
3779     ## Finds the algorithm in the study by its type name.
3780     #  Finds only the algorithms, which have been created in smeshpyD engine.
3781     #  @return SMESH.SMESH_Algo
3782     def FindAlgorithm (self, algoname, smeshpyD):
3783         study = smeshpyD.GetCurrentStudy()
3784         #to do: find component by smeshpyD object, not by its data type
3785         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3786         if scomp is not None:
3787             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3788             # Check if the root label of the algorithms exists
3789             if res and hypRoot is not None:
3790                 iter = study.NewChildIterator(hypRoot)
3791                 # Check all published algorithms
3792                 while iter.More():
3793                     algo_so_i = iter.Value()
3794                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3795                     if attr is not None:
3796                         anIOR = attr.Value()
3797                         algo_o_i = salome.orb.string_to_object(anIOR)
3798                         if algo_o_i is not None:
3799                             # Check if this is an algorithm
3800                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3801                             if algo_i is not None:
3802                                 # Checks if the algorithm belongs to the current engine
3803                                 if smeshpyD.GetObjectId(algo_i) > 0:
3804                                     # Check if this is the required algorithm
3805                                     if algo_i.GetName() == algoname:
3806                                         # found!!!
3807                                         return algo_i
3808                                     pass
3809                                 pass
3810                             pass
3811                         pass
3812                     iter.Next()
3813                     pass
3814                 pass
3815             pass
3816         return None
3817
3818     ## If the algorithm is global, returns 0; \n
3819     #  else returns the submesh associated to this algorithm.
3820     def GetSubMesh(self):
3821         return self.subm
3822
3823     ## Returns the wrapped mesher.
3824     def GetAlgorithm(self):
3825         return self.algo
3826
3827     ## Gets the list of hypothesis that can be used with this algorithm
3828     def GetCompatibleHypothesis(self):
3829         mylist = []
3830         if self.algo:
3831             mylist = self.algo.GetCompatibleHypothesis()
3832         return mylist
3833
3834     ## Gets the name of the algorithm
3835     def GetName(self):
3836         GetName(self.algo)
3837
3838     ## Sets the name to the algorithm
3839     def SetName(self, name):
3840         self.mesh.smeshpyD.SetName(self.algo, name)
3841
3842     ## Gets the id of the algorithm
3843     def GetId(self):
3844         return self.algo.GetId()
3845
3846     ## Private method.
3847     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3848         if geom is None:
3849             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3850         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3851         if algo is None:
3852             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3853             pass
3854         self.Assign(algo, mesh, geom)
3855         return self.algo
3856
3857     ## Private method
3858     def Assign(self, algo, mesh, geom):
3859         if geom is None:
3860             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3861         self.mesh = mesh
3862         piece = mesh.geom
3863         name = ""
3864         if not geom:
3865             self.geom = piece
3866         else:
3867             self.geom = geom
3868             try:
3869                 name = GetName(geom)
3870                 pass
3871             except:
3872                 name = mesh.geompyD.SubShapeName(geom, piece)
3873                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3874                 pass
3875             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3876
3877         self.algo = algo
3878         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3879         TreatHypoStatus( status, algo.GetName(), name, True )
3880
3881     def CompareHyp (self, hyp, args):
3882         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3883         return False
3884
3885     def CompareEqualHyp (self, hyp, args):
3886         return True
3887
3888     ## Private method
3889     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3890                     UseExisting=0, CompareMethod=""):
3891         hypo = None
3892         if UseExisting:
3893             if CompareMethod == "": CompareMethod = self.CompareHyp
3894             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3895             pass
3896         if hypo is None:
3897             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3898             a = ""
3899             s = "="
3900             i = 0
3901             n = len(args)
3902             while i<n:
3903                 a = a + s + str(args[i])
3904                 s = ","
3905                 i = i + 1
3906                 pass
3907             self.mesh.smeshpyD.SetName(hypo, hyp + a)
3908             pass
3909         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3910         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3911         return hypo
3912
3913     ## Returns entry of the shape to mesh in the study
3914     def MainShapeEntry(self):
3915         entry = ""
3916         if not self.mesh or not self.mesh.GetMesh(): return entry
3917         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3918         study = self.mesh.smeshpyD.GetCurrentStudy()
3919         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
3920         sobj = study.FindObjectIOR(ior)
3921         if sobj: entry = sobj.GetID()
3922         if not entry: return ""
3923         return entry
3924
3925 # Public class: Mesh_Segment
3926 # --------------------------
3927
3928 ## Class to define a segment 1D algorithm for discretization
3929 #
3930 #  More details.
3931 #  @ingroup l3_algos_basic
3932 class Mesh_Segment(Mesh_Algorithm):
3933
3934     ## Private constructor.
3935     def __init__(self, mesh, geom=0):
3936         Mesh_Algorithm.__init__(self)
3937         self.Create(mesh, geom, "Regular_1D")
3938
3939     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3940     #  @param l for the length of segments that cut an edge
3941     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3942     #                    the same parameters, else (default) - creates a new one
3943     #  @param p precision, used for calculation of the number of segments.
3944     #           The precision should be a positive, meaningful value within the range [0,1].
3945     #           In general, the number of segments is calculated with the formula:
3946     #           nb = ceil((edge_length / l) - p)
3947     #           Function ceil rounds its argument to the higher integer.
3948     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3949     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3950     #               p=1 means rounding of (edge_length / l) to the lower integer.
3951     #           Default value is 1e-07.
3952     #  @return an instance of StdMeshers_LocalLength hypothesis
3953     #  @ingroup l3_hypos_1dhyps
3954     def LocalLength(self, l, UseExisting=0, p=1e-07):
3955         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3956                               CompareMethod=self.CompareLocalLength)
3957         hyp.SetLength(l)
3958         hyp.SetPrecision(p)
3959         return hyp
3960
3961     ## Private method
3962     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3963     def CompareLocalLength(self, hyp, args):
3964         if IsEqual(hyp.GetLength(), args[0]):
3965             return IsEqual(hyp.GetPrecision(), args[1])
3966         return False
3967
3968     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3969     #  @param length is optional maximal allowed length of segment, if it is omitted
3970     #                the preestimated length is used that depends on geometry size
3971     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3972     #                     the same parameters, else (default) - create a new one
3973     #  @return an instance of StdMeshers_MaxLength hypothesis
3974     #  @ingroup l3_hypos_1dhyps
3975     def MaxSize(self, length=0.0, UseExisting=0):
3976         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3977         if length > 0.0:
3978             # set given length
3979             hyp.SetLength(length)
3980         if not UseExisting:
3981             # set preestimated length
3982             gen = self.mesh.smeshpyD
3983             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3984                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
3985                                                        False) # <- byMesh
3986             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3987             if preHyp:
3988                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3989                 pass
3990             pass
3991         hyp.SetUsePreestimatedLength( length == 0.0 )
3992         return hyp
3993         
3994     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3995     #  @param n for the number of segments that cut an edge
3996     #  @param s for the scale factor (optional)
3997     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3998     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3999     #                     the same parameters, else (default) - create a new one
4000     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
4001     #  @ingroup l3_hypos_1dhyps
4002     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4003         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4004             reversedEdges, UseExisting = [], reversedEdges
4005         entry = self.MainShapeEntry()
4006         if s == []:
4007             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4008                                   UseExisting=UseExisting,
4009                                   CompareMethod=self.CompareNumberOfSegments)
4010         else:
4011             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4012                                   UseExisting=UseExisting,
4013                                   CompareMethod=self.CompareNumberOfSegments)
4014             hyp.SetDistrType( 1 )
4015             hyp.SetScaleFactor(s)
4016         hyp.SetNumberOfSegments(n)
4017         hyp.SetReversedEdges( reversedEdges )
4018         hyp.SetObjectEntry( entry )
4019         return hyp
4020
4021     ## Private method
4022     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4023     def CompareNumberOfSegments(self, hyp, args):
4024         if hyp.GetNumberOfSegments() == args[0]:
4025             if len(args) == 3:
4026                 if hyp.GetReversedEdges() == args[1]:
4027                     if not args[1] or hyp.GetObjectEntry() == args[2]:
4028                         return True
4029             else:
4030                 if hyp.GetReversedEdges() == args[2]:
4031                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4032                         if hyp.GetDistrType() == 1:
4033                             if IsEqual(hyp.GetScaleFactor(), args[1]):
4034                                 return True
4035         return False
4036
4037     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4038     #  @param start defines the length of the first segment
4039     #  @param end   defines the length of the last  segment
4040     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4041     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4042     #                     the same parameters, else (default) - creates a new one
4043     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4044     #  @ingroup l3_hypos_1dhyps
4045     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4046         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4047             reversedEdges, UseExisting = [], reversedEdges
4048         entry = self.MainShapeEntry()
4049         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4050                               UseExisting=UseExisting,
4051                               CompareMethod=self.CompareArithmetic1D)
4052         hyp.SetStartLength(start)
4053         hyp.SetEndLength(end)
4054         hyp.SetReversedEdges( reversedEdges )
4055         hyp.SetObjectEntry( entry )
4056         return hyp
4057
4058     ## Private method
4059     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4060     def CompareArithmetic1D(self, hyp, args):
4061         if IsEqual(hyp.GetLength(1), args[0]):
4062             if IsEqual(hyp.GetLength(0), args[1]):
4063                 if hyp.GetReversedEdges() == args[2]:
4064                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4065                         return True
4066         return False
4067
4068
4069     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4070     # on curve from 0 to 1 (additionally it is neecessary to check
4071     # orientation of edges and create list of reversed edges if it is
4072     # needed) and sets numbers of segments between given points (default
4073     # values are equals 1
4074     #  @param points defines the list of parameters on curve
4075     #  @param nbSegs defines the list of numbers of segments
4076     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4077     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4078     #                     the same parameters, else (default) - creates a new one
4079     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4080     #  @ingroup l3_hypos_1dhyps
4081     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4082         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4083             reversedEdges, UseExisting = [], reversedEdges
4084         if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4085             for i in range( len( reversedEdges )):
4086                 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4087         entry = self.MainShapeEntry()
4088         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4089                               UseExisting=UseExisting,
4090                               CompareMethod=self.CompareFixedPoints1D)
4091         hyp.SetPoints(points)
4092         hyp.SetNbSegments(nbSegs)
4093         hyp.SetReversedEdges(reversedEdges)
4094         hyp.SetObjectEntry(entry)
4095         return hyp
4096
4097     ## Private method
4098     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4099     ## as the given arguments
4100     def CompareFixedPoints1D(self, hyp, args):
4101         if hyp.GetPoints() == args[0]:
4102             if hyp.GetNbSegments() == args[1]:
4103                 if hyp.GetReversedEdges() == args[2]:
4104                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4105                         return True
4106         return False
4107
4108
4109
4110     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4111     #  @param start defines the length of the first segment
4112     #  @param end   defines the length of the last  segment
4113     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4114     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4115     #                     the same parameters, else (default) - creates a new one
4116     #  @return an instance of StdMeshers_StartEndLength hypothesis
4117     #  @ingroup l3_hypos_1dhyps
4118     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4119         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4120             reversedEdges, UseExisting = [], reversedEdges
4121         entry = self.MainShapeEntry()
4122         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4123                               UseExisting=UseExisting,
4124                               CompareMethod=self.CompareStartEndLength)
4125         hyp.SetStartLength(start)
4126         hyp.SetEndLength(end)
4127         hyp.SetReversedEdges( reversedEdges )
4128         hyp.SetObjectEntry( entry )
4129         return hyp
4130
4131     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4132     def CompareStartEndLength(self, hyp, args):
4133         if IsEqual(hyp.GetLength(1), args[0]):
4134             if IsEqual(hyp.GetLength(0), args[1]):
4135                 if hyp.GetReversedEdges() == args[2]:
4136                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4137                         return True
4138         return False
4139
4140     ## Defines "Deflection1D" hypothesis
4141     #  @param d for the deflection
4142     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4143     #                     the same parameters, else (default) - create a new one
4144     #  @ingroup l3_hypos_1dhyps
4145     def Deflection1D(self, d, UseExisting=0):
4146         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4147                               CompareMethod=self.CompareDeflection1D)
4148         hyp.SetDeflection(d)
4149         return hyp
4150
4151     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4152     def CompareDeflection1D(self, hyp, args):
4153         return IsEqual(hyp.GetDeflection(), args[0])
4154
4155     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4156     #  the opposite side in case of quadrangular faces
4157     #  @ingroup l3_hypos_additi
4158     def Propagation(self):
4159         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4160
4161     ## Defines "AutomaticLength" hypothesis
4162     #  @param fineness for the fineness [0-1]
4163     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
4164     #                     same parameters, else (default) - create a new one
4165     #  @ingroup l3_hypos_1dhyps
4166     def AutomaticLength(self, fineness=0, UseExisting=0):
4167         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4168                               CompareMethod=self.CompareAutomaticLength)
4169         hyp.SetFineness( fineness )
4170         return hyp
4171
4172     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4173     def CompareAutomaticLength(self, hyp, args):
4174         return IsEqual(hyp.GetFineness(), args[0])
4175
4176     ## Defines "SegmentLengthAroundVertex" hypothesis
4177     #  @param length for the segment length
4178     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
4179     #         Any other integer value means that the hypothesis will be set on the
4180     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
4181     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4182     #                   the same parameters, else (default) - creates a new one
4183     #  @ingroup l3_algos_segmarv
4184     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4185         import types
4186         store_geom = self.geom
4187         if type(vertex) is types.IntType:
4188             if vertex == 0 or vertex == 1:
4189                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4190                 self.geom = vertex
4191                 pass
4192             pass
4193         else:
4194             self.geom = vertex
4195             pass
4196         ### 0D algorithm
4197         if self.geom is None:
4198             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4199         try:
4200             name = GetName(self.geom)
4201             pass
4202         except:
4203             piece = self.mesh.geom
4204             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4205             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4206             pass
4207         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4208         if algo is None:
4209             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4210             pass
4211         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4212         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4213         ###
4214         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4215                               CompareMethod=self.CompareLengthNearVertex)
4216         self.geom = store_geom
4217         hyp.SetLength( length )
4218         return hyp
4219
4220     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4221     #  @ingroup l3_algos_segmarv
4222     def CompareLengthNearVertex(self, hyp, args):
4223         return IsEqual(hyp.GetLength(), args[0])
4224
4225     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4226     #  If the 2D mesher sees that all boundary edges are quadratic,
4227     #  it generates quadratic faces, else it generates linear faces using
4228     #  medium nodes as if they are vertices.
4229     #  The 3D mesher generates quadratic volumes only if all boundary faces
4230     #  are quadratic, else it fails.
4231     #
4232     #  @ingroup l3_hypos_additi
4233     def QuadraticMesh(self):
4234         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4235         return hyp
4236
4237 # Public class: Mesh_CompositeSegment
4238 # --------------------------
4239
4240 ## Defines a segment 1D algorithm for discretization
4241 #
4242 #  @ingroup l3_algos_basic
4243 class Mesh_CompositeSegment(Mesh_Segment):
4244
4245     ## Private constructor.
4246     def __init__(self, mesh, geom=0):
4247         self.Create(mesh, geom, "CompositeSegment_1D")
4248
4249
4250 # Public class: Mesh_Segment_Python
4251 # ---------------------------------
4252
4253 ## Defines a segment 1D algorithm for discretization with python function
4254 #
4255 #  @ingroup l3_algos_basic
4256 class Mesh_Segment_Python(Mesh_Segment):
4257
4258     ## Private constructor.
4259     def __init__(self, mesh, geom=0):
4260         import Python1dPlugin
4261         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4262
4263     ## Defines "PythonSplit1D" hypothesis
4264     #  @param n for the number of segments that cut an edge
4265     #  @param func for the python function that calculates the length of all segments
4266     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4267     #                     the same parameters, else (default) - creates a new one
4268     #  @ingroup l3_hypos_1dhyps
4269     def PythonSplit1D(self, n, func, UseExisting=0):
4270         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4271                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4272         hyp.SetNumberOfSegments(n)
4273         hyp.SetPythonLog10RatioFunction(func)
4274         return hyp
4275
4276     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4277     def ComparePythonSplit1D(self, hyp, args):
4278         #if hyp.GetNumberOfSegments() == args[0]:
4279         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
4280         #        return True
4281         return False
4282
4283 # Public class: Mesh_Triangle
4284 # ---------------------------
4285
4286 ## Defines a triangle 2D algorithm
4287 #
4288 #  @ingroup l3_algos_basic
4289 class Mesh_Triangle(Mesh_Algorithm):
4290
4291     # default values
4292     algoType = 0
4293     params = 0
4294
4295     _angleMeshS = 8
4296     _gradation  = 1.1
4297
4298     ## Private constructor.
4299     def __init__(self, mesh, algoType, geom=0):
4300         Mesh_Algorithm.__init__(self)
4301
4302         self.algoType = algoType
4303         if algoType == MEFISTO:
4304             self.Create(mesh, geom, "MEFISTO_2D")
4305             pass
4306         elif algoType == BLSURF:
4307             CheckPlugin(BLSURF)
4308             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4309             #self.SetPhysicalMesh() - PAL19680
4310         elif algoType == NETGEN:
4311             CheckPlugin(NETGEN)
4312             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4313             pass
4314         elif algoType == NETGEN_2D:
4315             CheckPlugin(NETGEN)
4316             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4317             pass
4318
4319     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4320     #  @param area for the maximum area of each triangle
4321     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
4322     #                     same parameters, else (default) - creates a new one
4323     #
4324     #  Only for algoType == MEFISTO || NETGEN_2D
4325     #  @ingroup l3_hypos_2dhyps
4326     def MaxElementArea(self, area, UseExisting=0):
4327         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4328             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4329                                   CompareMethod=self.CompareMaxElementArea)
4330         elif self.algoType == NETGEN:
4331             hyp = self.Parameters(SIMPLE)
4332         hyp.SetMaxElementArea(area)
4333         return hyp
4334
4335     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4336     def CompareMaxElementArea(self, hyp, args):
4337         return IsEqual(hyp.GetMaxElementArea(), args[0])
4338
4339     ## Defines "LengthFromEdges" hypothesis to build triangles
4340     #  based on the length of the edges taken from the wire
4341     #
4342     #  Only for algoType == MEFISTO || NETGEN_2D
4343     #  @ingroup l3_hypos_2dhyps
4344     def LengthFromEdges(self):
4345         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4346             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4347             return hyp
4348         elif self.algoType == NETGEN:
4349             hyp = self.Parameters(SIMPLE)
4350             hyp.LengthFromEdges()
4351             return hyp
4352
4353     ## Sets a way to define size of mesh elements to generate.
4354     #  @param thePhysicalMesh is: DefaultSize or Custom.
4355     #  @ingroup l3_hypos_blsurf
4356     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4357         # Parameter of BLSURF algo
4358         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4359
4360     ## Sets size of mesh elements to generate.
4361     #  @ingroup l3_hypos_blsurf
4362     def SetPhySize(self, theVal):
4363         # Parameter of BLSURF algo
4364         self.SetPhysicalMesh(1) #Custom - else why to set the size?
4365         self.Parameters().SetPhySize(theVal)
4366
4367     ## Sets lower boundary of mesh element size (PhySize).
4368     #  @ingroup l3_hypos_blsurf
4369     def SetPhyMin(self, theVal=-1):
4370         #  Parameter of BLSURF algo
4371         self.Parameters().SetPhyMin(theVal)
4372
4373     ## Sets upper boundary of mesh element size (PhySize).
4374     #  @ingroup l3_hypos_blsurf
4375     def SetPhyMax(self, theVal=-1):
4376         #  Parameter of BLSURF algo
4377         self.Parameters().SetPhyMax(theVal)
4378
4379     ## Sets a way to define maximum angular deflection of mesh from CAD model.
4380     #  @param theGeometricMesh is: DefaultGeom or Custom
4381     #  @ingroup l3_hypos_blsurf
4382     def SetGeometricMesh(self, theGeometricMesh=0):
4383         #  Parameter of BLSURF algo
4384         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4385         self.params.SetGeometricMesh(theGeometricMesh)
4386
4387     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4388     #  @ingroup l3_hypos_blsurf
4389     def SetAngleMeshS(self, theVal=_angleMeshS):
4390         #  Parameter of BLSURF algo
4391         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4392         self.params.SetAngleMeshS(theVal)
4393
4394     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4395     #  @ingroup l3_hypos_blsurf
4396     def SetAngleMeshC(self, theVal=_angleMeshS):
4397         #  Parameter of BLSURF algo
4398         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4399         self.params.SetAngleMeshC(theVal)
4400
4401     ## Sets lower boundary of mesh element size computed to respect angular deflection.
4402     #  @ingroup l3_hypos_blsurf
4403     def SetGeoMin(self, theVal=-1):
4404         #  Parameter of BLSURF algo
4405         self.Parameters().SetGeoMin(theVal)
4406
4407     ## Sets upper boundary of mesh element size computed to respect angular deflection.
4408     #  @ingroup l3_hypos_blsurf
4409     def SetGeoMax(self, theVal=-1):
4410         #  Parameter of BLSURF algo
4411         self.Parameters().SetGeoMax(theVal)
4412
4413     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4414     #  @ingroup l3_hypos_blsurf
4415     def SetGradation(self, theVal=_gradation):
4416         #  Parameter of BLSURF algo
4417         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4418         self.params.SetGradation(theVal)
4419
4420     ## Sets topology usage way.
4421     # @param way defines how mesh conformity is assured <ul>
4422     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4423     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4424     #  @ingroup l3_hypos_blsurf
4425     def SetTopology(self, way):
4426         #  Parameter of BLSURF algo
4427         self.Parameters().SetTopology(way)
4428
4429     ## To respect geometrical edges or not.
4430     #  @ingroup l3_hypos_blsurf
4431     def SetDecimesh(self, toIgnoreEdges=False):
4432         #  Parameter of BLSURF algo
4433         self.Parameters().SetDecimesh(toIgnoreEdges)
4434
4435     ## Sets verbosity level in the range 0 to 100.
4436     #  @ingroup l3_hypos_blsurf
4437     def SetVerbosity(self, level):
4438         #  Parameter of BLSURF algo
4439         self.Parameters().SetVerbosity(level)
4440
4441     ## Sets advanced option value.
4442     #  @ingroup l3_hypos_blsurf
4443     def SetOptionValue(self, optionName, level):
4444         #  Parameter of BLSURF algo
4445         self.Parameters().SetOptionValue(optionName,level)
4446
4447     ## Sets QuadAllowed flag.
4448     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
4449     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
4450     def SetQuadAllowed(self, toAllow=True):
4451         if self.algoType == NETGEN_2D:
4452             if toAllow: # add QuadranglePreference
4453                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4454             else:       # remove QuadranglePreference
4455                 for hyp in self.mesh.GetHypothesisList( self.geom ):
4456                     if hyp.GetName() == "QuadranglePreference":
4457                         self.mesh.RemoveHypothesis( self.geom, hyp )
4458                         pass
4459                     pass
4460                 pass
4461             return
4462         if self.Parameters():
4463             self.params.SetQuadAllowed(toAllow)
4464             return
4465
4466     ## Defines hypothesis having several parameters
4467     #
4468     #  @ingroup l3_hypos_netgen
4469     def Parameters(self, which=SOLE):
4470         if self.params:
4471             return self.params
4472         if self.algoType == NETGEN:
4473             if which == SIMPLE:
4474                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4475                                               "libNETGENEngine.so", UseExisting=0)
4476             else:
4477                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4478                                               "libNETGENEngine.so", UseExisting=0)
4479             return self.params
4480         elif self.algoType == MEFISTO:
4481             print "Mefisto algo support no multi-parameter hypothesis"
4482             return None
4483         elif self.algoType == NETGEN_2D:
4484             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4485             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4486             return None
4487         elif self.algoType == BLSURF:
4488             self.params = self.Hypothesis("BLSURF_Parameters", [],
4489                                           "libBLSURFEngine.so", UseExisting=0)
4490             return self.params
4491         else:
4492             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4493         return None
4494
4495     ## Sets MaxSize
4496     #
4497     #  Only for algoType == NETGEN
4498     #  @ingroup l3_hypos_netgen
4499     def SetMaxSize(self, theSize):
4500         if self.Parameters():
4501             self.params.SetMaxSize(theSize)
4502
4503     ## Sets SecondOrder flag
4504     #
4505     #  Only for algoType == NETGEN
4506     #  @ingroup l3_hypos_netgen
4507     def SetSecondOrder(self, theVal):
4508         if self.Parameters():
4509             self.params.SetSecondOrder(theVal)
4510
4511     ## Sets Optimize flag
4512     #
4513     #  Only for algoType == NETGEN
4514     #  @ingroup l3_hypos_netgen
4515     def SetOptimize(self, theVal):
4516         if self.Parameters():
4517             self.params.SetOptimize(theVal)
4518
4519     ## Sets Fineness
4520     #  @param theFineness is:
4521     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4522     #
4523     #  Only for algoType == NETGEN
4524     #  @ingroup l3_hypos_netgen
4525     def SetFineness(self, theFineness):
4526         if self.Parameters():
4527             self.params.SetFineness(theFineness)
4528
4529     ## Sets GrowthRate
4530     #
4531     #  Only for algoType == NETGEN
4532     #  @ingroup l3_hypos_netgen
4533     def SetGrowthRate(self, theRate):
4534         if self.Parameters():
4535             self.params.SetGrowthRate(theRate)
4536
4537     ## Sets NbSegPerEdge
4538     #
4539     #  Only for algoType == NETGEN
4540     #  @ingroup l3_hypos_netgen
4541     def SetNbSegPerEdge(self, theVal):
4542         if self.Parameters():
4543             self.params.SetNbSegPerEdge(theVal)
4544
4545     ## Sets NbSegPerRadius
4546     #
4547     #  Only for algoType == NETGEN
4548     #  @ingroup l3_hypos_netgen
4549     def SetNbSegPerRadius(self, theVal):
4550         if self.Parameters():
4551             self.params.SetNbSegPerRadius(theVal)
4552
4553     ## Sets number of segments overriding value set by SetLocalLength()
4554     #
4555     #  Only for algoType == NETGEN
4556     #  @ingroup l3_hypos_netgen
4557     def SetNumberOfSegments(self, theVal):
4558         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4559
4560     ## Sets number of segments overriding value set by SetNumberOfSegments()
4561     #
4562     #  Only for algoType == NETGEN
4563     #  @ingroup l3_hypos_netgen
4564     def SetLocalLength(self, theVal):
4565         self.Parameters(SIMPLE).SetLocalLength(theVal)
4566
4567     pass
4568
4569
4570 # Public class: Mesh_Quadrangle
4571 # -----------------------------
4572
4573 ## Defines a quadrangle 2D algorithm
4574 #
4575 #  @ingroup l3_algos_basic
4576 class Mesh_Quadrangle(Mesh_Algorithm):
4577
4578     ## Private constructor.
4579     def __init__(self, mesh, geom=0):
4580         Mesh_Algorithm.__init__(self)
4581         self.Create(mesh, geom, "Quadrangle_2D")
4582
4583     ## Defines "QuadranglePreference" hypothesis, forcing construction
4584     #  of quadrangles if the number of nodes on the opposite edges is not the same
4585     #  while the total number of nodes on edges is even
4586     #
4587     #  @ingroup l3_hypos_additi
4588     def QuadranglePreference(self):
4589         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4590                               CompareMethod=self.CompareEqualHyp)
4591         return hyp
4592
4593     ## Defines "TrianglePreference" hypothesis, forcing construction
4594     #  of triangles in the refinement area if the number of nodes
4595     #  on the opposite edges is not the same
4596     #
4597     #  @ingroup l3_hypos_additi
4598     def TrianglePreference(self):
4599         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4600                               CompareMethod=self.CompareEqualHyp)
4601         return hyp
4602
4603     ## Defines "QuadrangleParams" hypothesis
4604     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
4605     #                 will be created while other elements will be quadrangles.
4606     #                 Vertex can be either a GEOM_Object or a vertex ID within the
4607     #                 shape to mesh
4608     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
4609     #                   the same parameters, else (default) - creates a new one
4610     #
4611     #  @ingroup l3_hypos_additi
4612     def TriangleVertex(self, vertex, UseExisting=0):
4613         vertexID = vertex
4614         if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4615             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4616         hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4617                               CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4618         hyp.SetTriaVertex( vertexID )
4619         return hyp
4620
4621
4622 # Public class: Mesh_Tetrahedron
4623 # ------------------------------
4624
4625 ## Defines a tetrahedron 3D algorithm
4626 #
4627 #  @ingroup l3_algos_basic
4628 class Mesh_Tetrahedron(Mesh_Algorithm):
4629
4630     params = 0
4631     algoType = 0
4632
4633     ## Private constructor.
4634     def __init__(self, mesh, algoType, geom=0):
4635         Mesh_Algorithm.__init__(self)
4636
4637         if algoType == NETGEN:
4638             CheckPlugin(NETGEN)
4639             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4640             pass
4641
4642         elif algoType == FULL_NETGEN:
4643             CheckPlugin(NETGEN)
4644             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4645             pass
4646
4647         elif algoType == GHS3D:
4648             CheckPlugin(GHS3D)
4649             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4650             pass
4651
4652         elif algoType == GHS3DPRL:
4653             CheckPlugin(GHS3DPRL)
4654             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4655             pass
4656
4657         self.algoType = algoType
4658
4659     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4660     #  @param vol for the maximum volume of each tetrahedron
4661     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4662     #                   the same parameters, else (default) - creates a new one
4663     #  @ingroup l3_hypos_maxvol
4664     def MaxElementVolume(self, vol, UseExisting=0):
4665         if self.algoType == NETGEN:
4666             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4667                                   CompareMethod=self.CompareMaxElementVolume)
4668             hyp.SetMaxElementVolume(vol)
4669             return hyp
4670         elif self.algoType == FULL_NETGEN:
4671             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4672         return None
4673
4674     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4675     def CompareMaxElementVolume(self, hyp, args):
4676         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4677
4678     ## Defines hypothesis having several parameters
4679     #
4680     #  @ingroup l3_hypos_netgen
4681     def Parameters(self, which=SOLE):
4682         if self.params:
4683             return self.params
4684
4685         if self.algoType == FULL_NETGEN:
4686             if which == SIMPLE:
4687                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4688                                               "libNETGENEngine.so", UseExisting=0)
4689             else:
4690                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4691                                               "libNETGENEngine.so", UseExisting=0)
4692             return self.params
4693
4694         if self.algoType == GHS3D:
4695             self.params = self.Hypothesis("GHS3D_Parameters", [],
4696                                           "libGHS3DEngine.so", UseExisting=0)
4697             return self.params
4698
4699         if self.algoType == GHS3DPRL:
4700             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4701                                           "libGHS3DPRLEngine.so", UseExisting=0)
4702             return self.params
4703
4704         print "Algo supports no multi-parameter hypothesis"
4705         return None
4706
4707     ## Sets MaxSize
4708     #  Parameter of FULL_NETGEN
4709     #  @ingroup l3_hypos_netgen
4710     def SetMaxSize(self, theSize):
4711         self.Parameters().SetMaxSize(theSize)
4712
4713     ## Sets SecondOrder flag
4714     #  Parameter of FULL_NETGEN
4715     #  @ingroup l3_hypos_netgen
4716     def SetSecondOrder(self, theVal):
4717         self.Parameters().SetSecondOrder(theVal)
4718
4719     ## Sets Optimize flag
4720     #  Parameter of FULL_NETGEN
4721     #  @ingroup l3_hypos_netgen
4722     def SetOptimize(self, theVal):
4723         self.Parameters().SetOptimize(theVal)
4724
4725     ## Sets Fineness
4726     #  @param theFineness is:
4727     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4728     #  Parameter of FULL_NETGEN
4729     #  @ingroup l3_hypos_netgen
4730     def SetFineness(self, theFineness):
4731         self.Parameters().SetFineness(theFineness)
4732
4733     ## Sets GrowthRate
4734     #  Parameter of FULL_NETGEN
4735     #  @ingroup l3_hypos_netgen
4736     def SetGrowthRate(self, theRate):
4737         self.Parameters().SetGrowthRate(theRate)
4738
4739     ## Sets NbSegPerEdge
4740     #  Parameter of FULL_NETGEN
4741     #  @ingroup l3_hypos_netgen
4742     def SetNbSegPerEdge(self, theVal):
4743         self.Parameters().SetNbSegPerEdge(theVal)
4744
4745     ## Sets NbSegPerRadius
4746     #  Parameter of FULL_NETGEN
4747     #  @ingroup l3_hypos_netgen
4748     def SetNbSegPerRadius(self, theVal):
4749         self.Parameters().SetNbSegPerRadius(theVal)
4750
4751     ## Sets number of segments overriding value set by SetLocalLength()
4752     #  Only for algoType == NETGEN_FULL
4753     #  @ingroup l3_hypos_netgen
4754     def SetNumberOfSegments(self, theVal):
4755         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4756
4757     ## Sets number of segments overriding value set by SetNumberOfSegments()
4758     #  Only for algoType == NETGEN_FULL
4759     #  @ingroup l3_hypos_netgen
4760     def SetLocalLength(self, theVal):
4761         self.Parameters(SIMPLE).SetLocalLength(theVal)
4762
4763     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4764     #  Overrides value set by LengthFromEdges()
4765     #  Only for algoType == NETGEN_FULL
4766     #  @ingroup l3_hypos_netgen
4767     def MaxElementArea(self, area):
4768         self.Parameters(SIMPLE).SetMaxElementArea(area)
4769
4770     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4771     #  Overrides value set by MaxElementArea()
4772     #  Only for algoType == NETGEN_FULL
4773     #  @ingroup l3_hypos_netgen
4774     def LengthFromEdges(self):
4775         self.Parameters(SIMPLE).LengthFromEdges()
4776
4777     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4778     #  Overrides value set by MaxElementVolume()
4779     #  Only for algoType == NETGEN_FULL
4780     #  @ingroup l3_hypos_netgen
4781     def LengthFromFaces(self):
4782         self.Parameters(SIMPLE).LengthFromFaces()
4783
4784     ## To mesh "holes" in a solid or not. Default is to mesh.
4785     #  @ingroup l3_hypos_ghs3dh
4786     def SetToMeshHoles(self, toMesh):
4787         #  Parameter of GHS3D
4788         self.Parameters().SetToMeshHoles(toMesh)
4789
4790     ## Set Optimization level:
4791     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4792     #   Strong_Optimization.
4793     # Default is Standard_Optimization
4794     #  @ingroup l3_hypos_ghs3dh
4795     def SetOptimizationLevel(self, level):
4796         #  Parameter of GHS3D
4797         self.Parameters().SetOptimizationLevel(level)
4798
4799     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4800     #  @ingroup l3_hypos_ghs3dh
4801     def SetMaximumMemory(self, MB):
4802         #  Advanced parameter of GHS3D
4803         self.Parameters().SetMaximumMemory(MB)
4804
4805     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4806     #  automatic memory adjustment mode.
4807     #  @ingroup l3_hypos_ghs3dh
4808     def SetInitialMemory(self, MB):
4809         #  Advanced parameter of GHS3D
4810         self.Parameters().SetInitialMemory(MB)
4811
4812     ## Path to working directory.
4813     #  @ingroup l3_hypos_ghs3dh
4814     def SetWorkingDirectory(self, path):
4815         #  Advanced parameter of GHS3D
4816         self.Parameters().SetWorkingDirectory(path)
4817
4818     ## To keep working files or remove them. Log file remains in case of errors anyway.
4819     #  @ingroup l3_hypos_ghs3dh
4820     def SetKeepFiles(self, toKeep):
4821         #  Advanced parameter of GHS3D and GHS3DPRL
4822         self.Parameters().SetKeepFiles(toKeep)
4823
4824     ## To set verbose level [0-10]. <ul>
4825     #<li> 0 - no standard output,
4826     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4827     #     indicates when the final mesh is being saved. In addition the software
4828     #     gives indication regarding the CPU time.
4829     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4830     #     histogram of the skin mesh, quality statistics histogram together with
4831     #     the characteristics of the final mesh.</ul>
4832     #  @ingroup l3_hypos_ghs3dh
4833     def SetVerboseLevel(self, level):
4834         #  Advanced parameter of GHS3D
4835         self.Parameters().SetVerboseLevel(level)
4836
4837     ## To create new nodes.
4838     #  @ingroup l3_hypos_ghs3dh
4839     def SetToCreateNewNodes(self, toCreate):
4840         #  Advanced parameter of GHS3D
4841         self.Parameters().SetToCreateNewNodes(toCreate)
4842
4843     ## To use boundary recovery version which tries to create mesh on a very poor
4844     #  quality surface mesh.
4845     #  @ingroup l3_hypos_ghs3dh
4846     def SetToUseBoundaryRecoveryVersion(self, toUse):
4847         #  Advanced parameter of GHS3D
4848         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4849
4850     ## Sets command line option as text.
4851     #  @ingroup l3_hypos_ghs3dh
4852     def SetTextOption(self, option):
4853         #  Advanced parameter of GHS3D
4854         self.Parameters().SetTextOption(option)
4855
4856     ## Sets MED files name and path.
4857     def SetMEDName(self, value):
4858         self.Parameters().SetMEDName(value)
4859
4860     ## Sets the number of partition of the initial mesh
4861     def SetNbPart(self, value):
4862         self.Parameters().SetNbPart(value)
4863
4864     ## When big mesh, start tepal in background
4865     def SetBackground(self, value):
4866         self.Parameters().SetBackground(value)
4867
4868 # Public class: Mesh_Hexahedron
4869 # ------------------------------
4870
4871 ## Defines a hexahedron 3D algorithm
4872 #
4873 #  @ingroup l3_algos_basic
4874 class Mesh_Hexahedron(Mesh_Algorithm):
4875
4876     params = 0
4877     algoType = 0
4878
4879     ## Private constructor.
4880     def __init__(self, mesh, algoType=Hexa, geom=0):
4881         Mesh_Algorithm.__init__(self)
4882
4883         self.algoType = algoType
4884
4885         if algoType == Hexa:
4886             self.Create(mesh, geom, "Hexa_3D")
4887             pass
4888
4889         elif algoType == Hexotic:
4890             CheckPlugin(Hexotic)
4891             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4892             pass
4893
4894     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4895     #  @ingroup l3_hypos_hexotic
4896     def MinMaxQuad(self, min=3, max=8, quad=True):
4897         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4898                                       UseExisting=0)
4899         self.params.SetHexesMinLevel(min)
4900         self.params.SetHexesMaxLevel(max)
4901         self.params.SetHexoticQuadrangles(quad)
4902         return self.params
4903
4904 # Deprecated, only for compatibility!
4905 # Public class: Mesh_Netgen
4906 # ------------------------------
4907
4908 ## Defines a NETGEN-based 2D or 3D algorithm
4909 #  that needs no discrete boundary (i.e. independent)
4910 #
4911 #  This class is deprecated, only for compatibility!
4912 #
4913 #  More details.
4914 #  @ingroup l3_algos_basic
4915 class Mesh_Netgen(Mesh_Algorithm):
4916
4917     is3D = 0
4918
4919     ## Private constructor.
4920     def __init__(self, mesh, is3D, geom=0):
4921         Mesh_Algorithm.__init__(self)
4922
4923         CheckPlugin(NETGEN)
4924
4925         self.is3D = is3D
4926         if is3D:
4927             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4928             pass
4929
4930         else:
4931             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4932             pass
4933
4934     ## Defines the hypothesis containing parameters of the algorithm
4935     def Parameters(self):
4936         if self.is3D:
4937             hyp = self.Hypothesis("NETGEN_Parameters", [],
4938                                   "libNETGENEngine.so", UseExisting=0)
4939         else:
4940             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4941                                   "libNETGENEngine.so", UseExisting=0)
4942         return hyp
4943
4944 # Public class: Mesh_Projection1D
4945 # ------------------------------
4946
4947 ## Defines a projection 1D algorithm
4948 #  @ingroup l3_algos_proj
4949 #
4950 class Mesh_Projection1D(Mesh_Algorithm):
4951
4952     ## Private constructor.
4953     def __init__(self, mesh, geom=0):
4954         Mesh_Algorithm.__init__(self)
4955         self.Create(mesh, geom, "Projection_1D")
4956
4957     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4958     #  a mesh pattern is taken, and, optionally, the association of vertices
4959     #  between the source edge and a target edge (to which a hypothesis is assigned)
4960     #  @param edge from which nodes distribution is taken
4961     #  @param mesh from which nodes distribution is taken (optional)
4962     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4963     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4964     #  to associate with \a srcV (optional)
4965     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4966     #                     the same parameters, else (default) - creates a new one
4967     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4968         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4969                               UseExisting=0)
4970                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4971         hyp.SetSourceEdge( edge )
4972         if not mesh is None and isinstance(mesh, Mesh):
4973             mesh = mesh.GetMesh()
4974         hyp.SetSourceMesh( mesh )
4975         hyp.SetVertexAssociation( srcV, tgtV )
4976         return hyp
4977
4978     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4979     #def CompareSourceEdge(self, hyp, args):
4980     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4981     #    return False
4982
4983
4984 # Public class: Mesh_Projection2D
4985 # ------------------------------
4986
4987 ## Defines a projection 2D algorithm
4988 #  @ingroup l3_algos_proj
4989 #
4990 class Mesh_Projection2D(Mesh_Algorithm):
4991
4992     ## Private constructor.
4993     def __init__(self, mesh, geom=0):
4994         Mesh_Algorithm.__init__(self)
4995         self.Create(mesh, geom, "Projection_2D")
4996
4997     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4998     #  a mesh pattern is taken, and, optionally, the association of vertices
4999     #  between the source face and the target face (to which a hypothesis is assigned)
5000     #  @param face from which the mesh pattern is taken
5001     #  @param mesh from which the mesh pattern is taken (optional)
5002     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5003     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5004     #               to associate with \a srcV1 (optional)
5005     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5006     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5007     #               to associate with \a srcV2 (optional)
5008     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
5009     #                     the same parameters, else (default) - forces the creation a new one
5010     #
5011     #  Note: all association vertices must belong to one edge of a face
5012     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5013                    srcV2=None, tgtV2=None, UseExisting=0):
5014         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5015                               UseExisting=0)
5016                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5017         hyp.SetSourceFace( face )
5018         if not mesh is None and isinstance(mesh, Mesh):
5019             mesh = mesh.GetMesh()
5020         hyp.SetSourceMesh( mesh )
5021         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5022         return hyp
5023
5024     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5025     #def CompareSourceFace(self, hyp, args):
5026     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5027     #    return False
5028
5029 # Public class: Mesh_Projection3D
5030 # ------------------------------
5031
5032 ## Defines a projection 3D algorithm
5033 #  @ingroup l3_algos_proj
5034 #
5035 class Mesh_Projection3D(Mesh_Algorithm):
5036
5037     ## Private constructor.
5038     def __init__(self, mesh, geom=0):
5039         Mesh_Algorithm.__init__(self)
5040         self.Create(mesh, geom, "Projection_3D")
5041
5042     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5043     #  the mesh pattern is taken, and, optionally, the  association of vertices
5044     #  between the source and the target solid  (to which a hipothesis is assigned)
5045     #  @param solid from where the mesh pattern is taken
5046     #  @param mesh from where the mesh pattern is taken (optional)
5047     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5048     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5049     #  to associate with \a srcV1 (optional)
5050     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5051     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5052     #  to associate with \a srcV2 (optional)
5053     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
5054     #                     the same parameters, else (default) - creates a new one
5055     #
5056     #  Note: association vertices must belong to one edge of a solid
5057     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5058                       srcV2=0, tgtV2=0, UseExisting=0):
5059         hyp = self.Hypothesis("ProjectionSource3D",
5060                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5061                               UseExisting=0)
5062                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5063         hyp.SetSource3DShape( solid )
5064         if not mesh is None and isinstance(mesh, Mesh):
5065             mesh = mesh.GetMesh()
5066         hyp.SetSourceMesh( mesh )
5067         if srcV1 and srcV2 and tgtV1 and tgtV2:
5068             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5069         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5070         return hyp
5071
5072     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5073     #def CompareSourceShape3D(self, hyp, args):
5074     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5075     #    return False
5076
5077
5078 # Public class: Mesh_Prism
5079 # ------------------------
5080
5081 ## Defines a 3D extrusion algorithm
5082 #  @ingroup l3_algos_3dextr
5083 #
5084 class Mesh_Prism3D(Mesh_Algorithm):
5085
5086     ## Private constructor.
5087     def __init__(self, mesh, geom=0):
5088         Mesh_Algorithm.__init__(self)
5089         self.Create(mesh, geom, "Prism_3D")
5090
5091 # Public class: Mesh_RadialPrism
5092 # -------------------------------
5093
5094 ## Defines a Radial Prism 3D algorithm
5095 #  @ingroup l3_algos_radialp
5096 #
5097 class Mesh_RadialPrism3D(Mesh_Algorithm):
5098
5099     ## Private constructor.
5100     def __init__(self, mesh, geom=0):
5101         Mesh_Algorithm.__init__(self)
5102         self.Create(mesh, geom, "RadialPrism_3D")
5103
5104         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5105         self.nbLayers = None
5106
5107     ## Return 3D hypothesis holding the 1D one
5108     def Get3DHypothesis(self):
5109         return self.distribHyp
5110
5111     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5112     #  hypothesis. Returns the created hypothesis
5113     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5114         #print "OwnHypothesis",hypType
5115         if not self.nbLayers is None:
5116             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5117             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5118         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5119         self.mesh.smeshpyD.SetCurrentStudy( None )
5120         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5121         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5122         self.distribHyp.SetLayerDistribution( hyp )
5123         return hyp
5124
5125     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5126     #  prisms to build between the inner and outer shells
5127     #  @param n number of layers
5128     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5129     #                     the same parameters, else (default) - creates a new one
5130     def NumberOfLayers(self, n, UseExisting=0):
5131         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5132         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5133                                         CompareMethod=self.CompareNumberOfLayers)
5134         self.nbLayers.SetNumberOfLayers( n )
5135         return self.nbLayers
5136
5137     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5138     def CompareNumberOfLayers(self, hyp, args):
5139         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5140
5141     ## Defines "LocalLength" hypothesis, specifying the segment length
5142     #  to build between the inner and the outer shells
5143     #  @param l the length of segments
5144     #  @param p the precision of rounding
5145     def LocalLength(self, l, p=1e-07):
5146         hyp = self.OwnHypothesis("LocalLength", [l,p])
5147         hyp.SetLength(l)
5148         hyp.SetPrecision(p)
5149         return hyp
5150
5151     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5152     #  prisms to build between the inner and the outer shells.
5153     #  @param n the number of layers
5154     #  @param s the scale factor (optional)
5155     def NumberOfSegments(self, n, s=[]):
5156         if s == []:
5157             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5158         else:
5159             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5160             hyp.SetDistrType( 1 )
5161             hyp.SetScaleFactor(s)
5162         hyp.SetNumberOfSegments(n)
5163         return hyp
5164
5165     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5166     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
5167     #  @param start  the length of the first segment
5168     #  @param end    the length of the last  segment
5169     def Arithmetic1D(self, start, end ):
5170         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5171         hyp.SetLength(start, 1)
5172         hyp.SetLength(end  , 0)
5173         return hyp
5174
5175     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5176     #  to build between the inner and the outer shells as geometric length increasing
5177     #  @param start for the length of the first segment
5178     #  @param end   for the length of the last  segment
5179     def StartEndLength(self, start, end):
5180         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5181         hyp.SetLength(start, 1)
5182         hyp.SetLength(end  , 0)
5183         return hyp
5184
5185     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5186     #  to build between the inner and outer shells
5187     #  @param fineness defines the quality of the mesh within the range [0-1]
5188     def AutomaticLength(self, fineness=0):
5189         hyp = self.OwnHypothesis("AutomaticLength")
5190         hyp.SetFineness( fineness )
5191         return hyp
5192
5193 # Public class: Mesh_RadialQuadrangle1D2D
5194 # -------------------------------
5195
5196 ## Defines a Radial Quadrangle 1D2D algorithm
5197 #  @ingroup l2_algos_radialq
5198 #
5199 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5200
5201     ## Private constructor.
5202     def __init__(self, mesh, geom=0):
5203         Mesh_Algorithm.__init__(self)
5204         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5205
5206         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5207         self.nbLayers = None
5208
5209     ## Return 2D hypothesis holding the 1D one
5210     def Get2DHypothesis(self):
5211         return self.distribHyp
5212
5213     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5214     #  hypothesis. Returns the created hypothesis
5215     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5216         #print "OwnHypothesis",hypType
5217         if self.nbLayers:
5218             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5219         if self.distribHyp is None:
5220             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5221         else:
5222             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5223         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5224         self.mesh.smeshpyD.SetCurrentStudy( None )
5225         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5226         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5227         self.distribHyp.SetLayerDistribution( hyp )
5228         return hyp
5229
5230     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5231     #  @param n number of layers
5232     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5233     #                     the same parameters, else (default) - creates a new one
5234     def NumberOfLayers(self, n, UseExisting=0):
5235         if self.distribHyp:
5236             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5237         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5238                                         CompareMethod=self.CompareNumberOfLayers)
5239         self.nbLayers.SetNumberOfLayers( n )
5240         return self.nbLayers
5241
5242     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5243     def CompareNumberOfLayers(self, hyp, args):
5244         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5245
5246     ## Defines "LocalLength" hypothesis, specifying the segment length
5247     #  @param l the length of segments
5248     #  @param p the precision of rounding
5249     def LocalLength(self, l, p=1e-07):
5250         hyp = self.OwnHypothesis("LocalLength", [l,p])
5251         hyp.SetLength(l)
5252         hyp.SetPrecision(p)
5253         return hyp
5254
5255     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5256     #  @param n the number of layers
5257     #  @param s the scale factor (optional)
5258     def NumberOfSegments(self, n, s=[]):
5259         if s == []:
5260             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5261         else:
5262             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5263             hyp.SetDistrType( 1 )
5264             hyp.SetScaleFactor(s)
5265         hyp.SetNumberOfSegments(n)
5266         return hyp
5267
5268     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5269     #  with a length that changes in arithmetic progression
5270     #  @param start  the length of the first segment
5271     #  @param end    the length of the last  segment
5272     def Arithmetic1D(self, start, end ):
5273         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5274         hyp.SetLength(start, 1)
5275         hyp.SetLength(end  , 0)
5276         return hyp
5277
5278     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5279     #  as geometric length increasing
5280     #  @param start for the length of the first segment
5281     #  @param end   for the length of the last  segment
5282     def StartEndLength(self, start, end):
5283         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5284         hyp.SetLength(start, 1)
5285         hyp.SetLength(end  , 0)
5286         return hyp
5287
5288     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5289     #  @param fineness defines the quality of the mesh within the range [0-1]
5290     def AutomaticLength(self, fineness=0):
5291         hyp = self.OwnHypothesis("AutomaticLength")
5292         hyp.SetFineness( fineness )
5293         return hyp
5294
5295
5296 # Private class: Mesh_UseExisting
5297 # -------------------------------
5298 class Mesh_UseExisting(Mesh_Algorithm):
5299
5300     def __init__(self, dim, mesh, geom=0):
5301         if dim == 1:
5302             self.Create(mesh, geom, "UseExisting_1D")
5303         else:
5304             self.Create(mesh, geom, "UseExisting_2D")
5305
5306
5307 import salome_notebook
5308 notebook = salome_notebook.notebook
5309
5310 ##Return values of the notebook variables
5311 def ParseParameters(last, nbParams,nbParam, value):
5312     result = None
5313     strResult = ""
5314     counter = 0
5315     listSize = len(last)
5316     for n in range(0,nbParams):
5317         if n+1 != nbParam:
5318             if counter < listSize:
5319                 strResult = strResult + last[counter]
5320             else:
5321                 strResult = strResult + ""
5322         else:
5323             if isinstance(value, str):
5324                 if notebook.isVariable(value):
5325                     result = notebook.get(value)
5326                     strResult=strResult+value
5327                 else:
5328                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5329             else:
5330                 strResult=strResult+str(value)
5331                 result = value
5332         if nbParams - 1 != counter:
5333             strResult=strResult+var_separator #":"
5334         counter = counter+1
5335     return result, strResult
5336
5337 #Wrapper class for StdMeshers_LocalLength hypothesis
5338 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5339
5340     ## Set Length parameter value
5341     #  @param length numerical value or name of variable from notebook
5342     def SetLength(self, length):
5343         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5344         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5345         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5346
5347    ## Set Precision parameter value
5348    #  @param precision numerical value or name of variable from notebook
5349     def SetPrecision(self, precision):
5350         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5351         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5352         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5353
5354 #Registering the new proxy for LocalLength
5355 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5356
5357
5358 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5359 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5360     
5361     def SetLayerDistribution(self, hypo):
5362         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5363         hypo.ClearParameters();
5364         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5365
5366 #Registering the new proxy for LayerDistribution
5367 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5368
5369 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5370 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5371     
5372     ## Set Length parameter value
5373     #  @param length numerical value or name of variable from notebook    
5374     def SetLength(self, length):
5375         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5376         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5377         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5378
5379 #Registering the new proxy for SegmentLengthAroundVertex
5380 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5381
5382
5383 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5384 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5385     
5386     ## Set Length parameter value
5387     #  @param length   numerical value or name of variable from notebook
5388     #  @param isStart  true is length is Start Length, otherwise false
5389     def SetLength(self, length, isStart):
5390         nb = 2
5391         if isStart:
5392             nb = 1
5393         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5394         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5395         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5396         
5397 #Registering the new proxy for Arithmetic1D
5398 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5399
5400 #Wrapper class for StdMeshers_Deflection1D hypothesis
5401 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5402     
5403     ## Set Deflection parameter value
5404     #  @param deflection numerical value or name of variable from notebook    
5405     def SetDeflection(self, deflection):
5406         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5407         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5408         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5409
5410 #Registering the new proxy for Deflection1D
5411 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5412
5413 #Wrapper class for StdMeshers_StartEndLength hypothesis
5414 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5415     
5416     ## Set Length parameter value
5417     #  @param length  numerical value or name of variable from notebook
5418     #  @param isStart true is length is Start Length, otherwise false
5419     def SetLength(self, length, isStart):
5420         nb = 2
5421         if isStart:
5422             nb = 1
5423         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5424         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5425         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5426         
5427 #Registering the new proxy for StartEndLength
5428 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5429
5430 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5431 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5432     
5433     ## Set Max Element Area parameter value
5434     #  @param area  numerical value or name of variable from notebook
5435     def SetMaxElementArea(self, area):
5436         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5437         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5438         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5439         
5440 #Registering the new proxy for MaxElementArea
5441 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5442
5443
5444 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5445 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5446     
5447     ## Set Max Element Volume parameter value
5448     #  @param volume numerical value or name of variable from notebook
5449     def SetMaxElementVolume(self, volume):
5450         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5451         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5452         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5453         
5454 #Registering the new proxy for MaxElementVolume
5455 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5456
5457
5458 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5459 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5460     
5461     ## Set Number Of Layers parameter value
5462     #  @param nbLayers  numerical value or name of variable from notebook
5463     def SetNumberOfLayers(self, nbLayers):
5464         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5465         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5466         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5467         
5468 #Registering the new proxy for NumberOfLayers
5469 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5470
5471 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5472 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5473     
5474     ## Set Number Of Segments parameter value
5475     #  @param nbSeg numerical value or name of variable from notebook
5476     def SetNumberOfSegments(self, nbSeg):
5477         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5478         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5479         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5480         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5481         
5482     ## Set Scale Factor parameter value
5483     #  @param factor numerical value or name of variable from notebook
5484     def SetScaleFactor(self, factor):
5485         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5486         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5487         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5488         
5489 #Registering the new proxy for NumberOfSegments
5490 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5491
5492 if not noNETGENPlugin:
5493     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5494     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5495
5496         ## Set Max Size parameter value
5497         #  @param maxsize numerical value or name of variable from notebook
5498         def SetMaxSize(self, maxsize):
5499             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5500             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5501             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5502             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5503
5504         ## Set Growth Rate parameter value
5505         #  @param value  numerical value or name of variable from notebook
5506         def SetGrowthRate(self, value):
5507             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5508             value, parameters = ParseParameters(lastParameters,4,2,value)
5509             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5510             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5511
5512         ## Set Number of Segments per Edge parameter value
5513         #  @param value  numerical value or name of variable from notebook
5514         def SetNbSegPerEdge(self, value):
5515             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5516             value, parameters = ParseParameters(lastParameters,4,3,value)
5517             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5518             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5519
5520         ## Set Number of Segments per Radius parameter value
5521         #  @param value  numerical value or name of variable from notebook
5522         def SetNbSegPerRadius(self, value):
5523             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5524             value, parameters = ParseParameters(lastParameters,4,4,value)
5525             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5526             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5527
5528     #Registering the new proxy for NETGENPlugin_Hypothesis
5529     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5530
5531
5532     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5533     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5534         pass
5535
5536     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5537     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5538
5539     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5540     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5541
5542         ## Set Number of Segments parameter value
5543         #  @param nbSeg numerical value or name of variable from notebook
5544         def SetNumberOfSegments(self, nbSeg):
5545             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5546             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5547             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5548             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5549
5550         ## Set Local Length parameter value
5551         #  @param length numerical value or name of variable from notebook
5552         def SetLocalLength(self, length):
5553             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5554             length, parameters = ParseParameters(lastParameters,2,1,length)
5555             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5556             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5557
5558         ## Set Max Element Area parameter value
5559         #  @param area numerical value or name of variable from notebook    
5560         def SetMaxElementArea(self, area):
5561             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5562             area, parameters = ParseParameters(lastParameters,2,2,area)
5563             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5564             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5565
5566         def LengthFromEdges(self):
5567             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5568             value = 0;
5569             value, parameters = ParseParameters(lastParameters,2,2,value)
5570             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5571             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5572
5573     #Registering the new proxy for NETGEN_SimpleParameters_2D
5574     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5575
5576
5577     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5578     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5579         ## Set Max Element Volume parameter value
5580         #  @param volume numerical value or name of variable from notebook    
5581         def SetMaxElementVolume(self, volume):
5582             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5583             volume, parameters = ParseParameters(lastParameters,3,3,volume)
5584             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5585             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5586
5587         def LengthFromFaces(self):
5588             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5589             value = 0;
5590             value, parameters = ParseParameters(lastParameters,3,3,value)
5591             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5592             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5593
5594     #Registering the new proxy for NETGEN_SimpleParameters_3D
5595     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5596
5597     pass # if not noNETGENPlugin:
5598
5599 class Pattern(SMESH._objref_SMESH_Pattern):
5600
5601     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5602         flag = False
5603         if isinstance(theNodeIndexOnKeyPoint1,str):
5604             flag = True
5605         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5606         if flag:
5607             theNodeIndexOnKeyPoint1 -= 1
5608         theMesh.SetParameters(Parameters)
5609         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5610
5611     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5612         flag0 = False
5613         flag1 = False
5614         if isinstance(theNode000Index,str):
5615             flag0 = True
5616         if isinstance(theNode001Index,str):
5617             flag1 = True
5618         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5619         if flag0:
5620             theNode000Index -= 1
5621         if flag1:
5622             theNode001Index -= 1
5623         theMesh.SetParameters(Parameters)
5624         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5625
5626 #Registering the new proxy for Pattern
5627 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)