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