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