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