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