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