Salome HOME
0020672: EDF 1243 SMESH : Be able to transform mixed mesh
[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 nodes of given face (counted from zero) for given volumic element.
2057     #  @ingroup l1_meshinfo
2058     def GetElemFaceNodes(self,elemId, faceIndex):
2059         return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2060
2061     ## Returns an element based on all given nodes.
2062     #  @ingroup l1_meshinfo
2063     def FindElementByNodes(self,nodes):
2064         return self.mesh.FindElementByNodes(nodes)
2065
2066     ## Returns true if the given element is a polygon
2067     #  @ingroup l1_meshinfo
2068     def IsPoly(self, id):
2069         return self.mesh.IsPoly(id)
2070
2071     ## Returns true if the given element is quadratic
2072     #  @ingroup l1_meshinfo
2073     def IsQuadratic(self, id):
2074         return self.mesh.IsQuadratic(id)
2075
2076     ## Returns XYZ coordinates of the barycenter of the given element
2077     #  \n If there is no element for the given ID - returns an empty list
2078     #  @return a list of three double values
2079     #  @ingroup l1_meshinfo
2080     def BaryCenter(self, id):
2081         return self.mesh.BaryCenter(id)
2082
2083
2084     # Mesh edition (SMESH_MeshEditor functionality):
2085     # ---------------------------------------------
2086
2087     ## Removes the elements from the mesh by ids
2088     #  @param IDsOfElements is a list of ids of elements to remove
2089     #  @return True or False
2090     #  @ingroup l2_modif_del
2091     def RemoveElements(self, IDsOfElements):
2092         return self.editor.RemoveElements(IDsOfElements)
2093
2094     ## Removes nodes from mesh by ids
2095     #  @param IDsOfNodes is a list of ids of nodes to remove
2096     #  @return True or False
2097     #  @ingroup l2_modif_del
2098     def RemoveNodes(self, IDsOfNodes):
2099         return self.editor.RemoveNodes(IDsOfNodes)
2100
2101     ## Add a node to the mesh by coordinates
2102     #  @return Id of the new node
2103     #  @ingroup l2_modif_add
2104     def AddNode(self, x, y, z):
2105         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2106         self.mesh.SetParameters(Parameters)
2107         return self.editor.AddNode( x, y, z)
2108
2109     ## Creates a 0D element on a node with given number.
2110     #  @param IDOfNode the ID of node for creation of the element.
2111     #  @return the Id of the new 0D element
2112     #  @ingroup l2_modif_add
2113     def Add0DElement(self, IDOfNode):
2114         return self.editor.Add0DElement(IDOfNode)
2115
2116     ## Creates a linear or quadratic edge (this is determined
2117     #  by the number of given nodes).
2118     #  @param IDsOfNodes the list of node IDs for creation of the element.
2119     #  The order of nodes in this list should correspond to the description
2120     #  of MED. \n This description is located by the following link:
2121     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2122     #  @return the Id of the new edge
2123     #  @ingroup l2_modif_add
2124     def AddEdge(self, IDsOfNodes):
2125         return self.editor.AddEdge(IDsOfNodes)
2126
2127     ## Creates a linear or quadratic face (this is determined
2128     #  by the number of given nodes).
2129     #  @param IDsOfNodes the list of node IDs for creation of the element.
2130     #  The order of nodes in this list should correspond to the description
2131     #  of MED. \n This description is located by the following link:
2132     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2133     #  @return the Id of the new face
2134     #  @ingroup l2_modif_add
2135     def AddFace(self, IDsOfNodes):
2136         return self.editor.AddFace(IDsOfNodes)
2137
2138     ## Adds a polygonal face to the mesh by the list of node IDs
2139     #  @param IdsOfNodes the list of node IDs for creation of the element.
2140     #  @return the Id of the new face
2141     #  @ingroup l2_modif_add
2142     def AddPolygonalFace(self, IdsOfNodes):
2143         return self.editor.AddPolygonalFace(IdsOfNodes)
2144
2145     ## Creates both simple and quadratic volume (this is determined
2146     #  by the number of given nodes).
2147     #  @param IDsOfNodes the list of node IDs for creation of the element.
2148     #  The order of nodes in this list should correspond to the description
2149     #  of MED. \n This description is located by the following link:
2150     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2151     #  @return the Id of the new volumic element
2152     #  @ingroup l2_modif_add
2153     def AddVolume(self, IDsOfNodes):
2154         return self.editor.AddVolume(IDsOfNodes)
2155
2156     ## Creates a volume of many faces, giving nodes for each face.
2157     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
2158     #  @param Quantities the list of integer values, Quantities[i]
2159     #         gives the quantity of nodes in face number i.
2160     #  @return the Id of the new volumic element
2161     #  @ingroup l2_modif_add
2162     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2163         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2164
2165     ## Creates a volume of many faces, giving the IDs of the existing faces.
2166     #  @param IdsOfFaces the list of face IDs for volume creation.
2167     #
2168     #  Note:  The created volume will refer only to the nodes
2169     #         of the given faces, not to the faces themselves.
2170     #  @return the Id of the new volumic element
2171     #  @ingroup l2_modif_add
2172     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2173         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2174
2175
2176     ## @brief Binds a node to a vertex
2177     #  @param NodeID a node ID
2178     #  @param Vertex a vertex or vertex ID
2179     #  @return True if succeed else raises an exception
2180     #  @ingroup l2_modif_add
2181     def SetNodeOnVertex(self, NodeID, Vertex):
2182         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2183             VertexID = Vertex.GetSubShapeIndices()[0]
2184         else:
2185             VertexID = Vertex
2186         try:
2187             self.editor.SetNodeOnVertex(NodeID, VertexID)
2188         except SALOME.SALOME_Exception, inst:
2189             raise ValueError, inst.details.text
2190         return True
2191
2192
2193     ## @brief Stores the node position on an edge
2194     #  @param NodeID a node ID
2195     #  @param Edge an edge or edge ID
2196     #  @param paramOnEdge a parameter on the edge where the node is located
2197     #  @return True if succeed else raises an exception
2198     #  @ingroup l2_modif_add
2199     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2200         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2201             EdgeID = Edge.GetSubShapeIndices()[0]
2202         else:
2203             EdgeID = Edge
2204         try:
2205             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2206         except SALOME.SALOME_Exception, inst:
2207             raise ValueError, inst.details.text
2208         return True
2209
2210     ## @brief Stores node position on a face
2211     #  @param NodeID a node ID
2212     #  @param Face a face or face ID
2213     #  @param u U parameter on the face where the node is located
2214     #  @param v V parameter on the face where the node is located
2215     #  @return True if succeed else raises an exception
2216     #  @ingroup l2_modif_add
2217     def SetNodeOnFace(self, NodeID, Face, u, v):
2218         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2219             FaceID = Face.GetSubShapeIndices()[0]
2220         else:
2221             FaceID = Face
2222         try:
2223             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2224         except SALOME.SALOME_Exception, inst:
2225             raise ValueError, inst.details.text
2226         return True
2227
2228     ## @brief Binds a node to a solid
2229     #  @param NodeID a node ID
2230     #  @param Solid  a solid or solid ID
2231     #  @return True if succeed else raises an exception
2232     #  @ingroup l2_modif_add
2233     def SetNodeInVolume(self, NodeID, Solid):
2234         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2235             SolidID = Solid.GetSubShapeIndices()[0]
2236         else:
2237             SolidID = Solid
2238         try:
2239             self.editor.SetNodeInVolume(NodeID, SolidID)
2240         except SALOME.SALOME_Exception, inst:
2241             raise ValueError, inst.details.text
2242         return True
2243
2244     ## @brief Bind an element to a shape
2245     #  @param ElementID an element ID
2246     #  @param Shape a shape or shape ID
2247     #  @return True if succeed else raises an exception
2248     #  @ingroup l2_modif_add
2249     def SetMeshElementOnShape(self, ElementID, Shape):
2250         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2251             ShapeID = Shape.GetSubShapeIndices()[0]
2252         else:
2253             ShapeID = Shape
2254         try:
2255             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2256         except SALOME.SALOME_Exception, inst:
2257             raise ValueError, inst.details.text
2258         return True
2259
2260
2261     ## Moves the node with the given id
2262     #  @param NodeID the id of the node
2263     #  @param x  a new X coordinate
2264     #  @param y  a new Y coordinate
2265     #  @param z  a new Z coordinate
2266     #  @return True if succeed else False
2267     #  @ingroup l2_modif_movenode
2268     def MoveNode(self, NodeID, x, y, z):
2269         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2270         self.mesh.SetParameters(Parameters)
2271         return self.editor.MoveNode(NodeID, x, y, z)
2272
2273     ## Finds the node closest to a point and moves it to a point location
2274     #  @param x  the X coordinate of a point
2275     #  @param y  the Y coordinate of a point
2276     #  @param z  the Z coordinate of a point
2277     #  @param NodeID if specified (>0), the node with this ID is moved,
2278     #  otherwise, the node closest to point (@a x,@a y,@a z) is moved
2279     #  @return the ID of a node
2280     #  @ingroup l2_modif_throughp
2281     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2282         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2283         self.mesh.SetParameters(Parameters)
2284         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2285
2286     ## Finds the node closest to a point
2287     #  @param x  the X coordinate of a point
2288     #  @param y  the Y coordinate of a point
2289     #  @param z  the Z coordinate of a point
2290     #  @return the ID of a node
2291     #  @ingroup l2_modif_throughp
2292     def FindNodeClosestTo(self, x, y, z):
2293         #preview = self.mesh.GetMeshEditPreviewer()
2294         #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2295         return self.editor.FindNodeClosestTo(x, y, z)
2296
2297     ## Finds the elements where a point lays IN or ON
2298     #  @param x  the X coordinate of a point
2299     #  @param y  the Y coordinate of a point
2300     #  @param z  the Z coordinate of a point
2301     #  @param elementType type of elements to find (SMESH.ALL type
2302     #         means elements of any type excluding nodes and 0D elements)
2303     #  @return list of IDs of found elements
2304     #  @ingroup l2_modif_throughp
2305     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2306         return self.editor.FindElementsByPoint(x, y, z, elementType)
2307         
2308     # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2309     # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2310      
2311     def GetPointState(self, x, y, z):
2312         return self.editor.GetPointState(x, y, z)
2313
2314     ## Finds the node closest to a point and moves it to a point location
2315     #  @param x  the X coordinate of a point
2316     #  @param y  the Y coordinate of a point
2317     #  @param z  the Z coordinate of a point
2318     #  @return the ID of a moved node
2319     #  @ingroup l2_modif_throughp
2320     def MeshToPassThroughAPoint(self, x, y, z):
2321         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2322
2323     ## Replaces two neighbour triangles sharing Node1-Node2 link
2324     #  with the triangles built on the same 4 nodes but having other common link.
2325     #  @param NodeID1  the ID of the first node
2326     #  @param NodeID2  the ID of the second node
2327     #  @return false if proper faces were not found
2328     #  @ingroup l2_modif_invdiag
2329     def InverseDiag(self, NodeID1, NodeID2):
2330         return self.editor.InverseDiag(NodeID1, NodeID2)
2331
2332     ## Replaces two neighbour triangles sharing Node1-Node2 link
2333     #  with a quadrangle built on the same 4 nodes.
2334     #  @param NodeID1  the ID of the first node
2335     #  @param NodeID2  the ID of the second node
2336     #  @return false if proper faces were not found
2337     #  @ingroup l2_modif_unitetri
2338     def DeleteDiag(self, NodeID1, NodeID2):
2339         return self.editor.DeleteDiag(NodeID1, NodeID2)
2340
2341     ## Reorients elements by ids
2342     #  @param IDsOfElements if undefined reorients all mesh elements
2343     #  @return True if succeed else False
2344     #  @ingroup l2_modif_changori
2345     def Reorient(self, IDsOfElements=None):
2346         if IDsOfElements == None:
2347             IDsOfElements = self.GetElementsId()
2348         return self.editor.Reorient(IDsOfElements)
2349
2350     ## Reorients all elements of the object
2351     #  @param theObject mesh, submesh or group
2352     #  @return True if succeed else False
2353     #  @ingroup l2_modif_changori
2354     def ReorientObject(self, theObject):
2355         if ( isinstance( theObject, Mesh )):
2356             theObject = theObject.GetMesh()
2357         return self.editor.ReorientObject(theObject)
2358
2359     ## Fuses the neighbouring triangles into quadrangles.
2360     #  @param IDsOfElements The triangles to be fused,
2361     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
2362     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2363     #                       is still performed; theMaxAngle is mesured in radians.
2364     #                       Also it could be a name of variable which defines angle in degrees.
2365     #  @return TRUE in case of success, FALSE otherwise.
2366     #  @ingroup l2_modif_unitetri
2367     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2368         flag = False
2369         if isinstance(MaxAngle,str):
2370             flag = True
2371         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2372         if flag:
2373             MaxAngle = DegreesToRadians(MaxAngle)
2374         if IDsOfElements == []:
2375             IDsOfElements = self.GetElementsId()
2376         self.mesh.SetParameters(Parameters)
2377         Functor = 0
2378         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2379             Functor = theCriterion
2380         else:
2381             Functor = self.smeshpyD.GetFunctor(theCriterion)
2382         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2383
2384     ## Fuses the neighbouring triangles of the object into quadrangles
2385     #  @param theObject is mesh, submesh or group
2386     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2387     #  @param MaxAngle   a max angle between element normals at which the fusion
2388     #                   is still performed; theMaxAngle is mesured in radians.
2389     #  @return TRUE in case of success, FALSE otherwise.
2390     #  @ingroup l2_modif_unitetri
2391     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2392         if ( isinstance( theObject, Mesh )):
2393             theObject = theObject.GetMesh()
2394         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2395
2396     ## Splits quadrangles into triangles.
2397     #  @param IDsOfElements the faces to be splitted.
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 QuadToTri (self, IDsOfElements, theCriterion):
2402         if IDsOfElements == []:
2403             IDsOfElements = self.GetElementsId()
2404         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2405
2406     ## Splits quadrangles into triangles.
2407     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
2408     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2409     #  @return TRUE in case of success, FALSE otherwise.
2410     #  @ingroup l2_modif_cutquadr
2411     def QuadToTriObject (self, theObject, theCriterion):
2412         if ( isinstance( theObject, Mesh )):
2413             theObject = theObject.GetMesh()
2414         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2415
2416     ## Splits quadrangles into triangles.
2417     #  @param IDsOfElements the faces to be splitted
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 SplitQuad (self, IDsOfElements, Diag13):
2422         if IDsOfElements == []:
2423             IDsOfElements = self.GetElementsId()
2424         return self.editor.SplitQuad(IDsOfElements, Diag13)
2425
2426     ## Splits quadrangles into triangles.
2427     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2428     #  @param Diag13    is used to choose a diagonal for splitting.
2429     #  @return TRUE in case of success, FALSE otherwise.
2430     #  @ingroup l2_modif_cutquadr
2431     def SplitQuadObject (self, theObject, Diag13):
2432         if ( isinstance( theObject, Mesh )):
2433             theObject = theObject.GetMesh()
2434         return self.editor.SplitQuadObject(theObject, Diag13)
2435
2436     ## Finds a better splitting of the given quadrangle.
2437     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2438     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
2439     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2440     #          diagonal is better, 0 if error occurs.
2441     #  @ingroup l2_modif_cutquadr
2442     def BestSplit (self, IDOfQuad, theCriterion):
2443         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2444
2445     ## Splits volumic elements into tetrahedrons
2446     #  @param elemIDs either list of elements or mesh or group or submesh
2447     #  @param method  flags passing splitting method:
2448     #         1 - split the hexahedron into 5 tetrahedrons
2449     #         2 - split the hexahedron into 6 tetrahedrons
2450     #  @ingroup l2_modif_cutquadr
2451     def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2452         if isinstance( elemIDs, Mesh ):
2453             elemIDs = elemIDs.GetMesh()
2454         self.editor.SplitVolumesIntoTetra(elemIDs, method)
2455
2456     ## Splits quadrangle faces near triangular facets of volumes
2457     #
2458     #  @ingroup l1_auxiliary
2459     def SplitQuadsNearTriangularFacets(self):
2460         faces_array = self.GetElementsByType(SMESH.FACE)
2461         for face_id in faces_array:
2462             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2463                 quad_nodes = self.mesh.GetElemNodes(face_id)
2464                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2465                 isVolumeFound = False
2466                 for node1_elem in node1_elems:
2467                     if not isVolumeFound:
2468                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2469                             nb_nodes = self.GetElemNbNodes(node1_elem)
2470                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2471                                 volume_elem = node1_elem
2472                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2473                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2474                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2475                                         isVolumeFound = True
2476                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2477                                             self.SplitQuad([face_id], False) # diagonal 2-4
2478                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2479                                         isVolumeFound = True
2480                                         self.SplitQuad([face_id], True) # diagonal 1-3
2481                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2482                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2483                                         isVolumeFound = True
2484                                         self.SplitQuad([face_id], True) # diagonal 1-3
2485
2486     ## @brief Splits hexahedrons into tetrahedrons.
2487     #
2488     #  This operation uses pattern mapping functionality for splitting.
2489     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2490     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2491     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2492     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2493     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2494     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2495     #  @return TRUE in case of success, FALSE otherwise.
2496     #  @ingroup l1_auxiliary
2497     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2498         # Pattern:     5.---------.6
2499         #              /|#*      /|
2500         #             / | #*    / |
2501         #            /  |  # * /  |
2502         #           /   |   # /*  |
2503         # (0,0,1) 4.---------.7 * |
2504         #          |#*  |1   | # *|
2505         #          | # *.----|---#.2
2506         #          |  #/ *   |   /
2507         #          |  /#  *  |  /
2508         #          | /   # * | /
2509         #          |/      #*|/
2510         # (0,0,0) 0.---------.3
2511         pattern_tetra = "!!! Nb of points: \n 8 \n\
2512         !!! Points: \n\
2513         0 0 0  !- 0 \n\
2514         0 1 0  !- 1 \n\
2515         1 1 0  !- 2 \n\
2516         1 0 0  !- 3 \n\
2517         0 0 1  !- 4 \n\
2518         0 1 1  !- 5 \n\
2519         1 1 1  !- 6 \n\
2520         1 0 1  !- 7 \n\
2521         !!! Indices of points of 6 tetras: \n\
2522         0 3 4 1 \n\
2523         7 4 3 1 \n\
2524         4 7 5 1 \n\
2525         6 2 5 7 \n\
2526         1 5 2 7 \n\
2527         2 3 1 7 \n"
2528
2529         pattern = self.smeshpyD.GetPattern()
2530         isDone  = pattern.LoadFromFile(pattern_tetra)
2531         if not isDone:
2532             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2533             return isDone
2534
2535         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2536         isDone = pattern.MakeMesh(self.mesh, False, False)
2537         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2538
2539         # split quafrangle faces near triangular facets of volumes
2540         self.SplitQuadsNearTriangularFacets()
2541
2542         return isDone
2543
2544     ## @brief Split hexahedrons into prisms.
2545     #
2546     #  Uses the pattern mapping functionality for splitting.
2547     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2548     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2549     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2550     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2551     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2552     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2553     #  @return TRUE in case of success, FALSE otherwise.
2554     #  @ingroup l1_auxiliary
2555     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2556         # Pattern:     5.---------.6
2557         #              /|#       /|
2558         #             / | #     / |
2559         #            /  |  #   /  |
2560         #           /   |   # /   |
2561         # (0,0,1) 4.---------.7   |
2562         #          |    |    |    |
2563         #          |   1.----|----.2
2564         #          |   / *   |   /
2565         #          |  /   *  |  /
2566         #          | /     * | /
2567         #          |/       *|/
2568         # (0,0,0) 0.---------.3
2569         pattern_prism = "!!! Nb of points: \n 8 \n\
2570         !!! Points: \n\
2571         0 0 0  !- 0 \n\
2572         0 1 0  !- 1 \n\
2573         1 1 0  !- 2 \n\
2574         1 0 0  !- 3 \n\
2575         0 0 1  !- 4 \n\
2576         0 1 1  !- 5 \n\
2577         1 1 1  !- 6 \n\
2578         1 0 1  !- 7 \n\
2579         !!! Indices of points of 2 prisms: \n\
2580         0 1 3 4 5 7 \n\
2581         2 3 1 6 7 5 \n"
2582
2583         pattern = self.smeshpyD.GetPattern()
2584         isDone  = pattern.LoadFromFile(pattern_prism)
2585         if not isDone:
2586             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2587             return isDone
2588
2589         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2590         isDone = pattern.MakeMesh(self.mesh, False, False)
2591         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2592
2593         # Splits quafrangle faces near triangular facets of volumes
2594         self.SplitQuadsNearTriangularFacets()
2595
2596         return isDone
2597
2598     ## Smoothes elements
2599     #  @param IDsOfElements the list if ids of elements to smooth
2600     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2601     #  Note that nodes built on edges and boundary nodes are always fixed.
2602     #  @param MaxNbOfIterations the maximum number of iterations
2603     #  @param MaxAspectRatio varies in range [1.0, inf]
2604     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2605     #  @return TRUE in case of success, FALSE otherwise.
2606     #  @ingroup l2_modif_smooth
2607     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2608                MaxNbOfIterations, MaxAspectRatio, Method):
2609         if IDsOfElements == []:
2610             IDsOfElements = self.GetElementsId()
2611         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2612         self.mesh.SetParameters(Parameters)
2613         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2614                                   MaxNbOfIterations, MaxAspectRatio, Method)
2615
2616     ## Smoothes elements which belong to the given object
2617     #  @param theObject the object to smooth
2618     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2619     #  Note that nodes built on edges and boundary nodes are always fixed.
2620     #  @param MaxNbOfIterations the maximum number of iterations
2621     #  @param MaxAspectRatio varies in range [1.0, inf]
2622     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2623     #  @return TRUE in case of success, FALSE otherwise.
2624     #  @ingroup l2_modif_smooth
2625     def SmoothObject(self, theObject, IDsOfFixedNodes,
2626                      MaxNbOfIterations, MaxAspectRatio, Method):
2627         if ( isinstance( theObject, Mesh )):
2628             theObject = theObject.GetMesh()
2629         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2630                                         MaxNbOfIterations, MaxAspectRatio, Method)
2631
2632     ## Parametrically smoothes the given elements
2633     #  @param IDsOfElements the list if ids of elements to smooth
2634     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2635     #  Note that nodes built on edges and boundary nodes are always fixed.
2636     #  @param MaxNbOfIterations the maximum number of iterations
2637     #  @param MaxAspectRatio varies in range [1.0, inf]
2638     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2639     #  @return TRUE in case of success, FALSE otherwise.
2640     #  @ingroup l2_modif_smooth
2641     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2642                          MaxNbOfIterations, MaxAspectRatio, Method):
2643         if IDsOfElements == []:
2644             IDsOfElements = self.GetElementsId()
2645         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2646         self.mesh.SetParameters(Parameters)
2647         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2648                                             MaxNbOfIterations, MaxAspectRatio, Method)
2649
2650     ## Parametrically smoothes the elements which belong to the given object
2651     #  @param theObject the object to smooth
2652     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2653     #  Note that nodes built on edges and boundary nodes are always fixed.
2654     #  @param MaxNbOfIterations the maximum number of iterations
2655     #  @param MaxAspectRatio varies in range [1.0, inf]
2656     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2657     #  @return TRUE in case of success, FALSE otherwise.
2658     #  @ingroup l2_modif_smooth
2659     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2660                                MaxNbOfIterations, MaxAspectRatio, Method):
2661         if ( isinstance( theObject, Mesh )):
2662             theObject = theObject.GetMesh()
2663         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2664                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2665
2666     ## Converts the mesh to quadratic, deletes old elements, replacing
2667     #  them with quadratic with the same id.
2668     #  @ingroup l2_modif_tofromqu
2669     def ConvertToQuadratic(self, theForce3d):
2670         self.editor.ConvertToQuadratic(theForce3d)
2671
2672     ## Converts the mesh from quadratic to ordinary,
2673     #  deletes old quadratic elements, \n replacing
2674     #  them with ordinary mesh elements with the same id.
2675     #  @return TRUE in case of success, FALSE otherwise.
2676     #  @ingroup l2_modif_tofromqu
2677     def ConvertFromQuadratic(self):
2678         return self.editor.ConvertFromQuadratic()
2679
2680     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2681     #  @return TRUE if operation has been completed successfully, FALSE otherwise
2682     #  @ingroup l2_modif_edit
2683     def  Make2DMeshFrom3D(self):
2684         return self.editor. Make2DMeshFrom3D()
2685         
2686     ## Renumber mesh nodes
2687     #  @ingroup l2_modif_renumber
2688     def RenumberNodes(self):
2689         self.editor.RenumberNodes()
2690
2691     ## Renumber mesh elements
2692     #  @ingroup l2_modif_renumber
2693     def RenumberElements(self):
2694         self.editor.RenumberElements()
2695
2696     ## Generates new elements by rotation of the elements around the axis
2697     #  @param IDsOfElements the list of ids of elements to sweep
2698     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2699     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2700     #  @param NbOfSteps the number of steps
2701     #  @param Tolerance tolerance
2702     #  @param MakeGroups forces the generation of new groups from existing ones
2703     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2704     #                    of all steps, else - size of each step
2705     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2706     #  @ingroup l2_modif_extrurev
2707     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2708                       MakeGroups=False, TotalAngle=False):
2709         flag = False
2710         if isinstance(AngleInRadians,str):
2711             flag = True
2712         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2713         if flag:
2714             AngleInRadians = DegreesToRadians(AngleInRadians)
2715         if IDsOfElements == []:
2716             IDsOfElements = self.GetElementsId()
2717         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2718             Axis = self.smeshpyD.GetAxisStruct(Axis)
2719         Axis,AxisParameters = ParseAxisStruct(Axis)
2720         if TotalAngle and NbOfSteps:
2721             AngleInRadians /= NbOfSteps
2722         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2723         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2724         self.mesh.SetParameters(Parameters)
2725         if MakeGroups:
2726             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2727                                                        AngleInRadians, NbOfSteps, Tolerance)
2728         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2729         return []
2730
2731     ## Generates new elements by rotation of the elements of object around the axis
2732     #  @param theObject object which elements should be sweeped
2733     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2734     #  @param AngleInRadians the angle of Rotation
2735     #  @param NbOfSteps number of steps
2736     #  @param Tolerance tolerance
2737     #  @param MakeGroups forces the generation of new groups from existing ones
2738     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2739     #                    of all steps, else - size of each step
2740     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2741     #  @ingroup l2_modif_extrurev
2742     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2743                             MakeGroups=False, TotalAngle=False):
2744         flag = False
2745         if isinstance(AngleInRadians,str):
2746             flag = True
2747         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2748         if flag:
2749             AngleInRadians = DegreesToRadians(AngleInRadians)
2750         if ( isinstance( theObject, Mesh )):
2751             theObject = theObject.GetMesh()
2752         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2753             Axis = self.smeshpyD.GetAxisStruct(Axis)
2754         Axis,AxisParameters = ParseAxisStruct(Axis)
2755         if TotalAngle and NbOfSteps:
2756             AngleInRadians /= NbOfSteps
2757         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2758         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2759         self.mesh.SetParameters(Parameters)
2760         if MakeGroups:
2761             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2762                                                              NbOfSteps, Tolerance)
2763         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2764         return []
2765
2766     ## Generates new elements by rotation of the elements of object around the axis
2767     #  @param theObject object which elements should be sweeped
2768     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2769     #  @param AngleInRadians the angle of Rotation
2770     #  @param NbOfSteps number of steps
2771     #  @param Tolerance tolerance
2772     #  @param MakeGroups forces the generation of new groups from existing ones
2773     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2774     #                    of all steps, else - size of each step
2775     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2776     #  @ingroup l2_modif_extrurev
2777     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2778                               MakeGroups=False, TotalAngle=False):
2779         flag = False
2780         if isinstance(AngleInRadians,str):
2781             flag = True
2782         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2783         if flag:
2784             AngleInRadians = DegreesToRadians(AngleInRadians)
2785         if ( isinstance( theObject, Mesh )):
2786             theObject = theObject.GetMesh()
2787         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2788             Axis = self.smeshpyD.GetAxisStruct(Axis)
2789         Axis,AxisParameters = ParseAxisStruct(Axis)
2790         if TotalAngle and NbOfSteps:
2791             AngleInRadians /= NbOfSteps
2792         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2793         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2794         self.mesh.SetParameters(Parameters)
2795         if MakeGroups:
2796             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2797                                                                NbOfSteps, Tolerance)
2798         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2799         return []
2800
2801     ## Generates new elements by rotation of the elements of object around the axis
2802     #  @param theObject object which elements should be sweeped
2803     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2804     #  @param AngleInRadians the angle of Rotation
2805     #  @param NbOfSteps number of steps
2806     #  @param Tolerance tolerance
2807     #  @param MakeGroups forces the generation of new groups from existing ones
2808     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2809     #                    of all steps, else - size of each step
2810     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2811     #  @ingroup l2_modif_extrurev
2812     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2813                               MakeGroups=False, TotalAngle=False):
2814         flag = False
2815         if isinstance(AngleInRadians,str):
2816             flag = True
2817         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2818         if flag:
2819             AngleInRadians = DegreesToRadians(AngleInRadians)
2820         if ( isinstance( theObject, Mesh )):
2821             theObject = theObject.GetMesh()
2822         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2823             Axis = self.smeshpyD.GetAxisStruct(Axis)
2824         Axis,AxisParameters = ParseAxisStruct(Axis)
2825         if TotalAngle and NbOfSteps:
2826             AngleInRadians /= NbOfSteps
2827         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2828         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2829         self.mesh.SetParameters(Parameters)
2830         if MakeGroups:
2831             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2832                                                              NbOfSteps, Tolerance)
2833         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2834         return []
2835
2836     ## Generates new elements by extrusion of the elements with given ids
2837     #  @param IDsOfElements the list of elements ids for extrusion
2838     #  @param StepVector vector, defining the direction and value of extrusion
2839     #  @param NbOfSteps the number of steps
2840     #  @param MakeGroups forces the generation of new groups from existing ones
2841     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2842     #  @ingroup l2_modif_extrurev
2843     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2844         if IDsOfElements == []:
2845             IDsOfElements = self.GetElementsId()
2846         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2847             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2848         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2849         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2850         Parameters = StepVectorParameters + var_separator + Parameters
2851         self.mesh.SetParameters(Parameters)
2852         if MakeGroups:
2853             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2854         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2855         return []
2856
2857     ## Generates new elements by extrusion of the elements with given ids
2858     #  @param IDsOfElements is ids of elements
2859     #  @param StepVector vector, defining the direction and value of extrusion
2860     #  @param NbOfSteps the number of steps
2861     #  @param ExtrFlags sets flags for extrusion
2862     #  @param SewTolerance uses for comparing locations of nodes if flag
2863     #         EXTRUSION_FLAG_SEW is set
2864     #  @param MakeGroups forces the generation of new groups from existing ones
2865     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2866     #  @ingroup l2_modif_extrurev
2867     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2868                           ExtrFlags, SewTolerance, MakeGroups=False):
2869         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2870             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2871         if MakeGroups:
2872             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2873                                                            ExtrFlags, SewTolerance)
2874         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2875                                       ExtrFlags, SewTolerance)
2876         return []
2877
2878     ## Generates new elements by extrusion of the elements which belong to the object
2879     #  @param theObject the 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 forces the generation of 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 ExtrusionSweepObject(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.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2896         self.editor.ExtrusionSweepObject(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 to generate 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 ExtrusionSweepObject1D(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.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2917         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2918         return []
2919
2920     ## Generates new elements by extrusion of the elements which belong to the object
2921     #  @param theObject object which elements should be processed
2922     #  @param StepVector vector, defining the direction and value of extrusion
2923     #  @param NbOfSteps the number of steps
2924     #  @param MakeGroups forces the generation of new groups from existing ones
2925     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2926     #  @ingroup l2_modif_extrurev
2927     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2928         if ( isinstance( theObject, Mesh )):
2929             theObject = theObject.GetMesh()
2930         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2931             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2932         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2933         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2934         Parameters = StepVectorParameters + var_separator + Parameters
2935         self.mesh.SetParameters(Parameters)
2936         if MakeGroups:
2937             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2938         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2939         return []
2940
2941
2942
2943     ## Generates new elements by extrusion of the given elements
2944     #  The path of extrusion must be a meshed edge.
2945     #  @param Base mesh or list of ids of elements for extrusion
2946     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2947     #  @param NodeStart the start node from Path. Defines the direction of extrusion
2948     #  @param HasAngles allows the shape to be rotated around the path
2949     #                   to get the resulting mesh in a helical fashion
2950     #  @param Angles list of angles in radians
2951     #  @param LinearVariation forces the computation of rotation angles as linear
2952     #                         variation of the given Angles along path steps
2953     #  @param HasRefPoint allows using the reference point
2954     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2955     #         The User can specify any point as the Reference Point.
2956     #  @param MakeGroups forces the generation of new groups from existing ones
2957     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
2958     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2959     #          only SMESH::Extrusion_Error otherwise
2960     #  @ingroup l2_modif_extrurev
2961     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2962                             HasAngles, Angles, LinearVariation,
2963                             HasRefPoint, RefPoint, MakeGroups, ElemType):
2964         Angles,AnglesParameters = ParseAngles(Angles)
2965         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2966         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2967             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2968             pass
2969         Parameters = AnglesParameters + var_separator + RefPointParameters
2970         self.mesh.SetParameters(Parameters)
2971
2972         if isinstance(Base,list):
2973             IDsOfElements = []
2974             if Base == []: IDsOfElements = self.GetElementsId()
2975             else: IDsOfElements = Base
2976             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2977                                                    HasAngles, Angles, LinearVariation,
2978                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
2979         else:
2980             if isinstance(Base,Mesh):
2981                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2982                                                           HasAngles, Angles, LinearVariation,
2983                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
2984             else:
2985                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2986
2987
2988     ## Generates new elements by extrusion of the given elements
2989     #  The path of extrusion must be a meshed edge.
2990     #  @param IDsOfElements ids of elements
2991     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2992     #  @param PathShape shape(edge) defines the sub-mesh for the path
2993     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2994     #  @param HasAngles allows the shape to be rotated around the path
2995     #                   to get the resulting mesh in a helical fashion
2996     #  @param Angles list of angles in radians
2997     #  @param HasRefPoint allows using the reference point
2998     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2999     #         The User can specify any point as the Reference Point.
3000     #  @param MakeGroups forces the generation of new groups from existing ones
3001     #  @param LinearVariation forces the computation of rotation angles as linear
3002     #                         variation of the given Angles along path steps
3003     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3004     #          only SMESH::Extrusion_Error otherwise
3005     #  @ingroup l2_modif_extrurev
3006     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3007                            HasAngles, Angles, HasRefPoint, RefPoint,
3008                            MakeGroups=False, LinearVariation=False):
3009         Angles,AnglesParameters = ParseAngles(Angles)
3010         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3011         if IDsOfElements == []:
3012             IDsOfElements = self.GetElementsId()
3013         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3014             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3015             pass
3016         if ( isinstance( PathMesh, Mesh )):
3017             PathMesh = PathMesh.GetMesh()
3018         if HasAngles and Angles and LinearVariation:
3019             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3020             pass
3021         Parameters = AnglesParameters + var_separator + RefPointParameters
3022         self.mesh.SetParameters(Parameters)
3023         if MakeGroups:
3024             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3025                                                             PathShape, NodeStart, HasAngles,
3026                                                             Angles, HasRefPoint, RefPoint)
3027         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3028                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3029
3030     ## Generates new elements by extrusion of the elements which belong to the object
3031     #  The path of extrusion must be a meshed edge.
3032     #  @param theObject the object which elements should be processed
3033     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3034     #  @param PathShape shape(edge) defines the sub-mesh for the path
3035     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3036     #  @param HasAngles allows the shape to be rotated around the path
3037     #                   to get the resulting mesh in a helical fashion
3038     #  @param Angles list of angles
3039     #  @param HasRefPoint allows using the reference point
3040     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3041     #         The User can specify any point as the Reference Point.
3042     #  @param MakeGroups forces the generation of new groups from existing ones
3043     #  @param LinearVariation forces the computation of rotation angles as linear
3044     #                         variation of the given Angles along path steps
3045     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3046     #          only SMESH::Extrusion_Error otherwise
3047     #  @ingroup l2_modif_extrurev
3048     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3049                                  HasAngles, Angles, HasRefPoint, RefPoint,
3050                                  MakeGroups=False, LinearVariation=False):
3051         Angles,AnglesParameters = ParseAngles(Angles)
3052         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3053         if ( isinstance( theObject, Mesh )):
3054             theObject = theObject.GetMesh()
3055         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3056             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3057         if ( isinstance( PathMesh, Mesh )):
3058             PathMesh = PathMesh.GetMesh()
3059         if HasAngles and Angles and LinearVariation:
3060             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3061             pass
3062         Parameters = AnglesParameters + var_separator + RefPointParameters
3063         self.mesh.SetParameters(Parameters)
3064         if MakeGroups:
3065             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3066                                                                   PathShape, NodeStart, HasAngles,
3067                                                                   Angles, HasRefPoint, RefPoint)
3068         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3069                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3070                                                     RefPoint)
3071
3072     ## Generates new elements by extrusion of the elements which belong to the object
3073     #  The path of extrusion must be a meshed edge.
3074     #  @param theObject the object which elements should be processed
3075     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3076     #  @param PathShape shape(edge) defines the sub-mesh for the path
3077     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3078     #  @param HasAngles allows the shape to be rotated around the path
3079     #                   to get the resulting mesh in a helical fashion
3080     #  @param Angles list of angles
3081     #  @param HasRefPoint allows using the reference point
3082     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3083     #         The User can specify any point as the Reference Point.
3084     #  @param MakeGroups forces the generation of new groups from existing ones
3085     #  @param LinearVariation forces the computation of rotation angles as linear
3086     #                         variation of the given Angles along path steps
3087     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3088     #          only SMESH::Extrusion_Error otherwise
3089     #  @ingroup l2_modif_extrurev
3090     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3091                                    HasAngles, Angles, HasRefPoint, RefPoint,
3092                                    MakeGroups=False, LinearVariation=False):
3093         Angles,AnglesParameters = ParseAngles(Angles)
3094         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3095         if ( isinstance( theObject, Mesh )):
3096             theObject = theObject.GetMesh()
3097         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3098             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3099         if ( isinstance( PathMesh, Mesh )):
3100             PathMesh = PathMesh.GetMesh()
3101         if HasAngles and Angles and LinearVariation:
3102             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3103             pass
3104         Parameters = AnglesParameters + var_separator + RefPointParameters
3105         self.mesh.SetParameters(Parameters)
3106         if MakeGroups:
3107             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3108                                                                     PathShape, NodeStart, HasAngles,
3109                                                                     Angles, HasRefPoint, RefPoint)
3110         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3111                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3112                                                       RefPoint)
3113
3114     ## Generates new elements by extrusion of the elements which belong to the object
3115     #  The path of extrusion must be a meshed edge.
3116     #  @param theObject the object which elements should be processed
3117     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3118     #  @param PathShape shape(edge) defines the sub-mesh for the path
3119     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3120     #  @param HasAngles allows the shape to be rotated around the path
3121     #                   to get the resulting mesh in a helical fashion
3122     #  @param Angles list of angles
3123     #  @param HasRefPoint allows using the reference point
3124     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3125     #         The User can specify any point as the Reference Point.
3126     #  @param MakeGroups forces the generation of new groups from existing ones
3127     #  @param LinearVariation forces the computation of rotation angles as linear
3128     #                         variation of the given Angles along path steps
3129     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3130     #          only SMESH::Extrusion_Error otherwise
3131     #  @ingroup l2_modif_extrurev
3132     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3133                                    HasAngles, Angles, HasRefPoint, RefPoint,
3134                                    MakeGroups=False, LinearVariation=False):
3135         Angles,AnglesParameters = ParseAngles(Angles)
3136         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3137         if ( isinstance( theObject, Mesh )):
3138             theObject = theObject.GetMesh()
3139         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3140             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3141         if ( isinstance( PathMesh, Mesh )):
3142             PathMesh = PathMesh.GetMesh()
3143         if HasAngles and Angles and LinearVariation:
3144             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3145             pass
3146         Parameters = AnglesParameters + var_separator + RefPointParameters
3147         self.mesh.SetParameters(Parameters)
3148         if MakeGroups:
3149             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3150                                                                     PathShape, NodeStart, HasAngles,
3151                                                                     Angles, HasRefPoint, RefPoint)
3152         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3153                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3154                                                       RefPoint)
3155
3156     ## Creates a symmetrical copy of mesh elements
3157     #  @param IDsOfElements 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 Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3162     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3163     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3164     #  @ingroup l2_modif_trsf
3165     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
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         self.mesh.SetParameters(Parameters)
3172         if Copy and MakeGroups:
3173             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3174         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3175         return []
3176
3177     ## Creates a new mesh by a symmetrical copy of mesh elements
3178     #  @param IDsOfElements the list of elements ids
3179     #  @param Mirror is AxisStruct or geom object (point, line, plane)
3180     #  @param theMirrorType is  POINT, AXIS or PLANE
3181     #  If the Mirror is a geom object this parameter is unnecessary
3182     #  @param MakeGroups to generate new groups from existing ones
3183     #  @param NewMeshName a name of the new mesh to create
3184     #  @return instance of Mesh class
3185     #  @ingroup l2_modif_trsf
3186     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3187         if IDsOfElements == []:
3188             IDsOfElements = self.GetElementsId()
3189         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3190             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3191         Mirror,Parameters = ParseAxisStruct(Mirror)
3192         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3193                                           MakeGroups, NewMeshName)
3194         mesh.SetParameters(Parameters)
3195         return Mesh(self.smeshpyD,self.geompyD,mesh)
3196
3197     ## Creates 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 is  POINT, AXIS or PLANE
3201     #  If the Mirror is a geom object this parameter is unnecessary
3202     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3203     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3204     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3205     #  @ingroup l2_modif_trsf
3206     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
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         self.mesh.SetParameters(Parameters)
3213         if Copy and MakeGroups:
3214             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3215         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3216         return []
3217
3218     ## Creates a new mesh by a symmetrical copy of the object
3219     #  @param theObject mesh, submesh or group
3220     #  @param Mirror AxisStruct or geom object (point, line, plane)
3221     #  @param theMirrorType POINT, AXIS or PLANE
3222     #  If the Mirror is a geom object this parameter is unnecessary
3223     #  @param MakeGroups forces the generation of new groups from existing ones
3224     #  @param NewMeshName the name of the new mesh to create
3225     #  @return instance of Mesh class
3226     #  @ingroup l2_modif_trsf
3227     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3228         if ( isinstance( theObject, Mesh )):
3229             theObject = theObject.GetMesh()
3230         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3231             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3232         Mirror,Parameters = ParseAxisStruct(Mirror)
3233         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3234                                                 MakeGroups, NewMeshName)
3235         mesh.SetParameters(Parameters)
3236         return Mesh( self.smeshpyD,self.geompyD,mesh )
3237
3238     ## Translates the elements
3239     #  @param IDsOfElements list of elements ids
3240     #  @param Vector the direction of translation (DirStruct or vector)
3241     #  @param Copy allows copying the translated elements
3242     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3243     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3244     #  @ingroup l2_modif_trsf
3245     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3246         if IDsOfElements == []:
3247             IDsOfElements = self.GetElementsId()
3248         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3249             Vector = self.smeshpyD.GetDirStruct(Vector)
3250         Vector,Parameters = ParseDirStruct(Vector)
3251         self.mesh.SetParameters(Parameters)
3252         if Copy and MakeGroups:
3253             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3254         self.editor.Translate(IDsOfElements, Vector, Copy)
3255         return []
3256
3257     ## Creates a new mesh of translated elements
3258     #  @param IDsOfElements list of elements ids
3259     #  @param Vector the direction of translation (DirStruct or vector)
3260     #  @param MakeGroups forces the generation of new groups from existing ones
3261     #  @param NewMeshName the name of the newly created mesh
3262     #  @return instance of Mesh class
3263     #  @ingroup l2_modif_trsf
3264     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3265         if IDsOfElements == []:
3266             IDsOfElements = self.GetElementsId()
3267         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3268             Vector = self.smeshpyD.GetDirStruct(Vector)
3269         Vector,Parameters = ParseDirStruct(Vector)
3270         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3271         mesh.SetParameters(Parameters)
3272         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3273
3274     ## Translates the object
3275     #  @param theObject the object to translate (mesh, submesh, or group)
3276     #  @param Vector direction of translation (DirStruct or geom vector)
3277     #  @param Copy allows copying the translated elements
3278     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3279     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3280     #  @ingroup l2_modif_trsf
3281     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3282         if ( isinstance( theObject, Mesh )):
3283             theObject = theObject.GetMesh()
3284         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3285             Vector = self.smeshpyD.GetDirStruct(Vector)
3286         Vector,Parameters = ParseDirStruct(Vector)
3287         self.mesh.SetParameters(Parameters)
3288         if Copy and MakeGroups:
3289             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3290         self.editor.TranslateObject(theObject, Vector, Copy)
3291         return []
3292
3293     ## Creates a new mesh from the translated object
3294     #  @param theObject the object to translate (mesh, submesh, or group)
3295     #  @param Vector the direction of translation (DirStruct or geom vector)
3296     #  @param MakeGroups forces the generation of new groups from existing ones
3297     #  @param NewMeshName the name of the newly created mesh
3298     #  @return instance of Mesh class
3299     #  @ingroup l2_modif_trsf
3300     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3301         if (isinstance(theObject, Mesh)):
3302             theObject = theObject.GetMesh()
3303         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3304             Vector = self.smeshpyD.GetDirStruct(Vector)
3305         Vector,Parameters = ParseDirStruct(Vector)
3306         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3307         mesh.SetParameters(Parameters)
3308         return Mesh( self.smeshpyD, self.geompyD, mesh )
3309
3310
3311
3312     ## Scales the object
3313     #  @param theObject - the object to translate (mesh, submesh, or group)
3314     #  @param thePoint - base point for scale
3315     #  @param theScaleFact - scale factors for axises
3316     #  @param Copy - allows copying the translated elements
3317     #  @param MakeGroups - forces the generation of new groups from existing
3318     #                      ones (if Copy)
3319     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3320     #          empty list otherwise
3321     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3322         if ( isinstance( theObject, Mesh )):
3323             theObject = theObject.GetMesh()
3324         if ( isinstance( theObject, list )):
3325             theObject = self.editor.MakeIDSource(theObject)
3326
3327         thePoint, Parameters = ParsePointStruct(thePoint)
3328         self.mesh.SetParameters(Parameters)
3329
3330         if Copy and MakeGroups:
3331             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3332         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3333         return []
3334
3335     ## Creates a new mesh from the translated object
3336     #  @param theObject - the object to translate (mesh, submesh, or group)
3337     #  @param thePoint - base point for scale
3338     #  @param theScaleFact - scale factors for axises
3339     #  @param MakeGroups - forces the generation of new groups from existing ones
3340     #  @param NewMeshName - the name of the newly created mesh
3341     #  @return instance of Mesh class
3342     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3343         if (isinstance(theObject, Mesh)):
3344             theObject = theObject.GetMesh()
3345         if ( isinstance( theObject, list )):
3346             theObject = self.editor.MakeIDSource(theObject)
3347
3348         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3349                                          MakeGroups, NewMeshName)
3350         #mesh.SetParameters(Parameters)
3351         return Mesh( self.smeshpyD, self.geompyD, mesh )
3352
3353
3354
3355     ## Rotates the elements
3356     #  @param IDsOfElements list of elements ids
3357     #  @param Axis the axis of rotation (AxisStruct or geom line)
3358     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3359     #  @param Copy allows copying the rotated elements
3360     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3361     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3362     #  @ingroup l2_modif_trsf
3363     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3364         flag = False
3365         if isinstance(AngleInRadians,str):
3366             flag = True
3367         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3368         if flag:
3369             AngleInRadians = DegreesToRadians(AngleInRadians)
3370         if IDsOfElements == []:
3371             IDsOfElements = self.GetElementsId()
3372         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3373             Axis = self.smeshpyD.GetAxisStruct(Axis)
3374         Axis,AxisParameters = ParseAxisStruct(Axis)
3375         Parameters = AxisParameters + var_separator + Parameters
3376         self.mesh.SetParameters(Parameters)
3377         if Copy and MakeGroups:
3378             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3379         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3380         return []
3381
3382     ## Creates a new mesh of rotated elements
3383     #  @param IDsOfElements list of element ids
3384     #  @param Axis the axis of rotation (AxisStruct or geom line)
3385     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3386     #  @param MakeGroups forces the generation of new groups from existing ones
3387     #  @param NewMeshName the name of the newly created mesh
3388     #  @return instance of Mesh class
3389     #  @ingroup l2_modif_trsf
3390     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3391         flag = False
3392         if isinstance(AngleInRadians,str):
3393             flag = True
3394         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3395         if flag:
3396             AngleInRadians = DegreesToRadians(AngleInRadians)
3397         if IDsOfElements == []:
3398             IDsOfElements = self.GetElementsId()
3399         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3400             Axis = self.smeshpyD.GetAxisStruct(Axis)
3401         Axis,AxisParameters = ParseAxisStruct(Axis)
3402         Parameters = AxisParameters + var_separator + Parameters
3403         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3404                                           MakeGroups, NewMeshName)
3405         mesh.SetParameters(Parameters)
3406         return Mesh( self.smeshpyD, self.geompyD, mesh )
3407
3408     ## Rotates the object
3409     #  @param theObject the object to rotate( mesh, submesh, or group)
3410     #  @param Axis the axis of rotation (AxisStruct or geom line)
3411     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3412     #  @param Copy allows copying the rotated elements
3413     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3414     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3415     #  @ingroup l2_modif_trsf
3416     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3417         flag = False
3418         if isinstance(AngleInRadians,str):
3419             flag = True
3420         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3421         if flag:
3422             AngleInRadians = DegreesToRadians(AngleInRadians)
3423         if (isinstance(theObject, Mesh)):
3424             theObject = theObject.GetMesh()
3425         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3426             Axis = self.smeshpyD.GetAxisStruct(Axis)
3427         Axis,AxisParameters = ParseAxisStruct(Axis)
3428         Parameters = AxisParameters + ":" + Parameters
3429         self.mesh.SetParameters(Parameters)
3430         if Copy and MakeGroups:
3431             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3432         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3433         return []
3434
3435     ## Creates a new mesh from the rotated object
3436     #  @param theObject the object to rotate (mesh, submesh, or group)
3437     #  @param Axis the axis of rotation (AxisStruct or geom line)
3438     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3439     #  @param MakeGroups forces the generation of new groups from existing ones
3440     #  @param NewMeshName the name of the newly created mesh
3441     #  @return instance of Mesh class
3442     #  @ingroup l2_modif_trsf
3443     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3444         flag = False
3445         if isinstance(AngleInRadians,str):
3446             flag = True
3447         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3448         if flag:
3449             AngleInRadians = DegreesToRadians(AngleInRadians)
3450         if (isinstance( theObject, Mesh )):
3451             theObject = theObject.GetMesh()
3452         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3453             Axis = self.smeshpyD.GetAxisStruct(Axis)
3454         Axis,AxisParameters = ParseAxisStruct(Axis)
3455         Parameters = AxisParameters + ":" + Parameters
3456         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3457                                                        MakeGroups, NewMeshName)
3458         mesh.SetParameters(Parameters)
3459         return Mesh( self.smeshpyD, self.geompyD, mesh )
3460
3461     ## Finds groups of ajacent nodes within Tolerance.
3462     #  @param Tolerance the value of tolerance
3463     #  @return the list of groups of nodes
3464     #  @ingroup l2_modif_trsf
3465     def FindCoincidentNodes (self, Tolerance):
3466         return self.editor.FindCoincidentNodes(Tolerance)
3467
3468     ## Finds groups of ajacent nodes within Tolerance.
3469     #  @param Tolerance the value of tolerance
3470     #  @param SubMeshOrGroup SubMesh or Group
3471     #  @return the list of groups of nodes
3472     #  @ingroup l2_modif_trsf
3473     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3474         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3475
3476     ## Merges nodes
3477     #  @param GroupsOfNodes the list of groups of nodes
3478     #  @ingroup l2_modif_trsf
3479     def MergeNodes (self, GroupsOfNodes):
3480         self.editor.MergeNodes(GroupsOfNodes)
3481
3482     ## Finds the elements built on the same nodes.
3483     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3484     #  @return a list of groups of equal elements
3485     #  @ingroup l2_modif_trsf
3486     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3487         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3488             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3489         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3490
3491     ## Merges elements in each given group.
3492     #  @param GroupsOfElementsID groups of elements for merging
3493     #  @ingroup l2_modif_trsf
3494     def MergeElements(self, GroupsOfElementsID):
3495         self.editor.MergeElements(GroupsOfElementsID)
3496
3497     ## Leaves one element and removes all other elements built on the same nodes.
3498     #  @ingroup l2_modif_trsf
3499     def MergeEqualElements(self):
3500         self.editor.MergeEqualElements()
3501
3502     ## Sews free borders
3503     #  @return SMESH::Sew_Error
3504     #  @ingroup l2_modif_trsf
3505     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3506                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3507                         CreatePolygons, CreatePolyedrs):
3508         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3509                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3510                                           CreatePolygons, CreatePolyedrs)
3511
3512     ## Sews conform free borders
3513     #  @return SMESH::Sew_Error
3514     #  @ingroup l2_modif_trsf
3515     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3516                                FirstNodeID2, SecondNodeID2):
3517         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3518                                                  FirstNodeID2, SecondNodeID2)
3519
3520     ## Sews border to side
3521     #  @return SMESH::Sew_Error
3522     #  @ingroup l2_modif_trsf
3523     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3524                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3525         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3526                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3527
3528     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3529     #  merged with the nodes of elements of Side2.
3530     #  The number of elements in theSide1 and in theSide2 must be
3531     #  equal and they should have similar nodal connectivity.
3532     #  The nodes to merge should belong to side borders and
3533     #  the first node should be linked to the second.
3534     #  @return SMESH::Sew_Error
3535     #  @ingroup l2_modif_trsf
3536     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3537                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3538                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3539         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3540                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3541                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3542
3543     ## Sets new nodes for the given element.
3544     #  @param ide the element id
3545     #  @param newIDs nodes ids
3546     #  @return If the number of nodes does not correspond to the type of element - returns false
3547     #  @ingroup l2_modif_edit
3548     def ChangeElemNodes(self, ide, newIDs):
3549         return self.editor.ChangeElemNodes(ide, newIDs)
3550
3551     ## If during the last operation of MeshEditor some nodes were
3552     #  created, this method returns the list of their IDs, \n
3553     #  if new nodes were not created - returns empty list
3554     #  @return the list of integer values (can be empty)
3555     #  @ingroup l1_auxiliary
3556     def GetLastCreatedNodes(self):
3557         return self.editor.GetLastCreatedNodes()
3558
3559     ## If during the last operation of MeshEditor some elements were
3560     #  created this method returns the list of their IDs, \n
3561     #  if new elements were not created - returns empty list
3562     #  @return the list of integer values (can be empty)
3563     #  @ingroup l1_auxiliary
3564     def GetLastCreatedElems(self):
3565         return self.editor.GetLastCreatedElems()
3566
3567      ## Creates a hole in a mesh by doubling the nodes of some particular elements
3568     #  @param theNodes identifiers of nodes to be doubled
3569     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
3570     #         nodes. If list of element identifiers is empty then nodes are doubled but 
3571     #         they not assigned to elements
3572     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3573     #  @ingroup l2_modif_edit
3574     def DoubleNodes(self, theNodes, theModifiedElems):
3575         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3576         
3577     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3578     #  This method provided for convenience works as DoubleNodes() described above.
3579     #  @param theNodes identifiers of node to be doubled
3580     #  @param theModifiedElems identifiers of elements to be updated
3581     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3582     #  @ingroup l2_modif_edit
3583     def DoubleNode(self, theNodeId, theModifiedElems):
3584         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3585         
3586     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3587     #  This method provided for convenience works as DoubleNodes() described above.
3588     #  @param theNodes group of nodes to be doubled
3589     #  @param theModifiedElems group of elements to be updated.
3590     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3591     #  @ingroup l2_modif_edit
3592     def DoubleNodeGroup(self, theNodes, theModifiedElems):
3593         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3594         
3595     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3596     #  This method provided for convenience works as DoubleNodes() described above.
3597     #  @param theNodes list of groups of nodes to be doubled
3598     #  @param theModifiedElems list of groups of elements to be updated.
3599     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3600     #  @ingroup l2_modif_edit
3601     def DoubleNodeGroups(self, theNodes, theModifiedElems):
3602         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3603     
3604     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3605     #  @param theElems - the list of elements (edges or faces) to be replicated
3606     #         The nodes for duplication could be found from these elements
3607     #  @param theNodesNot - list of nodes to NOT replicate
3608     #  @param theAffectedElems - the list of elements (cells and edges) to which the 
3609     #         replicated nodes should be associated to.
3610     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3611     #  @ingroup l2_modif_edit
3612     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3613         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3614         
3615     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3616     #  @param theElems - the list of elements (edges or faces) to be replicated
3617     #         The nodes for duplication could be found from these elements
3618     #  @param theNodesNot - list of nodes to NOT replicate
3619     #  @param theShape - shape to detect affected elements (element which geometric center
3620     #         located on or inside shape).
3621     #         The replicated nodes should be associated to affected elements.
3622     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3623     #  @ingroup l2_modif_edit
3624     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3625         return self.editor.DoubleNodeElemInRegion(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 - group of of elements (edges or faces) to be replicated
3630     #  @param theNodesNot - group of nodes not to replicated
3631     #  @param theAffectedElems - group of elements to which the replicated nodes
3632     #         should be associated to.
3633     #  @ingroup l2_modif_edit
3634     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3635         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3636         
3637     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3638     #  This method provided for convenience works as DoubleNodes() described above.
3639     #  @param theElems - group of of elements (edges or faces) to be replicated
3640     #  @param theNodesNot - group of nodes not to replicated
3641     #  @param theShape - shape to detect affected elements (element which geometric center
3642     #         located on or inside shape).
3643     #         The replicated nodes should be associated to affected elements.
3644     #  @ingroup l2_modif_edit
3645     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3646         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3647         
3648     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3649     #  This method provided for convenience works as DoubleNodes() described above.
3650     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3651     #  @param theNodesNot - list of groups of nodes not to replicated
3652     #  @param theAffectedElems - group of elements to which the replicated nodes
3653     #         should be associated to.
3654     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3655     #  @ingroup l2_modif_edit
3656     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3657         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3658
3659     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3660     #  This method provided for convenience works as DoubleNodes() described above.
3661     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3662     #  @param theNodesNot - list of groups of nodes not to replicated
3663     #  @param theShape - shape to detect affected elements (element which geometric center
3664     #         located on or inside shape).
3665     #         The replicated nodes should be associated to affected elements.
3666     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3667     #  @ingroup l2_modif_edit
3668     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3669         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3670
3671 ## The mother class to define algorithm, it is not recommended to use it directly.
3672 #
3673 #  More details.
3674 #  @ingroup l2_algorithms
3675 class Mesh_Algorithm:
3676     #  @class Mesh_Algorithm
3677     #  @brief Class Mesh_Algorithm
3678
3679     #def __init__(self,smesh):
3680     #    self.smesh=smesh
3681     def __init__(self):
3682         self.mesh = None
3683         self.geom = None
3684         self.subm = None
3685         self.algo = None
3686
3687     ## Finds a hypothesis in the study by its type name and parameters.
3688     #  Finds only the hypotheses created in smeshpyD engine.
3689     #  @return SMESH.SMESH_Hypothesis
3690     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3691         study = smeshpyD.GetCurrentStudy()
3692         #to do: find component by smeshpyD object, not by its data type
3693         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3694         if scomp is not None:
3695             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3696             # Check if the root label of the hypotheses exists
3697             if res and hypRoot is not None:
3698                 iter = study.NewChildIterator(hypRoot)
3699                 # Check all published hypotheses
3700                 while iter.More():
3701                     hypo_so_i = iter.Value()
3702                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3703                     if attr is not None:
3704                         anIOR = attr.Value()
3705                         hypo_o_i = salome.orb.string_to_object(anIOR)
3706                         if hypo_o_i is not None:
3707                             # Check if this is a hypothesis
3708                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3709                             if hypo_i is not None:
3710                                 # Check if the hypothesis belongs to current engine
3711                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3712                                     # Check if this is the required hypothesis
3713                                     if hypo_i.GetName() == hypname:
3714                                         # Check arguments
3715                                         if CompareMethod(hypo_i, args):
3716                                             # found!!!
3717                                             return hypo_i
3718                                         pass
3719                                     pass
3720                                 pass
3721                             pass
3722                         pass
3723                     iter.Next()
3724                     pass
3725                 pass
3726             pass
3727         return None
3728
3729     ## Finds the algorithm in the study by its type name.
3730     #  Finds only the algorithms, which have been created in smeshpyD engine.
3731     #  @return SMESH.SMESH_Algo
3732     def FindAlgorithm (self, algoname, smeshpyD):
3733         study = smeshpyD.GetCurrentStudy()
3734         #to do: find component by smeshpyD object, not by its data type
3735         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3736         if scomp is not None:
3737             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3738             # Check if the root label of the algorithms exists
3739             if res and hypRoot is not None:
3740                 iter = study.NewChildIterator(hypRoot)
3741                 # Check all published algorithms
3742                 while iter.More():
3743                     algo_so_i = iter.Value()
3744                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3745                     if attr is not None:
3746                         anIOR = attr.Value()
3747                         algo_o_i = salome.orb.string_to_object(anIOR)
3748                         if algo_o_i is not None:
3749                             # Check if this is an algorithm
3750                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3751                             if algo_i is not None:
3752                                 # Checks if the algorithm belongs to the current engine
3753                                 if smeshpyD.GetObjectId(algo_i) > 0:
3754                                     # Check if this is the required algorithm
3755                                     if algo_i.GetName() == algoname:
3756                                         # found!!!
3757                                         return algo_i
3758                                     pass
3759                                 pass
3760                             pass
3761                         pass
3762                     iter.Next()
3763                     pass
3764                 pass
3765             pass
3766         return None
3767
3768     ## If the algorithm is global, returns 0; \n
3769     #  else returns the submesh associated to this algorithm.
3770     def GetSubMesh(self):
3771         return self.subm
3772
3773     ## Returns the wrapped mesher.
3774     def GetAlgorithm(self):
3775         return self.algo
3776
3777     ## Gets the list of hypothesis that can be used with this algorithm
3778     def GetCompatibleHypothesis(self):
3779         mylist = []
3780         if self.algo:
3781             mylist = self.algo.GetCompatibleHypothesis()
3782         return mylist
3783
3784     ## Gets the name of the algorithm
3785     def GetName(self):
3786         GetName(self.algo)
3787
3788     ## Sets the name to the algorithm
3789     def SetName(self, name):
3790         self.mesh.smeshpyD.SetName(self.algo, name)
3791
3792     ## Gets the id of the algorithm
3793     def GetId(self):
3794         return self.algo.GetId()
3795
3796     ## Private method.
3797     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3798         if geom is None:
3799             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3800         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3801         if algo is None:
3802             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3803             pass
3804         self.Assign(algo, mesh, geom)
3805         return self.algo
3806
3807     ## Private method
3808     def Assign(self, algo, mesh, geom):
3809         if geom is None:
3810             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3811         self.mesh = mesh
3812         piece = mesh.geom
3813         name = ""
3814         if not geom:
3815             self.geom = piece
3816         else:
3817             self.geom = geom
3818             try:
3819                 name = GetName(geom)
3820                 pass
3821             except:
3822                 name = mesh.geompyD.SubShapeName(geom, piece)
3823                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3824                 pass
3825             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3826
3827         self.algo = algo
3828         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3829         TreatHypoStatus( status, algo.GetName(), name, True )
3830
3831     def CompareHyp (self, hyp, args):
3832         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3833         return False
3834
3835     def CompareEqualHyp (self, hyp, args):
3836         return True
3837
3838     ## Private method
3839     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3840                     UseExisting=0, CompareMethod=""):
3841         hypo = None
3842         if UseExisting:
3843             if CompareMethod == "": CompareMethod = self.CompareHyp
3844             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3845             pass
3846         if hypo is None:
3847             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3848             a = ""
3849             s = "="
3850             i = 0
3851             n = len(args)
3852             while i<n:
3853                 a = a + s + str(args[i])
3854                 s = ","
3855                 i = i + 1
3856                 pass
3857             self.mesh.smeshpyD.SetName(hypo, hyp + a)
3858             pass
3859         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3860         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3861         return hypo
3862
3863     ## Returns entry of the shape to mesh in the study
3864     def MainShapeEntry(self):
3865         entry = ""
3866         if not self.mesh or not self.mesh.GetMesh(): return entry
3867         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3868         study = self.mesh.smeshpyD.GetCurrentStudy()
3869         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
3870         sobj = study.FindObjectIOR(ior)
3871         if sobj: entry = sobj.GetID()
3872         if not entry: return ""
3873         return entry
3874
3875 # Public class: Mesh_Segment
3876 # --------------------------
3877
3878 ## Class to define a segment 1D algorithm for discretization
3879 #
3880 #  More details.
3881 #  @ingroup l3_algos_basic
3882 class Mesh_Segment(Mesh_Algorithm):
3883
3884     ## Private constructor.
3885     def __init__(self, mesh, geom=0):
3886         Mesh_Algorithm.__init__(self)
3887         self.Create(mesh, geom, "Regular_1D")
3888
3889     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3890     #  @param l for the length of segments that cut an edge
3891     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3892     #                    the same parameters, else (default) - creates a new one
3893     #  @param p precision, used for calculation of the number of segments.
3894     #           The precision should be a positive, meaningful value within the range [0,1].
3895     #           In general, the number of segments is calculated with the formula:
3896     #           nb = ceil((edge_length / l) - p)
3897     #           Function ceil rounds its argument to the higher integer.
3898     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3899     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3900     #               p=1 means rounding of (edge_length / l) to the lower integer.
3901     #           Default value is 1e-07.
3902     #  @return an instance of StdMeshers_LocalLength hypothesis
3903     #  @ingroup l3_hypos_1dhyps
3904     def LocalLength(self, l, UseExisting=0, p=1e-07):
3905         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3906                               CompareMethod=self.CompareLocalLength)
3907         hyp.SetLength(l)
3908         hyp.SetPrecision(p)
3909         return hyp
3910
3911     ## Private method
3912     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3913     def CompareLocalLength(self, hyp, args):
3914         if IsEqual(hyp.GetLength(), args[0]):
3915             return IsEqual(hyp.GetPrecision(), args[1])
3916         return False
3917
3918     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3919     #  @param length is optional maximal allowed length of segment, if it is omitted
3920     #                the preestimated length is used that depends on geometry size
3921     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3922     #                     the same parameters, else (default) - create a new one
3923     #  @return an instance of StdMeshers_MaxLength hypothesis
3924     #  @ingroup l3_hypos_1dhyps
3925     def MaxSize(self, length=0.0, UseExisting=0):
3926         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3927         if length > 0.0:
3928             # set given length
3929             hyp.SetLength(length)
3930         if not UseExisting:
3931             # set preestimated length
3932             gen = self.mesh.smeshpyD
3933             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3934                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
3935                                                        False) # <- byMesh
3936             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3937             if preHyp:
3938                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3939                 pass
3940             pass
3941         hyp.SetUsePreestimatedLength( length == 0.0 )
3942         return hyp
3943         
3944     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3945     #  @param n for the number of segments that cut an edge
3946     #  @param s for the scale factor (optional)
3947     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3948     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3949     #                     the same parameters, else (default) - create a new one
3950     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
3951     #  @ingroup l3_hypos_1dhyps
3952     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3953         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3954             reversedEdges, UseExisting = [], reversedEdges
3955         entry = self.MainShapeEntry()
3956         if s == []:
3957             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3958                                   UseExisting=UseExisting,
3959                                   CompareMethod=self.CompareNumberOfSegments)
3960         else:
3961             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3962                                   UseExisting=UseExisting,
3963                                   CompareMethod=self.CompareNumberOfSegments)
3964             hyp.SetDistrType( 1 )
3965             hyp.SetScaleFactor(s)
3966         hyp.SetNumberOfSegments(n)
3967         hyp.SetReversedEdges( reversedEdges )
3968         hyp.SetObjectEntry( entry )
3969         return hyp
3970
3971     ## Private method
3972     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3973     def CompareNumberOfSegments(self, hyp, args):
3974         if hyp.GetNumberOfSegments() == args[0]:
3975             if len(args) == 3:
3976                 if hyp.GetReversedEdges() == args[1]:
3977                     if not args[1] or hyp.GetObjectEntry() == args[2]:
3978                         return True
3979             else:
3980                 if hyp.GetReversedEdges() == args[2]:
3981                     if not args[2] or hyp.GetObjectEntry() == args[3]:
3982                         if hyp.GetDistrType() == 1:
3983                             if IsEqual(hyp.GetScaleFactor(), args[1]):
3984                                 return True
3985         return False
3986
3987     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3988     #  @param start defines the length of the first segment
3989     #  @param end   defines the length of the last  segment
3990     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3991     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3992     #                     the same parameters, else (default) - creates a new one
3993     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
3994     #  @ingroup l3_hypos_1dhyps
3995     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3996         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3997             reversedEdges, UseExisting = [], reversedEdges
3998         entry = self.MainShapeEntry()
3999         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4000                               UseExisting=UseExisting,
4001                               CompareMethod=self.CompareArithmetic1D)
4002         hyp.SetStartLength(start)
4003         hyp.SetEndLength(end)
4004         hyp.SetReversedEdges( reversedEdges )
4005         hyp.SetObjectEntry( entry )
4006         return hyp
4007
4008     ## Private method
4009     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4010     def CompareArithmetic1D(self, hyp, args):
4011         if IsEqual(hyp.GetLength(1), args[0]):
4012             if IsEqual(hyp.GetLength(0), args[1]):
4013                 if hyp.GetReversedEdges() == args[2]:
4014                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4015                         return True
4016         return False
4017
4018
4019     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4020     # on curve from 0 to 1 (additionally it is neecessary to check
4021     # orientation of edges and create list of reversed edges if it is
4022     # needed) and sets numbers of segments between given points (default
4023     # values are equals 1
4024     #  @param points defines the list of parameters on curve
4025     #  @param nbSegs defines the list of numbers of segments
4026     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4027     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4028     #                     the same parameters, else (default) - creates a new one
4029     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4030     #  @ingroup l3_hypos_1dhyps
4031     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4032         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4033             reversedEdges, UseExisting = [], reversedEdges
4034         if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4035             for i in range( len( reversedEdges )):
4036                 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4037         entry = self.MainShapeEntry()
4038         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4039                               UseExisting=UseExisting,
4040                               CompareMethod=self.CompareFixedPoints1D)
4041         hyp.SetPoints(points)
4042         hyp.SetNbSegments(nbSegs)
4043         hyp.SetReversedEdges(reversedEdges)
4044         hyp.SetObjectEntry(entry)
4045         return hyp
4046
4047     ## Private method
4048     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4049     ## as the given arguments
4050     def CompareFixedPoints1D(self, hyp, args):
4051         if hyp.GetPoints() == args[0]:
4052             if hyp.GetNbSegments() == args[1]:
4053                 if hyp.GetReversedEdges() == args[2]:
4054                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4055                         return True
4056         return False
4057
4058
4059
4060     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4061     #  @param start defines the length of the first segment
4062     #  @param end   defines the length of the last  segment
4063     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4064     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4065     #                     the same parameters, else (default) - creates a new one
4066     #  @return an instance of StdMeshers_StartEndLength hypothesis
4067     #  @ingroup l3_hypos_1dhyps
4068     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4069         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4070             reversedEdges, UseExisting = [], reversedEdges
4071         entry = self.MainShapeEntry()
4072         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4073                               UseExisting=UseExisting,
4074                               CompareMethod=self.CompareStartEndLength)
4075         hyp.SetStartLength(start)
4076         hyp.SetEndLength(end)
4077         hyp.SetReversedEdges( reversedEdges )
4078         hyp.SetObjectEntry( entry )
4079         return hyp
4080
4081     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4082     def CompareStartEndLength(self, hyp, args):
4083         if IsEqual(hyp.GetLength(1), args[0]):
4084             if IsEqual(hyp.GetLength(0), args[1]):
4085                 if hyp.GetReversedEdges() == args[2]:
4086                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4087                         return True
4088         return False
4089
4090     ## Defines "Deflection1D" hypothesis
4091     #  @param d for the deflection
4092     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4093     #                     the same parameters, else (default) - create a new one
4094     #  @ingroup l3_hypos_1dhyps
4095     def Deflection1D(self, d, UseExisting=0):
4096         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4097                               CompareMethod=self.CompareDeflection1D)
4098         hyp.SetDeflection(d)
4099         return hyp
4100
4101     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4102     def CompareDeflection1D(self, hyp, args):
4103         return IsEqual(hyp.GetDeflection(), args[0])
4104
4105     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4106     #  the opposite side in case of quadrangular faces
4107     #  @ingroup l3_hypos_additi
4108     def Propagation(self):
4109         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4110
4111     ## Defines "AutomaticLength" hypothesis
4112     #  @param fineness for the fineness [0-1]
4113     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
4114     #                     same parameters, else (default) - create a new one
4115     #  @ingroup l3_hypos_1dhyps
4116     def AutomaticLength(self, fineness=0, UseExisting=0):
4117         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4118                               CompareMethod=self.CompareAutomaticLength)
4119         hyp.SetFineness( fineness )
4120         return hyp
4121
4122     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4123     def CompareAutomaticLength(self, hyp, args):
4124         return IsEqual(hyp.GetFineness(), args[0])
4125
4126     ## Defines "SegmentLengthAroundVertex" hypothesis
4127     #  @param length for the segment length
4128     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
4129     #         Any other integer value means that the hypothesis will be set on the
4130     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
4131     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4132     #                   the same parameters, else (default) - creates a new one
4133     #  @ingroup l3_algos_segmarv
4134     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4135         import types
4136         store_geom = self.geom
4137         if type(vertex) is types.IntType:
4138             if vertex == 0 or vertex == 1:
4139                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4140                 self.geom = vertex
4141                 pass
4142             pass
4143         else:
4144             self.geom = vertex
4145             pass
4146         ### 0D algorithm
4147         if self.geom is None:
4148             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4149         try:
4150             name = GetName(self.geom)
4151             pass
4152         except:
4153             piece = self.mesh.geom
4154             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4155             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4156             pass
4157         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4158         if algo is None:
4159             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4160             pass
4161         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4162         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4163         ###
4164         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4165                               CompareMethod=self.CompareLengthNearVertex)
4166         self.geom = store_geom
4167         hyp.SetLength( length )
4168         return hyp
4169
4170     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4171     #  @ingroup l3_algos_segmarv
4172     def CompareLengthNearVertex(self, hyp, args):
4173         return IsEqual(hyp.GetLength(), args[0])
4174
4175     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4176     #  If the 2D mesher sees that all boundary edges are quadratic,
4177     #  it generates quadratic faces, else it generates linear faces using
4178     #  medium nodes as if they are vertices.
4179     #  The 3D mesher generates quadratic volumes only if all boundary faces
4180     #  are quadratic, else it fails.
4181     #
4182     #  @ingroup l3_hypos_additi
4183     def QuadraticMesh(self):
4184         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4185         return hyp
4186
4187 # Public class: Mesh_CompositeSegment
4188 # --------------------------
4189
4190 ## Defines a segment 1D algorithm for discretization
4191 #
4192 #  @ingroup l3_algos_basic
4193 class Mesh_CompositeSegment(Mesh_Segment):
4194
4195     ## Private constructor.
4196     def __init__(self, mesh, geom=0):
4197         self.Create(mesh, geom, "CompositeSegment_1D")
4198
4199
4200 # Public class: Mesh_Segment_Python
4201 # ---------------------------------
4202
4203 ## Defines a segment 1D algorithm for discretization with python function
4204 #
4205 #  @ingroup l3_algos_basic
4206 class Mesh_Segment_Python(Mesh_Segment):
4207
4208     ## Private constructor.
4209     def __init__(self, mesh, geom=0):
4210         import Python1dPlugin
4211         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4212
4213     ## Defines "PythonSplit1D" hypothesis
4214     #  @param n for the number of segments that cut an edge
4215     #  @param func for the python function that calculates the length of all segments
4216     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4217     #                     the same parameters, else (default) - creates a new one
4218     #  @ingroup l3_hypos_1dhyps
4219     def PythonSplit1D(self, n, func, UseExisting=0):
4220         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4221                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4222         hyp.SetNumberOfSegments(n)
4223         hyp.SetPythonLog10RatioFunction(func)
4224         return hyp
4225
4226     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4227     def ComparePythonSplit1D(self, hyp, args):
4228         #if hyp.GetNumberOfSegments() == args[0]:
4229         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
4230         #        return True
4231         return False
4232
4233 # Public class: Mesh_Triangle
4234 # ---------------------------
4235
4236 ## Defines a triangle 2D algorithm
4237 #
4238 #  @ingroup l3_algos_basic
4239 class Mesh_Triangle(Mesh_Algorithm):
4240
4241     # default values
4242     algoType = 0
4243     params = 0
4244
4245     _angleMeshS = 8
4246     _gradation  = 1.1
4247
4248     ## Private constructor.
4249     def __init__(self, mesh, algoType, geom=0):
4250         Mesh_Algorithm.__init__(self)
4251
4252         self.algoType = algoType
4253         if algoType == MEFISTO:
4254             self.Create(mesh, geom, "MEFISTO_2D")
4255             pass
4256         elif algoType == BLSURF:
4257             CheckPlugin(BLSURF)
4258             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4259             #self.SetPhysicalMesh() - PAL19680
4260         elif algoType == NETGEN:
4261             CheckPlugin(NETGEN)
4262             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4263             pass
4264         elif algoType == NETGEN_2D:
4265             CheckPlugin(NETGEN)
4266             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4267             pass
4268
4269     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4270     #  @param area for the maximum area of each triangle
4271     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
4272     #                     same parameters, else (default) - creates a new one
4273     #
4274     #  Only for algoType == MEFISTO || NETGEN_2D
4275     #  @ingroup l3_hypos_2dhyps
4276     def MaxElementArea(self, area, UseExisting=0):
4277         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4278             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4279                                   CompareMethod=self.CompareMaxElementArea)
4280         elif self.algoType == NETGEN:
4281             hyp = self.Parameters(SIMPLE)
4282         hyp.SetMaxElementArea(area)
4283         return hyp
4284
4285     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4286     def CompareMaxElementArea(self, hyp, args):
4287         return IsEqual(hyp.GetMaxElementArea(), args[0])
4288
4289     ## Defines "LengthFromEdges" hypothesis to build triangles
4290     #  based on the length of the edges taken from the wire
4291     #
4292     #  Only for algoType == MEFISTO || NETGEN_2D
4293     #  @ingroup l3_hypos_2dhyps
4294     def LengthFromEdges(self):
4295         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4296             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4297             return hyp
4298         elif self.algoType == NETGEN:
4299             hyp = self.Parameters(SIMPLE)
4300             hyp.LengthFromEdges()
4301             return hyp
4302
4303     ## Sets a way to define size of mesh elements to generate.
4304     #  @param thePhysicalMesh is: DefaultSize or Custom.
4305     #  @ingroup l3_hypos_blsurf
4306     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4307         # Parameter of BLSURF algo
4308         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4309
4310     ## Sets size of mesh elements to generate.
4311     #  @ingroup l3_hypos_blsurf
4312     def SetPhySize(self, theVal):
4313         # Parameter of BLSURF algo
4314         self.SetPhysicalMesh(1) #Custom - else why to set the size?
4315         self.Parameters().SetPhySize(theVal)
4316
4317     ## Sets lower boundary of mesh element size (PhySize).
4318     #  @ingroup l3_hypos_blsurf
4319     def SetPhyMin(self, theVal=-1):
4320         #  Parameter of BLSURF algo
4321         self.Parameters().SetPhyMin(theVal)
4322
4323     ## Sets upper boundary of mesh element size (PhySize).
4324     #  @ingroup l3_hypos_blsurf
4325     def SetPhyMax(self, theVal=-1):
4326         #  Parameter of BLSURF algo
4327         self.Parameters().SetPhyMax(theVal)
4328
4329     ## Sets a way to define maximum angular deflection of mesh from CAD model.
4330     #  @param theGeometricMesh is: DefaultGeom or Custom
4331     #  @ingroup l3_hypos_blsurf
4332     def SetGeometricMesh(self, theGeometricMesh=0):
4333         #  Parameter of BLSURF algo
4334         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4335         self.params.SetGeometricMesh(theGeometricMesh)
4336
4337     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4338     #  @ingroup l3_hypos_blsurf
4339     def SetAngleMeshS(self, theVal=_angleMeshS):
4340         #  Parameter of BLSURF algo
4341         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4342         self.params.SetAngleMeshS(theVal)
4343
4344     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4345     #  @ingroup l3_hypos_blsurf
4346     def SetAngleMeshC(self, theVal=_angleMeshS):
4347         #  Parameter of BLSURF algo
4348         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4349         self.params.SetAngleMeshC(theVal)
4350
4351     ## Sets lower boundary of mesh element size computed to respect angular deflection.
4352     #  @ingroup l3_hypos_blsurf
4353     def SetGeoMin(self, theVal=-1):
4354         #  Parameter of BLSURF algo
4355         self.Parameters().SetGeoMin(theVal)
4356
4357     ## Sets upper boundary of mesh element size computed to respect angular deflection.
4358     #  @ingroup l3_hypos_blsurf
4359     def SetGeoMax(self, theVal=-1):
4360         #  Parameter of BLSURF algo
4361         self.Parameters().SetGeoMax(theVal)
4362
4363     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4364     #  @ingroup l3_hypos_blsurf
4365     def SetGradation(self, theVal=_gradation):
4366         #  Parameter of BLSURF algo
4367         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4368         self.params.SetGradation(theVal)
4369
4370     ## Sets topology usage way.
4371     # @param way defines how mesh conformity is assured <ul>
4372     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4373     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4374     #  @ingroup l3_hypos_blsurf
4375     def SetTopology(self, way):
4376         #  Parameter of BLSURF algo
4377         self.Parameters().SetTopology(way)
4378
4379     ## To respect geometrical edges or not.
4380     #  @ingroup l3_hypos_blsurf
4381     def SetDecimesh(self, toIgnoreEdges=False):
4382         #  Parameter of BLSURF algo
4383         self.Parameters().SetDecimesh(toIgnoreEdges)
4384
4385     ## Sets verbosity level in the range 0 to 100.
4386     #  @ingroup l3_hypos_blsurf
4387     def SetVerbosity(self, level):
4388         #  Parameter of BLSURF algo
4389         self.Parameters().SetVerbosity(level)
4390
4391     ## Sets advanced option value.
4392     #  @ingroup l3_hypos_blsurf
4393     def SetOptionValue(self, optionName, level):
4394         #  Parameter of BLSURF algo
4395         self.Parameters().SetOptionValue(optionName,level)
4396
4397     ## Sets QuadAllowed flag.
4398     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
4399     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
4400     def SetQuadAllowed(self, toAllow=True):
4401         if self.algoType == NETGEN_2D:
4402             if toAllow: # add QuadranglePreference
4403                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4404             else:       # remove QuadranglePreference
4405                 for hyp in self.mesh.GetHypothesisList( self.geom ):
4406                     if hyp.GetName() == "QuadranglePreference":
4407                         self.mesh.RemoveHypothesis( self.geom, hyp )
4408                         pass
4409                     pass
4410                 pass
4411             return
4412         if self.Parameters():
4413             self.params.SetQuadAllowed(toAllow)
4414             return
4415
4416     ## Defines hypothesis having several parameters
4417     #
4418     #  @ingroup l3_hypos_netgen
4419     def Parameters(self, which=SOLE):
4420         if self.params:
4421             return self.params
4422         if self.algoType == NETGEN:
4423             if which == SIMPLE:
4424                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4425                                               "libNETGENEngine.so", UseExisting=0)
4426             else:
4427                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4428                                               "libNETGENEngine.so", UseExisting=0)
4429             return self.params
4430         elif self.algoType == MEFISTO:
4431             print "Mefisto algo support no multi-parameter hypothesis"
4432             return None
4433         elif self.algoType == NETGEN_2D:
4434             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4435             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4436             return None
4437         elif self.algoType == BLSURF:
4438             self.params = self.Hypothesis("BLSURF_Parameters", [],
4439                                           "libBLSURFEngine.so", UseExisting=0)
4440             return self.params
4441         else:
4442             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4443         return None
4444
4445     ## Sets MaxSize
4446     #
4447     #  Only for algoType == NETGEN
4448     #  @ingroup l3_hypos_netgen
4449     def SetMaxSize(self, theSize):
4450         if self.Parameters():
4451             self.params.SetMaxSize(theSize)
4452
4453     ## Sets SecondOrder flag
4454     #
4455     #  Only for algoType == NETGEN
4456     #  @ingroup l3_hypos_netgen
4457     def SetSecondOrder(self, theVal):
4458         if self.Parameters():
4459             self.params.SetSecondOrder(theVal)
4460
4461     ## Sets Optimize flag
4462     #
4463     #  Only for algoType == NETGEN
4464     #  @ingroup l3_hypos_netgen
4465     def SetOptimize(self, theVal):
4466         if self.Parameters():
4467             self.params.SetOptimize(theVal)
4468
4469     ## Sets Fineness
4470     #  @param theFineness is:
4471     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4472     #
4473     #  Only for algoType == NETGEN
4474     #  @ingroup l3_hypos_netgen
4475     def SetFineness(self, theFineness):
4476         if self.Parameters():
4477             self.params.SetFineness(theFineness)
4478
4479     ## Sets GrowthRate
4480     #
4481     #  Only for algoType == NETGEN
4482     #  @ingroup l3_hypos_netgen
4483     def SetGrowthRate(self, theRate):
4484         if self.Parameters():
4485             self.params.SetGrowthRate(theRate)
4486
4487     ## Sets NbSegPerEdge
4488     #
4489     #  Only for algoType == NETGEN
4490     #  @ingroup l3_hypos_netgen
4491     def SetNbSegPerEdge(self, theVal):
4492         if self.Parameters():
4493             self.params.SetNbSegPerEdge(theVal)
4494
4495     ## Sets NbSegPerRadius
4496     #
4497     #  Only for algoType == NETGEN
4498     #  @ingroup l3_hypos_netgen
4499     def SetNbSegPerRadius(self, theVal):
4500         if self.Parameters():
4501             self.params.SetNbSegPerRadius(theVal)
4502
4503     ## Sets number of segments overriding value set by SetLocalLength()
4504     #
4505     #  Only for algoType == NETGEN
4506     #  @ingroup l3_hypos_netgen
4507     def SetNumberOfSegments(self, theVal):
4508         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4509
4510     ## Sets number of segments overriding value set by SetNumberOfSegments()
4511     #
4512     #  Only for algoType == NETGEN
4513     #  @ingroup l3_hypos_netgen
4514     def SetLocalLength(self, theVal):
4515         self.Parameters(SIMPLE).SetLocalLength(theVal)
4516
4517     pass
4518
4519
4520 # Public class: Mesh_Quadrangle
4521 # -----------------------------
4522
4523 ## Defines a quadrangle 2D algorithm
4524 #
4525 #  @ingroup l3_algos_basic
4526 class Mesh_Quadrangle(Mesh_Algorithm):
4527
4528     ## Private constructor.
4529     def __init__(self, mesh, geom=0):
4530         Mesh_Algorithm.__init__(self)
4531         self.Create(mesh, geom, "Quadrangle_2D")
4532
4533     ## Defines "QuadranglePreference" hypothesis, forcing construction
4534     #  of quadrangles if the number of nodes on the opposite edges is not the same
4535     #  while the total number of nodes on edges is even
4536     #
4537     #  @ingroup l3_hypos_additi
4538     def QuadranglePreference(self):
4539         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4540                               CompareMethod=self.CompareEqualHyp)
4541         return hyp
4542
4543     ## Defines "TrianglePreference" hypothesis, forcing construction
4544     #  of triangles in the refinement area if the number of nodes
4545     #  on the opposite edges is not the same
4546     #
4547     #  @ingroup l3_hypos_additi
4548     def TrianglePreference(self):
4549         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4550                               CompareMethod=self.CompareEqualHyp)
4551         return hyp
4552
4553     ## Defines "QuadrangleParams" hypothesis
4554     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
4555     #                 will be created while other elements will be quadrangles.
4556     #                 Vertex can be either a GEOM_Object or a vertex ID within the
4557     #                 shape to mesh
4558     #
4559     #  @ingroup l3_hypos_additi
4560     def TriangleVertex(self, vertex, UseExisting=0):
4561         vertexID = vertex
4562         if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4563             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4564         hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4565                               CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4566         hyp.SetTriaVertex( vertexID )
4567         return hyp
4568
4569
4570 # Public class: Mesh_Tetrahedron
4571 # ------------------------------
4572
4573 ## Defines a tetrahedron 3D algorithm
4574 #
4575 #  @ingroup l3_algos_basic
4576 class Mesh_Tetrahedron(Mesh_Algorithm):
4577
4578     params = 0
4579     algoType = 0
4580
4581     ## Private constructor.
4582     def __init__(self, mesh, algoType, geom=0):
4583         Mesh_Algorithm.__init__(self)
4584
4585         if algoType == NETGEN:
4586             CheckPlugin(NETGEN)
4587             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4588             pass
4589
4590         elif algoType == FULL_NETGEN:
4591             CheckPlugin(NETGEN)
4592             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4593             pass
4594
4595         elif algoType == GHS3D:
4596             CheckPlugin(GHS3D)
4597             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4598             pass
4599
4600         elif algoType == GHS3DPRL:
4601             CheckPlugin(GHS3DPRL)
4602             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4603             pass
4604
4605         self.algoType = algoType
4606
4607     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4608     #  @param vol for the maximum volume of each tetrahedron
4609     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4610     #                   the same parameters, else (default) - creates a new one
4611     #  @ingroup l3_hypos_maxvol
4612     def MaxElementVolume(self, vol, UseExisting=0):
4613         if self.algoType == NETGEN:
4614             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4615                                   CompareMethod=self.CompareMaxElementVolume)
4616             hyp.SetMaxElementVolume(vol)
4617             return hyp
4618         elif self.algoType == FULL_NETGEN:
4619             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4620         return None
4621
4622     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4623     def CompareMaxElementVolume(self, hyp, args):
4624         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4625
4626     ## Defines hypothesis having several parameters
4627     #
4628     #  @ingroup l3_hypos_netgen
4629     def Parameters(self, which=SOLE):
4630         if self.params:
4631             return self.params
4632
4633         if self.algoType == FULL_NETGEN:
4634             if which == SIMPLE:
4635                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4636                                               "libNETGENEngine.so", UseExisting=0)
4637             else:
4638                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4639                                               "libNETGENEngine.so", UseExisting=0)
4640             return self.params
4641
4642         if self.algoType == GHS3D:
4643             self.params = self.Hypothesis("GHS3D_Parameters", [],
4644                                           "libGHS3DEngine.so", UseExisting=0)
4645             return self.params
4646
4647         if self.algoType == GHS3DPRL:
4648             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4649                                           "libGHS3DPRLEngine.so", UseExisting=0)
4650             return self.params
4651
4652         print "Algo supports no multi-parameter hypothesis"
4653         return None
4654
4655     ## Sets MaxSize
4656     #  Parameter of FULL_NETGEN
4657     #  @ingroup l3_hypos_netgen
4658     def SetMaxSize(self, theSize):
4659         self.Parameters().SetMaxSize(theSize)
4660
4661     ## Sets SecondOrder flag
4662     #  Parameter of FULL_NETGEN
4663     #  @ingroup l3_hypos_netgen
4664     def SetSecondOrder(self, theVal):
4665         self.Parameters().SetSecondOrder(theVal)
4666
4667     ## Sets Optimize flag
4668     #  Parameter of FULL_NETGEN
4669     #  @ingroup l3_hypos_netgen
4670     def SetOptimize(self, theVal):
4671         self.Parameters().SetOptimize(theVal)
4672
4673     ## Sets Fineness
4674     #  @param theFineness is:
4675     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4676     #  Parameter of FULL_NETGEN
4677     #  @ingroup l3_hypos_netgen
4678     def SetFineness(self, theFineness):
4679         self.Parameters().SetFineness(theFineness)
4680
4681     ## Sets GrowthRate
4682     #  Parameter of FULL_NETGEN
4683     #  @ingroup l3_hypos_netgen
4684     def SetGrowthRate(self, theRate):
4685         self.Parameters().SetGrowthRate(theRate)
4686
4687     ## Sets NbSegPerEdge
4688     #  Parameter of FULL_NETGEN
4689     #  @ingroup l3_hypos_netgen
4690     def SetNbSegPerEdge(self, theVal):
4691         self.Parameters().SetNbSegPerEdge(theVal)
4692
4693     ## Sets NbSegPerRadius
4694     #  Parameter of FULL_NETGEN
4695     #  @ingroup l3_hypos_netgen
4696     def SetNbSegPerRadius(self, theVal):
4697         self.Parameters().SetNbSegPerRadius(theVal)
4698
4699     ## Sets number of segments overriding value set by SetLocalLength()
4700     #  Only for algoType == NETGEN_FULL
4701     #  @ingroup l3_hypos_netgen
4702     def SetNumberOfSegments(self, theVal):
4703         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4704
4705     ## Sets number of segments overriding value set by SetNumberOfSegments()
4706     #  Only for algoType == NETGEN_FULL
4707     #  @ingroup l3_hypos_netgen
4708     def SetLocalLength(self, theVal):
4709         self.Parameters(SIMPLE).SetLocalLength(theVal)
4710
4711     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4712     #  Overrides value set by LengthFromEdges()
4713     #  Only for algoType == NETGEN_FULL
4714     #  @ingroup l3_hypos_netgen
4715     def MaxElementArea(self, area):
4716         self.Parameters(SIMPLE).SetMaxElementArea(area)
4717
4718     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4719     #  Overrides value set by MaxElementArea()
4720     #  Only for algoType == NETGEN_FULL
4721     #  @ingroup l3_hypos_netgen
4722     def LengthFromEdges(self):
4723         self.Parameters(SIMPLE).LengthFromEdges()
4724
4725     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4726     #  Overrides value set by MaxElementVolume()
4727     #  Only for algoType == NETGEN_FULL
4728     #  @ingroup l3_hypos_netgen
4729     def LengthFromFaces(self):
4730         self.Parameters(SIMPLE).LengthFromFaces()
4731
4732     ## To mesh "holes" in a solid or not. Default is to mesh.
4733     #  @ingroup l3_hypos_ghs3dh
4734     def SetToMeshHoles(self, toMesh):
4735         #  Parameter of GHS3D
4736         self.Parameters().SetToMeshHoles(toMesh)
4737
4738     ## Set Optimization level:
4739     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4740     #   Strong_Optimization.
4741     # Default is Standard_Optimization
4742     #  @ingroup l3_hypos_ghs3dh
4743     def SetOptimizationLevel(self, level):
4744         #  Parameter of GHS3D
4745         self.Parameters().SetOptimizationLevel(level)
4746
4747     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4748     #  @ingroup l3_hypos_ghs3dh
4749     def SetMaximumMemory(self, MB):
4750         #  Advanced parameter of GHS3D
4751         self.Parameters().SetMaximumMemory(MB)
4752
4753     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4754     #  automatic memory adjustment mode.
4755     #  @ingroup l3_hypos_ghs3dh
4756     def SetInitialMemory(self, MB):
4757         #  Advanced parameter of GHS3D
4758         self.Parameters().SetInitialMemory(MB)
4759
4760     ## Path to working directory.
4761     #  @ingroup l3_hypos_ghs3dh
4762     def SetWorkingDirectory(self, path):
4763         #  Advanced parameter of GHS3D
4764         self.Parameters().SetWorkingDirectory(path)
4765
4766     ## To keep working files or remove them. Log file remains in case of errors anyway.
4767     #  @ingroup l3_hypos_ghs3dh
4768     def SetKeepFiles(self, toKeep):
4769         #  Advanced parameter of GHS3D and GHS3DPRL
4770         self.Parameters().SetKeepFiles(toKeep)
4771
4772     ## To set verbose level [0-10]. <ul>
4773     #<li> 0 - no standard output,
4774     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4775     #     indicates when the final mesh is being saved. In addition the software
4776     #     gives indication regarding the CPU time.
4777     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4778     #     histogram of the skin mesh, quality statistics histogram together with
4779     #     the characteristics of the final mesh.</ul>
4780     #  @ingroup l3_hypos_ghs3dh
4781     def SetVerboseLevel(self, level):
4782         #  Advanced parameter of GHS3D
4783         self.Parameters().SetVerboseLevel(level)
4784
4785     ## To create new nodes.
4786     #  @ingroup l3_hypos_ghs3dh
4787     def SetToCreateNewNodes(self, toCreate):
4788         #  Advanced parameter of GHS3D
4789         self.Parameters().SetToCreateNewNodes(toCreate)
4790
4791     ## To use boundary recovery version which tries to create mesh on a very poor
4792     #  quality surface mesh.
4793     #  @ingroup l3_hypos_ghs3dh
4794     def SetToUseBoundaryRecoveryVersion(self, toUse):
4795         #  Advanced parameter of GHS3D
4796         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4797
4798     ## Sets command line option as text.
4799     #  @ingroup l3_hypos_ghs3dh
4800     def SetTextOption(self, option):
4801         #  Advanced parameter of GHS3D
4802         self.Parameters().SetTextOption(option)
4803
4804     ## Sets MED files name and path.
4805     def SetMEDName(self, value):
4806         self.Parameters().SetMEDName(value)
4807
4808     ## Sets the number of partition of the initial mesh
4809     def SetNbPart(self, value):
4810         self.Parameters().SetNbPart(value)
4811
4812     ## When big mesh, start tepal in background
4813     def SetBackground(self, value):
4814         self.Parameters().SetBackground(value)
4815
4816 # Public class: Mesh_Hexahedron
4817 # ------------------------------
4818
4819 ## Defines a hexahedron 3D algorithm
4820 #
4821 #  @ingroup l3_algos_basic
4822 class Mesh_Hexahedron(Mesh_Algorithm):
4823
4824     params = 0
4825     algoType = 0
4826
4827     ## Private constructor.
4828     def __init__(self, mesh, algoType=Hexa, geom=0):
4829         Mesh_Algorithm.__init__(self)
4830
4831         self.algoType = algoType
4832
4833         if algoType == Hexa:
4834             self.Create(mesh, geom, "Hexa_3D")
4835             pass
4836
4837         elif algoType == Hexotic:
4838             CheckPlugin(Hexotic)
4839             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4840             pass
4841
4842     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4843     #  @ingroup l3_hypos_hexotic
4844     def MinMaxQuad(self, min=3, max=8, quad=True):
4845         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4846                                       UseExisting=0)
4847         self.params.SetHexesMinLevel(min)
4848         self.params.SetHexesMaxLevel(max)
4849         self.params.SetHexoticQuadrangles(quad)
4850         return self.params
4851
4852 # Deprecated, only for compatibility!
4853 # Public class: Mesh_Netgen
4854 # ------------------------------
4855
4856 ## Defines a NETGEN-based 2D or 3D algorithm
4857 #  that needs no discrete boundary (i.e. independent)
4858 #
4859 #  This class is deprecated, only for compatibility!
4860 #
4861 #  More details.
4862 #  @ingroup l3_algos_basic
4863 class Mesh_Netgen(Mesh_Algorithm):
4864
4865     is3D = 0
4866
4867     ## Private constructor.
4868     def __init__(self, mesh, is3D, geom=0):
4869         Mesh_Algorithm.__init__(self)
4870
4871         CheckPlugin(NETGEN)
4872
4873         self.is3D = is3D
4874         if is3D:
4875             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4876             pass
4877
4878         else:
4879             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4880             pass
4881
4882     ## Defines the hypothesis containing parameters of the algorithm
4883     def Parameters(self):
4884         if self.is3D:
4885             hyp = self.Hypothesis("NETGEN_Parameters", [],
4886                                   "libNETGENEngine.so", UseExisting=0)
4887         else:
4888             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4889                                   "libNETGENEngine.so", UseExisting=0)
4890         return hyp
4891
4892 # Public class: Mesh_Projection1D
4893 # ------------------------------
4894
4895 ## Defines a projection 1D algorithm
4896 #  @ingroup l3_algos_proj
4897 #
4898 class Mesh_Projection1D(Mesh_Algorithm):
4899
4900     ## Private constructor.
4901     def __init__(self, mesh, geom=0):
4902         Mesh_Algorithm.__init__(self)
4903         self.Create(mesh, geom, "Projection_1D")
4904
4905     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4906     #  a mesh pattern is taken, and, optionally, the association of vertices
4907     #  between the source edge and a target edge (to which a hypothesis is assigned)
4908     #  @param edge from which nodes distribution is taken
4909     #  @param mesh from which nodes distribution is taken (optional)
4910     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4911     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4912     #  to associate with \a srcV (optional)
4913     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4914     #                     the same parameters, else (default) - creates a new one
4915     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4916         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4917                               UseExisting=0)
4918                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4919         hyp.SetSourceEdge( edge )
4920         if not mesh is None and isinstance(mesh, Mesh):
4921             mesh = mesh.GetMesh()
4922         hyp.SetSourceMesh( mesh )
4923         hyp.SetVertexAssociation( srcV, tgtV )
4924         return hyp
4925
4926     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4927     #def CompareSourceEdge(self, hyp, args):
4928     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4929     #    return False
4930
4931
4932 # Public class: Mesh_Projection2D
4933 # ------------------------------
4934
4935 ## Defines a projection 2D algorithm
4936 #  @ingroup l3_algos_proj
4937 #
4938 class Mesh_Projection2D(Mesh_Algorithm):
4939
4940     ## Private constructor.
4941     def __init__(self, mesh, geom=0):
4942         Mesh_Algorithm.__init__(self)
4943         self.Create(mesh, geom, "Projection_2D")
4944
4945     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4946     #  a mesh pattern is taken, and, optionally, the association of vertices
4947     #  between the source face and the target face (to which a hypothesis is assigned)
4948     #  @param face from which the mesh pattern is taken
4949     #  @param mesh from which the mesh pattern is taken (optional)
4950     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4951     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4952     #               to associate with \a srcV1 (optional)
4953     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4954     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4955     #               to associate with \a srcV2 (optional)
4956     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
4957     #                     the same parameters, else (default) - forces the creation a new one
4958     #
4959     #  Note: all association vertices must belong to one edge of a face
4960     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4961                    srcV2=None, tgtV2=None, UseExisting=0):
4962         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4963                               UseExisting=0)
4964                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4965         hyp.SetSourceFace( face )
4966         if not mesh is None and isinstance(mesh, Mesh):
4967             mesh = mesh.GetMesh()
4968         hyp.SetSourceMesh( mesh )
4969         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4970         return hyp
4971
4972     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4973     #def CompareSourceFace(self, hyp, args):
4974     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4975     #    return False
4976
4977 # Public class: Mesh_Projection3D
4978 # ------------------------------
4979
4980 ## Defines a projection 3D algorithm
4981 #  @ingroup l3_algos_proj
4982 #
4983 class Mesh_Projection3D(Mesh_Algorithm):
4984
4985     ## Private constructor.
4986     def __init__(self, mesh, geom=0):
4987         Mesh_Algorithm.__init__(self)
4988         self.Create(mesh, geom, "Projection_3D")
4989
4990     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4991     #  the mesh pattern is taken, and, optionally, the  association of vertices
4992     #  between the source and the target solid  (to which a hipothesis is assigned)
4993     #  @param solid from where the mesh pattern is taken
4994     #  @param mesh from where the mesh pattern is taken (optional)
4995     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4996     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4997     #  to associate with \a srcV1 (optional)
4998     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4999     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5000     #  to associate with \a srcV2 (optional)
5001     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
5002     #                     the same parameters, else (default) - creates a new one
5003     #
5004     #  Note: association vertices must belong to one edge of a solid
5005     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5006                       srcV2=0, tgtV2=0, UseExisting=0):
5007         hyp = self.Hypothesis("ProjectionSource3D",
5008                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5009                               UseExisting=0)
5010                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5011         hyp.SetSource3DShape( solid )
5012         if not mesh is None and isinstance(mesh, Mesh):
5013             mesh = mesh.GetMesh()
5014         hyp.SetSourceMesh( mesh )
5015         if srcV1 and srcV2 and tgtV1 and tgtV2:
5016             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5017         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5018         return hyp
5019
5020     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5021     #def CompareSourceShape3D(self, hyp, args):
5022     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5023     #    return False
5024
5025
5026 # Public class: Mesh_Prism
5027 # ------------------------
5028
5029 ## Defines a 3D extrusion algorithm
5030 #  @ingroup l3_algos_3dextr
5031 #
5032 class Mesh_Prism3D(Mesh_Algorithm):
5033
5034     ## Private constructor.
5035     def __init__(self, mesh, geom=0):
5036         Mesh_Algorithm.__init__(self)
5037         self.Create(mesh, geom, "Prism_3D")
5038
5039 # Public class: Mesh_RadialPrism
5040 # -------------------------------
5041
5042 ## Defines a Radial Prism 3D algorithm
5043 #  @ingroup l3_algos_radialp
5044 #
5045 class Mesh_RadialPrism3D(Mesh_Algorithm):
5046
5047     ## Private constructor.
5048     def __init__(self, mesh, geom=0):
5049         Mesh_Algorithm.__init__(self)
5050         self.Create(mesh, geom, "RadialPrism_3D")
5051
5052         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5053         self.nbLayers = None
5054
5055     ## Return 3D hypothesis holding the 1D one
5056     def Get3DHypothesis(self):
5057         return self.distribHyp
5058
5059     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5060     #  hypothesis. Returns the created hypothesis
5061     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5062         #print "OwnHypothesis",hypType
5063         if not self.nbLayers is None:
5064             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5065             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5066         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5067         self.mesh.smeshpyD.SetCurrentStudy( None )
5068         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5069         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5070         self.distribHyp.SetLayerDistribution( hyp )
5071         return hyp
5072
5073     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5074     #  prisms to build between the inner and outer shells
5075     #  @param n number of layers
5076     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5077     #                     the same parameters, else (default) - creates a new one
5078     def NumberOfLayers(self, n, UseExisting=0):
5079         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5080         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5081                                         CompareMethod=self.CompareNumberOfLayers)
5082         self.nbLayers.SetNumberOfLayers( n )
5083         return self.nbLayers
5084
5085     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5086     def CompareNumberOfLayers(self, hyp, args):
5087         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5088
5089     ## Defines "LocalLength" hypothesis, specifying the segment length
5090     #  to build between the inner and the outer shells
5091     #  @param l the length of segments
5092     #  @param p the precision of rounding
5093     def LocalLength(self, l, p=1e-07):
5094         hyp = self.OwnHypothesis("LocalLength", [l,p])
5095         hyp.SetLength(l)
5096         hyp.SetPrecision(p)
5097         return hyp
5098
5099     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5100     #  prisms to build between the inner and the outer shells.
5101     #  @param n the number of layers
5102     #  @param s the scale factor (optional)
5103     def NumberOfSegments(self, n, s=[]):
5104         if s == []:
5105             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5106         else:
5107             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5108             hyp.SetDistrType( 1 )
5109             hyp.SetScaleFactor(s)
5110         hyp.SetNumberOfSegments(n)
5111         return hyp
5112
5113     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5114     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
5115     #  @param start  the length of the first segment
5116     #  @param end    the length of the last  segment
5117     def Arithmetic1D(self, start, end ):
5118         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5119         hyp.SetLength(start, 1)
5120         hyp.SetLength(end  , 0)
5121         return hyp
5122
5123     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5124     #  to build between the inner and the outer shells as geometric length increasing
5125     #  @param start for the length of the first segment
5126     #  @param end   for the length of the last  segment
5127     def StartEndLength(self, start, end):
5128         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5129         hyp.SetLength(start, 1)
5130         hyp.SetLength(end  , 0)
5131         return hyp
5132
5133     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5134     #  to build between the inner and outer shells
5135     #  @param fineness defines the quality of the mesh within the range [0-1]
5136     def AutomaticLength(self, fineness=0):
5137         hyp = self.OwnHypothesis("AutomaticLength")
5138         hyp.SetFineness( fineness )
5139         return hyp
5140
5141 # Public class: Mesh_RadialQuadrangle1D2D
5142 # -------------------------------
5143
5144 ## Defines a Radial Quadrangle 1D2D algorithm
5145 #  @ingroup l2_algos_radialq
5146 #
5147 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5148
5149     ## Private constructor.
5150     def __init__(self, mesh, geom=0):
5151         Mesh_Algorithm.__init__(self)
5152         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5153
5154         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5155         self.nbLayers = None
5156
5157     ## Return 2D hypothesis holding the 1D one
5158     def Get2DHypothesis(self):
5159         return self.distribHyp
5160
5161     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5162     #  hypothesis. Returns the created hypothesis
5163     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5164         #print "OwnHypothesis",hypType
5165         if self.nbLayers:
5166             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5167         if self.distribHyp is None:
5168             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5169         else:
5170             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5171         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5172         self.mesh.smeshpyD.SetCurrentStudy( None )
5173         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5174         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5175         self.distribHyp.SetLayerDistribution( hyp )
5176         return hyp
5177
5178     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5179     #  @param n number of layers
5180     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5181     #                     the same parameters, else (default) - creates a new one
5182     def NumberOfLayers(self, n, UseExisting=0):
5183         if self.distribHyp:
5184             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5185         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5186                                         CompareMethod=self.CompareNumberOfLayers)
5187         self.nbLayers.SetNumberOfLayers( n )
5188         return self.nbLayers
5189
5190     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5191     def CompareNumberOfLayers(self, hyp, args):
5192         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5193
5194     ## Defines "LocalLength" hypothesis, specifying the segment length
5195     #  @param l the length of segments
5196     #  @param p the precision of rounding
5197     def LocalLength(self, l, p=1e-07):
5198         hyp = self.OwnHypothesis("LocalLength", [l,p])
5199         hyp.SetLength(l)
5200         hyp.SetPrecision(p)
5201         return hyp
5202
5203     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5204     #  @param n the number of layers
5205     #  @param s the scale factor (optional)
5206     def NumberOfSegments(self, n, s=[]):
5207         if s == []:
5208             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5209         else:
5210             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5211             hyp.SetDistrType( 1 )
5212             hyp.SetScaleFactor(s)
5213         hyp.SetNumberOfSegments(n)
5214         return hyp
5215
5216     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5217     #  with a length that changes in arithmetic progression
5218     #  @param start  the length of the first segment
5219     #  @param end    the length of the last  segment
5220     def Arithmetic1D(self, start, end ):
5221         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5222         hyp.SetLength(start, 1)
5223         hyp.SetLength(end  , 0)
5224         return hyp
5225
5226     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5227     #  as geometric length increasing
5228     #  @param start for the length of the first segment
5229     #  @param end   for the length of the last  segment
5230     def StartEndLength(self, start, end):
5231         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5232         hyp.SetLength(start, 1)
5233         hyp.SetLength(end  , 0)
5234         return hyp
5235
5236     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5237     #  @param fineness defines the quality of the mesh within the range [0-1]
5238     def AutomaticLength(self, fineness=0):
5239         hyp = self.OwnHypothesis("AutomaticLength")
5240         hyp.SetFineness( fineness )
5241         return hyp
5242
5243
5244 # Private class: Mesh_UseExisting
5245 # -------------------------------
5246 class Mesh_UseExisting(Mesh_Algorithm):
5247
5248     def __init__(self, dim, mesh, geom=0):
5249         if dim == 1:
5250             self.Create(mesh, geom, "UseExisting_1D")
5251         else:
5252             self.Create(mesh, geom, "UseExisting_2D")
5253
5254
5255 import salome_notebook
5256 notebook = salome_notebook.notebook
5257
5258 ##Return values of the notebook variables
5259 def ParseParameters(last, nbParams,nbParam, value):
5260     result = None
5261     strResult = ""
5262     counter = 0
5263     listSize = len(last)
5264     for n in range(0,nbParams):
5265         if n+1 != nbParam:
5266             if counter < listSize:
5267                 strResult = strResult + last[counter]
5268             else:
5269                 strResult = strResult + ""
5270         else:
5271             if isinstance(value, str):
5272                 if notebook.isVariable(value):
5273                     result = notebook.get(value)
5274                     strResult=strResult+value
5275                 else:
5276                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5277             else:
5278                 strResult=strResult+str(value)
5279                 result = value
5280         if nbParams - 1 != counter:
5281             strResult=strResult+var_separator #":"
5282         counter = counter+1
5283     return result, strResult
5284
5285 #Wrapper class for StdMeshers_LocalLength hypothesis
5286 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5287
5288     ## Set Length parameter value
5289     #  @param length numerical value or name of variable from notebook
5290     def SetLength(self, length):
5291         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5292         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5293         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5294
5295    ## Set Precision parameter value
5296    #  @param precision numerical value or name of variable from notebook
5297     def SetPrecision(self, precision):
5298         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5299         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5300         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5301
5302 #Registering the new proxy for LocalLength
5303 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5304
5305
5306 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5307 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5308     
5309     def SetLayerDistribution(self, hypo):
5310         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5311         hypo.ClearParameters();
5312         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5313
5314 #Registering the new proxy for LayerDistribution
5315 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5316
5317 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5318 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5319     
5320     ## Set Length parameter value
5321     #  @param length numerical value or name of variable from notebook    
5322     def SetLength(self, length):
5323         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5324         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5325         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5326
5327 #Registering the new proxy for SegmentLengthAroundVertex
5328 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5329
5330
5331 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5332 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5333     
5334     ## Set Length parameter value
5335     #  @param length   numerical value or name of variable from notebook
5336     #  @param isStart  true is length is Start Length, otherwise false
5337     def SetLength(self, length, isStart):
5338         nb = 2
5339         if isStart:
5340             nb = 1
5341         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5342         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5343         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5344         
5345 #Registering the new proxy for Arithmetic1D
5346 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5347
5348 #Wrapper class for StdMeshers_Deflection1D hypothesis
5349 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5350     
5351     ## Set Deflection parameter value
5352     #  @param deflection numerical value or name of variable from notebook    
5353     def SetDeflection(self, deflection):
5354         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5355         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5356         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5357
5358 #Registering the new proxy for Deflection1D
5359 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5360
5361 #Wrapper class for StdMeshers_StartEndLength hypothesis
5362 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5363     
5364     ## Set Length parameter value
5365     #  @param length  numerical value or name of variable from notebook
5366     #  @param isStart true is length is Start Length, otherwise false
5367     def SetLength(self, length, isStart):
5368         nb = 2
5369         if isStart:
5370             nb = 1
5371         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5372         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5373         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5374         
5375 #Registering the new proxy for StartEndLength
5376 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5377
5378 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5379 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5380     
5381     ## Set Max Element Area parameter value
5382     #  @param area  numerical value or name of variable from notebook
5383     def SetMaxElementArea(self, area):
5384         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5385         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5386         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5387         
5388 #Registering the new proxy for MaxElementArea
5389 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5390
5391
5392 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5393 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5394     
5395     ## Set Max Element Volume parameter value
5396     #  @param volume numerical value or name of variable from notebook
5397     def SetMaxElementVolume(self, volume):
5398         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5399         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5400         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5401         
5402 #Registering the new proxy for MaxElementVolume
5403 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5404
5405
5406 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5407 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5408     
5409     ## Set Number Of Layers parameter value
5410     #  @param nbLayers  numerical value or name of variable from notebook
5411     def SetNumberOfLayers(self, nbLayers):
5412         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5413         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5414         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5415         
5416 #Registering the new proxy for NumberOfLayers
5417 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5418
5419 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5420 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5421     
5422     ## Set Number Of Segments parameter value
5423     #  @param nbSeg numerical value or name of variable from notebook
5424     def SetNumberOfSegments(self, nbSeg):
5425         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5426         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5427         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5428         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5429         
5430     ## Set Scale Factor parameter value
5431     #  @param factor numerical value or name of variable from notebook
5432     def SetScaleFactor(self, factor):
5433         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5434         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5435         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5436         
5437 #Registering the new proxy for NumberOfSegments
5438 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5439
5440 if not noNETGENPlugin:
5441     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5442     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5443
5444         ## Set Max Size parameter value
5445         #  @param maxsize numerical value or name of variable from notebook
5446         def SetMaxSize(self, maxsize):
5447             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5448             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5449             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5450             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5451
5452         ## Set Growth Rate parameter value
5453         #  @param value  numerical value or name of variable from notebook
5454         def SetGrowthRate(self, value):
5455             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5456             value, parameters = ParseParameters(lastParameters,4,2,value)
5457             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5458             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5459
5460         ## Set Number of Segments per Edge parameter value
5461         #  @param value  numerical value or name of variable from notebook
5462         def SetNbSegPerEdge(self, value):
5463             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5464             value, parameters = ParseParameters(lastParameters,4,3,value)
5465             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5466             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5467
5468         ## Set Number of Segments per Radius parameter value
5469         #  @param value  numerical value or name of variable from notebook
5470         def SetNbSegPerRadius(self, value):
5471             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5472             value, parameters = ParseParameters(lastParameters,4,4,value)
5473             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5474             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5475
5476     #Registering the new proxy for NETGENPlugin_Hypothesis
5477     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5478
5479
5480     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5481     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5482         pass
5483
5484     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5485     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5486
5487     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5488     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5489
5490         ## Set Number of Segments parameter value
5491         #  @param nbSeg numerical value or name of variable from notebook
5492         def SetNumberOfSegments(self, nbSeg):
5493             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5494             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5495             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5496             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5497
5498         ## Set Local Length parameter value
5499         #  @param length numerical value or name of variable from notebook
5500         def SetLocalLength(self, length):
5501             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5502             length, parameters = ParseParameters(lastParameters,2,1,length)
5503             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5504             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5505
5506         ## Set Max Element Area parameter value
5507         #  @param area numerical value or name of variable from notebook    
5508         def SetMaxElementArea(self, area):
5509             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5510             area, parameters = ParseParameters(lastParameters,2,2,area)
5511             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5512             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5513
5514         def LengthFromEdges(self):
5515             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5516             value = 0;
5517             value, parameters = ParseParameters(lastParameters,2,2,value)
5518             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5519             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5520
5521     #Registering the new proxy for NETGEN_SimpleParameters_2D
5522     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5523
5524
5525     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5526     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5527         ## Set Max Element Volume parameter value
5528         #  @param volume numerical value or name of variable from notebook    
5529         def SetMaxElementVolume(self, volume):
5530             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5531             volume, parameters = ParseParameters(lastParameters,3,3,volume)
5532             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5533             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5534
5535         def LengthFromFaces(self):
5536             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5537             value = 0;
5538             value, parameters = ParseParameters(lastParameters,3,3,value)
5539             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5540             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5541
5542     #Registering the new proxy for NETGEN_SimpleParameters_3D
5543     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5544
5545     pass # if not noNETGENPlugin:
5546
5547 class Pattern(SMESH._objref_SMESH_Pattern):
5548
5549     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5550         flag = False
5551         if isinstance(theNodeIndexOnKeyPoint1,str):
5552             flag = True
5553         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5554         if flag:
5555             theNodeIndexOnKeyPoint1 -= 1
5556         theMesh.SetParameters(Parameters)
5557         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5558
5559     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5560         flag0 = False
5561         flag1 = False
5562         if isinstance(theNode000Index,str):
5563             flag0 = True
5564         if isinstance(theNode001Index,str):
5565             flag1 = True
5566         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5567         if flag0:
5568             theNode000Index -= 1
5569         if flag1:
5570             theNode001Index -= 1
5571         theMesh.SetParameters(Parameters)
5572         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5573
5574 #Registering the new proxy for Pattern
5575 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)