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