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