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