Salome HOME
319ad7dccb0ee7266feb019e6fb0edd21df1d1d9
[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                 try:
1193                     mainIOR  = salome.orb.object_to_string(geom)
1194                     for sname in salome.myStudyManager.GetOpenStudies():
1195                         s = salome.myStudyManager.GetStudyByName(sname)
1196                         if not s: continue
1197                         mainSO = s.FindObjectIOR(mainIOR)
1198                         if not mainSO: continue
1199                         subIt = s.NewChildIterator(mainSO)
1200                         while subIt.More():
1201                             subSO = subIt.Value()
1202                             subIt.Next()
1203                             obj = subSO.GetObject()
1204                             if not obj: continue
1205                             go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1206                             if not go: continue
1207                             ids = go.GetSubShapeIndices()
1208                             if len(ids) == 1 and ids[0] == err.subShapeID:
1209                                 shapeText = '"%s"' % subSO.GetName()
1210                                 break
1211                     if not shapeText:
1212                         shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1213                         if shape:
1214                             shapeText = "%s #%s" % (shape.GetShapeType(), err.subShapeID)
1215                         else:
1216                             shapeText = "%subshape #%s" % (err.subShapeID)
1217                 except:
1218                     shapeText = "%subshape #%s" % (err.subShapeID)
1219                 errText = ""
1220                 stdErrors = ["OK",                 #COMPERR_OK            
1221                              "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1222                              "std::exception",     #COMPERR_STD_EXCEPTION 
1223                              "OCC exception",      #COMPERR_OCC_EXCEPTION 
1224                              "SALOME exception",   #COMPERR_SLM_EXCEPTION 
1225                              "Unknown exception",  #COMPERR_EXCEPTION     
1226                              "Memory allocation problem", #COMPERR_MEMORY_PB     
1227                              "Algorithm failed",   #COMPERR_ALGO_FAILED   
1228                              "Unexpected geometry"]#COMPERR_BAD_SHAPE
1229                 if err.code > 0:
1230                     if err.code < len(stdErrors): errText = stdErrors[err.code]
1231                 else:
1232                     errText = "code %s" % -err.code
1233                 if errText: errText += ". "
1234                 errText += err.comment
1235                 if allReasons != "":allReasons += "\n"
1236                 allReasons += '"%s" failed on %s. Error: %s' %(err.algoName, shapeText, errText)
1237                 pass
1238
1239             # Treat hyp errors
1240             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1241             for err in errors:
1242                 if err.isGlobalAlgo:
1243                     glob = "global"
1244                 else:
1245                     glob = "local"
1246                     pass
1247                 dim = err.algoDim
1248                 name = err.algoName
1249                 if len(name) == 0:
1250                     reason = '%s %sD algorithm is missing' % (glob, dim)
1251                 elif err.state == HYP_MISSING:
1252                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1253                               % (glob, dim, name, dim))
1254                 elif err.state == HYP_NOTCONFORM:
1255                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1256                 elif err.state == HYP_BAD_PARAMETER:
1257                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1258                               % ( glob, dim, name ))
1259                 elif err.state == HYP_BAD_GEOMETRY:
1260                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1261                               'geometry' % ( glob, dim, name ))
1262                 else:
1263                     reason = "For unknown reason."+\
1264                              " Revise Mesh.Compute() implementation in smeshDC.py!"
1265                     pass
1266                 if allReasons != "":allReasons += "\n"
1267                 allReasons += reason
1268                 pass
1269             if allReasons != "":
1270                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1271                 print allReasons
1272                 ok = False
1273             elif not ok:
1274                 print '"' + GetName(self.mesh) + '"',"has not been computed."
1275                 pass
1276             pass
1277         if salome.sg.hasDesktop():
1278             smeshgui = salome.ImportComponentGUI("SMESH")
1279             smeshgui.Init(self.mesh.GetStudyId())
1280             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1281             salome.sg.updateObjBrowser(1)
1282             pass
1283         return ok
1284
1285     ## Return submesh objects list in meshing order
1286     #  @return list of list of submesh objects
1287     #  @ingroup l2_construct
1288     def GetMeshOrder(self):
1289         return self.mesh.GetMeshOrder()
1290
1291     ## Return submesh objects list in meshing order
1292     #  @return list of list of submesh objects
1293     #  @ingroup l2_construct
1294     def SetMeshOrder(self, submeshes):
1295         return self.mesh.SetMeshOrder(submeshes)
1296
1297     ## Removes all nodes and elements
1298     #  @ingroup l2_construct
1299     def Clear(self):
1300         self.mesh.Clear()
1301         if salome.sg.hasDesktop():
1302             smeshgui = salome.ImportComponentGUI("SMESH")
1303             smeshgui.Init(self.mesh.GetStudyId())
1304             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1305             salome.sg.updateObjBrowser(1)
1306
1307     ## Removes all nodes and elements of indicated shape
1308     #  @ingroup l2_construct
1309     def ClearSubMesh(self, geomId):
1310         self.mesh.ClearSubMesh(geomId)
1311         if salome.sg.hasDesktop():
1312             smeshgui = salome.ImportComponentGUI("SMESH")
1313             smeshgui.Init(self.mesh.GetStudyId())
1314             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1315             salome.sg.updateObjBrowser(1)
1316
1317     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1318     #  @param fineness [0,-1] defines mesh fineness
1319     #  @return True or False
1320     #  @ingroup l3_algos_basic
1321     def AutomaticTetrahedralization(self, fineness=0):
1322         dim = self.MeshDimension()
1323         # assign hypotheses
1324         self.RemoveGlobalHypotheses()
1325         self.Segment().AutomaticLength(fineness)
1326         if dim > 1 :
1327             self.Triangle().LengthFromEdges()
1328             pass
1329         if dim > 2 :
1330             self.Tetrahedron(NETGEN)
1331             pass
1332         return self.Compute()
1333
1334     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1335     #  @param fineness [0,-1] defines mesh fineness
1336     #  @return True or False
1337     #  @ingroup l3_algos_basic
1338     def AutomaticHexahedralization(self, fineness=0):
1339         dim = self.MeshDimension()
1340         # assign the hypotheses
1341         self.RemoveGlobalHypotheses()
1342         self.Segment().AutomaticLength(fineness)
1343         if dim > 1 :
1344             self.Quadrangle()
1345             pass
1346         if dim > 2 :
1347             self.Hexahedron()
1348             pass
1349         return self.Compute()
1350
1351     ## Assigns a hypothesis
1352     #  @param hyp a hypothesis to assign
1353     #  @param geom a subhape of mesh geometry
1354     #  @return SMESH.Hypothesis_Status
1355     #  @ingroup l2_hypotheses
1356     def AddHypothesis(self, hyp, geom=0):
1357         if isinstance( hyp, Mesh_Algorithm ):
1358             hyp = hyp.GetAlgorithm()
1359             pass
1360         if not geom:
1361             geom = self.geom
1362             if not geom:
1363                 geom = self.mesh.GetShapeToMesh()
1364             pass
1365         status = self.mesh.AddHypothesis(geom, hyp)
1366         isAlgo = hyp._narrow( SMESH_Algo )
1367         hyp_name = GetName( hyp )
1368         geom_name = ""
1369         if geom:
1370             geom_name = GetName( geom )
1371         TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1372         return status
1373
1374     ## Unassigns a hypothesis
1375     #  @param hyp a hypothesis to unassign
1376     #  @param geom a subshape of mesh geometry
1377     #  @return SMESH.Hypothesis_Status
1378     #  @ingroup l2_hypotheses
1379     def RemoveHypothesis(self, hyp, geom=0):
1380         if isinstance( hyp, Mesh_Algorithm ):
1381             hyp = hyp.GetAlgorithm()
1382             pass
1383         if not geom:
1384             geom = self.geom
1385             pass
1386         status = self.mesh.RemoveHypothesis(geom, hyp)
1387         return status
1388
1389     ## Gets the list of hypotheses added on a geometry
1390     #  @param geom a subshape of mesh geometry
1391     #  @return the sequence of SMESH_Hypothesis
1392     #  @ingroup l2_hypotheses
1393     def GetHypothesisList(self, geom):
1394         return self.mesh.GetHypothesisList( geom )
1395
1396     ## Removes all global hypotheses
1397     #  @ingroup l2_hypotheses
1398     def RemoveGlobalHypotheses(self):
1399         current_hyps = self.mesh.GetHypothesisList( self.geom )
1400         for hyp in current_hyps:
1401             self.mesh.RemoveHypothesis( self.geom, hyp )
1402             pass
1403         pass
1404
1405     ## Creates a mesh group based on the geometric object \a grp
1406     #  and gives a \a name, \n if this parameter is not defined
1407     #  the name is the same as the geometric group name \n
1408     #  Note: Works like GroupOnGeom().
1409     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
1410     #  @param name the name of the mesh group
1411     #  @return SMESH_GroupOnGeom
1412     #  @ingroup l2_grps_create
1413     def Group(self, grp, name=""):
1414         return self.GroupOnGeom(grp, name)
1415
1416     ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1417     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
1418     #  @param f the file name
1419     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1420     #  @param opt boolean parameter for creating/not creating
1421     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1422     #  @ingroup l2_impexp
1423     def ExportToMED(self, f, version, opt=0):
1424         self.mesh.ExportToMED(f, opt, version)
1425
1426     ## Exports the mesh in a file in MED format
1427     #  @param f is the file name
1428     #  @param auto_groups boolean parameter for creating/not creating
1429     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1430     #  the typical use is auto_groups=false.
1431     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1432     #  @ingroup l2_impexp
1433     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1434         self.mesh.ExportToMED(f, auto_groups, version)
1435
1436     ## Exports the mesh in a file in DAT format
1437     #  @param f the file name
1438     #  @ingroup l2_impexp
1439     def ExportDAT(self, f):
1440         self.mesh.ExportDAT(f)
1441
1442     ## Exports the mesh in a file in UNV format
1443     #  @param f the file name
1444     #  @ingroup l2_impexp
1445     def ExportUNV(self, f):
1446         self.mesh.ExportUNV(f)
1447
1448     ## Export the mesh in a file in STL format
1449     #  @param f the file name
1450     #  @param ascii defines the file encoding
1451     #  @ingroup l2_impexp
1452     def ExportSTL(self, f, ascii=1):
1453         self.mesh.ExportSTL(f, ascii)
1454
1455
1456     # Operations with groups:
1457     # ----------------------
1458
1459     ## Creates an empty mesh group
1460     #  @param elementType the type of elements in the group
1461     #  @param name the name of the mesh group
1462     #  @return SMESH_Group
1463     #  @ingroup l2_grps_create
1464     def CreateEmptyGroup(self, elementType, name):
1465         return self.mesh.CreateGroup(elementType, name)
1466
1467     ## Creates a mesh group based on the geometrical object \a grp
1468     #  and gives a \a name, \n if this parameter is not defined
1469     #  the name is the same as the geometrical group name
1470     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
1471     #  @param name the name of the mesh group
1472     #  @param typ  the type of elements in the group. If not set, it is
1473     #              automatically detected by the type of the geometry
1474     #  @return SMESH_GroupOnGeom
1475     #  @ingroup l2_grps_create
1476     def GroupOnGeom(self, grp, name="", typ=None):
1477         if name == "":
1478             name = grp.GetName()
1479
1480         if typ == None:
1481             tgeo = str(grp.GetShapeType())
1482             if tgeo == "VERTEX":
1483                 typ = NODE
1484             elif tgeo == "EDGE":
1485                 typ = EDGE
1486             elif tgeo == "FACE":
1487                 typ = FACE
1488             elif tgeo == "SOLID":
1489                 typ = VOLUME
1490             elif tgeo == "SHELL":
1491                 typ = VOLUME
1492             elif tgeo == "COMPOUND":
1493                 try: # it raises on a compound of compounds
1494                     if len( self.geompyD.GetObjectIDs( grp )) == 0:
1495                         print "Mesh.Group: empty geometric group", GetName( grp )
1496                         return 0
1497                     pass
1498                 except:
1499                     pass
1500                 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1501                     # group
1502                     tgeo = self.geompyD.GetType(grp)
1503                     if tgeo == geompyDC.ShapeType["VERTEX"]:
1504                         typ = NODE
1505                     elif tgeo == geompyDC.ShapeType["EDGE"]:
1506                         typ = EDGE
1507                     elif tgeo == geompyDC.ShapeType["FACE"]:
1508                         typ = FACE
1509                     elif tgeo == geompyDC.ShapeType["SOLID"]:
1510                         typ = VOLUME
1511                         pass
1512                     pass
1513                 else:
1514                     # just a compound
1515                     for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1516                                                 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1517                         if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1518                             typ = elemType
1519                             break
1520                         pass
1521                     pass
1522                 pass
1523             pass
1524         if typ == None:
1525             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1526             return 0
1527         else:
1528             return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1529
1530     ## Creates a mesh group by the given ids of elements
1531     #  @param groupName the name of the mesh group
1532     #  @param elementType the type of elements in the group
1533     #  @param elemIDs the list of ids
1534     #  @return SMESH_Group
1535     #  @ingroup l2_grps_create
1536     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1537         group = self.mesh.CreateGroup(elementType, groupName)
1538         group.Add(elemIDs)
1539         return group
1540
1541     ## Creates a mesh group by the given conditions
1542     #  @param groupName the name of the mesh group
1543     #  @param elementType the type of elements in the group
1544     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1545     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1546     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
1547     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
1548     #  @return SMESH_Group
1549     #  @ingroup l2_grps_create
1550     def MakeGroup(self,
1551                   groupName,
1552                   elementType,
1553                   CritType=FT_Undefined,
1554                   Compare=FT_EqualTo,
1555                   Treshold="",
1556                   UnaryOp=FT_Undefined):
1557         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1558         group = self.MakeGroupByCriterion(groupName, aCriterion)
1559         return group
1560
1561     ## Creates a mesh group by the given criterion
1562     #  @param groupName the name of the mesh group
1563     #  @param Criterion the instance of Criterion class
1564     #  @return SMESH_Group
1565     #  @ingroup l2_grps_create
1566     def MakeGroupByCriterion(self, groupName, Criterion):
1567         aFilterMgr = self.smeshpyD.CreateFilterManager()
1568         aFilter = aFilterMgr.CreateFilter()
1569         aCriteria = []
1570         aCriteria.append(Criterion)
1571         aFilter.SetCriteria(aCriteria)
1572         group = self.MakeGroupByFilter(groupName, aFilter)
1573         return group
1574
1575     ## Creates a mesh group by the given criteria (list of criteria)
1576     #  @param groupName the name of the mesh group
1577     #  @param theCriteria the list of criteria
1578     #  @return SMESH_Group
1579     #  @ingroup l2_grps_create
1580     def MakeGroupByCriteria(self, groupName, theCriteria):
1581         aFilterMgr = self.smeshpyD.CreateFilterManager()
1582         aFilter = aFilterMgr.CreateFilter()
1583         aFilter.SetCriteria(theCriteria)
1584         group = self.MakeGroupByFilter(groupName, aFilter)
1585         return group
1586
1587     ## Creates a mesh group by the given filter
1588     #  @param groupName the name of the mesh group
1589     #  @param theFilter the instance of Filter class
1590     #  @return SMESH_Group
1591     #  @ingroup l2_grps_create
1592     def MakeGroupByFilter(self, groupName, theFilter):
1593         anIds = theFilter.GetElementsId(self.mesh)
1594         anElemType = theFilter.GetElementType()
1595         group = self.MakeGroupByIds(groupName, anElemType, anIds)
1596         return group
1597
1598     ## Passes mesh elements through the given filter and return IDs of fitting elements
1599     #  @param theFilter SMESH_Filter
1600     #  @return a list of ids
1601     #  @ingroup l1_controls
1602     def GetIdsFromFilter(self, theFilter):
1603         return theFilter.GetElementsId(self.mesh)
1604
1605     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1606     #  Returns a list of special structures (borders).
1607     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1608     #  @ingroup l1_controls
1609     def GetFreeBorders(self):
1610         aFilterMgr = self.smeshpyD.CreateFilterManager()
1611         aPredicate = aFilterMgr.CreateFreeEdges()
1612         aPredicate.SetMesh(self.mesh)
1613         aBorders = aPredicate.GetBorders()
1614         return aBorders
1615
1616     ## Removes a group
1617     #  @ingroup l2_grps_delete
1618     def RemoveGroup(self, group):
1619         self.mesh.RemoveGroup(group)
1620
1621     ## Removes a group with its contents
1622     #  @ingroup l2_grps_delete
1623     def RemoveGroupWithContents(self, group):
1624         self.mesh.RemoveGroupWithContents(group)
1625
1626     ## Gets the list of groups existing in the mesh
1627     #  @return a sequence of SMESH_GroupBase
1628     #  @ingroup l2_grps_create
1629     def GetGroups(self):
1630         return self.mesh.GetGroups()
1631
1632     ## Gets the number of groups existing in the mesh
1633     #  @return the quantity of groups as an integer value
1634     #  @ingroup l2_grps_create
1635     def NbGroups(self):
1636         return self.mesh.NbGroups()
1637
1638     ## Gets the list of names of groups existing in the mesh
1639     #  @return list of strings
1640     #  @ingroup l2_grps_create
1641     def GetGroupNames(self):
1642         groups = self.GetGroups()
1643         names = []
1644         for group in groups:
1645             names.append(group.GetName())
1646         return names
1647
1648     ## Produces a union of two groups
1649     #  A new group is created. All mesh elements that are
1650     #  present in the initial groups are added to the new one
1651     #  @return an instance of SMESH_Group
1652     #  @ingroup l2_grps_operon
1653     def UnionGroups(self, group1, group2, name):
1654         return self.mesh.UnionGroups(group1, group2, name)
1655         
1656     ## Produces a union list of groups
1657     #  New group is created. All mesh elements that are present in 
1658     #  initial groups are added to the new one
1659     #  @return an instance of SMESH_Group
1660     #  @ingroup l2_grps_operon
1661     def UnionListOfGroups(self, groups, name):
1662       return self.mesh.UnionListOfGroups(groups, name)
1663       
1664     ## Prodices an intersection of two groups
1665     #  A new group is created. All mesh elements that are common
1666     #  for the two initial groups are added to the new one.
1667     #  @return an instance of SMESH_Group
1668     #  @ingroup l2_grps_operon
1669     def IntersectGroups(self, group1, group2, name):
1670         return self.mesh.IntersectGroups(group1, group2, name)
1671         
1672     ## Produces an intersection of groups
1673     #  New group is created. All mesh elements that are present in all 
1674     #  initial groups simultaneously are added to the new one
1675     #  @return an instance of SMESH_Group
1676     #  @ingroup l2_grps_operon
1677     def IntersectListOfGroups(self, groups, name):
1678       return self.mesh.IntersectListOfGroups(groups, name)
1679
1680     ## Produces a cut of two groups
1681     #  A new group is created. All mesh elements that are present in
1682     #  the main group but are not present in the tool group are added to the new one
1683     #  @return an instance of SMESH_Group
1684     #  @ingroup l2_grps_operon
1685     def CutGroups(self, main_group, tool_group, name):
1686         return self.mesh.CutGroups(main_group, tool_group, name)
1687         
1688     ## Produces a cut of groups
1689     #  A new group is created. All mesh elements that are present in main groups 
1690     #  but do not present in tool groups are added to the new one
1691     #  @return an instance of SMESH_Group
1692     #  @ingroup l2_grps_operon
1693     def CutListOfGroups(self, main_groups, tool_groups, name):
1694       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1695       
1696     ## Produces a group of elements with specified element type using list of existing groups
1697     #  A new group is created. System 
1698     #  1) extract all nodes on which groups elements are built
1699     #  2) combine all elements of specified dimension laying on these nodes
1700     #  @return an instance of SMESH_Group
1701     #  @ingroup l2_grps_operon
1702     def CreateDimGroup(self, groups, elem_type, name):
1703       return self.mesh.CreateDimGroup(groups, elem_type, name)
1704
1705
1706     ## Convert group on geom into standalone group
1707     #  @ingroup l2_grps_delete
1708     def ConvertToStandalone(self, group):
1709         return self.mesh.ConvertToStandalone(group)
1710
1711     # Get some info about mesh:
1712     # ------------------------
1713
1714     ## Returns the log of nodes and elements added or removed
1715     #  since the previous clear of the log.
1716     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1717     #  @return list of log_block structures:
1718     #                                        commandType
1719     #                                        number
1720     #                                        coords
1721     #                                        indexes
1722     #  @ingroup l1_auxiliary
1723     def GetLog(self, clearAfterGet):
1724         return self.mesh.GetLog(clearAfterGet)
1725
1726     ## Clears the log of nodes and elements added or removed since the previous
1727     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1728     #  @ingroup l1_auxiliary
1729     def ClearLog(self):
1730         self.mesh.ClearLog()
1731
1732     ## Toggles auto color mode on the object.
1733     #  @param theAutoColor the flag which toggles auto color mode.
1734     #  @ingroup l1_auxiliary
1735     def SetAutoColor(self, theAutoColor):
1736         self.mesh.SetAutoColor(theAutoColor)
1737
1738     ## Gets flag of object auto color mode.
1739     #  @return True or False
1740     #  @ingroup l1_auxiliary
1741     def GetAutoColor(self):
1742         return self.mesh.GetAutoColor()
1743
1744     ## Gets the internal ID
1745     #  @return integer value, which is the internal Id of the mesh
1746     #  @ingroup l1_auxiliary
1747     def GetId(self):
1748         return self.mesh.GetId()
1749
1750     ## Get the study Id
1751     #  @return integer value, which is the study Id of the mesh
1752     #  @ingroup l1_auxiliary
1753     def GetStudyId(self):
1754         return self.mesh.GetStudyId()
1755
1756     ## Checks the group names for duplications.
1757     #  Consider the maximum group name length stored in MED file.
1758     #  @return True or False
1759     #  @ingroup l1_auxiliary
1760     def HasDuplicatedGroupNamesMED(self):
1761         return self.mesh.HasDuplicatedGroupNamesMED()
1762
1763     ## Obtains the mesh editor tool
1764     #  @return an instance of SMESH_MeshEditor
1765     #  @ingroup l1_modifying
1766     def GetMeshEditor(self):
1767         return self.mesh.GetMeshEditor()
1768
1769     ## Gets MED Mesh
1770     #  @return an instance of SALOME_MED::MESH
1771     #  @ingroup l1_auxiliary
1772     def GetMEDMesh(self):
1773         return self.mesh.GetMEDMesh()
1774
1775
1776     # Get informations about mesh contents:
1777     # ------------------------------------
1778
1779     ## Gets the mesh stattistic
1780     #  @return dictionary type element - count of elements
1781     #  @ingroup l1_meshinfo
1782     def GetMeshInfo(self, obj = None):
1783         if not obj: obj = self.mesh
1784         return self.smeshpyD.GetMeshInfo(obj)
1785
1786     ## Returns the number of nodes in the mesh
1787     #  @return an integer value
1788     #  @ingroup l1_meshinfo
1789     def NbNodes(self):
1790         return self.mesh.NbNodes()
1791
1792     ## Returns the number of elements in the mesh
1793     #  @return an integer value
1794     #  @ingroup l1_meshinfo
1795     def NbElements(self):
1796         return self.mesh.NbElements()
1797
1798     ## Returns the number of 0d elements in the mesh
1799     #  @return an integer value
1800     #  @ingroup l1_meshinfo
1801     def Nb0DElements(self):
1802         return self.mesh.Nb0DElements()
1803
1804     ## Returns the number of edges in the mesh
1805     #  @return an integer value
1806     #  @ingroup l1_meshinfo
1807     def NbEdges(self):
1808         return self.mesh.NbEdges()
1809
1810     ## Returns the number of edges with the given order in the mesh
1811     #  @param elementOrder the order of elements:
1812     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1813     #  @return an integer value
1814     #  @ingroup l1_meshinfo
1815     def NbEdgesOfOrder(self, elementOrder):
1816         return self.mesh.NbEdgesOfOrder(elementOrder)
1817
1818     ## Returns the number of faces in the mesh
1819     #  @return an integer value
1820     #  @ingroup l1_meshinfo
1821     def NbFaces(self):
1822         return self.mesh.NbFaces()
1823
1824     ## Returns the number of faces with the given order in the mesh
1825     #  @param elementOrder the order of elements:
1826     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1827     #  @return an integer value
1828     #  @ingroup l1_meshinfo
1829     def NbFacesOfOrder(self, elementOrder):
1830         return self.mesh.NbFacesOfOrder(elementOrder)
1831
1832     ## Returns the number of triangles in the mesh
1833     #  @return an integer value
1834     #  @ingroup l1_meshinfo
1835     def NbTriangles(self):
1836         return self.mesh.NbTriangles()
1837
1838     ## Returns the number of triangles with the given order in the mesh
1839     #  @param elementOrder is the order of elements:
1840     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1841     #  @return an integer value
1842     #  @ingroup l1_meshinfo
1843     def NbTrianglesOfOrder(self, elementOrder):
1844         return self.mesh.NbTrianglesOfOrder(elementOrder)
1845
1846     ## Returns the number of quadrangles in the mesh
1847     #  @return an integer value
1848     #  @ingroup l1_meshinfo
1849     def NbQuadrangles(self):
1850         return self.mesh.NbQuadrangles()
1851
1852     ## Returns the number of quadrangles with the given order in the mesh
1853     #  @param elementOrder the order of elements:
1854     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1855     #  @return an integer value
1856     #  @ingroup l1_meshinfo
1857     def NbQuadranglesOfOrder(self, elementOrder):
1858         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1859
1860     ## Returns the number of polygons in the mesh
1861     #  @return an integer value
1862     #  @ingroup l1_meshinfo
1863     def NbPolygons(self):
1864         return self.mesh.NbPolygons()
1865
1866     ## Returns the number of volumes in the mesh
1867     #  @return an integer value
1868     #  @ingroup l1_meshinfo
1869     def NbVolumes(self):
1870         return self.mesh.NbVolumes()
1871
1872     ## Returns the number of volumes with the given order in the mesh
1873     #  @param elementOrder  the order of elements:
1874     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1875     #  @return an integer value
1876     #  @ingroup l1_meshinfo
1877     def NbVolumesOfOrder(self, elementOrder):
1878         return self.mesh.NbVolumesOfOrder(elementOrder)
1879
1880     ## Returns the number of tetrahedrons in the mesh
1881     #  @return an integer value
1882     #  @ingroup l1_meshinfo
1883     def NbTetras(self):
1884         return self.mesh.NbTetras()
1885
1886     ## Returns the number of tetrahedrons with the given order in the mesh
1887     #  @param elementOrder  the order of elements:
1888     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1889     #  @return an integer value
1890     #  @ingroup l1_meshinfo
1891     def NbTetrasOfOrder(self, elementOrder):
1892         return self.mesh.NbTetrasOfOrder(elementOrder)
1893
1894     ## Returns the number of hexahedrons in the mesh
1895     #  @return an integer value
1896     #  @ingroup l1_meshinfo
1897     def NbHexas(self):
1898         return self.mesh.NbHexas()
1899
1900     ## Returns the number of hexahedrons with the given order in the mesh
1901     #  @param elementOrder  the order of elements:
1902     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1903     #  @return an integer value
1904     #  @ingroup l1_meshinfo
1905     def NbHexasOfOrder(self, elementOrder):
1906         return self.mesh.NbHexasOfOrder(elementOrder)
1907
1908     ## Returns the number of pyramids in the mesh
1909     #  @return an integer value
1910     #  @ingroup l1_meshinfo
1911     def NbPyramids(self):
1912         return self.mesh.NbPyramids()
1913
1914     ## Returns the number of pyramids with the given order in the mesh
1915     #  @param elementOrder  the order of elements:
1916     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1917     #  @return an integer value
1918     #  @ingroup l1_meshinfo
1919     def NbPyramidsOfOrder(self, elementOrder):
1920         return self.mesh.NbPyramidsOfOrder(elementOrder)
1921
1922     ## Returns the number of prisms in the mesh
1923     #  @return an integer value
1924     #  @ingroup l1_meshinfo
1925     def NbPrisms(self):
1926         return self.mesh.NbPrisms()
1927
1928     ## Returns the number of prisms with the given order in the mesh
1929     #  @param elementOrder  the order of elements:
1930     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1931     #  @return an integer value
1932     #  @ingroup l1_meshinfo
1933     def NbPrismsOfOrder(self, elementOrder):
1934         return self.mesh.NbPrismsOfOrder(elementOrder)
1935
1936     ## Returns the number of polyhedrons in the mesh
1937     #  @return an integer value
1938     #  @ingroup l1_meshinfo
1939     def NbPolyhedrons(self):
1940         return self.mesh.NbPolyhedrons()
1941
1942     ## Returns the number of submeshes in the mesh
1943     #  @return an integer value
1944     #  @ingroup l1_meshinfo
1945     def NbSubMesh(self):
1946         return self.mesh.NbSubMesh()
1947
1948     ## Returns the list of mesh elements IDs
1949     #  @return the list of integer values
1950     #  @ingroup l1_meshinfo
1951     def GetElementsId(self):
1952         return self.mesh.GetElementsId()
1953
1954     ## Returns the list of IDs of mesh elements with the given type
1955     #  @param elementType  the required type of elements
1956     #  @return list of integer values
1957     #  @ingroup l1_meshinfo
1958     def GetElementsByType(self, elementType):
1959         return self.mesh.GetElementsByType(elementType)
1960
1961     ## Returns the list of mesh nodes IDs
1962     #  @return the list of integer values
1963     #  @ingroup l1_meshinfo
1964     def GetNodesId(self):
1965         return self.mesh.GetNodesId()
1966
1967     # Get the information about mesh elements:
1968     # ------------------------------------
1969
1970     ## Returns the type of mesh element
1971     #  @return the value from SMESH::ElementType enumeration
1972     #  @ingroup l1_meshinfo
1973     def GetElementType(self, id, iselem):
1974         return self.mesh.GetElementType(id, iselem)
1975
1976     ## Returns the geometric type of mesh element
1977     #  @return the value from SMESH::EntityType enumeration
1978     #  @ingroup l1_meshinfo
1979     def GetElementGeomType(self, id):
1980         return self.mesh.GetElementGeomType(id)
1981
1982     ## Returns the list of submesh elements IDs
1983     #  @param Shape a geom object(subshape) IOR
1984     #         Shape must be the subshape of a ShapeToMesh()
1985     #  @return the list of integer values
1986     #  @ingroup l1_meshinfo
1987     def GetSubMeshElementsId(self, Shape):
1988         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1989             ShapeID = Shape.GetSubShapeIndices()[0]
1990         else:
1991             ShapeID = Shape
1992         return self.mesh.GetSubMeshElementsId(ShapeID)
1993
1994     ## Returns the list of submesh nodes IDs
1995     #  @param Shape a geom object(subshape) IOR
1996     #         Shape must be the subshape of a ShapeToMesh()
1997     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1998     #  @return the list of integer values
1999     #  @ingroup l1_meshinfo
2000     def GetSubMeshNodesId(self, Shape, all):
2001         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2002             ShapeID = Shape.GetSubShapeIndices()[0]
2003         else:
2004             ShapeID = Shape
2005         return self.mesh.GetSubMeshNodesId(ShapeID, all)
2006
2007     ## Returns type of elements on given shape
2008     #  @param Shape a geom object(subshape) IOR
2009     #         Shape must be a subshape of a ShapeToMesh()
2010     #  @return element type
2011     #  @ingroup l1_meshinfo
2012     def GetSubMeshElementType(self, Shape):
2013         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2014             ShapeID = Shape.GetSubShapeIndices()[0]
2015         else:
2016             ShapeID = Shape
2017         return self.mesh.GetSubMeshElementType(ShapeID)
2018
2019     ## Gets the mesh description
2020     #  @return string value
2021     #  @ingroup l1_meshinfo
2022     def Dump(self):
2023         return self.mesh.Dump()
2024
2025
2026     # Get the information about nodes and elements of a mesh by its IDs:
2027     # -----------------------------------------------------------
2028
2029     ## Gets XYZ coordinates of a node
2030     #  \n If there is no nodes for the given ID - returns an empty list
2031     #  @return a list of double precision values
2032     #  @ingroup l1_meshinfo
2033     def GetNodeXYZ(self, id):
2034         return self.mesh.GetNodeXYZ(id)
2035
2036     ## Returns list of IDs of inverse elements for the given node
2037     #  \n If there is no node for the given ID - returns an empty list
2038     #  @return a list of integer values
2039     #  @ingroup l1_meshinfo
2040     def GetNodeInverseElements(self, id):
2041         return self.mesh.GetNodeInverseElements(id)
2042
2043     ## @brief Returns the position of a node on the shape
2044     #  @return SMESH::NodePosition
2045     #  @ingroup l1_meshinfo
2046     def GetNodePosition(self,NodeID):
2047         return self.mesh.GetNodePosition(NodeID)
2048
2049     ## If the given element is a node, returns the ID of shape
2050     #  \n If there is no node for the given ID - returns -1
2051     #  @return an integer value
2052     #  @ingroup l1_meshinfo
2053     def GetShapeID(self, id):
2054         return self.mesh.GetShapeID(id)
2055
2056     ## Returns the ID of the result shape after
2057     #  FindShape() from SMESH_MeshEditor for the given element
2058     #  \n If there is no element for the given ID - returns -1
2059     #  @return an integer value
2060     #  @ingroup l1_meshinfo
2061     def GetShapeIDForElem(self,id):
2062         return self.mesh.GetShapeIDForElem(id)
2063
2064     ## Returns the number of nodes for the given element
2065     #  \n If there is no element for the given ID - returns -1
2066     #  @return an integer value
2067     #  @ingroup l1_meshinfo
2068     def GetElemNbNodes(self, id):
2069         return self.mesh.GetElemNbNodes(id)
2070
2071     ## Returns the node ID the given index for the given element
2072     #  \n If there is no element for the given ID - returns -1
2073     #  \n If there is no node for the given index - returns -2
2074     #  @return an integer value
2075     #  @ingroup l1_meshinfo
2076     def GetElemNode(self, id, index):
2077         return self.mesh.GetElemNode(id, index)
2078
2079     ## Returns the IDs of nodes of the given element
2080     #  @return a list of integer values
2081     #  @ingroup l1_meshinfo
2082     def GetElemNodes(self, id):
2083         return self.mesh.GetElemNodes(id)
2084
2085     ## Returns true if the given node is the medium node in the given quadratic element
2086     #  @ingroup l1_meshinfo
2087     def IsMediumNode(self, elementID, nodeID):
2088         return self.mesh.IsMediumNode(elementID, nodeID)
2089
2090     ## Returns true if the given node is the medium node in one of quadratic elements
2091     #  @ingroup l1_meshinfo
2092     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2093         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2094
2095     ## Returns the number of edges for the given element
2096     #  @ingroup l1_meshinfo
2097     def ElemNbEdges(self, id):
2098         return self.mesh.ElemNbEdges(id)
2099
2100     ## Returns the number of faces for the given element
2101     #  @ingroup l1_meshinfo
2102     def ElemNbFaces(self, id):
2103         return self.mesh.ElemNbFaces(id)
2104
2105     ## Returns nodes of given face (counted from zero) for given volumic element.
2106     #  @ingroup l1_meshinfo
2107     def GetElemFaceNodes(self,elemId, faceIndex):
2108         return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2109
2110     ## Returns an element based on all given nodes.
2111     #  @ingroup l1_meshinfo
2112     def FindElementByNodes(self,nodes):
2113         return self.mesh.FindElementByNodes(nodes)
2114
2115     ## Returns true if the given element is a polygon
2116     #  @ingroup l1_meshinfo
2117     def IsPoly(self, id):
2118         return self.mesh.IsPoly(id)
2119
2120     ## Returns true if the given element is quadratic
2121     #  @ingroup l1_meshinfo
2122     def IsQuadratic(self, id):
2123         return self.mesh.IsQuadratic(id)
2124
2125     ## Returns XYZ coordinates of the barycenter of the given element
2126     #  \n If there is no element for the given ID - returns an empty list
2127     #  @return a list of three double values
2128     #  @ingroup l1_meshinfo
2129     def BaryCenter(self, id):
2130         return self.mesh.BaryCenter(id)
2131
2132
2133     # Mesh edition (SMESH_MeshEditor functionality):
2134     # ---------------------------------------------
2135
2136     ## Removes the elements from the mesh by ids
2137     #  @param IDsOfElements is a list of ids of elements to remove
2138     #  @return True or False
2139     #  @ingroup l2_modif_del
2140     def RemoveElements(self, IDsOfElements):
2141         return self.editor.RemoveElements(IDsOfElements)
2142
2143     ## Removes nodes from mesh by ids
2144     #  @param IDsOfNodes is a list of ids of nodes to remove
2145     #  @return True or False
2146     #  @ingroup l2_modif_del
2147     def RemoveNodes(self, IDsOfNodes):
2148         return self.editor.RemoveNodes(IDsOfNodes)
2149
2150     ## Add a node to the mesh by coordinates
2151     #  @return Id of the new node
2152     #  @ingroup l2_modif_add
2153     def AddNode(self, x, y, z):
2154         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2155         self.mesh.SetParameters(Parameters)
2156         return self.editor.AddNode( x, y, z)
2157
2158     ## Creates a 0D element on a node with given number.
2159     #  @param IDOfNode the ID of node for creation of the element.
2160     #  @return the Id of the new 0D element
2161     #  @ingroup l2_modif_add
2162     def Add0DElement(self, IDOfNode):
2163         return self.editor.Add0DElement(IDOfNode)
2164
2165     ## Creates a linear or quadratic edge (this is determined
2166     #  by the number of given nodes).
2167     #  @param IDsOfNodes the list of node IDs for creation of the element.
2168     #  The order of nodes in this list should correspond to the description
2169     #  of MED. \n This description is located by the following link:
2170     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2171     #  @return the Id of the new edge
2172     #  @ingroup l2_modif_add
2173     def AddEdge(self, IDsOfNodes):
2174         return self.editor.AddEdge(IDsOfNodes)
2175
2176     ## Creates a linear or quadratic face (this is determined
2177     #  by the number of given nodes).
2178     #  @param IDsOfNodes the list of node IDs for creation of the element.
2179     #  The order of nodes in this list should correspond to the description
2180     #  of MED. \n This description is located by the following link:
2181     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2182     #  @return the Id of the new face
2183     #  @ingroup l2_modif_add
2184     def AddFace(self, IDsOfNodes):
2185         return self.editor.AddFace(IDsOfNodes)
2186
2187     ## Adds a polygonal face to the mesh by the list of node IDs
2188     #  @param IdsOfNodes the list of node IDs for creation of the element.
2189     #  @return the Id of the new face
2190     #  @ingroup l2_modif_add
2191     def AddPolygonalFace(self, IdsOfNodes):
2192         return self.editor.AddPolygonalFace(IdsOfNodes)
2193
2194     ## Creates both simple and quadratic volume (this is determined
2195     #  by the number of given nodes).
2196     #  @param IDsOfNodes the list of node IDs for creation of the element.
2197     #  The order of nodes in this list should correspond to the description
2198     #  of MED. \n This description is located by the following link:
2199     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2200     #  @return the Id of the new volumic element
2201     #  @ingroup l2_modif_add
2202     def AddVolume(self, IDsOfNodes):
2203         return self.editor.AddVolume(IDsOfNodes)
2204
2205     ## Creates a volume of many faces, giving nodes for each face.
2206     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
2207     #  @param Quantities the list of integer values, Quantities[i]
2208     #         gives the quantity of nodes in face number i.
2209     #  @return the Id of the new volumic element
2210     #  @ingroup l2_modif_add
2211     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2212         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2213
2214     ## Creates a volume of many faces, giving the IDs of the existing faces.
2215     #  @param IdsOfFaces the list of face IDs for volume creation.
2216     #
2217     #  Note:  The created volume will refer only to the nodes
2218     #         of the given faces, not to the faces themselves.
2219     #  @return the Id of the new volumic element
2220     #  @ingroup l2_modif_add
2221     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2222         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2223
2224
2225     ## @brief Binds a node to a vertex
2226     #  @param NodeID a node ID
2227     #  @param Vertex a vertex or vertex ID
2228     #  @return True if succeed else raises an exception
2229     #  @ingroup l2_modif_add
2230     def SetNodeOnVertex(self, NodeID, Vertex):
2231         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2232             VertexID = Vertex.GetSubShapeIndices()[0]
2233         else:
2234             VertexID = Vertex
2235         try:
2236             self.editor.SetNodeOnVertex(NodeID, VertexID)
2237         except SALOME.SALOME_Exception, inst:
2238             raise ValueError, inst.details.text
2239         return True
2240
2241
2242     ## @brief Stores the node position on an edge
2243     #  @param NodeID a node ID
2244     #  @param Edge an edge or edge ID
2245     #  @param paramOnEdge a parameter on the edge where the node is located
2246     #  @return True if succeed else raises an exception
2247     #  @ingroup l2_modif_add
2248     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2249         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2250             EdgeID = Edge.GetSubShapeIndices()[0]
2251         else:
2252             EdgeID = Edge
2253         try:
2254             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2255         except SALOME.SALOME_Exception, inst:
2256             raise ValueError, inst.details.text
2257         return True
2258
2259     ## @brief Stores node position on a face
2260     #  @param NodeID a node ID
2261     #  @param Face a face or face ID
2262     #  @param u U parameter on the face where the node is located
2263     #  @param v V parameter on the face where the node is located
2264     #  @return True if succeed else raises an exception
2265     #  @ingroup l2_modif_add
2266     def SetNodeOnFace(self, NodeID, Face, u, v):
2267         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2268             FaceID = Face.GetSubShapeIndices()[0]
2269         else:
2270             FaceID = Face
2271         try:
2272             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2273         except SALOME.SALOME_Exception, inst:
2274             raise ValueError, inst.details.text
2275         return True
2276
2277     ## @brief Binds a node to a solid
2278     #  @param NodeID a node ID
2279     #  @param Solid  a solid or solid ID
2280     #  @return True if succeed else raises an exception
2281     #  @ingroup l2_modif_add
2282     def SetNodeInVolume(self, NodeID, Solid):
2283         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2284             SolidID = Solid.GetSubShapeIndices()[0]
2285         else:
2286             SolidID = Solid
2287         try:
2288             self.editor.SetNodeInVolume(NodeID, SolidID)
2289         except SALOME.SALOME_Exception, inst:
2290             raise ValueError, inst.details.text
2291         return True
2292
2293     ## @brief Bind an element to a shape
2294     #  @param ElementID an element ID
2295     #  @param Shape a shape or shape ID
2296     #  @return True if succeed else raises an exception
2297     #  @ingroup l2_modif_add
2298     def SetMeshElementOnShape(self, ElementID, Shape):
2299         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2300             ShapeID = Shape.GetSubShapeIndices()[0]
2301         else:
2302             ShapeID = Shape
2303         try:
2304             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2305         except SALOME.SALOME_Exception, inst:
2306             raise ValueError, inst.details.text
2307         return True
2308
2309
2310     ## Moves the node with the given id
2311     #  @param NodeID the id of the node
2312     #  @param x  a new X coordinate
2313     #  @param y  a new Y coordinate
2314     #  @param z  a new Z coordinate
2315     #  @return True if succeed else False
2316     #  @ingroup l2_modif_movenode
2317     def MoveNode(self, NodeID, x, y, z):
2318         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2319         self.mesh.SetParameters(Parameters)
2320         return self.editor.MoveNode(NodeID, x, y, z)
2321
2322     ## Finds the node closest to a point and moves it to a point location
2323     #  @param x  the X coordinate of a point
2324     #  @param y  the Y coordinate of a point
2325     #  @param z  the Z coordinate of a point
2326     #  @param NodeID if specified (>0), the node with this ID is moved,
2327     #  otherwise, the node closest to point (@a x,@a y,@a z) is moved
2328     #  @return the ID of a node
2329     #  @ingroup l2_modif_throughp
2330     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2331         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2332         self.mesh.SetParameters(Parameters)
2333         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2334
2335     ## Finds the node closest to a point
2336     #  @param x  the X coordinate of a point
2337     #  @param y  the Y coordinate of a point
2338     #  @param z  the Z coordinate of a point
2339     #  @return the ID of a node
2340     #  @ingroup l2_modif_throughp
2341     def FindNodeClosestTo(self, x, y, z):
2342         #preview = self.mesh.GetMeshEditPreviewer()
2343         #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2344         return self.editor.FindNodeClosestTo(x, y, z)
2345
2346     ## Finds the elements where a point lays IN or ON
2347     #  @param x  the X coordinate of a point
2348     #  @param y  the Y coordinate of a point
2349     #  @param z  the Z coordinate of a point
2350     #  @param elementType type of elements to find (SMESH.ALL type
2351     #         means elements of any type excluding nodes and 0D elements)
2352     #  @return list of IDs of found elements
2353     #  @ingroup l2_modif_throughp
2354     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2355         return self.editor.FindElementsByPoint(x, y, z, elementType)
2356         
2357     # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2358     # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2359      
2360     def GetPointState(self, x, y, z):
2361         return self.editor.GetPointState(x, y, z)
2362
2363     ## Finds the node closest to a point and moves it to a point location
2364     #  @param x  the X coordinate of a point
2365     #  @param y  the Y coordinate of a point
2366     #  @param z  the Z coordinate of a point
2367     #  @return the ID of a moved node
2368     #  @ingroup l2_modif_throughp
2369     def MeshToPassThroughAPoint(self, x, y, z):
2370         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2371
2372     ## Replaces two neighbour triangles sharing Node1-Node2 link
2373     #  with the triangles built on the same 4 nodes but having other common link.
2374     #  @param NodeID1  the ID of the first node
2375     #  @param NodeID2  the ID of the second node
2376     #  @return false if proper faces were not found
2377     #  @ingroup l2_modif_invdiag
2378     def InverseDiag(self, NodeID1, NodeID2):
2379         return self.editor.InverseDiag(NodeID1, NodeID2)
2380
2381     ## Replaces two neighbour triangles sharing Node1-Node2 link
2382     #  with a quadrangle built on the same 4 nodes.
2383     #  @param NodeID1  the ID of the first node
2384     #  @param NodeID2  the ID of the second node
2385     #  @return false if proper faces were not found
2386     #  @ingroup l2_modif_unitetri
2387     def DeleteDiag(self, NodeID1, NodeID2):
2388         return self.editor.DeleteDiag(NodeID1, NodeID2)
2389
2390     ## Reorients elements by ids
2391     #  @param IDsOfElements if undefined reorients all mesh elements
2392     #  @return True if succeed else False
2393     #  @ingroup l2_modif_changori
2394     def Reorient(self, IDsOfElements=None):
2395         if IDsOfElements == None:
2396             IDsOfElements = self.GetElementsId()
2397         return self.editor.Reorient(IDsOfElements)
2398
2399     ## Reorients all elements of the object
2400     #  @param theObject mesh, submesh or group
2401     #  @return True if succeed else False
2402     #  @ingroup l2_modif_changori
2403     def ReorientObject(self, theObject):
2404         if ( isinstance( theObject, Mesh )):
2405             theObject = theObject.GetMesh()
2406         return self.editor.ReorientObject(theObject)
2407
2408     ## Fuses the neighbouring triangles into quadrangles.
2409     #  @param IDsOfElements The triangles to be fused,
2410     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
2411     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2412     #                       is still performed; theMaxAngle is mesured in radians.
2413     #                       Also it could be a name of variable which defines angle in degrees.
2414     #  @return TRUE in case of success, FALSE otherwise.
2415     #  @ingroup l2_modif_unitetri
2416     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2417         flag = False
2418         if isinstance(MaxAngle,str):
2419             flag = True
2420         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2421         if flag:
2422             MaxAngle = DegreesToRadians(MaxAngle)
2423         if IDsOfElements == []:
2424             IDsOfElements = self.GetElementsId()
2425         self.mesh.SetParameters(Parameters)
2426         Functor = 0
2427         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2428             Functor = theCriterion
2429         else:
2430             Functor = self.smeshpyD.GetFunctor(theCriterion)
2431         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2432
2433     ## Fuses the neighbouring triangles of the object into quadrangles
2434     #  @param theObject is mesh, submesh or group
2435     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2436     #  @param MaxAngle   a max angle between element normals at which the fusion
2437     #                   is still performed; theMaxAngle is mesured in radians.
2438     #  @return TRUE in case of success, FALSE otherwise.
2439     #  @ingroup l2_modif_unitetri
2440     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2441         if ( isinstance( theObject, Mesh )):
2442             theObject = theObject.GetMesh()
2443         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2444
2445     ## Splits quadrangles into triangles.
2446     #  @param IDsOfElements the faces to be splitted.
2447     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2448     #  @return TRUE in case of success, FALSE otherwise.
2449     #  @ingroup l2_modif_cutquadr
2450     def QuadToTri (self, IDsOfElements, theCriterion):
2451         if IDsOfElements == []:
2452             IDsOfElements = self.GetElementsId()
2453         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2454
2455     ## Splits quadrangles into triangles.
2456     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
2457     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2458     #  @return TRUE in case of success, FALSE otherwise.
2459     #  @ingroup l2_modif_cutquadr
2460     def QuadToTriObject (self, theObject, theCriterion):
2461         if ( isinstance( theObject, Mesh )):
2462             theObject = theObject.GetMesh()
2463         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2464
2465     ## Splits quadrangles into triangles.
2466     #  @param IDsOfElements the faces to be splitted
2467     #  @param Diag13        is used to choose a diagonal for splitting.
2468     #  @return TRUE in case of success, FALSE otherwise.
2469     #  @ingroup l2_modif_cutquadr
2470     def SplitQuad (self, IDsOfElements, Diag13):
2471         if IDsOfElements == []:
2472             IDsOfElements = self.GetElementsId()
2473         return self.editor.SplitQuad(IDsOfElements, Diag13)
2474
2475     ## Splits quadrangles into triangles.
2476     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2477     #  @param Diag13    is used to choose a diagonal for splitting.
2478     #  @return TRUE in case of success, FALSE otherwise.
2479     #  @ingroup l2_modif_cutquadr
2480     def SplitQuadObject (self, theObject, Diag13):
2481         if ( isinstance( theObject, Mesh )):
2482             theObject = theObject.GetMesh()
2483         return self.editor.SplitQuadObject(theObject, Diag13)
2484
2485     ## Finds a better splitting of the given quadrangle.
2486     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2487     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
2488     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2489     #          diagonal is better, 0 if error occurs.
2490     #  @ingroup l2_modif_cutquadr
2491     def BestSplit (self, IDOfQuad, theCriterion):
2492         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2493
2494     ## Splits volumic elements into tetrahedrons
2495     #  @param elemIDs either list of elements or mesh or group or submesh
2496     #  @param method  flags passing splitting method:
2497     #         1 - split the hexahedron into 5 tetrahedrons
2498     #         2 - split the hexahedron into 6 tetrahedrons
2499     #  @ingroup l2_modif_cutquadr
2500     def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2501         if isinstance( elemIDs, Mesh ):
2502             elemIDs = elemIDs.GetMesh()
2503         self.editor.SplitVolumesIntoTetra(elemIDs, method)
2504
2505     ## Splits quadrangle faces near triangular facets of volumes
2506     #
2507     #  @ingroup l1_auxiliary
2508     def SplitQuadsNearTriangularFacets(self):
2509         faces_array = self.GetElementsByType(SMESH.FACE)
2510         for face_id in faces_array:
2511             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2512                 quad_nodes = self.mesh.GetElemNodes(face_id)
2513                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2514                 isVolumeFound = False
2515                 for node1_elem in node1_elems:
2516                     if not isVolumeFound:
2517                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2518                             nb_nodes = self.GetElemNbNodes(node1_elem)
2519                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2520                                 volume_elem = node1_elem
2521                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2522                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2523                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2524                                         isVolumeFound = True
2525                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2526                                             self.SplitQuad([face_id], False) # diagonal 2-4
2527                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2528                                         isVolumeFound = True
2529                                         self.SplitQuad([face_id], True) # diagonal 1-3
2530                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2531                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2532                                         isVolumeFound = True
2533                                         self.SplitQuad([face_id], True) # diagonal 1-3
2534
2535     ## @brief Splits hexahedrons into tetrahedrons.
2536     #
2537     #  This operation uses pattern mapping functionality for splitting.
2538     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2539     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2540     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2541     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2542     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2543     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2544     #  @return TRUE in case of success, FALSE otherwise.
2545     #  @ingroup l1_auxiliary
2546     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2547         # Pattern:     5.---------.6
2548         #              /|#*      /|
2549         #             / | #*    / |
2550         #            /  |  # * /  |
2551         #           /   |   # /*  |
2552         # (0,0,1) 4.---------.7 * |
2553         #          |#*  |1   | # *|
2554         #          | # *.----|---#.2
2555         #          |  #/ *   |   /
2556         #          |  /#  *  |  /
2557         #          | /   # * | /
2558         #          |/      #*|/
2559         # (0,0,0) 0.---------.3
2560         pattern_tetra = "!!! Nb of points: \n 8 \n\
2561         !!! Points: \n\
2562         0 0 0  !- 0 \n\
2563         0 1 0  !- 1 \n\
2564         1 1 0  !- 2 \n\
2565         1 0 0  !- 3 \n\
2566         0 0 1  !- 4 \n\
2567         0 1 1  !- 5 \n\
2568         1 1 1  !- 6 \n\
2569         1 0 1  !- 7 \n\
2570         !!! Indices of points of 6 tetras: \n\
2571         0 3 4 1 \n\
2572         7 4 3 1 \n\
2573         4 7 5 1 \n\
2574         6 2 5 7 \n\
2575         1 5 2 7 \n\
2576         2 3 1 7 \n"
2577
2578         pattern = self.smeshpyD.GetPattern()
2579         isDone  = pattern.LoadFromFile(pattern_tetra)
2580         if not isDone:
2581             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2582             return isDone
2583
2584         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2585         isDone = pattern.MakeMesh(self.mesh, False, False)
2586         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2587
2588         # split quafrangle faces near triangular facets of volumes
2589         self.SplitQuadsNearTriangularFacets()
2590
2591         return isDone
2592
2593     ## @brief Split hexahedrons into prisms.
2594     #
2595     #  Uses the pattern mapping functionality for splitting.
2596     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2597     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2598     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2599     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2600     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2601     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2602     #  @return TRUE in case of success, FALSE otherwise.
2603     #  @ingroup l1_auxiliary
2604     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2605         # Pattern:     5.---------.6
2606         #              /|#       /|
2607         #             / | #     / |
2608         #            /  |  #   /  |
2609         #           /   |   # /   |
2610         # (0,0,1) 4.---------.7   |
2611         #          |    |    |    |
2612         #          |   1.----|----.2
2613         #          |   / *   |   /
2614         #          |  /   *  |  /
2615         #          | /     * | /
2616         #          |/       *|/
2617         # (0,0,0) 0.---------.3
2618         pattern_prism = "!!! Nb of points: \n 8 \n\
2619         !!! Points: \n\
2620         0 0 0  !- 0 \n\
2621         0 1 0  !- 1 \n\
2622         1 1 0  !- 2 \n\
2623         1 0 0  !- 3 \n\
2624         0 0 1  !- 4 \n\
2625         0 1 1  !- 5 \n\
2626         1 1 1  !- 6 \n\
2627         1 0 1  !- 7 \n\
2628         !!! Indices of points of 2 prisms: \n\
2629         0 1 3 4 5 7 \n\
2630         2 3 1 6 7 5 \n"
2631
2632         pattern = self.smeshpyD.GetPattern()
2633         isDone  = pattern.LoadFromFile(pattern_prism)
2634         if not isDone:
2635             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2636             return isDone
2637
2638         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2639         isDone = pattern.MakeMesh(self.mesh, False, False)
2640         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2641
2642         # Splits quafrangle faces near triangular facets of volumes
2643         self.SplitQuadsNearTriangularFacets()
2644
2645         return isDone
2646
2647     ## Smoothes elements
2648     #  @param IDsOfElements the list if ids of elements to smooth
2649     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2650     #  Note that nodes built on edges and boundary nodes are always fixed.
2651     #  @param MaxNbOfIterations the maximum number of iterations
2652     #  @param MaxAspectRatio varies in range [1.0, inf]
2653     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2654     #  @return TRUE in case of success, FALSE otherwise.
2655     #  @ingroup l2_modif_smooth
2656     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2657                MaxNbOfIterations, MaxAspectRatio, Method):
2658         if IDsOfElements == []:
2659             IDsOfElements = self.GetElementsId()
2660         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2661         self.mesh.SetParameters(Parameters)
2662         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2663                                   MaxNbOfIterations, MaxAspectRatio, Method)
2664
2665     ## Smoothes elements which belong to the given object
2666     #  @param theObject the object to smooth
2667     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2668     #  Note that nodes built on edges and boundary nodes are always fixed.
2669     #  @param MaxNbOfIterations the maximum number of iterations
2670     #  @param MaxAspectRatio varies in range [1.0, inf]
2671     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2672     #  @return TRUE in case of success, FALSE otherwise.
2673     #  @ingroup l2_modif_smooth
2674     def SmoothObject(self, theObject, IDsOfFixedNodes,
2675                      MaxNbOfIterations, MaxAspectRatio, Method):
2676         if ( isinstance( theObject, Mesh )):
2677             theObject = theObject.GetMesh()
2678         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2679                                         MaxNbOfIterations, MaxAspectRatio, Method)
2680
2681     ## Parametrically smoothes the given elements
2682     #  @param IDsOfElements the list if ids of elements to smooth
2683     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2684     #  Note that nodes built on edges and boundary nodes are always fixed.
2685     #  @param MaxNbOfIterations the maximum number of iterations
2686     #  @param MaxAspectRatio varies in range [1.0, inf]
2687     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2688     #  @return TRUE in case of success, FALSE otherwise.
2689     #  @ingroup l2_modif_smooth
2690     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2691                          MaxNbOfIterations, MaxAspectRatio, Method):
2692         if IDsOfElements == []:
2693             IDsOfElements = self.GetElementsId()
2694         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2695         self.mesh.SetParameters(Parameters)
2696         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2697                                             MaxNbOfIterations, MaxAspectRatio, Method)
2698
2699     ## Parametrically smoothes the elements which belong to the given object
2700     #  @param theObject the object to smooth
2701     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2702     #  Note that nodes built on edges and boundary nodes are always fixed.
2703     #  @param MaxNbOfIterations the maximum number of iterations
2704     #  @param MaxAspectRatio varies in range [1.0, inf]
2705     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2706     #  @return TRUE in case of success, FALSE otherwise.
2707     #  @ingroup l2_modif_smooth
2708     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2709                                MaxNbOfIterations, MaxAspectRatio, Method):
2710         if ( isinstance( theObject, Mesh )):
2711             theObject = theObject.GetMesh()
2712         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2713                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2714
2715     ## Converts the mesh to quadratic, deletes old elements, replacing
2716     #  them with quadratic with the same id.
2717     #  @ingroup l2_modif_tofromqu
2718     def ConvertToQuadratic(self, theForce3d):
2719         self.editor.ConvertToQuadratic(theForce3d)
2720
2721     ## Converts the mesh from quadratic to ordinary,
2722     #  deletes old quadratic elements, \n replacing
2723     #  them with ordinary mesh elements with the same id.
2724     #  @return TRUE in case of success, FALSE otherwise.
2725     #  @ingroup l2_modif_tofromqu
2726     def ConvertFromQuadratic(self):
2727         return self.editor.ConvertFromQuadratic()
2728
2729     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2730     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2731     #  @ingroup l2_modif_edit
2732     def  Make2DMeshFrom3D(self):
2733         return self.editor. Make2DMeshFrom3D()
2734         
2735     ## Renumber mesh nodes
2736     #  @ingroup l2_modif_renumber
2737     def RenumberNodes(self):
2738         self.editor.RenumberNodes()
2739
2740     ## Renumber mesh elements
2741     #  @ingroup l2_modif_renumber
2742     def RenumberElements(self):
2743         self.editor.RenumberElements()
2744
2745     ## Generates new elements by rotation of the elements around the axis
2746     #  @param IDsOfElements the list of ids of elements to sweep
2747     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2748     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2749     #  @param NbOfSteps the number of steps
2750     #  @param Tolerance tolerance
2751     #  @param MakeGroups forces the generation of new groups from existing ones
2752     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2753     #                    of all steps, else - size of each step
2754     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2755     #  @ingroup l2_modif_extrurev
2756     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2757                       MakeGroups=False, TotalAngle=False):
2758         flag = False
2759         if isinstance(AngleInRadians,str):
2760             flag = True
2761         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2762         if flag:
2763             AngleInRadians = DegreesToRadians(AngleInRadians)
2764         if IDsOfElements == []:
2765             IDsOfElements = self.GetElementsId()
2766         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2767             Axis = self.smeshpyD.GetAxisStruct(Axis)
2768         Axis,AxisParameters = ParseAxisStruct(Axis)
2769         if TotalAngle and NbOfSteps:
2770             AngleInRadians /= NbOfSteps
2771         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2772         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2773         self.mesh.SetParameters(Parameters)
2774         if MakeGroups:
2775             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2776                                                        AngleInRadians, NbOfSteps, Tolerance)
2777         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2778         return []
2779
2780     ## Generates new elements by rotation of the elements of object around the axis
2781     #  @param theObject object which elements should be sweeped
2782     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2783     #  @param AngleInRadians the angle of Rotation
2784     #  @param NbOfSteps number of steps
2785     #  @param Tolerance tolerance
2786     #  @param MakeGroups forces the generation of new groups from existing ones
2787     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2788     #                    of all steps, else - size of each step
2789     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2790     #  @ingroup l2_modif_extrurev
2791     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2792                             MakeGroups=False, TotalAngle=False):
2793         flag = False
2794         if isinstance(AngleInRadians,str):
2795             flag = True
2796         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2797         if flag:
2798             AngleInRadians = DegreesToRadians(AngleInRadians)
2799         if ( isinstance( theObject, Mesh )):
2800             theObject = theObject.GetMesh()
2801         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2802             Axis = self.smeshpyD.GetAxisStruct(Axis)
2803         Axis,AxisParameters = ParseAxisStruct(Axis)
2804         if TotalAngle and NbOfSteps:
2805             AngleInRadians /= NbOfSteps
2806         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2807         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2808         self.mesh.SetParameters(Parameters)
2809         if MakeGroups:
2810             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2811                                                              NbOfSteps, Tolerance)
2812         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2813         return []
2814
2815     ## Generates new elements by rotation of the elements of object around the axis
2816     #  @param theObject object which elements should be sweeped
2817     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2818     #  @param AngleInRadians the angle of Rotation
2819     #  @param NbOfSteps number of steps
2820     #  @param Tolerance tolerance
2821     #  @param MakeGroups forces the generation of new groups from existing ones
2822     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2823     #                    of all steps, else - size of each step
2824     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2825     #  @ingroup l2_modif_extrurev
2826     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2827                               MakeGroups=False, TotalAngle=False):
2828         flag = False
2829         if isinstance(AngleInRadians,str):
2830             flag = True
2831         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2832         if flag:
2833             AngleInRadians = DegreesToRadians(AngleInRadians)
2834         if ( isinstance( theObject, Mesh )):
2835             theObject = theObject.GetMesh()
2836         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2837             Axis = self.smeshpyD.GetAxisStruct(Axis)
2838         Axis,AxisParameters = ParseAxisStruct(Axis)
2839         if TotalAngle and NbOfSteps:
2840             AngleInRadians /= NbOfSteps
2841         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2842         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2843         self.mesh.SetParameters(Parameters)
2844         if MakeGroups:
2845             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2846                                                                NbOfSteps, Tolerance)
2847         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2848         return []
2849
2850     ## Generates new elements by rotation of the elements of object around the axis
2851     #  @param theObject object which elements should be sweeped
2852     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2853     #  @param AngleInRadians the angle of Rotation
2854     #  @param NbOfSteps number of steps
2855     #  @param Tolerance tolerance
2856     #  @param MakeGroups forces the generation of new groups from existing ones
2857     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2858     #                    of all steps, else - size of each step
2859     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2860     #  @ingroup l2_modif_extrurev
2861     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2862                               MakeGroups=False, TotalAngle=False):
2863         flag = False
2864         if isinstance(AngleInRadians,str):
2865             flag = True
2866         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2867         if flag:
2868             AngleInRadians = DegreesToRadians(AngleInRadians)
2869         if ( isinstance( theObject, Mesh )):
2870             theObject = theObject.GetMesh()
2871         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2872             Axis = self.smeshpyD.GetAxisStruct(Axis)
2873         Axis,AxisParameters = ParseAxisStruct(Axis)
2874         if TotalAngle and NbOfSteps:
2875             AngleInRadians /= NbOfSteps
2876         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2877         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2878         self.mesh.SetParameters(Parameters)
2879         if MakeGroups:
2880             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2881                                                              NbOfSteps, Tolerance)
2882         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2883         return []
2884
2885     ## Generates new elements by extrusion of the elements with given ids
2886     #  @param IDsOfElements the list of elements ids for extrusion
2887     #  @param StepVector vector, defining the direction and value of extrusion
2888     #  @param NbOfSteps the number of steps
2889     #  @param MakeGroups forces the generation of new groups from existing ones
2890     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2891     #  @ingroup l2_modif_extrurev
2892     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2893         if IDsOfElements == []:
2894             IDsOfElements = self.GetElementsId()
2895         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2896             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2897         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2898         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2899         Parameters = StepVectorParameters + var_separator + Parameters
2900         self.mesh.SetParameters(Parameters)
2901         if MakeGroups:
2902             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2903         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2904         return []
2905
2906     ## Generates new elements by extrusion of the elements with given ids
2907     #  @param IDsOfElements is ids of elements
2908     #  @param StepVector vector, defining the direction and value of extrusion
2909     #  @param NbOfSteps the number of steps
2910     #  @param ExtrFlags sets flags for extrusion
2911     #  @param SewTolerance uses for comparing locations of nodes if flag
2912     #         EXTRUSION_FLAG_SEW is set
2913     #  @param MakeGroups forces the generation of new groups from existing ones
2914     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2915     #  @ingroup l2_modif_extrurev
2916     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2917                           ExtrFlags, SewTolerance, MakeGroups=False):
2918         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2919             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2920         if MakeGroups:
2921             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2922                                                            ExtrFlags, SewTolerance)
2923         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2924                                       ExtrFlags, SewTolerance)
2925         return []
2926
2927     ## Generates new elements by extrusion of the elements which belong to the object
2928     #  @param theObject the object which elements should be processed
2929     #  @param StepVector vector, defining the direction and value of extrusion
2930     #  @param NbOfSteps the number of steps
2931     #  @param MakeGroups forces the generation of new groups from existing ones
2932     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2933     #  @ingroup l2_modif_extrurev
2934     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2935         if ( isinstance( theObject, Mesh )):
2936             theObject = theObject.GetMesh()
2937         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2938             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2939         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2940         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2941         Parameters = StepVectorParameters + var_separator + Parameters
2942         self.mesh.SetParameters(Parameters)
2943         if MakeGroups:
2944             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2945         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2946         return []
2947
2948     ## Generates new elements by extrusion of the elements which belong to the object
2949     #  @param theObject object which elements should be processed
2950     #  @param StepVector vector, defining the direction and value of extrusion
2951     #  @param NbOfSteps the number of steps
2952     #  @param MakeGroups to generate new groups from existing ones
2953     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2954     #  @ingroup l2_modif_extrurev
2955     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2956         if ( isinstance( theObject, Mesh )):
2957             theObject = theObject.GetMesh()
2958         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2959             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2960         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2961         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2962         Parameters = StepVectorParameters + var_separator + Parameters
2963         self.mesh.SetParameters(Parameters)
2964         if MakeGroups:
2965             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2966         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2967         return []
2968
2969     ## Generates new elements by extrusion of the elements which belong to the object
2970     #  @param theObject object which elements should be processed
2971     #  @param StepVector vector, defining the direction and value of extrusion
2972     #  @param NbOfSteps the number of steps
2973     #  @param MakeGroups forces the generation of new groups from existing ones
2974     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2975     #  @ingroup l2_modif_extrurev
2976     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2977         if ( isinstance( theObject, Mesh )):
2978             theObject = theObject.GetMesh()
2979         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2980             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2981         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2982         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2983         Parameters = StepVectorParameters + var_separator + Parameters
2984         self.mesh.SetParameters(Parameters)
2985         if MakeGroups:
2986             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2987         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2988         return []
2989
2990
2991
2992     ## Generates new elements by extrusion of the given elements
2993     #  The path of extrusion must be a meshed edge.
2994     #  @param Base mesh or list of ids of elements for extrusion
2995     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2996     #  @param NodeStart the start node from Path. Defines the direction of extrusion
2997     #  @param HasAngles allows the shape to be rotated around the path
2998     #                   to get the resulting mesh in a helical fashion
2999     #  @param Angles list of angles in radians
3000     #  @param LinearVariation forces the computation of rotation angles as linear
3001     #                         variation of the given Angles along path steps
3002     #  @param HasRefPoint allows using the reference point
3003     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3004     #         The User can specify any point as the Reference Point.
3005     #  @param MakeGroups forces the generation of new groups from existing ones
3006     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
3007     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3008     #          only SMESH::Extrusion_Error otherwise
3009     #  @ingroup l2_modif_extrurev
3010     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3011                             HasAngles, Angles, LinearVariation,
3012                             HasRefPoint, RefPoint, MakeGroups, ElemType):
3013         Angles,AnglesParameters = ParseAngles(Angles)
3014         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3015         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3016             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3017             pass
3018         Parameters = AnglesParameters + var_separator + RefPointParameters
3019         self.mesh.SetParameters(Parameters)
3020
3021         if isinstance(Base,list):
3022             IDsOfElements = []
3023             if Base == []: IDsOfElements = self.GetElementsId()
3024             else: IDsOfElements = Base
3025             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3026                                                    HasAngles, Angles, LinearVariation,
3027                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
3028         else:
3029             if isinstance(Base,Mesh):
3030                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3031                                                           HasAngles, Angles, LinearVariation,
3032                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
3033             else:
3034                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3035
3036
3037     ## Generates new elements by extrusion of the given elements
3038     #  The path of extrusion must be a meshed edge.
3039     #  @param IDsOfElements ids of elements
3040     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3041     #  @param PathShape shape(edge) defines the sub-mesh for the path
3042     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3043     #  @param HasAngles allows the shape to be rotated around the path
3044     #                   to get the resulting mesh in a helical fashion
3045     #  @param Angles list of angles in radians
3046     #  @param HasRefPoint allows using the reference point
3047     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3048     #         The User can specify any point as the Reference Point.
3049     #  @param MakeGroups forces the generation of new groups from existing ones
3050     #  @param LinearVariation forces the computation of rotation angles as linear
3051     #                         variation of the given Angles along path steps
3052     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3053     #          only SMESH::Extrusion_Error otherwise
3054     #  @ingroup l2_modif_extrurev
3055     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3056                            HasAngles, Angles, HasRefPoint, RefPoint,
3057                            MakeGroups=False, LinearVariation=False):
3058         Angles,AnglesParameters = ParseAngles(Angles)
3059         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3060         if IDsOfElements == []:
3061             IDsOfElements = self.GetElementsId()
3062         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3063             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3064             pass
3065         if ( isinstance( PathMesh, Mesh )):
3066             PathMesh = PathMesh.GetMesh()
3067         if HasAngles and Angles and LinearVariation:
3068             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3069             pass
3070         Parameters = AnglesParameters + var_separator + RefPointParameters
3071         self.mesh.SetParameters(Parameters)
3072         if MakeGroups:
3073             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3074                                                             PathShape, NodeStart, HasAngles,
3075                                                             Angles, HasRefPoint, RefPoint)
3076         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3077                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3078
3079     ## Generates new elements by extrusion of the elements which belong to the object
3080     #  The path of extrusion must be a meshed edge.
3081     #  @param theObject the object which elements should be processed
3082     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3083     #  @param PathShape shape(edge) defines the sub-mesh for the path
3084     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3085     #  @param HasAngles allows the shape to be rotated around the path
3086     #                   to get the resulting mesh in a helical fashion
3087     #  @param Angles list of angles
3088     #  @param HasRefPoint allows using the reference point
3089     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3090     #         The User can specify any point as the Reference Point.
3091     #  @param MakeGroups forces the generation of new groups from existing ones
3092     #  @param LinearVariation forces the computation of rotation angles as linear
3093     #                         variation of the given Angles along path steps
3094     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3095     #          only SMESH::Extrusion_Error otherwise
3096     #  @ingroup l2_modif_extrurev
3097     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3098                                  HasAngles, Angles, HasRefPoint, RefPoint,
3099                                  MakeGroups=False, LinearVariation=False):
3100         Angles,AnglesParameters = ParseAngles(Angles)
3101         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3102         if ( isinstance( theObject, Mesh )):
3103             theObject = theObject.GetMesh()
3104         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3105             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3106         if ( isinstance( PathMesh, Mesh )):
3107             PathMesh = PathMesh.GetMesh()
3108         if HasAngles and Angles and LinearVariation:
3109             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3110             pass
3111         Parameters = AnglesParameters + var_separator + RefPointParameters
3112         self.mesh.SetParameters(Parameters)
3113         if MakeGroups:
3114             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3115                                                                   PathShape, NodeStart, HasAngles,
3116                                                                   Angles, HasRefPoint, RefPoint)
3117         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3118                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3119                                                     RefPoint)
3120
3121     ## Generates new elements by extrusion of the elements which belong to the object
3122     #  The path of extrusion must be a meshed edge.
3123     #  @param theObject the object which elements should be processed
3124     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3125     #  @param PathShape shape(edge) defines the sub-mesh for the path
3126     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3127     #  @param HasAngles allows the shape to be rotated around the path
3128     #                   to get the resulting mesh in a helical fashion
3129     #  @param Angles list of angles
3130     #  @param HasRefPoint allows using the reference point
3131     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3132     #         The User can specify any point as the Reference Point.
3133     #  @param MakeGroups forces the generation of new groups from existing ones
3134     #  @param LinearVariation forces the computation of rotation angles as linear
3135     #                         variation of the given Angles along path steps
3136     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3137     #          only SMESH::Extrusion_Error otherwise
3138     #  @ingroup l2_modif_extrurev
3139     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3140                                    HasAngles, Angles, HasRefPoint, RefPoint,
3141                                    MakeGroups=False, LinearVariation=False):
3142         Angles,AnglesParameters = ParseAngles(Angles)
3143         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3144         if ( isinstance( theObject, Mesh )):
3145             theObject = theObject.GetMesh()
3146         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3147             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3148         if ( isinstance( PathMesh, Mesh )):
3149             PathMesh = PathMesh.GetMesh()
3150         if HasAngles and Angles and LinearVariation:
3151             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3152             pass
3153         Parameters = AnglesParameters + var_separator + RefPointParameters
3154         self.mesh.SetParameters(Parameters)
3155         if MakeGroups:
3156             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3157                                                                     PathShape, NodeStart, HasAngles,
3158                                                                     Angles, HasRefPoint, RefPoint)
3159         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3160                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3161                                                       RefPoint)
3162
3163     ## Generates new elements by extrusion of the elements which belong to the object
3164     #  The path of extrusion must be a meshed edge.
3165     #  @param theObject the object which elements should be processed
3166     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3167     #  @param PathShape shape(edge) defines the sub-mesh for the path
3168     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3169     #  @param HasAngles allows the shape to be rotated around the path
3170     #                   to get the resulting mesh in a helical fashion
3171     #  @param Angles list of angles
3172     #  @param HasRefPoint allows using the reference point
3173     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3174     #         The User can specify any point as the Reference Point.
3175     #  @param MakeGroups forces the generation of new groups from existing ones
3176     #  @param LinearVariation forces the computation of rotation angles as linear
3177     #                         variation of the given Angles along path steps
3178     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3179     #          only SMESH::Extrusion_Error otherwise
3180     #  @ingroup l2_modif_extrurev
3181     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3182                                    HasAngles, Angles, HasRefPoint, RefPoint,
3183                                    MakeGroups=False, LinearVariation=False):
3184         Angles,AnglesParameters = ParseAngles(Angles)
3185         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3186         if ( isinstance( theObject, Mesh )):
3187             theObject = theObject.GetMesh()
3188         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3189             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3190         if ( isinstance( PathMesh, Mesh )):
3191             PathMesh = PathMesh.GetMesh()
3192         if HasAngles and Angles and LinearVariation:
3193             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3194             pass
3195         Parameters = AnglesParameters + var_separator + RefPointParameters
3196         self.mesh.SetParameters(Parameters)
3197         if MakeGroups:
3198             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3199                                                                     PathShape, NodeStart, HasAngles,
3200                                                                     Angles, HasRefPoint, RefPoint)
3201         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3202                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3203                                                       RefPoint)
3204
3205     ## Creates a symmetrical copy of mesh elements
3206     #  @param IDsOfElements list of elements ids
3207     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3208     #  @param theMirrorType is  POINT, AXIS or PLANE
3209     #  If the Mirror is a geom object this parameter is unnecessary
3210     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3211     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3212     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3213     #  @ingroup l2_modif_trsf
3214     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3215         if IDsOfElements == []:
3216             IDsOfElements = self.GetElementsId()
3217         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3218             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3219         Mirror,Parameters = ParseAxisStruct(Mirror)
3220         self.mesh.SetParameters(Parameters)
3221         if Copy and MakeGroups:
3222             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3223         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3224         return []
3225
3226     ## Creates a new mesh by a symmetrical copy of mesh elements
3227     #  @param IDsOfElements the list of elements ids
3228     #  @param Mirror is AxisStruct or geom object (point, line, plane)
3229     #  @param theMirrorType is  POINT, AXIS or PLANE
3230     #  If the Mirror is a geom object this parameter is unnecessary
3231     #  @param MakeGroups to generate new groups from existing ones
3232     #  @param NewMeshName a name of the new mesh to create
3233     #  @return instance of Mesh class
3234     #  @ingroup l2_modif_trsf
3235     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3236         if IDsOfElements == []:
3237             IDsOfElements = self.GetElementsId()
3238         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3239             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3240         Mirror,Parameters = ParseAxisStruct(Mirror)
3241         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3242                                           MakeGroups, NewMeshName)
3243         mesh.SetParameters(Parameters)
3244         return Mesh(self.smeshpyD,self.geompyD,mesh)
3245
3246     ## Creates a symmetrical copy of the object
3247     #  @param theObject mesh, submesh or group
3248     #  @param Mirror AxisStruct or geom object (point, line, plane)
3249     #  @param theMirrorType is  POINT, AXIS or PLANE
3250     #  If the Mirror is a geom object this parameter is unnecessary
3251     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3252     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3253     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3254     #  @ingroup l2_modif_trsf
3255     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3256         if ( isinstance( theObject, Mesh )):
3257             theObject = theObject.GetMesh()
3258         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3259             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3260         Mirror,Parameters = ParseAxisStruct(Mirror)
3261         self.mesh.SetParameters(Parameters)
3262         if Copy and MakeGroups:
3263             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3264         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3265         return []
3266
3267     ## Creates a new mesh by a symmetrical copy of the object
3268     #  @param theObject mesh, submesh or group
3269     #  @param Mirror AxisStruct or geom object (point, line, plane)
3270     #  @param theMirrorType POINT, AXIS or PLANE
3271     #  If the Mirror is a geom object this parameter is unnecessary
3272     #  @param MakeGroups forces the generation of new groups from existing ones
3273     #  @param NewMeshName the name of the new mesh to create
3274     #  @return instance of Mesh class
3275     #  @ingroup l2_modif_trsf
3276     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3277         if ( isinstance( theObject, Mesh )):
3278             theObject = theObject.GetMesh()
3279         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3280             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3281         Mirror,Parameters = ParseAxisStruct(Mirror)
3282         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3283                                                 MakeGroups, NewMeshName)
3284         mesh.SetParameters(Parameters)
3285         return Mesh( self.smeshpyD,self.geompyD,mesh )
3286
3287     ## Translates the elements
3288     #  @param IDsOfElements list of elements ids
3289     #  @param Vector the direction of translation (DirStruct or vector)
3290     #  @param Copy allows copying the translated elements
3291     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3292     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3293     #  @ingroup l2_modif_trsf
3294     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3295         if IDsOfElements == []:
3296             IDsOfElements = self.GetElementsId()
3297         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3298             Vector = self.smeshpyD.GetDirStruct(Vector)
3299         Vector,Parameters = ParseDirStruct(Vector)
3300         self.mesh.SetParameters(Parameters)
3301         if Copy and MakeGroups:
3302             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3303         self.editor.Translate(IDsOfElements, Vector, Copy)
3304         return []
3305
3306     ## Creates a new mesh of translated elements
3307     #  @param IDsOfElements list of elements ids
3308     #  @param Vector the direction of translation (DirStruct or vector)
3309     #  @param MakeGroups forces the generation of new groups from existing ones
3310     #  @param NewMeshName the name of the newly created mesh
3311     #  @return instance of Mesh class
3312     #  @ingroup l2_modif_trsf
3313     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3314         if IDsOfElements == []:
3315             IDsOfElements = self.GetElementsId()
3316         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3317             Vector = self.smeshpyD.GetDirStruct(Vector)
3318         Vector,Parameters = ParseDirStruct(Vector)
3319         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3320         mesh.SetParameters(Parameters)
3321         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3322
3323     ## Translates the object
3324     #  @param theObject the object to translate (mesh, submesh, or group)
3325     #  @param Vector direction of translation (DirStruct or geom vector)
3326     #  @param Copy allows copying the translated elements
3327     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3328     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3329     #  @ingroup l2_modif_trsf
3330     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3331         if ( isinstance( theObject, Mesh )):
3332             theObject = theObject.GetMesh()
3333         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3334             Vector = self.smeshpyD.GetDirStruct(Vector)
3335         Vector,Parameters = ParseDirStruct(Vector)
3336         self.mesh.SetParameters(Parameters)
3337         if Copy and MakeGroups:
3338             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3339         self.editor.TranslateObject(theObject, Vector, Copy)
3340         return []
3341
3342     ## Creates a new mesh from the translated object
3343     #  @param theObject the object to translate (mesh, submesh, or group)
3344     #  @param Vector the direction of translation (DirStruct or geom vector)
3345     #  @param MakeGroups forces the generation of new groups from existing ones
3346     #  @param NewMeshName the name of the newly created mesh
3347     #  @return instance of Mesh class
3348     #  @ingroup l2_modif_trsf
3349     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3350         if (isinstance(theObject, Mesh)):
3351             theObject = theObject.GetMesh()
3352         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3353             Vector = self.smeshpyD.GetDirStruct(Vector)
3354         Vector,Parameters = ParseDirStruct(Vector)
3355         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3356         mesh.SetParameters(Parameters)
3357         return Mesh( self.smeshpyD, self.geompyD, mesh )
3358
3359
3360
3361     ## Scales the object
3362     #  @param theObject - the object to translate (mesh, submesh, or group)
3363     #  @param thePoint - base point for scale
3364     #  @param theScaleFact - scale factors for axises
3365     #  @param Copy - allows copying the translated elements
3366     #  @param MakeGroups - forces the generation of new groups from existing
3367     #                      ones (if Copy)
3368     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3369     #          empty list otherwise
3370     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3371         if ( isinstance( theObject, Mesh )):
3372             theObject = theObject.GetMesh()
3373         if ( isinstance( theObject, list )):
3374             theObject = self.editor.MakeIDSource(theObject)
3375
3376         thePoint, Parameters = ParsePointStruct(thePoint)
3377         self.mesh.SetParameters(Parameters)
3378
3379         if Copy and MakeGroups:
3380             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3381         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3382         return []
3383
3384     ## Creates a new mesh from the translated object
3385     #  @param theObject - the object to translate (mesh, submesh, or group)
3386     #  @param thePoint - base point for scale
3387     #  @param theScaleFact - scale factors for axises
3388     #  @param MakeGroups - forces the generation of new groups from existing ones
3389     #  @param NewMeshName - the name of the newly created mesh
3390     #  @return instance of Mesh class
3391     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3392         if (isinstance(theObject, Mesh)):
3393             theObject = theObject.GetMesh()
3394         if ( isinstance( theObject, list )):
3395             theObject = self.editor.MakeIDSource(theObject)
3396
3397         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3398                                          MakeGroups, NewMeshName)
3399         #mesh.SetParameters(Parameters)
3400         return Mesh( self.smeshpyD, self.geompyD, mesh )
3401
3402
3403
3404     ## Rotates the elements
3405     #  @param IDsOfElements list of elements ids
3406     #  @param Axis the axis of rotation (AxisStruct or geom line)
3407     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3408     #  @param Copy allows copying the rotated elements
3409     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3410     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3411     #  @ingroup l2_modif_trsf
3412     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3413         flag = False
3414         if isinstance(AngleInRadians,str):
3415             flag = True
3416         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3417         if flag:
3418             AngleInRadians = DegreesToRadians(AngleInRadians)
3419         if IDsOfElements == []:
3420             IDsOfElements = self.GetElementsId()
3421         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3422             Axis = self.smeshpyD.GetAxisStruct(Axis)
3423         Axis,AxisParameters = ParseAxisStruct(Axis)
3424         Parameters = AxisParameters + var_separator + Parameters
3425         self.mesh.SetParameters(Parameters)
3426         if Copy and MakeGroups:
3427             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3428         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3429         return []
3430
3431     ## Creates a new mesh of rotated elements
3432     #  @param IDsOfElements list of element ids
3433     #  @param Axis the axis of rotation (AxisStruct or geom line)
3434     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3435     #  @param MakeGroups forces the generation of new groups from existing ones
3436     #  @param NewMeshName the name of the newly created mesh
3437     #  @return instance of Mesh class
3438     #  @ingroup l2_modif_trsf
3439     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3440         flag = False
3441         if isinstance(AngleInRadians,str):
3442             flag = True
3443         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3444         if flag:
3445             AngleInRadians = DegreesToRadians(AngleInRadians)
3446         if IDsOfElements == []:
3447             IDsOfElements = self.GetElementsId()
3448         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3449             Axis = self.smeshpyD.GetAxisStruct(Axis)
3450         Axis,AxisParameters = ParseAxisStruct(Axis)
3451         Parameters = AxisParameters + var_separator + Parameters
3452         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3453                                           MakeGroups, NewMeshName)
3454         mesh.SetParameters(Parameters)
3455         return Mesh( self.smeshpyD, self.geompyD, mesh )
3456
3457     ## Rotates the object
3458     #  @param theObject the object to rotate( mesh, submesh, or group)
3459     #  @param Axis the axis of rotation (AxisStruct or geom line)
3460     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3461     #  @param Copy allows copying the rotated elements
3462     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3463     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3464     #  @ingroup l2_modif_trsf
3465     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3466         flag = False
3467         if isinstance(AngleInRadians,str):
3468             flag = True
3469         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3470         if flag:
3471             AngleInRadians = DegreesToRadians(AngleInRadians)
3472         if (isinstance(theObject, Mesh)):
3473             theObject = theObject.GetMesh()
3474         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3475             Axis = self.smeshpyD.GetAxisStruct(Axis)
3476         Axis,AxisParameters = ParseAxisStruct(Axis)
3477         Parameters = AxisParameters + ":" + Parameters
3478         self.mesh.SetParameters(Parameters)
3479         if Copy and MakeGroups:
3480             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3481         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3482         return []
3483
3484     ## Creates a new mesh from the rotated object
3485     #  @param theObject the object to rotate (mesh, submesh, or group)
3486     #  @param Axis the axis of rotation (AxisStruct or geom line)
3487     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3488     #  @param MakeGroups forces the generation of new groups from existing ones
3489     #  @param NewMeshName the name of the newly created mesh
3490     #  @return instance of Mesh class
3491     #  @ingroup l2_modif_trsf
3492     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3493         flag = False
3494         if isinstance(AngleInRadians,str):
3495             flag = True
3496         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3497         if flag:
3498             AngleInRadians = DegreesToRadians(AngleInRadians)
3499         if (isinstance( theObject, Mesh )):
3500             theObject = theObject.GetMesh()
3501         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3502             Axis = self.smeshpyD.GetAxisStruct(Axis)
3503         Axis,AxisParameters = ParseAxisStruct(Axis)
3504         Parameters = AxisParameters + ":" + Parameters
3505         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3506                                                        MakeGroups, NewMeshName)
3507         mesh.SetParameters(Parameters)
3508         return Mesh( self.smeshpyD, self.geompyD, mesh )
3509
3510     ## Finds groups of ajacent nodes within Tolerance.
3511     #  @param Tolerance the value of tolerance
3512     #  @return the list of groups of nodes
3513     #  @ingroup l2_modif_trsf
3514     def FindCoincidentNodes (self, Tolerance):
3515         return self.editor.FindCoincidentNodes(Tolerance)
3516
3517     ## Finds groups of ajacent nodes within Tolerance.
3518     #  @param Tolerance the value of tolerance
3519     #  @param SubMeshOrGroup SubMesh or Group
3520     #  @return the list of groups of nodes
3521     #  @ingroup l2_modif_trsf
3522     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3523         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3524
3525     ## Merges nodes
3526     #  @param GroupsOfNodes the list of groups of nodes
3527     #  @ingroup l2_modif_trsf
3528     def MergeNodes (self, GroupsOfNodes):
3529         self.editor.MergeNodes(GroupsOfNodes)
3530
3531     ## Finds the elements built on the same nodes.
3532     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3533     #  @return a list of groups of equal elements
3534     #  @ingroup l2_modif_trsf
3535     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3536         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3537             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3538         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3539
3540     ## Merges elements in each given group.
3541     #  @param GroupsOfElementsID groups of elements for merging
3542     #  @ingroup l2_modif_trsf
3543     def MergeElements(self, GroupsOfElementsID):
3544         self.editor.MergeElements(GroupsOfElementsID)
3545
3546     ## Leaves one element and removes all other elements built on the same nodes.
3547     #  @ingroup l2_modif_trsf
3548     def MergeEqualElements(self):
3549         self.editor.MergeEqualElements()
3550
3551     ## Sews free borders
3552     #  @return SMESH::Sew_Error
3553     #  @ingroup l2_modif_trsf
3554     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3555                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3556                         CreatePolygons, CreatePolyedrs):
3557         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3558                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3559                                           CreatePolygons, CreatePolyedrs)
3560
3561     ## Sews conform free borders
3562     #  @return SMESH::Sew_Error
3563     #  @ingroup l2_modif_trsf
3564     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3565                                FirstNodeID2, SecondNodeID2):
3566         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3567                                                  FirstNodeID2, SecondNodeID2)
3568
3569     ## Sews border to side
3570     #  @return SMESH::Sew_Error
3571     #  @ingroup l2_modif_trsf
3572     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3573                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3574         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3575                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3576
3577     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3578     #  merged with the nodes of elements of Side2.
3579     #  The number of elements in theSide1 and in theSide2 must be
3580     #  equal and they should have similar nodal connectivity.
3581     #  The nodes to merge should belong to side borders and
3582     #  the first node should be linked to the second.
3583     #  @return SMESH::Sew_Error
3584     #  @ingroup l2_modif_trsf
3585     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3586                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3587                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3588         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3589                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3590                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3591
3592     ## Sets new nodes for the given element.
3593     #  @param ide the element id
3594     #  @param newIDs nodes ids
3595     #  @return If the number of nodes does not correspond to the type of element - returns false
3596     #  @ingroup l2_modif_edit
3597     def ChangeElemNodes(self, ide, newIDs):
3598         return self.editor.ChangeElemNodes(ide, newIDs)
3599
3600     ## If during the last operation of MeshEditor some nodes were
3601     #  created, this method returns the list of their IDs, \n
3602     #  if new nodes were not created - returns empty list
3603     #  @return the list of integer values (can be empty)
3604     #  @ingroup l1_auxiliary
3605     def GetLastCreatedNodes(self):
3606         return self.editor.GetLastCreatedNodes()
3607
3608     ## If during the last operation of MeshEditor some elements were
3609     #  created this method returns the list of their IDs, \n
3610     #  if new elements were not created - returns empty list
3611     #  @return the list of integer values (can be empty)
3612     #  @ingroup l1_auxiliary
3613     def GetLastCreatedElems(self):
3614         return self.editor.GetLastCreatedElems()
3615
3616      ## Creates a hole in a mesh by doubling the nodes of some particular elements
3617     #  @param theNodes identifiers of nodes to be doubled
3618     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
3619     #         nodes. If list of element identifiers is empty then nodes are doubled but 
3620     #         they not assigned to elements
3621     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3622     #  @ingroup l2_modif_edit
3623     def DoubleNodes(self, theNodes, theModifiedElems):
3624         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3625         
3626     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3627     #  This method provided for convenience works as DoubleNodes() described above.
3628     #  @param theNodes identifiers of node to be doubled
3629     #  @param theModifiedElems identifiers of elements to be updated
3630     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3631     #  @ingroup l2_modif_edit
3632     def DoubleNode(self, theNodeId, theModifiedElems):
3633         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3634         
3635     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3636     #  This method provided for convenience works as DoubleNodes() described above.
3637     #  @param theNodes group of nodes to be doubled
3638     #  @param theModifiedElems group of elements to be updated.
3639     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3640     #  @ingroup l2_modif_edit
3641     def DoubleNodeGroup(self, theNodes, theModifiedElems):
3642         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3643         
3644     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3645     #  This method provided for convenience works as DoubleNodes() described above.
3646     #  @param theNodes list of groups of nodes to be doubled
3647     #  @param theModifiedElems list of groups of elements to be updated.
3648     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3649     #  @ingroup l2_modif_edit
3650     def DoubleNodeGroups(self, theNodes, theModifiedElems):
3651         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3652     
3653     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3654     #  @param theElems - the list of elements (edges or faces) to be replicated
3655     #         The nodes for duplication could be found from these elements
3656     #  @param theNodesNot - list of nodes to NOT replicate
3657     #  @param theAffectedElems - the list of elements (cells and edges) to which the 
3658     #         replicated nodes should be associated to.
3659     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3660     #  @ingroup l2_modif_edit
3661     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3662         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3663         
3664     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3665     #  @param theElems - the list of elements (edges or faces) to be replicated
3666     #         The nodes for duplication could be found from these elements
3667     #  @param theNodesNot - list of nodes to NOT replicate
3668     #  @param theShape - shape to detect affected elements (element which geometric center
3669     #         located on or inside shape).
3670     #         The replicated nodes should be associated to affected elements.
3671     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3672     #  @ingroup l2_modif_edit
3673     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3674         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3675     
3676     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3677     #  This method provided for convenience works as DoubleNodes() described above.
3678     #  @param theElems - group of of elements (edges or faces) to be replicated
3679     #  @param theNodesNot - group of nodes not to replicated
3680     #  @param theAffectedElems - group of elements to which the replicated nodes
3681     #         should be associated to.
3682     #  @ingroup l2_modif_edit
3683     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3684         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3685         
3686     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3687     #  This method provided for convenience works as DoubleNodes() described above.
3688     #  @param theElems - group of of elements (edges or faces) to be replicated
3689     #  @param theNodesNot - group of nodes not to replicated
3690     #  @param theShape - shape to detect affected elements (element which geometric center
3691     #         located on or inside shape).
3692     #         The replicated nodes should be associated to affected elements.
3693     #  @ingroup l2_modif_edit
3694     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3695         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3696         
3697     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3698     #  This method provided for convenience works as DoubleNodes() described above.
3699     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3700     #  @param theNodesNot - list of groups of nodes not to replicated
3701     #  @param theAffectedElems - group of elements to which the replicated nodes
3702     #         should be associated to.
3703     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3704     #  @ingroup l2_modif_edit
3705     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3706         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3707
3708     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3709     #  This method provided for convenience works as DoubleNodes() described above.
3710     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3711     #  @param theNodesNot - list of groups of nodes not to replicated
3712     #  @param theShape - shape to detect affected elements (element which geometric center
3713     #         located on or inside shape).
3714     #         The replicated nodes should be associated to affected elements.
3715     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3716     #  @ingroup l2_modif_edit
3717     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3718         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3719
3720 ## The mother class to define algorithm, it is not recommended to use it directly.
3721 #
3722 #  More details.
3723 #  @ingroup l2_algorithms
3724 class Mesh_Algorithm:
3725     #  @class Mesh_Algorithm
3726     #  @brief Class Mesh_Algorithm
3727
3728     #def __init__(self,smesh):
3729     #    self.smesh=smesh
3730     def __init__(self):
3731         self.mesh = None
3732         self.geom = None
3733         self.subm = None
3734         self.algo = None
3735
3736     ## Finds a hypothesis in the study by its type name and parameters.
3737     #  Finds only the hypotheses created in smeshpyD engine.
3738     #  @return SMESH.SMESH_Hypothesis
3739     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3740         study = smeshpyD.GetCurrentStudy()
3741         #to do: find component by smeshpyD object, not by its data type
3742         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3743         if scomp is not None:
3744             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3745             # Check if the root label of the hypotheses exists
3746             if res and hypRoot is not None:
3747                 iter = study.NewChildIterator(hypRoot)
3748                 # Check all published hypotheses
3749                 while iter.More():
3750                     hypo_so_i = iter.Value()
3751                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3752                     if attr is not None:
3753                         anIOR = attr.Value()
3754                         hypo_o_i = salome.orb.string_to_object(anIOR)
3755                         if hypo_o_i is not None:
3756                             # Check if this is a hypothesis
3757                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3758                             if hypo_i is not None:
3759                                 # Check if the hypothesis belongs to current engine
3760                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3761                                     # Check if this is the required hypothesis
3762                                     if hypo_i.GetName() == hypname:
3763                                         # Check arguments
3764                                         if CompareMethod(hypo_i, args):
3765                                             # found!!!
3766                                             return hypo_i
3767                                         pass
3768                                     pass
3769                                 pass
3770                             pass
3771                         pass
3772                     iter.Next()
3773                     pass
3774                 pass
3775             pass
3776         return None
3777
3778     ## Finds the algorithm in the study by its type name.
3779     #  Finds only the algorithms, which have been created in smeshpyD engine.
3780     #  @return SMESH.SMESH_Algo
3781     def FindAlgorithm (self, algoname, smeshpyD):
3782         study = smeshpyD.GetCurrentStudy()
3783         #to do: find component by smeshpyD object, not by its data type
3784         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3785         if scomp is not None:
3786             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3787             # Check if the root label of the algorithms exists
3788             if res and hypRoot is not None:
3789                 iter = study.NewChildIterator(hypRoot)
3790                 # Check all published algorithms
3791                 while iter.More():
3792                     algo_so_i = iter.Value()
3793                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3794                     if attr is not None:
3795                         anIOR = attr.Value()
3796                         algo_o_i = salome.orb.string_to_object(anIOR)
3797                         if algo_o_i is not None:
3798                             # Check if this is an algorithm
3799                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3800                             if algo_i is not None:
3801                                 # Checks if the algorithm belongs to the current engine
3802                                 if smeshpyD.GetObjectId(algo_i) > 0:
3803                                     # Check if this is the required algorithm
3804                                     if algo_i.GetName() == algoname:
3805                                         # found!!!
3806                                         return algo_i
3807                                     pass
3808                                 pass
3809                             pass
3810                         pass
3811                     iter.Next()
3812                     pass
3813                 pass
3814             pass
3815         return None
3816
3817     ## If the algorithm is global, returns 0; \n
3818     #  else returns the submesh associated to this algorithm.
3819     def GetSubMesh(self):
3820         return self.subm
3821
3822     ## Returns the wrapped mesher.
3823     def GetAlgorithm(self):
3824         return self.algo
3825
3826     ## Gets the list of hypothesis that can be used with this algorithm
3827     def GetCompatibleHypothesis(self):
3828         mylist = []
3829         if self.algo:
3830             mylist = self.algo.GetCompatibleHypothesis()
3831         return mylist
3832
3833     ## Gets the name of the algorithm
3834     def GetName(self):
3835         GetName(self.algo)
3836
3837     ## Sets the name to the algorithm
3838     def SetName(self, name):
3839         self.mesh.smeshpyD.SetName(self.algo, name)
3840
3841     ## Gets the id of the algorithm
3842     def GetId(self):
3843         return self.algo.GetId()
3844
3845     ## Private method.
3846     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3847         if geom is None:
3848             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3849         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3850         if algo is None:
3851             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3852             pass
3853         self.Assign(algo, mesh, geom)
3854         return self.algo
3855
3856     ## Private method
3857     def Assign(self, algo, mesh, geom):
3858         if geom is None:
3859             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3860         self.mesh = mesh
3861         piece = mesh.geom
3862         name = ""
3863         if not geom:
3864             self.geom = piece
3865         else:
3866             self.geom = geom
3867             try:
3868                 name = GetName(geom)
3869                 pass
3870             except:
3871                 name = mesh.geompyD.SubShapeName(geom, piece)
3872                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3873                 pass
3874             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3875
3876         self.algo = algo
3877         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3878         TreatHypoStatus( status, algo.GetName(), name, True )
3879
3880     def CompareHyp (self, hyp, args):
3881         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3882         return False
3883
3884     def CompareEqualHyp (self, hyp, args):
3885         return True
3886
3887     ## Private method
3888     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3889                     UseExisting=0, CompareMethod=""):
3890         hypo = None
3891         if UseExisting:
3892             if CompareMethod == "": CompareMethod = self.CompareHyp
3893             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3894             pass
3895         if hypo is None:
3896             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3897             a = ""
3898             s = "="
3899             i = 0
3900             n = len(args)
3901             while i<n:
3902                 a = a + s + str(args[i])
3903                 s = ","
3904                 i = i + 1
3905                 pass
3906             self.mesh.smeshpyD.SetName(hypo, hyp + a)
3907             pass
3908         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3909         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3910         return hypo
3911
3912     ## Returns entry of the shape to mesh in the study
3913     def MainShapeEntry(self):
3914         entry = ""
3915         if not self.mesh or not self.mesh.GetMesh(): return entry
3916         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3917         study = self.mesh.smeshpyD.GetCurrentStudy()
3918         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
3919         sobj = study.FindObjectIOR(ior)
3920         if sobj: entry = sobj.GetID()
3921         if not entry: return ""
3922         return entry
3923
3924 # Public class: Mesh_Segment
3925 # --------------------------
3926
3927 ## Class to define a segment 1D algorithm for discretization
3928 #
3929 #  More details.
3930 #  @ingroup l3_algos_basic
3931 class Mesh_Segment(Mesh_Algorithm):
3932
3933     ## Private constructor.
3934     def __init__(self, mesh, geom=0):
3935         Mesh_Algorithm.__init__(self)
3936         self.Create(mesh, geom, "Regular_1D")
3937
3938     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3939     #  @param l for the length of segments that cut an edge
3940     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3941     #                    the same parameters, else (default) - creates a new one
3942     #  @param p precision, used for calculation of the number of segments.
3943     #           The precision should be a positive, meaningful value within the range [0,1].
3944     #           In general, the number of segments is calculated with the formula:
3945     #           nb = ceil((edge_length / l) - p)
3946     #           Function ceil rounds its argument to the higher integer.
3947     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3948     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3949     #               p=1 means rounding of (edge_length / l) to the lower integer.
3950     #           Default value is 1e-07.
3951     #  @return an instance of StdMeshers_LocalLength hypothesis
3952     #  @ingroup l3_hypos_1dhyps
3953     def LocalLength(self, l, UseExisting=0, p=1e-07):
3954         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3955                               CompareMethod=self.CompareLocalLength)
3956         hyp.SetLength(l)
3957         hyp.SetPrecision(p)
3958         return hyp
3959
3960     ## Private method
3961     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3962     def CompareLocalLength(self, hyp, args):
3963         if IsEqual(hyp.GetLength(), args[0]):
3964             return IsEqual(hyp.GetPrecision(), args[1])
3965         return False
3966
3967     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3968     #  @param length is optional maximal allowed length of segment, if it is omitted
3969     #                the preestimated length is used that depends on geometry size
3970     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3971     #                     the same parameters, else (default) - create a new one
3972     #  @return an instance of StdMeshers_MaxLength hypothesis
3973     #  @ingroup l3_hypos_1dhyps
3974     def MaxSize(self, length=0.0, UseExisting=0):
3975         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3976         if length > 0.0:
3977             # set given length
3978             hyp.SetLength(length)
3979         if not UseExisting:
3980             # set preestimated length
3981             gen = self.mesh.smeshpyD
3982             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3983                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
3984                                                        False) # <- byMesh
3985             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3986             if preHyp:
3987                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3988                 pass
3989             pass
3990         hyp.SetUsePreestimatedLength( length == 0.0 )
3991         return hyp
3992         
3993     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3994     #  @param n for the number of segments that cut an edge
3995     #  @param s for the scale factor (optional)
3996     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3997     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3998     #                     the same parameters, else (default) - create a new one
3999     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
4000     #  @ingroup l3_hypos_1dhyps
4001     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4002         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4003             reversedEdges, UseExisting = [], reversedEdges
4004         entry = self.MainShapeEntry()
4005         if s == []:
4006             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4007                                   UseExisting=UseExisting,
4008                                   CompareMethod=self.CompareNumberOfSegments)
4009         else:
4010             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4011                                   UseExisting=UseExisting,
4012                                   CompareMethod=self.CompareNumberOfSegments)
4013             hyp.SetDistrType( 1 )
4014             hyp.SetScaleFactor(s)
4015         hyp.SetNumberOfSegments(n)
4016         hyp.SetReversedEdges( reversedEdges )
4017         hyp.SetObjectEntry( entry )
4018         return hyp
4019
4020     ## Private method
4021     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4022     def CompareNumberOfSegments(self, hyp, args):
4023         if hyp.GetNumberOfSegments() == args[0]:
4024             if len(args) == 3:
4025                 if hyp.GetReversedEdges() == args[1]:
4026                     if not args[1] or hyp.GetObjectEntry() == args[2]:
4027                         return True
4028             else:
4029                 if hyp.GetReversedEdges() == args[2]:
4030                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4031                         if hyp.GetDistrType() == 1:
4032                             if IsEqual(hyp.GetScaleFactor(), args[1]):
4033                                 return True
4034         return False
4035
4036     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4037     #  @param start defines the length of the first segment
4038     #  @param end   defines the length of the last  segment
4039     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4040     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4041     #                     the same parameters, else (default) - creates a new one
4042     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4043     #  @ingroup l3_hypos_1dhyps
4044     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4045         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4046             reversedEdges, UseExisting = [], reversedEdges
4047         entry = self.MainShapeEntry()
4048         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4049                               UseExisting=UseExisting,
4050                               CompareMethod=self.CompareArithmetic1D)
4051         hyp.SetStartLength(start)
4052         hyp.SetEndLength(end)
4053         hyp.SetReversedEdges( reversedEdges )
4054         hyp.SetObjectEntry( entry )
4055         return hyp
4056
4057     ## Private method
4058     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4059     def CompareArithmetic1D(self, hyp, args):
4060         if IsEqual(hyp.GetLength(1), args[0]):
4061             if IsEqual(hyp.GetLength(0), args[1]):
4062                 if hyp.GetReversedEdges() == args[2]:
4063                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4064                         return True
4065         return False
4066
4067
4068     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4069     # on curve from 0 to 1 (additionally it is neecessary to check
4070     # orientation of edges and create list of reversed edges if it is
4071     # needed) and sets numbers of segments between given points (default
4072     # values are equals 1
4073     #  @param points defines the list of parameters on curve
4074     #  @param nbSegs defines the list of numbers of segments
4075     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4076     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4077     #                     the same parameters, else (default) - creates a new one
4078     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4079     #  @ingroup l3_hypos_1dhyps
4080     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4081         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4082             reversedEdges, UseExisting = [], reversedEdges
4083         if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4084             for i in range( len( reversedEdges )):
4085                 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4086         entry = self.MainShapeEntry()
4087         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4088                               UseExisting=UseExisting,
4089                               CompareMethod=self.CompareFixedPoints1D)
4090         hyp.SetPoints(points)
4091         hyp.SetNbSegments(nbSegs)
4092         hyp.SetReversedEdges(reversedEdges)
4093         hyp.SetObjectEntry(entry)
4094         return hyp
4095
4096     ## Private method
4097     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4098     ## as the given arguments
4099     def CompareFixedPoints1D(self, hyp, args):
4100         if hyp.GetPoints() == args[0]:
4101             if hyp.GetNbSegments() == args[1]:
4102                 if hyp.GetReversedEdges() == args[2]:
4103                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4104                         return True
4105         return False
4106
4107
4108
4109     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4110     #  @param start defines the length of the first segment
4111     #  @param end   defines the length of the last  segment
4112     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4113     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4114     #                     the same parameters, else (default) - creates a new one
4115     #  @return an instance of StdMeshers_StartEndLength hypothesis
4116     #  @ingroup l3_hypos_1dhyps
4117     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4118         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4119             reversedEdges, UseExisting = [], reversedEdges
4120         entry = self.MainShapeEntry()
4121         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4122                               UseExisting=UseExisting,
4123                               CompareMethod=self.CompareStartEndLength)
4124         hyp.SetStartLength(start)
4125         hyp.SetEndLength(end)
4126         hyp.SetReversedEdges( reversedEdges )
4127         hyp.SetObjectEntry( entry )
4128         return hyp
4129
4130     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4131     def CompareStartEndLength(self, hyp, args):
4132         if IsEqual(hyp.GetLength(1), args[0]):
4133             if IsEqual(hyp.GetLength(0), args[1]):
4134                 if hyp.GetReversedEdges() == args[2]:
4135                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4136                         return True
4137         return False
4138
4139     ## Defines "Deflection1D" hypothesis
4140     #  @param d for the deflection
4141     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4142     #                     the same parameters, else (default) - create a new one
4143     #  @ingroup l3_hypos_1dhyps
4144     def Deflection1D(self, d, UseExisting=0):
4145         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4146                               CompareMethod=self.CompareDeflection1D)
4147         hyp.SetDeflection(d)
4148         return hyp
4149
4150     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4151     def CompareDeflection1D(self, hyp, args):
4152         return IsEqual(hyp.GetDeflection(), args[0])
4153
4154     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4155     #  the opposite side in case of quadrangular faces
4156     #  @ingroup l3_hypos_additi
4157     def Propagation(self):
4158         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4159
4160     ## Defines "AutomaticLength" hypothesis
4161     #  @param fineness for the fineness [0-1]
4162     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
4163     #                     same parameters, else (default) - create a new one
4164     #  @ingroup l3_hypos_1dhyps
4165     def AutomaticLength(self, fineness=0, UseExisting=0):
4166         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4167                               CompareMethod=self.CompareAutomaticLength)
4168         hyp.SetFineness( fineness )
4169         return hyp
4170
4171     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4172     def CompareAutomaticLength(self, hyp, args):
4173         return IsEqual(hyp.GetFineness(), args[0])
4174
4175     ## Defines "SegmentLengthAroundVertex" hypothesis
4176     #  @param length for the segment length
4177     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
4178     #         Any other integer value means that the hypothesis will be set on the
4179     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
4180     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4181     #                   the same parameters, else (default) - creates a new one
4182     #  @ingroup l3_algos_segmarv
4183     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4184         import types
4185         store_geom = self.geom
4186         if type(vertex) is types.IntType:
4187             if vertex == 0 or vertex == 1:
4188                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4189                 self.geom = vertex
4190                 pass
4191             pass
4192         else:
4193             self.geom = vertex
4194             pass
4195         ### 0D algorithm
4196         if self.geom is None:
4197             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4198         try:
4199             name = GetName(self.geom)
4200             pass
4201         except:
4202             piece = self.mesh.geom
4203             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4204             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4205             pass
4206         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4207         if algo is None:
4208             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4209             pass
4210         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4211         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4212         ###
4213         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4214                               CompareMethod=self.CompareLengthNearVertex)
4215         self.geom = store_geom
4216         hyp.SetLength( length )
4217         return hyp
4218
4219     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4220     #  @ingroup l3_algos_segmarv
4221     def CompareLengthNearVertex(self, hyp, args):
4222         return IsEqual(hyp.GetLength(), args[0])
4223
4224     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4225     #  If the 2D mesher sees that all boundary edges are quadratic,
4226     #  it generates quadratic faces, else it generates linear faces using
4227     #  medium nodes as if they are vertices.
4228     #  The 3D mesher generates quadratic volumes only if all boundary faces
4229     #  are quadratic, else it fails.
4230     #
4231     #  @ingroup l3_hypos_additi
4232     def QuadraticMesh(self):
4233         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4234         return hyp
4235
4236 # Public class: Mesh_CompositeSegment
4237 # --------------------------
4238
4239 ## Defines a segment 1D algorithm for discretization
4240 #
4241 #  @ingroup l3_algos_basic
4242 class Mesh_CompositeSegment(Mesh_Segment):
4243
4244     ## Private constructor.
4245     def __init__(self, mesh, geom=0):
4246         self.Create(mesh, geom, "CompositeSegment_1D")
4247
4248
4249 # Public class: Mesh_Segment_Python
4250 # ---------------------------------
4251
4252 ## Defines a segment 1D algorithm for discretization with python function
4253 #
4254 #  @ingroup l3_algos_basic
4255 class Mesh_Segment_Python(Mesh_Segment):
4256
4257     ## Private constructor.
4258     def __init__(self, mesh, geom=0):
4259         import Python1dPlugin
4260         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4261
4262     ## Defines "PythonSplit1D" hypothesis
4263     #  @param n for the number of segments that cut an edge
4264     #  @param func for the python function that calculates the length of all segments
4265     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4266     #                     the same parameters, else (default) - creates a new one
4267     #  @ingroup l3_hypos_1dhyps
4268     def PythonSplit1D(self, n, func, UseExisting=0):
4269         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4270                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4271         hyp.SetNumberOfSegments(n)
4272         hyp.SetPythonLog10RatioFunction(func)
4273         return hyp
4274
4275     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4276     def ComparePythonSplit1D(self, hyp, args):
4277         #if hyp.GetNumberOfSegments() == args[0]:
4278         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
4279         #        return True
4280         return False
4281
4282 # Public class: Mesh_Triangle
4283 # ---------------------------
4284
4285 ## Defines a triangle 2D algorithm
4286 #
4287 #  @ingroup l3_algos_basic
4288 class Mesh_Triangle(Mesh_Algorithm):
4289
4290     # default values
4291     algoType = 0
4292     params = 0
4293
4294     _angleMeshS = 8
4295     _gradation  = 1.1
4296
4297     ## Private constructor.
4298     def __init__(self, mesh, algoType, geom=0):
4299         Mesh_Algorithm.__init__(self)
4300
4301         self.algoType = algoType
4302         if algoType == MEFISTO:
4303             self.Create(mesh, geom, "MEFISTO_2D")
4304             pass
4305         elif algoType == BLSURF:
4306             CheckPlugin(BLSURF)
4307             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4308             #self.SetPhysicalMesh() - PAL19680
4309         elif algoType == NETGEN:
4310             CheckPlugin(NETGEN)
4311             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4312             pass
4313         elif algoType == NETGEN_2D:
4314             CheckPlugin(NETGEN)
4315             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4316             pass
4317
4318     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4319     #  @param area for the maximum area of each triangle
4320     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
4321     #                     same parameters, else (default) - creates a new one
4322     #
4323     #  Only for algoType == MEFISTO || NETGEN_2D
4324     #  @ingroup l3_hypos_2dhyps
4325     def MaxElementArea(self, area, UseExisting=0):
4326         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4327             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4328                                   CompareMethod=self.CompareMaxElementArea)
4329         elif self.algoType == NETGEN:
4330             hyp = self.Parameters(SIMPLE)
4331         hyp.SetMaxElementArea(area)
4332         return hyp
4333
4334     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4335     def CompareMaxElementArea(self, hyp, args):
4336         return IsEqual(hyp.GetMaxElementArea(), args[0])
4337
4338     ## Defines "LengthFromEdges" hypothesis to build triangles
4339     #  based on the length of the edges taken from the wire
4340     #
4341     #  Only for algoType == MEFISTO || NETGEN_2D
4342     #  @ingroup l3_hypos_2dhyps
4343     def LengthFromEdges(self):
4344         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4345             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4346             return hyp
4347         elif self.algoType == NETGEN:
4348             hyp = self.Parameters(SIMPLE)
4349             hyp.LengthFromEdges()
4350             return hyp
4351
4352     ## Sets a way to define size of mesh elements to generate.
4353     #  @param thePhysicalMesh is: DefaultSize or Custom.
4354     #  @ingroup l3_hypos_blsurf
4355     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4356         # Parameter of BLSURF algo
4357         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4358
4359     ## Sets size of mesh elements to generate.
4360     #  @ingroup l3_hypos_blsurf
4361     def SetPhySize(self, theVal):
4362         # Parameter of BLSURF algo
4363         self.SetPhysicalMesh(1) #Custom - else why to set the size?
4364         self.Parameters().SetPhySize(theVal)
4365
4366     ## Sets lower boundary of mesh element size (PhySize).
4367     #  @ingroup l3_hypos_blsurf
4368     def SetPhyMin(self, theVal=-1):
4369         #  Parameter of BLSURF algo
4370         self.Parameters().SetPhyMin(theVal)
4371
4372     ## Sets upper boundary of mesh element size (PhySize).
4373     #  @ingroup l3_hypos_blsurf
4374     def SetPhyMax(self, theVal=-1):
4375         #  Parameter of BLSURF algo
4376         self.Parameters().SetPhyMax(theVal)
4377
4378     ## Sets a way to define maximum angular deflection of mesh from CAD model.
4379     #  @param theGeometricMesh is: DefaultGeom or Custom
4380     #  @ingroup l3_hypos_blsurf
4381     def SetGeometricMesh(self, theGeometricMesh=0):
4382         #  Parameter of BLSURF algo
4383         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4384         self.params.SetGeometricMesh(theGeometricMesh)
4385
4386     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4387     #  @ingroup l3_hypos_blsurf
4388     def SetAngleMeshS(self, theVal=_angleMeshS):
4389         #  Parameter of BLSURF algo
4390         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4391         self.params.SetAngleMeshS(theVal)
4392
4393     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4394     #  @ingroup l3_hypos_blsurf
4395     def SetAngleMeshC(self, theVal=_angleMeshS):
4396         #  Parameter of BLSURF algo
4397         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4398         self.params.SetAngleMeshC(theVal)
4399
4400     ## Sets lower boundary of mesh element size computed to respect angular deflection.
4401     #  @ingroup l3_hypos_blsurf
4402     def SetGeoMin(self, theVal=-1):
4403         #  Parameter of BLSURF algo
4404         self.Parameters().SetGeoMin(theVal)
4405
4406     ## Sets upper boundary of mesh element size computed to respect angular deflection.
4407     #  @ingroup l3_hypos_blsurf
4408     def SetGeoMax(self, theVal=-1):
4409         #  Parameter of BLSURF algo
4410         self.Parameters().SetGeoMax(theVal)
4411
4412     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4413     #  @ingroup l3_hypos_blsurf
4414     def SetGradation(self, theVal=_gradation):
4415         #  Parameter of BLSURF algo
4416         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4417         self.params.SetGradation(theVal)
4418
4419     ## Sets topology usage way.
4420     # @param way defines how mesh conformity is assured <ul>
4421     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4422     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4423     #  @ingroup l3_hypos_blsurf
4424     def SetTopology(self, way):
4425         #  Parameter of BLSURF algo
4426         self.Parameters().SetTopology(way)
4427
4428     ## To respect geometrical edges or not.
4429     #  @ingroup l3_hypos_blsurf
4430     def SetDecimesh(self, toIgnoreEdges=False):
4431         #  Parameter of BLSURF algo
4432         self.Parameters().SetDecimesh(toIgnoreEdges)
4433
4434     ## Sets verbosity level in the range 0 to 100.
4435     #  @ingroup l3_hypos_blsurf
4436     def SetVerbosity(self, level):
4437         #  Parameter of BLSURF algo
4438         self.Parameters().SetVerbosity(level)
4439
4440     ## Sets advanced option value.
4441     #  @ingroup l3_hypos_blsurf
4442     def SetOptionValue(self, optionName, level):
4443         #  Parameter of BLSURF algo
4444         self.Parameters().SetOptionValue(optionName,level)
4445
4446     ## Sets QuadAllowed flag.
4447     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
4448     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
4449     def SetQuadAllowed(self, toAllow=True):
4450         if self.algoType == NETGEN_2D:
4451             if toAllow: # add QuadranglePreference
4452                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4453             else:       # remove QuadranglePreference
4454                 for hyp in self.mesh.GetHypothesisList( self.geom ):
4455                     if hyp.GetName() == "QuadranglePreference":
4456                         self.mesh.RemoveHypothesis( self.geom, hyp )
4457                         pass
4458                     pass
4459                 pass
4460             return
4461         if self.Parameters():
4462             self.params.SetQuadAllowed(toAllow)
4463             return
4464
4465     ## Defines hypothesis having several parameters
4466     #
4467     #  @ingroup l3_hypos_netgen
4468     def Parameters(self, which=SOLE):
4469         if self.params:
4470             return self.params
4471         if self.algoType == NETGEN:
4472             if which == SIMPLE:
4473                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4474                                               "libNETGENEngine.so", UseExisting=0)
4475             else:
4476                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4477                                               "libNETGENEngine.so", UseExisting=0)
4478             return self.params
4479         elif self.algoType == MEFISTO:
4480             print "Mefisto algo support no multi-parameter hypothesis"
4481             return None
4482         elif self.algoType == NETGEN_2D:
4483             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4484             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4485             return None
4486         elif self.algoType == BLSURF:
4487             self.params = self.Hypothesis("BLSURF_Parameters", [],
4488                                           "libBLSURFEngine.so", UseExisting=0)
4489             return self.params
4490         else:
4491             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4492         return None
4493
4494     ## Sets MaxSize
4495     #
4496     #  Only for algoType == NETGEN
4497     #  @ingroup l3_hypos_netgen
4498     def SetMaxSize(self, theSize):
4499         if self.Parameters():
4500             self.params.SetMaxSize(theSize)
4501
4502     ## Sets SecondOrder flag
4503     #
4504     #  Only for algoType == NETGEN
4505     #  @ingroup l3_hypos_netgen
4506     def SetSecondOrder(self, theVal):
4507         if self.Parameters():
4508             self.params.SetSecondOrder(theVal)
4509
4510     ## Sets Optimize flag
4511     #
4512     #  Only for algoType == NETGEN
4513     #  @ingroup l3_hypos_netgen
4514     def SetOptimize(self, theVal):
4515         if self.Parameters():
4516             self.params.SetOptimize(theVal)
4517
4518     ## Sets Fineness
4519     #  @param theFineness is:
4520     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4521     #
4522     #  Only for algoType == NETGEN
4523     #  @ingroup l3_hypos_netgen
4524     def SetFineness(self, theFineness):
4525         if self.Parameters():
4526             self.params.SetFineness(theFineness)
4527
4528     ## Sets GrowthRate
4529     #
4530     #  Only for algoType == NETGEN
4531     #  @ingroup l3_hypos_netgen
4532     def SetGrowthRate(self, theRate):
4533         if self.Parameters():
4534             self.params.SetGrowthRate(theRate)
4535
4536     ## Sets NbSegPerEdge
4537     #
4538     #  Only for algoType == NETGEN
4539     #  @ingroup l3_hypos_netgen
4540     def SetNbSegPerEdge(self, theVal):
4541         if self.Parameters():
4542             self.params.SetNbSegPerEdge(theVal)
4543
4544     ## Sets NbSegPerRadius
4545     #
4546     #  Only for algoType == NETGEN
4547     #  @ingroup l3_hypos_netgen
4548     def SetNbSegPerRadius(self, theVal):
4549         if self.Parameters():
4550             self.params.SetNbSegPerRadius(theVal)
4551
4552     ## Sets number of segments overriding value set by SetLocalLength()
4553     #
4554     #  Only for algoType == NETGEN
4555     #  @ingroup l3_hypos_netgen
4556     def SetNumberOfSegments(self, theVal):
4557         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4558
4559     ## Sets number of segments overriding value set by SetNumberOfSegments()
4560     #
4561     #  Only for algoType == NETGEN
4562     #  @ingroup l3_hypos_netgen
4563     def SetLocalLength(self, theVal):
4564         self.Parameters(SIMPLE).SetLocalLength(theVal)
4565
4566     pass
4567
4568
4569 # Public class: Mesh_Quadrangle
4570 # -----------------------------
4571
4572 ## Defines a quadrangle 2D algorithm
4573 #
4574 #  @ingroup l3_algos_basic
4575 class Mesh_Quadrangle(Mesh_Algorithm):
4576
4577     ## Private constructor.
4578     def __init__(self, mesh, geom=0):
4579         Mesh_Algorithm.__init__(self)
4580         self.Create(mesh, geom, "Quadrangle_2D")
4581
4582     ## Defines "QuadranglePreference" hypothesis, forcing construction
4583     #  of quadrangles if the number of nodes on the opposite edges is not the same
4584     #  while the total number of nodes on edges is even
4585     #
4586     #  @ingroup l3_hypos_additi
4587     def QuadranglePreference(self):
4588         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4589                               CompareMethod=self.CompareEqualHyp)
4590         return hyp
4591
4592     ## Defines "TrianglePreference" hypothesis, forcing construction
4593     #  of triangles in the refinement area if the number of nodes
4594     #  on the opposite edges is not the same
4595     #
4596     #  @ingroup l3_hypos_additi
4597     def TrianglePreference(self):
4598         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4599                               CompareMethod=self.CompareEqualHyp)
4600         return hyp
4601
4602     ## Defines "QuadrangleParams" hypothesis
4603     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
4604     #                 will be created while other elements will be quadrangles.
4605     #                 Vertex can be either a GEOM_Object or a vertex ID within the
4606     #                 shape to mesh
4607     #
4608     #  @ingroup l3_hypos_additi
4609     def TriangleVertex(self, vertex, UseExisting=0):
4610         vertexID = vertex
4611         if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4612             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4613         hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4614                               CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4615         hyp.SetTriaVertex( vertexID )
4616         return hyp
4617
4618
4619 # Public class: Mesh_Tetrahedron
4620 # ------------------------------
4621
4622 ## Defines a tetrahedron 3D algorithm
4623 #
4624 #  @ingroup l3_algos_basic
4625 class Mesh_Tetrahedron(Mesh_Algorithm):
4626
4627     params = 0
4628     algoType = 0
4629
4630     ## Private constructor.
4631     def __init__(self, mesh, algoType, geom=0):
4632         Mesh_Algorithm.__init__(self)
4633
4634         if algoType == NETGEN:
4635             CheckPlugin(NETGEN)
4636             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4637             pass
4638
4639         elif algoType == FULL_NETGEN:
4640             CheckPlugin(NETGEN)
4641             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4642             pass
4643
4644         elif algoType == GHS3D:
4645             CheckPlugin(GHS3D)
4646             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4647             pass
4648
4649         elif algoType == GHS3DPRL:
4650             CheckPlugin(GHS3DPRL)
4651             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4652             pass
4653
4654         self.algoType = algoType
4655
4656     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4657     #  @param vol for the maximum volume of each tetrahedron
4658     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4659     #                   the same parameters, else (default) - creates a new one
4660     #  @ingroup l3_hypos_maxvol
4661     def MaxElementVolume(self, vol, UseExisting=0):
4662         if self.algoType == NETGEN:
4663             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4664                                   CompareMethod=self.CompareMaxElementVolume)
4665             hyp.SetMaxElementVolume(vol)
4666             return hyp
4667         elif self.algoType == FULL_NETGEN:
4668             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4669         return None
4670
4671     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4672     def CompareMaxElementVolume(self, hyp, args):
4673         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4674
4675     ## Defines hypothesis having several parameters
4676     #
4677     #  @ingroup l3_hypos_netgen
4678     def Parameters(self, which=SOLE):
4679         if self.params:
4680             return self.params
4681
4682         if self.algoType == FULL_NETGEN:
4683             if which == SIMPLE:
4684                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4685                                               "libNETGENEngine.so", UseExisting=0)
4686             else:
4687                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4688                                               "libNETGENEngine.so", UseExisting=0)
4689             return self.params
4690
4691         if self.algoType == GHS3D:
4692             self.params = self.Hypothesis("GHS3D_Parameters", [],
4693                                           "libGHS3DEngine.so", UseExisting=0)
4694             return self.params
4695
4696         if self.algoType == GHS3DPRL:
4697             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4698                                           "libGHS3DPRLEngine.so", UseExisting=0)
4699             return self.params
4700
4701         print "Algo supports no multi-parameter hypothesis"
4702         return None
4703
4704     ## Sets MaxSize
4705     #  Parameter of FULL_NETGEN
4706     #  @ingroup l3_hypos_netgen
4707     def SetMaxSize(self, theSize):
4708         self.Parameters().SetMaxSize(theSize)
4709
4710     ## Sets SecondOrder flag
4711     #  Parameter of FULL_NETGEN
4712     #  @ingroup l3_hypos_netgen
4713     def SetSecondOrder(self, theVal):
4714         self.Parameters().SetSecondOrder(theVal)
4715
4716     ## Sets Optimize flag
4717     #  Parameter of FULL_NETGEN
4718     #  @ingroup l3_hypos_netgen
4719     def SetOptimize(self, theVal):
4720         self.Parameters().SetOptimize(theVal)
4721
4722     ## Sets Fineness
4723     #  @param theFineness is:
4724     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4725     #  Parameter of FULL_NETGEN
4726     #  @ingroup l3_hypos_netgen
4727     def SetFineness(self, theFineness):
4728         self.Parameters().SetFineness(theFineness)
4729
4730     ## Sets GrowthRate
4731     #  Parameter of FULL_NETGEN
4732     #  @ingroup l3_hypos_netgen
4733     def SetGrowthRate(self, theRate):
4734         self.Parameters().SetGrowthRate(theRate)
4735
4736     ## Sets NbSegPerEdge
4737     #  Parameter of FULL_NETGEN
4738     #  @ingroup l3_hypos_netgen
4739     def SetNbSegPerEdge(self, theVal):
4740         self.Parameters().SetNbSegPerEdge(theVal)
4741
4742     ## Sets NbSegPerRadius
4743     #  Parameter of FULL_NETGEN
4744     #  @ingroup l3_hypos_netgen
4745     def SetNbSegPerRadius(self, theVal):
4746         self.Parameters().SetNbSegPerRadius(theVal)
4747
4748     ## Sets number of segments overriding value set by SetLocalLength()
4749     #  Only for algoType == NETGEN_FULL
4750     #  @ingroup l3_hypos_netgen
4751     def SetNumberOfSegments(self, theVal):
4752         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4753
4754     ## Sets number of segments overriding value set by SetNumberOfSegments()
4755     #  Only for algoType == NETGEN_FULL
4756     #  @ingroup l3_hypos_netgen
4757     def SetLocalLength(self, theVal):
4758         self.Parameters(SIMPLE).SetLocalLength(theVal)
4759
4760     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4761     #  Overrides value set by LengthFromEdges()
4762     #  Only for algoType == NETGEN_FULL
4763     #  @ingroup l3_hypos_netgen
4764     def MaxElementArea(self, area):
4765         self.Parameters(SIMPLE).SetMaxElementArea(area)
4766
4767     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4768     #  Overrides value set by MaxElementArea()
4769     #  Only for algoType == NETGEN_FULL
4770     #  @ingroup l3_hypos_netgen
4771     def LengthFromEdges(self):
4772         self.Parameters(SIMPLE).LengthFromEdges()
4773
4774     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4775     #  Overrides value set by MaxElementVolume()
4776     #  Only for algoType == NETGEN_FULL
4777     #  @ingroup l3_hypos_netgen
4778     def LengthFromFaces(self):
4779         self.Parameters(SIMPLE).LengthFromFaces()
4780
4781     ## To mesh "holes" in a solid or not. Default is to mesh.
4782     #  @ingroup l3_hypos_ghs3dh
4783     def SetToMeshHoles(self, toMesh):
4784         #  Parameter of GHS3D
4785         self.Parameters().SetToMeshHoles(toMesh)
4786
4787     ## Set Optimization level:
4788     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4789     #   Strong_Optimization.
4790     # Default is Standard_Optimization
4791     #  @ingroup l3_hypos_ghs3dh
4792     def SetOptimizationLevel(self, level):
4793         #  Parameter of GHS3D
4794         self.Parameters().SetOptimizationLevel(level)
4795
4796     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4797     #  @ingroup l3_hypos_ghs3dh
4798     def SetMaximumMemory(self, MB):
4799         #  Advanced parameter of GHS3D
4800         self.Parameters().SetMaximumMemory(MB)
4801
4802     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4803     #  automatic memory adjustment mode.
4804     #  @ingroup l3_hypos_ghs3dh
4805     def SetInitialMemory(self, MB):
4806         #  Advanced parameter of GHS3D
4807         self.Parameters().SetInitialMemory(MB)
4808
4809     ## Path to working directory.
4810     #  @ingroup l3_hypos_ghs3dh
4811     def SetWorkingDirectory(self, path):
4812         #  Advanced parameter of GHS3D
4813         self.Parameters().SetWorkingDirectory(path)
4814
4815     ## To keep working files or remove them. Log file remains in case of errors anyway.
4816     #  @ingroup l3_hypos_ghs3dh
4817     def SetKeepFiles(self, toKeep):
4818         #  Advanced parameter of GHS3D and GHS3DPRL
4819         self.Parameters().SetKeepFiles(toKeep)
4820
4821     ## To set verbose level [0-10]. <ul>
4822     #<li> 0 - no standard output,
4823     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4824     #     indicates when the final mesh is being saved. In addition the software
4825     #     gives indication regarding the CPU time.
4826     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4827     #     histogram of the skin mesh, quality statistics histogram together with
4828     #     the characteristics of the final mesh.</ul>
4829     #  @ingroup l3_hypos_ghs3dh
4830     def SetVerboseLevel(self, level):
4831         #  Advanced parameter of GHS3D
4832         self.Parameters().SetVerboseLevel(level)
4833
4834     ## To create new nodes.
4835     #  @ingroup l3_hypos_ghs3dh
4836     def SetToCreateNewNodes(self, toCreate):
4837         #  Advanced parameter of GHS3D
4838         self.Parameters().SetToCreateNewNodes(toCreate)
4839
4840     ## To use boundary recovery version which tries to create mesh on a very poor
4841     #  quality surface mesh.
4842     #  @ingroup l3_hypos_ghs3dh
4843     def SetToUseBoundaryRecoveryVersion(self, toUse):
4844         #  Advanced parameter of GHS3D
4845         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4846
4847     ## Sets command line option as text.
4848     #  @ingroup l3_hypos_ghs3dh
4849     def SetTextOption(self, option):
4850         #  Advanced parameter of GHS3D
4851         self.Parameters().SetTextOption(option)
4852
4853     ## Sets MED files name and path.
4854     def SetMEDName(self, value):
4855         self.Parameters().SetMEDName(value)
4856
4857     ## Sets the number of partition of the initial mesh
4858     def SetNbPart(self, value):
4859         self.Parameters().SetNbPart(value)
4860
4861     ## When big mesh, start tepal in background
4862     def SetBackground(self, value):
4863         self.Parameters().SetBackground(value)
4864
4865 # Public class: Mesh_Hexahedron
4866 # ------------------------------
4867
4868 ## Defines a hexahedron 3D algorithm
4869 #
4870 #  @ingroup l3_algos_basic
4871 class Mesh_Hexahedron(Mesh_Algorithm):
4872
4873     params = 0
4874     algoType = 0
4875
4876     ## Private constructor.
4877     def __init__(self, mesh, algoType=Hexa, geom=0):
4878         Mesh_Algorithm.__init__(self)
4879
4880         self.algoType = algoType
4881
4882         if algoType == Hexa:
4883             self.Create(mesh, geom, "Hexa_3D")
4884             pass
4885
4886         elif algoType == Hexotic:
4887             CheckPlugin(Hexotic)
4888             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4889             pass
4890
4891     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4892     #  @ingroup l3_hypos_hexotic
4893     def MinMaxQuad(self, min=3, max=8, quad=True):
4894         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4895                                       UseExisting=0)
4896         self.params.SetHexesMinLevel(min)
4897         self.params.SetHexesMaxLevel(max)
4898         self.params.SetHexoticQuadrangles(quad)
4899         return self.params
4900
4901 # Deprecated, only for compatibility!
4902 # Public class: Mesh_Netgen
4903 # ------------------------------
4904
4905 ## Defines a NETGEN-based 2D or 3D algorithm
4906 #  that needs no discrete boundary (i.e. independent)
4907 #
4908 #  This class is deprecated, only for compatibility!
4909 #
4910 #  More details.
4911 #  @ingroup l3_algos_basic
4912 class Mesh_Netgen(Mesh_Algorithm):
4913
4914     is3D = 0
4915
4916     ## Private constructor.
4917     def __init__(self, mesh, is3D, geom=0):
4918         Mesh_Algorithm.__init__(self)
4919
4920         CheckPlugin(NETGEN)
4921
4922         self.is3D = is3D
4923         if is3D:
4924             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4925             pass
4926
4927         else:
4928             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4929             pass
4930
4931     ## Defines the hypothesis containing parameters of the algorithm
4932     def Parameters(self):
4933         if self.is3D:
4934             hyp = self.Hypothesis("NETGEN_Parameters", [],
4935                                   "libNETGENEngine.so", UseExisting=0)
4936         else:
4937             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4938                                   "libNETGENEngine.so", UseExisting=0)
4939         return hyp
4940
4941 # Public class: Mesh_Projection1D
4942 # ------------------------------
4943
4944 ## Defines a projection 1D algorithm
4945 #  @ingroup l3_algos_proj
4946 #
4947 class Mesh_Projection1D(Mesh_Algorithm):
4948
4949     ## Private constructor.
4950     def __init__(self, mesh, geom=0):
4951         Mesh_Algorithm.__init__(self)
4952         self.Create(mesh, geom, "Projection_1D")
4953
4954     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4955     #  a mesh pattern is taken, and, optionally, the association of vertices
4956     #  between the source edge and a target edge (to which a hypothesis is assigned)
4957     #  @param edge from which nodes distribution is taken
4958     #  @param mesh from which nodes distribution is taken (optional)
4959     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4960     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4961     #  to associate with \a srcV (optional)
4962     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4963     #                     the same parameters, else (default) - creates a new one
4964     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4965         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4966                               UseExisting=0)
4967                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4968         hyp.SetSourceEdge( edge )
4969         if not mesh is None and isinstance(mesh, Mesh):
4970             mesh = mesh.GetMesh()
4971         hyp.SetSourceMesh( mesh )
4972         hyp.SetVertexAssociation( srcV, tgtV )
4973         return hyp
4974
4975     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4976     #def CompareSourceEdge(self, hyp, args):
4977     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4978     #    return False
4979
4980
4981 # Public class: Mesh_Projection2D
4982 # ------------------------------
4983
4984 ## Defines a projection 2D algorithm
4985 #  @ingroup l3_algos_proj
4986 #
4987 class Mesh_Projection2D(Mesh_Algorithm):
4988
4989     ## Private constructor.
4990     def __init__(self, mesh, geom=0):
4991         Mesh_Algorithm.__init__(self)
4992         self.Create(mesh, geom, "Projection_2D")
4993
4994     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4995     #  a mesh pattern is taken, and, optionally, the association of vertices
4996     #  between the source face and the target face (to which a hypothesis is assigned)
4997     #  @param face from which the mesh pattern is taken
4998     #  @param mesh from which the mesh pattern is taken (optional)
4999     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5000     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5001     #               to associate with \a srcV1 (optional)
5002     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5003     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5004     #               to associate with \a srcV2 (optional)
5005     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
5006     #                     the same parameters, else (default) - forces the creation a new one
5007     #
5008     #  Note: all association vertices must belong to one edge of a face
5009     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5010                    srcV2=None, tgtV2=None, UseExisting=0):
5011         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5012                               UseExisting=0)
5013                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5014         hyp.SetSourceFace( face )
5015         if not mesh is None and isinstance(mesh, Mesh):
5016             mesh = mesh.GetMesh()
5017         hyp.SetSourceMesh( mesh )
5018         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5019         return hyp
5020
5021     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5022     #def CompareSourceFace(self, hyp, args):
5023     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5024     #    return False
5025
5026 # Public class: Mesh_Projection3D
5027 # ------------------------------
5028
5029 ## Defines a projection 3D algorithm
5030 #  @ingroup l3_algos_proj
5031 #
5032 class Mesh_Projection3D(Mesh_Algorithm):
5033
5034     ## Private constructor.
5035     def __init__(self, mesh, geom=0):
5036         Mesh_Algorithm.__init__(self)
5037         self.Create(mesh, geom, "Projection_3D")
5038
5039     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5040     #  the mesh pattern is taken, and, optionally, the  association of vertices
5041     #  between the source and the target solid  (to which a hipothesis is assigned)
5042     #  @param solid from where the mesh pattern is taken
5043     #  @param mesh from where the mesh pattern is taken (optional)
5044     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5045     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5046     #  to associate with \a srcV1 (optional)
5047     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5048     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5049     #  to associate with \a srcV2 (optional)
5050     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
5051     #                     the same parameters, else (default) - creates a new one
5052     #
5053     #  Note: association vertices must belong to one edge of a solid
5054     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5055                       srcV2=0, tgtV2=0, UseExisting=0):
5056         hyp = self.Hypothesis("ProjectionSource3D",
5057                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5058                               UseExisting=0)
5059                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5060         hyp.SetSource3DShape( solid )
5061         if not mesh is None and isinstance(mesh, Mesh):
5062             mesh = mesh.GetMesh()
5063         hyp.SetSourceMesh( mesh )
5064         if srcV1 and srcV2 and tgtV1 and tgtV2:
5065             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5066         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5067         return hyp
5068
5069     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5070     #def CompareSourceShape3D(self, hyp, args):
5071     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5072     #    return False
5073
5074
5075 # Public class: Mesh_Prism
5076 # ------------------------
5077
5078 ## Defines a 3D extrusion algorithm
5079 #  @ingroup l3_algos_3dextr
5080 #
5081 class Mesh_Prism3D(Mesh_Algorithm):
5082
5083     ## Private constructor.
5084     def __init__(self, mesh, geom=0):
5085         Mesh_Algorithm.__init__(self)
5086         self.Create(mesh, geom, "Prism_3D")
5087
5088 # Public class: Mesh_RadialPrism
5089 # -------------------------------
5090
5091 ## Defines a Radial Prism 3D algorithm
5092 #  @ingroup l3_algos_radialp
5093 #
5094 class Mesh_RadialPrism3D(Mesh_Algorithm):
5095
5096     ## Private constructor.
5097     def __init__(self, mesh, geom=0):
5098         Mesh_Algorithm.__init__(self)
5099         self.Create(mesh, geom, "RadialPrism_3D")
5100
5101         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5102         self.nbLayers = None
5103
5104     ## Return 3D hypothesis holding the 1D one
5105     def Get3DHypothesis(self):
5106         return self.distribHyp
5107
5108     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5109     #  hypothesis. Returns the created hypothesis
5110     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5111         #print "OwnHypothesis",hypType
5112         if not self.nbLayers is None:
5113             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5114             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5115         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5116         self.mesh.smeshpyD.SetCurrentStudy( None )
5117         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5118         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5119         self.distribHyp.SetLayerDistribution( hyp )
5120         return hyp
5121
5122     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5123     #  prisms to build between the inner and outer shells
5124     #  @param n number of layers
5125     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5126     #                     the same parameters, else (default) - creates a new one
5127     def NumberOfLayers(self, n, UseExisting=0):
5128         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5129         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5130                                         CompareMethod=self.CompareNumberOfLayers)
5131         self.nbLayers.SetNumberOfLayers( n )
5132         return self.nbLayers
5133
5134     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5135     def CompareNumberOfLayers(self, hyp, args):
5136         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5137
5138     ## Defines "LocalLength" hypothesis, specifying the segment length
5139     #  to build between the inner and the outer shells
5140     #  @param l the length of segments
5141     #  @param p the precision of rounding
5142     def LocalLength(self, l, p=1e-07):
5143         hyp = self.OwnHypothesis("LocalLength", [l,p])
5144         hyp.SetLength(l)
5145         hyp.SetPrecision(p)
5146         return hyp
5147
5148     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5149     #  prisms to build between the inner and the outer shells.
5150     #  @param n the number of layers
5151     #  @param s the scale factor (optional)
5152     def NumberOfSegments(self, n, s=[]):
5153         if s == []:
5154             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5155         else:
5156             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5157             hyp.SetDistrType( 1 )
5158             hyp.SetScaleFactor(s)
5159         hyp.SetNumberOfSegments(n)
5160         return hyp
5161
5162     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5163     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
5164     #  @param start  the length of the first segment
5165     #  @param end    the length of the last  segment
5166     def Arithmetic1D(self, start, end ):
5167         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5168         hyp.SetLength(start, 1)
5169         hyp.SetLength(end  , 0)
5170         return hyp
5171
5172     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5173     #  to build between the inner and the outer shells as geometric length increasing
5174     #  @param start for the length of the first segment
5175     #  @param end   for the length of the last  segment
5176     def StartEndLength(self, start, end):
5177         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5178         hyp.SetLength(start, 1)
5179         hyp.SetLength(end  , 0)
5180         return hyp
5181
5182     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5183     #  to build between the inner and outer shells
5184     #  @param fineness defines the quality of the mesh within the range [0-1]
5185     def AutomaticLength(self, fineness=0):
5186         hyp = self.OwnHypothesis("AutomaticLength")
5187         hyp.SetFineness( fineness )
5188         return hyp
5189
5190 # Public class: Mesh_RadialQuadrangle1D2D
5191 # -------------------------------
5192
5193 ## Defines a Radial Quadrangle 1D2D algorithm
5194 #  @ingroup l2_algos_radialq
5195 #
5196 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5197
5198     ## Private constructor.
5199     def __init__(self, mesh, geom=0):
5200         Mesh_Algorithm.__init__(self)
5201         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5202
5203         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5204         self.nbLayers = None
5205
5206     ## Return 2D hypothesis holding the 1D one
5207     def Get2DHypothesis(self):
5208         return self.distribHyp
5209
5210     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5211     #  hypothesis. Returns the created hypothesis
5212     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5213         #print "OwnHypothesis",hypType
5214         if self.nbLayers:
5215             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5216         if self.distribHyp is None:
5217             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5218         else:
5219             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5220         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5221         self.mesh.smeshpyD.SetCurrentStudy( None )
5222         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5223         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5224         self.distribHyp.SetLayerDistribution( hyp )
5225         return hyp
5226
5227     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5228     #  @param n number of layers
5229     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5230     #                     the same parameters, else (default) - creates a new one
5231     def NumberOfLayers(self, n, UseExisting=0):
5232         if self.distribHyp:
5233             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5234         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5235                                         CompareMethod=self.CompareNumberOfLayers)
5236         self.nbLayers.SetNumberOfLayers( n )
5237         return self.nbLayers
5238
5239     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5240     def CompareNumberOfLayers(self, hyp, args):
5241         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5242
5243     ## Defines "LocalLength" hypothesis, specifying the segment length
5244     #  @param l the length of segments
5245     #  @param p the precision of rounding
5246     def LocalLength(self, l, p=1e-07):
5247         hyp = self.OwnHypothesis("LocalLength", [l,p])
5248         hyp.SetLength(l)
5249         hyp.SetPrecision(p)
5250         return hyp
5251
5252     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5253     #  @param n the number of layers
5254     #  @param s the scale factor (optional)
5255     def NumberOfSegments(self, n, s=[]):
5256         if s == []:
5257             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5258         else:
5259             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5260             hyp.SetDistrType( 1 )
5261             hyp.SetScaleFactor(s)
5262         hyp.SetNumberOfSegments(n)
5263         return hyp
5264
5265     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5266     #  with a length that changes in arithmetic progression
5267     #  @param start  the length of the first segment
5268     #  @param end    the length of the last  segment
5269     def Arithmetic1D(self, start, end ):
5270         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5271         hyp.SetLength(start, 1)
5272         hyp.SetLength(end  , 0)
5273         return hyp
5274
5275     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5276     #  as geometric length increasing
5277     #  @param start for the length of the first segment
5278     #  @param end   for the length of the last  segment
5279     def StartEndLength(self, start, end):
5280         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5281         hyp.SetLength(start, 1)
5282         hyp.SetLength(end  , 0)
5283         return hyp
5284
5285     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5286     #  @param fineness defines the quality of the mesh within the range [0-1]
5287     def AutomaticLength(self, fineness=0):
5288         hyp = self.OwnHypothesis("AutomaticLength")
5289         hyp.SetFineness( fineness )
5290         return hyp
5291
5292
5293 # Private class: Mesh_UseExisting
5294 # -------------------------------
5295 class Mesh_UseExisting(Mesh_Algorithm):
5296
5297     def __init__(self, dim, mesh, geom=0):
5298         if dim == 1:
5299             self.Create(mesh, geom, "UseExisting_1D")
5300         else:
5301             self.Create(mesh, geom, "UseExisting_2D")
5302
5303
5304 import salome_notebook
5305 notebook = salome_notebook.notebook
5306
5307 ##Return values of the notebook variables
5308 def ParseParameters(last, nbParams,nbParam, value):
5309     result = None
5310     strResult = ""
5311     counter = 0
5312     listSize = len(last)
5313     for n in range(0,nbParams):
5314         if n+1 != nbParam:
5315             if counter < listSize:
5316                 strResult = strResult + last[counter]
5317             else:
5318                 strResult = strResult + ""
5319         else:
5320             if isinstance(value, str):
5321                 if notebook.isVariable(value):
5322                     result = notebook.get(value)
5323                     strResult=strResult+value
5324                 else:
5325                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5326             else:
5327                 strResult=strResult+str(value)
5328                 result = value
5329         if nbParams - 1 != counter:
5330             strResult=strResult+var_separator #":"
5331         counter = counter+1
5332     return result, strResult
5333
5334 #Wrapper class for StdMeshers_LocalLength hypothesis
5335 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5336
5337     ## Set Length parameter value
5338     #  @param length numerical value or name of variable from notebook
5339     def SetLength(self, length):
5340         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5341         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5342         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5343
5344    ## Set Precision parameter value
5345    #  @param precision numerical value or name of variable from notebook
5346     def SetPrecision(self, precision):
5347         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5348         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5349         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5350
5351 #Registering the new proxy for LocalLength
5352 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5353
5354
5355 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5356 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5357     
5358     def SetLayerDistribution(self, hypo):
5359         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5360         hypo.ClearParameters();
5361         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5362
5363 #Registering the new proxy for LayerDistribution
5364 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5365
5366 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5367 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5368     
5369     ## Set Length parameter value
5370     #  @param length numerical value or name of variable from notebook    
5371     def SetLength(self, length):
5372         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5373         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5374         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5375
5376 #Registering the new proxy for SegmentLengthAroundVertex
5377 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5378
5379
5380 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5381 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5382     
5383     ## Set Length parameter value
5384     #  @param length   numerical value or name of variable from notebook
5385     #  @param isStart  true is length is Start Length, otherwise false
5386     def SetLength(self, length, isStart):
5387         nb = 2
5388         if isStart:
5389             nb = 1
5390         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5391         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5392         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5393         
5394 #Registering the new proxy for Arithmetic1D
5395 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5396
5397 #Wrapper class for StdMeshers_Deflection1D hypothesis
5398 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5399     
5400     ## Set Deflection parameter value
5401     #  @param deflection numerical value or name of variable from notebook    
5402     def SetDeflection(self, deflection):
5403         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5404         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5405         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5406
5407 #Registering the new proxy for Deflection1D
5408 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5409
5410 #Wrapper class for StdMeshers_StartEndLength hypothesis
5411 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5412     
5413     ## Set Length parameter value
5414     #  @param length  numerical value or name of variable from notebook
5415     #  @param isStart true is length is Start Length, otherwise false
5416     def SetLength(self, length, isStart):
5417         nb = 2
5418         if isStart:
5419             nb = 1
5420         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5421         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5422         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5423         
5424 #Registering the new proxy for StartEndLength
5425 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5426
5427 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5428 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5429     
5430     ## Set Max Element Area parameter value
5431     #  @param area  numerical value or name of variable from notebook
5432     def SetMaxElementArea(self, area):
5433         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5434         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5435         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5436         
5437 #Registering the new proxy for MaxElementArea
5438 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5439
5440
5441 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5442 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5443     
5444     ## Set Max Element Volume parameter value
5445     #  @param volume numerical value or name of variable from notebook
5446     def SetMaxElementVolume(self, volume):
5447         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5448         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5449         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5450         
5451 #Registering the new proxy for MaxElementVolume
5452 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5453
5454
5455 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5456 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5457     
5458     ## Set Number Of Layers parameter value
5459     #  @param nbLayers  numerical value or name of variable from notebook
5460     def SetNumberOfLayers(self, nbLayers):
5461         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5462         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5463         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5464         
5465 #Registering the new proxy for NumberOfLayers
5466 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5467
5468 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5469 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5470     
5471     ## Set Number Of Segments parameter value
5472     #  @param nbSeg numerical value or name of variable from notebook
5473     def SetNumberOfSegments(self, nbSeg):
5474         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5475         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5476         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5477         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5478         
5479     ## Set Scale Factor parameter value
5480     #  @param factor numerical value or name of variable from notebook
5481     def SetScaleFactor(self, factor):
5482         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5483         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5484         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5485         
5486 #Registering the new proxy for NumberOfSegments
5487 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5488
5489 if not noNETGENPlugin:
5490     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5491     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5492
5493         ## Set Max Size parameter value
5494         #  @param maxsize numerical value or name of variable from notebook
5495         def SetMaxSize(self, maxsize):
5496             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5497             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5498             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5499             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5500
5501         ## Set Growth Rate parameter value
5502         #  @param value  numerical value or name of variable from notebook
5503         def SetGrowthRate(self, value):
5504             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5505             value, parameters = ParseParameters(lastParameters,4,2,value)
5506             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5507             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5508
5509         ## Set Number of Segments per Edge parameter value
5510         #  @param value  numerical value or name of variable from notebook
5511         def SetNbSegPerEdge(self, value):
5512             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5513             value, parameters = ParseParameters(lastParameters,4,3,value)
5514             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5515             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5516
5517         ## Set Number of Segments per Radius parameter value
5518         #  @param value  numerical value or name of variable from notebook
5519         def SetNbSegPerRadius(self, value):
5520             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5521             value, parameters = ParseParameters(lastParameters,4,4,value)
5522             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5523             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5524
5525     #Registering the new proxy for NETGENPlugin_Hypothesis
5526     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5527
5528
5529     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5530     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5531         pass
5532
5533     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5534     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5535
5536     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5537     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5538
5539         ## Set Number of Segments parameter value
5540         #  @param nbSeg numerical value or name of variable from notebook
5541         def SetNumberOfSegments(self, nbSeg):
5542             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5543             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5544             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5545             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5546
5547         ## Set Local Length parameter value
5548         #  @param length numerical value or name of variable from notebook
5549         def SetLocalLength(self, length):
5550             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5551             length, parameters = ParseParameters(lastParameters,2,1,length)
5552             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5553             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5554
5555         ## Set Max Element Area parameter value
5556         #  @param area numerical value or name of variable from notebook    
5557         def SetMaxElementArea(self, area):
5558             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5559             area, parameters = ParseParameters(lastParameters,2,2,area)
5560             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5561             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5562
5563         def LengthFromEdges(self):
5564             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5565             value = 0;
5566             value, parameters = ParseParameters(lastParameters,2,2,value)
5567             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5568             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5569
5570     #Registering the new proxy for NETGEN_SimpleParameters_2D
5571     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5572
5573
5574     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5575     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5576         ## Set Max Element Volume parameter value
5577         #  @param volume numerical value or name of variable from notebook    
5578         def SetMaxElementVolume(self, volume):
5579             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5580             volume, parameters = ParseParameters(lastParameters,3,3,volume)
5581             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5582             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5583
5584         def LengthFromFaces(self):
5585             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5586             value = 0;
5587             value, parameters = ParseParameters(lastParameters,3,3,value)
5588             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5589             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5590
5591     #Registering the new proxy for NETGEN_SimpleParameters_3D
5592     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5593
5594     pass # if not noNETGENPlugin:
5595
5596 class Pattern(SMESH._objref_SMESH_Pattern):
5597
5598     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5599         flag = False
5600         if isinstance(theNodeIndexOnKeyPoint1,str):
5601             flag = True
5602         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5603         if flag:
5604             theNodeIndexOnKeyPoint1 -= 1
5605         theMesh.SetParameters(Parameters)
5606         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5607
5608     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5609         flag0 = False
5610         flag1 = False
5611         if isinstance(theNode000Index,str):
5612             flag0 = True
5613         if isinstance(theNode001Index,str):
5614             flag1 = True
5615         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5616         if flag0:
5617             theNode000Index -= 1
5618         if flag1:
5619             theNode001Index -= 1
5620         theMesh.SetParameters(Parameters)
5621         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5622
5623 #Registering the new proxy for Pattern
5624 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)