Back to index

salome-smesh  6.5.0
smeshDC.py
Go to the documentation of this file.
00001 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 #  File   : smesh.py
00020 #  Author : Francis KLOSS, OCC
00021 #  Module : SMESH
00022 
00023 """
00024  \namespace smesh
00025  \brief Module smesh
00026 """
00027 
00028 ## @defgroup l1_auxiliary Auxiliary methods and structures
00029 ## @defgroup l1_creating  Creating meshes
00030 ## @{
00031 ##   @defgroup l2_impexp     Importing and exporting meshes
00032 ##   @defgroup l2_construct  Constructing meshes
00033 ##   @defgroup l2_algorithms Defining Algorithms
00034 ##   @{
00035 ##     @defgroup l3_algos_basic   Basic meshing algorithms
00036 ##     @defgroup l3_algos_proj    Projection Algorithms
00037 ##     @defgroup l3_algos_radialp Radial Prism
00038 ##     @defgroup l3_algos_segmarv Segments around Vertex
00039 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
00040 
00041 ##   @}
00042 ##   @defgroup l2_hypotheses Defining hypotheses
00043 ##   @{
00044 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
00045 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
00046 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
00047 ##     @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
00048 ##     @defgroup l3_hypos_additi Additional Hypotheses
00049 
00050 ##   @}
00051 ##   @defgroup l2_submeshes Constructing submeshes
00052 ##   @defgroup l2_compounds Building Compounds
00053 ##   @defgroup l2_editing   Editing Meshes
00054 
00055 ## @}
00056 ## @defgroup l1_meshinfo  Mesh Information
00057 ## @defgroup l1_controls  Quality controls and Filtering
00058 ## @defgroup l1_grouping  Grouping elements
00059 ## @{
00060 ##   @defgroup l2_grps_create Creating groups
00061 ##   @defgroup l2_grps_edit   Editing groups
00062 ##   @defgroup l2_grps_operon Using operations on groups
00063 ##   @defgroup l2_grps_delete Deleting Groups
00064 
00065 ## @}
00066 ## @defgroup l1_modifying Modifying meshes
00067 ## @{
00068 ##   @defgroup l2_modif_add      Adding nodes and elements
00069 ##   @defgroup l2_modif_del      Removing nodes and elements
00070 ##   @defgroup l2_modif_edit     Modifying nodes and elements
00071 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
00072 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
00073 ##   @defgroup l2_modif_movenode Moving nodes
00074 ##   @defgroup l2_modif_throughp Mesh through point
00075 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
00076 ##   @defgroup l2_modif_unitetri Uniting triangles
00077 ##   @defgroup l2_modif_changori Changing orientation of elements
00078 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
00079 ##   @defgroup l2_modif_smooth   Smoothing
00080 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
00081 ##   @defgroup l2_modif_patterns Pattern mapping
00082 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
00083 
00084 ## @}
00085 ## @defgroup l1_measurements Measurements
00086 
00087 import salome
00088 import geompyDC
00089 
00090 import SMESH # This is necessary for back compatibility
00091 from   SMESH import *
00092 
00093 import SALOME
00094 import SALOMEDS
00095 
00096 ## @addtogroup l1_auxiliary
00097 ## @{
00098 
00099 # MirrorType enumeration
00100 POINT = SMESH_MeshEditor.POINT
00101 AXIS =  SMESH_MeshEditor.AXIS
00102 PLANE = SMESH_MeshEditor.PLANE
00103 
00104 # Smooth_Method enumeration
00105 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
00106 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
00107 
00108 PrecisionConfusion = 1e-07
00109 
00110 # TopAbs_State enumeration
00111 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
00112 
00113 # Methods of splitting a hexahedron into tetrahedra
00114 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
00115 
00116 ## Converts an angle from degrees to radians
00117 def DegreesToRadians(AngleInDegrees):
00118     from math import pi
00119     return AngleInDegrees * pi / 180.0
00120 
00121 import salome_notebook
00122 notebook = salome_notebook.notebook
00123 # Salome notebook variable separator
00124 var_separator = ":"
00125 
00126 ## Return list of variable values from salome notebook.
00127 #  The last argument, if is callable, is used to modify values got from notebook
00128 def ParseParameters(*args):
00129     Result = []
00130     Parameters = ""
00131     hasVariables = False
00132     varModifFun=None
00133     if args and callable( args[-1] ):
00134         args, varModifFun = args[:-1], args[-1]
00135     for parameter in args:
00136 
00137         Parameters += str(parameter) + var_separator
00138 
00139         if isinstance(parameter,str):
00140             # check if there is an inexistent variable name
00141             if not notebook.isVariable(parameter):
00142                 raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
00143             parameter = notebook.get(parameter)
00144             hasVariables = True
00145             if varModifFun:
00146                 parameter = varModifFun(parameter)
00147                 pass
00148             pass
00149         Result.append(parameter)
00150 
00151         pass
00152     Parameters = Parameters[:-1]
00153     Result.append( Parameters )
00154     Result.append( hasVariables )
00155     return Result
00156 
00157 # Parse parameters converting variables to radians
00158 def ParseAngles(*args):
00159     return ParseParameters( *( args + (DegreesToRadians, )))
00160 
00161 # Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
00162 # Parameters are stored in PointStruct.parameters attribute
00163 def __initPointStruct(point,*args):
00164     point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
00165     pass
00166 SMESH.PointStruct.__init__ = __initPointStruct
00167 
00168 # Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
00169 # Parameters are stored in AxisStruct.parameters attribute
00170 def __initAxisStruct(ax,*args):
00171     ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
00172     pass
00173 SMESH.AxisStruct.__init__ = __initAxisStruct
00174 
00175 
00176 def IsEqual(val1, val2, tol=PrecisionConfusion):
00177     if abs(val1 - val2) < tol:
00178         return True
00179     return False
00180 
00181 NO_NAME = "NoName"
00182 
00183 ## Gets object name
00184 def GetName(obj):
00185     if obj:
00186         # object not null
00187         if isinstance(obj, SALOMEDS._objref_SObject):
00188             # study object
00189             return obj.GetName()
00190         ior  = salome.orb.object_to_string(obj)
00191         if ior:
00192             # CORBA object
00193             studies = salome.myStudyManager.GetOpenStudies()
00194             for sname in studies:
00195                 s = salome.myStudyManager.GetStudyByName(sname)
00196                 if not s: continue
00197                 sobj = s.FindObjectIOR(ior)
00198                 if not sobj: continue
00199                 return sobj.GetName()
00200             if hasattr(obj, "GetName"):
00201                 # unknown CORBA object, having GetName() method
00202                 return obj.GetName()
00203             else:
00204                 # unknown CORBA object, no GetName() method
00205                 return NO_NAME
00206             pass
00207         if hasattr(obj, "GetName"):
00208             # unknown non-CORBA object, having GetName() method
00209             return obj.GetName()
00210         pass
00211     raise RuntimeError, "Null or invalid object"
00212 
00213 ## Prints error message if a hypothesis was not assigned.
00214 def TreatHypoStatus(status, hypName, geomName, isAlgo):
00215     if isAlgo:
00216         hypType = "algorithm"
00217     else:
00218         hypType = "hypothesis"
00219         pass
00220     if status == HYP_UNKNOWN_FATAL :
00221         reason = "for unknown reason"
00222     elif status == HYP_INCOMPATIBLE :
00223         reason = "this hypothesis mismatches the algorithm"
00224     elif status == HYP_NOTCONFORM :
00225         reason = "a non-conform mesh would be built"
00226     elif status == HYP_ALREADY_EXIST :
00227         if isAlgo: return # it does not influence anything
00228         reason = hypType + " of the same dimension is already assigned to this shape"
00229     elif status == HYP_BAD_DIM :
00230         reason = hypType + " mismatches the shape"
00231     elif status == HYP_CONCURENT :
00232         reason = "there are concurrent hypotheses on sub-shapes"
00233     elif status == HYP_BAD_SUBSHAPE :
00234         reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
00235     elif status == HYP_BAD_GEOMETRY:
00236         reason = "geometry mismatches the expectation of the algorithm"
00237     elif status == HYP_HIDDEN_ALGO:
00238         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
00239     elif status == HYP_HIDING_ALGO:
00240         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
00241     elif status == HYP_NEED_SHAPE:
00242         reason = "Algorithm can't work without shape"
00243     else:
00244         return
00245     hypName = '"' + hypName + '"'
00246     geomName= '"' + geomName+ '"'
00247     if status < HYP_UNKNOWN_FATAL and not geomName =='""':
00248         print hypName, "was assigned to",    geomName,"but", reason
00249     elif not geomName == '""':
00250         print hypName, "was not assigned to",geomName,":", reason
00251     else:
00252         print hypName, "was not assigned:", reason
00253         pass
00254 
00255 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
00256 def AssureGeomPublished(mesh, geom, name=''):
00257     if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
00258         return
00259     if not geom.IsSame( mesh.geom ) and \
00260            not geom.GetStudyEntry() and \
00261            mesh.smeshpyD.GetCurrentStudy():
00262         ## set the study
00263         studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
00264         if studyID != mesh.geompyD.myStudyId:
00265             mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
00266         ## get a name
00267         if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
00268             # for all groups SubShapeName() returns "Compound_-1"
00269             name = mesh.geompyD.SubShapeName(geom, mesh.geom)
00270         if not name:
00271             name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
00272         ## publish
00273         mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
00274     return
00275 
00276 ## Return the first vertex of a geomertical edge by ignoring orienation
00277 def FirstVertexOnCurve(edge):
00278     from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
00279     vv = SubShapeAll( edge, ShapeType["VERTEX"])
00280     if not vv:
00281         raise TypeError, "Given object has no vertices"
00282     if len( vv ) == 1: return vv[0]
00283     info = KindOfShape(edge)
00284     xyz = info[1:4] # coords of the first vertex
00285     xyz1  = PointCoordinates( vv[0] )
00286     xyz2  = PointCoordinates( vv[1] )
00287     dist1, dist2 = 0,0
00288     for i in range(3):
00289         dist1 += abs( xyz[i] - xyz1[i] )
00290         dist2 += abs( xyz[i] - xyz2[i] )
00291     if dist1 < dist2:
00292         return vv[0]
00293     else:
00294         return vv[1]
00295 
00296 # end of l1_auxiliary
00297 ## @}
00298 
00299 # All methods of this class are accessible directly from the smesh.py package.
00300 class smeshDC(SMESH._objref_SMESH_Gen):
00301 
00302     ## Dump component to the Python script
00303     #  This method overrides IDL function to allow default values for the parameters.
00304     def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
00305         return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
00306 
00307     ## Set mode of DumpPython(), \a historical or \a snapshot.
00308     # In the \a historical mode, the Python Dump script includes all commands
00309     # performed by SMESH engine. In the \a snapshot mode, commands
00310     # relating to objects removed from the Study are excluded from the script
00311     # as well as commands not influencing the current state of meshes
00312     def SetDumpPythonHistorical(self, isHistorical):
00313         if isHistorical: val = "true"
00314         else:            val = "false"
00315         SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
00316 
00317     ## Sets the current study and Geometry component
00318     #  @ingroup l1_auxiliary
00319     def init_smesh(self,theStudy,geompyD):
00320         self.SetCurrentStudy(theStudy,geompyD)
00321 
00322     ## Creates an empty Mesh. This mesh can have an underlying geometry.
00323     #  @param obj the Geometrical object on which the mesh is built. If not defined,
00324     #             the mesh will have no underlying geometry.
00325     #  @param name the name for the new mesh.
00326     #  @return an instance of Mesh class.
00327     #  @ingroup l2_construct
00328     def Mesh(self, obj=0, name=0):
00329         if isinstance(obj,str):
00330             obj,name = name,obj
00331         return Mesh(self,self.geompyD,obj,name)
00332 
00333     ## Returns a long value from enumeration
00334     #  Should be used for SMESH.FunctorType enumeration
00335     #  @ingroup l1_controls
00336     def EnumToLong(self,theItem):
00337         return theItem._v
00338 
00339     ## Returns a string representation of the color.
00340     #  To be used with filters.
00341     #  @param c color value (SALOMEDS.Color)
00342     #  @ingroup l1_controls
00343     def ColorToString(self,c):
00344         val = ""
00345         if isinstance(c, SALOMEDS.Color):
00346             val = "%s;%s;%s" % (c.R, c.G, c.B)
00347         elif isinstance(c, str):
00348             val = c
00349         else:
00350             raise ValueError, "Color value should be of string or SALOMEDS.Color type"
00351         return val
00352 
00353     ## Gets PointStruct from vertex
00354     #  @param theVertex a GEOM object(vertex)
00355     #  @return SMESH.PointStruct
00356     #  @ingroup l1_auxiliary
00357     def GetPointStruct(self,theVertex):
00358         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
00359         return PointStruct(x,y,z)
00360 
00361     ## Gets DirStruct from vector
00362     #  @param theVector a GEOM object(vector)
00363     #  @return SMESH.DirStruct
00364     #  @ingroup l1_auxiliary
00365     def GetDirStruct(self,theVector):
00366         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
00367         if(len(vertices) != 2):
00368             print "Error: vector object is incorrect."
00369             return None
00370         p1 = self.geompyD.PointCoordinates(vertices[0])
00371         p2 = self.geompyD.PointCoordinates(vertices[1])
00372         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
00373         dirst = DirStruct(pnt)
00374         return dirst
00375 
00376     ## Makes DirStruct from a triplet
00377     #  @param x,y,z vector components
00378     #  @return SMESH.DirStruct
00379     #  @ingroup l1_auxiliary
00380     def MakeDirStruct(self,x,y,z):
00381         pnt = PointStruct(x,y,z)
00382         return DirStruct(pnt)
00383 
00384     ## Get AxisStruct from object
00385     #  @param theObj a GEOM object (line or plane)
00386     #  @return SMESH.AxisStruct
00387     #  @ingroup l1_auxiliary
00388     def GetAxisStruct(self,theObj):
00389         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
00390         if len(edges) > 1:
00391             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
00392             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
00393             vertex1 = self.geompyD.PointCoordinates(vertex1)
00394             vertex2 = self.geompyD.PointCoordinates(vertex2)
00395             vertex3 = self.geompyD.PointCoordinates(vertex3)
00396             vertex4 = self.geompyD.PointCoordinates(vertex4)
00397             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
00398             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
00399             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] ]
00400             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
00401             return axis
00402         elif len(edges) == 1:
00403             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
00404             p1 = self.geompyD.PointCoordinates( vertex1 )
00405             p2 = self.geompyD.PointCoordinates( vertex2 )
00406             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
00407             return axis
00408         return None
00409 
00410     # From SMESH_Gen interface:
00411     # ------------------------
00412 
00413     ## Sets the given name to the object
00414     #  @param obj the object to rename
00415     #  @param name a new object name
00416     #  @ingroup l1_auxiliary
00417     def SetName(self, obj, name):
00418         if isinstance( obj, Mesh ):
00419             obj = obj.GetMesh()
00420         elif isinstance( obj, Mesh_Algorithm ):
00421             obj = obj.GetAlgorithm()
00422         ior  = salome.orb.object_to_string(obj)
00423         SMESH._objref_SMESH_Gen.SetName(self, ior, name)
00424 
00425     ## Sets the current mode
00426     #  @ingroup l1_auxiliary
00427     def SetEmbeddedMode( self,theMode ):
00428         #self.SetEmbeddedMode(theMode)
00429         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
00430 
00431     ## Gets the current mode
00432     #  @ingroup l1_auxiliary
00433     def IsEmbeddedMode(self):
00434         #return self.IsEmbeddedMode()
00435         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
00436 
00437     ## Sets the current study
00438     #  @ingroup l1_auxiliary
00439     def SetCurrentStudy( self, theStudy, geompyD = None ):
00440         #self.SetCurrentStudy(theStudy)
00441         if not geompyD:
00442             import geompy
00443             geompyD = geompy.geom
00444             pass
00445         self.geompyD=geompyD
00446         self.SetGeomEngine(geompyD)
00447         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
00448         global notebook
00449         if theStudy:
00450             notebook = salome_notebook.NoteBook( theStudy )
00451         else:
00452             notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
00453 
00454     ## Gets the current study
00455     #  @ingroup l1_auxiliary
00456     def GetCurrentStudy(self):
00457         #return self.GetCurrentStudy()
00458         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
00459 
00460     ## Creates a Mesh object importing data from the given UNV file
00461     #  @return an instance of Mesh class
00462     #  @ingroup l2_impexp
00463     def CreateMeshesFromUNV( self,theFileName ):
00464         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
00465         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00466         return aMesh
00467 
00468     ## Creates a Mesh object(s) importing data from the given MED file
00469     #  @return a list of Mesh class instances
00470     #  @ingroup l2_impexp
00471     def CreateMeshesFromMED( self,theFileName ):
00472         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
00473         aMeshes = []
00474         for iMesh in range(len(aSmeshMeshes)) :
00475             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
00476             aMeshes.append(aMesh)
00477         return aMeshes, aStatus
00478 
00479     ## Creates a Mesh object(s) importing data from the given SAUV file
00480     #  @return a list of Mesh class instances
00481     #  @ingroup l2_impexp
00482     def CreateMeshesFromSAUV( self,theFileName ):
00483         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
00484         aMeshes = []
00485         for iMesh in range(len(aSmeshMeshes)) :
00486             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
00487             aMeshes.append(aMesh)
00488         return aMeshes, aStatus
00489 
00490     ## Creates a Mesh object importing data from the given STL file
00491     #  @return an instance of Mesh class
00492     #  @ingroup l2_impexp
00493     def CreateMeshesFromSTL( self, theFileName ):
00494         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
00495         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00496         return aMesh
00497 
00498     ## Creates Mesh objects importing data from the given CGNS file
00499     #  @return an instance of Mesh class
00500     #  @ingroup l2_impexp
00501     def CreateMeshesFromCGNS( self, theFileName ):
00502         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
00503         aMeshes = []
00504         for iMesh in range(len(aSmeshMeshes)) :
00505             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
00506             aMeshes.append(aMesh)
00507         return aMeshes, aStatus
00508 
00509     ## Concatenate the given meshes into one mesh.
00510     #  @return an instance of Mesh class
00511     #  @param meshes the meshes to combine into one mesh
00512     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
00513     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
00514     #  @param mergeTolerance tolerance for merging nodes
00515     #  @param allGroups forces creation of groups of all elements
00516     def Concatenate( self, meshes, uniteIdenticalGroups,
00517                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
00518         if not meshes: return None
00519         for i,m in enumerate(meshes):
00520             if isinstance(m, Mesh):
00521                 meshes[i] = m.GetMesh()
00522         mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
00523         meshes[0].SetParameters(Parameters)
00524         if allGroups:
00525             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
00526                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
00527         else:
00528             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
00529                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
00530         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00531         return aMesh
00532 
00533     ## Create a mesh by copying a part of another mesh.
00534     #  @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
00535     #                  to copy nodes or elements not contained in any mesh object,
00536     #                  pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
00537     #  @param meshName a name of the new mesh
00538     #  @param toCopyGroups to create in the new mesh groups the copied elements belongs to
00539     #  @param toKeepIDs to preserve IDs of the copied elements or not
00540     #  @return an instance of Mesh class
00541     def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
00542         if (isinstance( meshPart, Mesh )):
00543             meshPart = meshPart.GetMesh()
00544         mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
00545         return Mesh(self, self.geompyD, mesh)
00546 
00547     ## From SMESH_Gen interface
00548     #  @return the list of integer values
00549     #  @ingroup l1_auxiliary
00550     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
00551         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
00552 
00553     ## From SMESH_Gen interface. Creates a pattern
00554     #  @return an instance of SMESH_Pattern
00555     #
00556     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
00557     #  @ingroup l2_modif_patterns
00558     def GetPattern(self):
00559         return SMESH._objref_SMESH_Gen.GetPattern(self)
00560 
00561     ## Sets number of segments per diagonal of boundary box of geometry by which
00562     #  default segment length of appropriate 1D hypotheses is defined.
00563     #  Default value is 10
00564     #  @ingroup l1_auxiliary
00565     def SetBoundaryBoxSegmentation(self, nbSegments):
00566         SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
00567 
00568     # Filtering. Auxiliary functions:
00569     # ------------------------------
00570 
00571     ## Creates an empty criterion
00572     #  @return SMESH.Filter.Criterion
00573     #  @ingroup l1_controls
00574     def GetEmptyCriterion(self):
00575         Type = self.EnumToLong(FT_Undefined)
00576         Compare = self.EnumToLong(FT_Undefined)
00577         Threshold = 0
00578         ThresholdStr = ""
00579         ThresholdID = ""
00580         UnaryOp = self.EnumToLong(FT_Undefined)
00581         BinaryOp = self.EnumToLong(FT_Undefined)
00582         Tolerance = 1e-07
00583         TypeOfElement = ALL
00584         Precision = -1 ##@1e-07
00585         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
00586                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
00587 
00588     ## Creates a criterion by the given parameters
00589     #  \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
00590     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
00591     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
00592     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
00593     #  @param Threshold the threshold value (range of ids as string, shape, numeric)
00594     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
00595     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
00596     #                  FT_Undefined (must be for the last criterion of all criteria)
00597     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
00598     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
00599     #  @return SMESH.Filter.Criterion
00600     #
00601     #  <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
00602     #  @ingroup l1_controls
00603     def GetCriterion(self,elementType,
00604                      CritType,
00605                      Compare = FT_EqualTo,
00606                      Threshold="",
00607                      UnaryOp=FT_Undefined,
00608                      BinaryOp=FT_Undefined,
00609                      Tolerance=1e-07):
00610         if not CritType in SMESH.FunctorType._items:
00611             raise TypeError, "CritType should be of SMESH.FunctorType"
00612         aCriterion = self.GetEmptyCriterion()
00613         aCriterion.TypeOfElement = elementType
00614         aCriterion.Type = self.EnumToLong(CritType)
00615         aCriterion.Tolerance = Tolerance
00616 
00617         aThreshold = Threshold
00618 
00619         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
00620             aCriterion.Compare = self.EnumToLong(Compare)
00621         elif Compare == "=" or Compare == "==":
00622             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00623         elif Compare == "<":
00624             aCriterion.Compare = self.EnumToLong(FT_LessThan)
00625         elif Compare == ">":
00626             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
00627         elif Compare != FT_Undefined:
00628             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00629             aThreshold = Compare
00630 
00631         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
00632                         FT_BelongToCylinder, FT_LyingOnGeom]:
00633             # Checks the Threshold
00634             if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
00635                 aCriterion.ThresholdStr = GetName(aThreshold)
00636                 aCriterion.ThresholdID = salome.ObjectToID(aThreshold)
00637             else:
00638                 print "Error: The Threshold should be a shape."
00639                 return None
00640             if isinstance(UnaryOp,float):
00641                 aCriterion.Tolerance = UnaryOp
00642                 UnaryOp = FT_Undefined
00643                 pass
00644         elif CritType == FT_RangeOfIds:
00645             # Checks the Threshold
00646             if isinstance(aThreshold, str):
00647                 aCriterion.ThresholdStr = aThreshold
00648             else:
00649                 print "Error: The Threshold should be a string."
00650                 return None
00651         elif CritType == FT_CoplanarFaces:
00652             # Checks the Threshold
00653             if isinstance(aThreshold, int):
00654                 aCriterion.ThresholdID = "%s"%aThreshold
00655             elif isinstance(aThreshold, str):
00656                 ID = int(aThreshold)
00657                 if ID < 1:
00658                     raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
00659                 aCriterion.ThresholdID = aThreshold
00660             else:
00661                 raise ValueError,\
00662                       "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
00663         elif CritType == FT_ElemGeomType:
00664             # Checks the Threshold
00665             try:
00666                 aCriterion.Threshold = self.EnumToLong(aThreshold)
00667                 assert( aThreshold in SMESH.GeometryType._items )
00668             except:
00669                 if isinstance(aThreshold, int):
00670                     aCriterion.Threshold = aThreshold
00671                 else:
00672                     print "Error: The Threshold should be an integer or SMESH.GeometryType."
00673                     return None
00674                 pass
00675             pass
00676         elif CritType == FT_GroupColor:
00677             # Checks the Threshold
00678             try:
00679                 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
00680             except:
00681                 print "Error: The threshold value should be of SALOMEDS.Color type"
00682                 return None
00683             pass
00684         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
00685                           FT_LinearOrQuadratic, FT_BadOrientedVolume,
00686                           FT_BareBorderFace, FT_BareBorderVolume,
00687                           FT_OverConstrainedFace, FT_OverConstrainedVolume,
00688                           FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
00689             # At this point the Threshold is unnecessary
00690             if aThreshold ==  FT_LogicalNOT:
00691                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00692             elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
00693                 aCriterion.BinaryOp = aThreshold
00694         else:
00695             # Check Threshold
00696             try:
00697                 aThreshold = float(aThreshold)
00698                 aCriterion.Threshold = aThreshold
00699             except:
00700                 print "Error: The Threshold should be a number."
00701                 return None
00702 
00703         if Threshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
00704             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00705 
00706         if Threshold in [FT_LogicalAND, FT_LogicalOR]:
00707             aCriterion.BinaryOp = self.EnumToLong(Threshold)
00708 
00709         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
00710             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
00711 
00712         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
00713             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
00714 
00715         return aCriterion
00716 
00717     ## Creates a filter with the given parameters
00718     #  @param elementType the type of elements in the group
00719     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
00720     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
00721     #  @param Threshold the threshold value (range of id ids as string, shape, numeric)
00722     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
00723     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
00724     #         FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
00725     #  @return SMESH_Filter
00726     #
00727     #  <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
00728     #  @ingroup l1_controls
00729     def GetFilter(self,elementType,
00730                   CritType=FT_Undefined,
00731                   Compare=FT_EqualTo,
00732                   Threshold="",
00733                   UnaryOp=FT_Undefined,
00734                   Tolerance=1e-07):
00735         aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
00736         aFilterMgr = self.CreateFilterManager()
00737         aFilter = aFilterMgr.CreateFilter()
00738         aCriteria = []
00739         aCriteria.append(aCriterion)
00740         aFilter.SetCriteria(aCriteria)
00741         aFilterMgr.UnRegister()
00742         return aFilter
00743 
00744     ## Creates a filter from criteria
00745     #  @param criteria a list of criteria
00746     #  @return SMESH_Filter
00747     #
00748     #  <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
00749     #  @ingroup l1_controls
00750     def GetFilterFromCriteria(self,criteria):
00751         aFilterMgr = self.CreateFilterManager()
00752         aFilter = aFilterMgr.CreateFilter()
00753         aFilter.SetCriteria(criteria)
00754         aFilterMgr.UnRegister()
00755         return aFilter
00756 
00757     ## Creates a numerical functor by its type
00758     #  @param theCriterion FT_...; functor type
00759     #  @return SMESH_NumericalFunctor
00760     #  @ingroup l1_controls
00761     def GetFunctor(self,theCriterion):
00762         aFilterMgr = self.CreateFilterManager()
00763         if theCriterion == FT_AspectRatio:
00764             return aFilterMgr.CreateAspectRatio()
00765         elif theCriterion == FT_AspectRatio3D:
00766             return aFilterMgr.CreateAspectRatio3D()
00767         elif theCriterion == FT_Warping:
00768             return aFilterMgr.CreateWarping()
00769         elif theCriterion == FT_MinimumAngle:
00770             return aFilterMgr.CreateMinimumAngle()
00771         elif theCriterion == FT_Taper:
00772             return aFilterMgr.CreateTaper()
00773         elif theCriterion == FT_Skew:
00774             return aFilterMgr.CreateSkew()
00775         elif theCriterion == FT_Area:
00776             return aFilterMgr.CreateArea()
00777         elif theCriterion == FT_Volume3D:
00778             return aFilterMgr.CreateVolume3D()
00779         elif theCriterion == FT_MaxElementLength2D:
00780             return aFilterMgr.CreateMaxElementLength2D()
00781         elif theCriterion == FT_MaxElementLength3D:
00782             return aFilterMgr.CreateMaxElementLength3D()
00783         elif theCriterion == FT_MultiConnection:
00784             return aFilterMgr.CreateMultiConnection()
00785         elif theCriterion == FT_MultiConnection2D:
00786             return aFilterMgr.CreateMultiConnection2D()
00787         elif theCriterion == FT_Length:
00788             return aFilterMgr.CreateLength()
00789         elif theCriterion == FT_Length2D:
00790             return aFilterMgr.CreateLength2D()
00791         else:
00792             print "Error: given parameter is not numerical functor type."
00793 
00794     ## Creates hypothesis
00795     #  @param theHType mesh hypothesis type (string)
00796     #  @param theLibName mesh plug-in library name
00797     #  @return created hypothesis instance
00798     def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
00799         hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
00800 
00801         if isinstance( hyp, SMESH._objref_SMESH_Algo ):
00802             return hyp
00803 
00804         # wrap hypothesis methods
00805         #print "HYPOTHESIS", theHType
00806         for meth_name in dir( hyp.__class__ ):
00807             if not meth_name.startswith("Get") and \
00808                not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ):
00809                 method = getattr ( hyp.__class__, meth_name )
00810                 if callable(method):
00811                     setattr( hyp, meth_name, hypMethodWrapper( hyp, method ))
00812 
00813         return hyp
00814 
00815     ## Gets the mesh statistic
00816     #  @return dictionary "element type" - "count of elements"
00817     #  @ingroup l1_meshinfo
00818     def GetMeshInfo(self, obj):
00819         if isinstance( obj, Mesh ):
00820             obj = obj.GetMesh()
00821         d = {}
00822         if hasattr(obj, "GetMeshInfo"):
00823             values = obj.GetMeshInfo()
00824             for i in range(SMESH.Entity_Last._v):
00825                 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
00826             pass
00827         return d
00828 
00829     ## Get minimum distance between two objects
00830     #
00831     #  If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
00832     #  If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
00833     #
00834     #  @param src1 first source object
00835     #  @param src2 second source object
00836     #  @param id1 node/element id from the first source
00837     #  @param id2 node/element id from the second (or first) source
00838     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
00839     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
00840     #  @return minimum distance value
00841     #  @sa GetMinDistance()
00842     #  @ingroup l1_measurements
00843     def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
00844         result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
00845         if result is None:
00846             result = 0.0
00847         else:
00848             result = result.value
00849         return result
00850 
00851     ## Get measure structure specifying minimum distance data between two objects
00852     #
00853     #  If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
00854     #  If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
00855     #
00856     #  @param src1 first source object
00857     #  @param src2 second source object
00858     #  @param id1 node/element id from the first source
00859     #  @param id2 node/element id from the second (or first) source
00860     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
00861     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
00862     #  @return Measure structure or None if input data is invalid
00863     #  @sa MinDistance()
00864     #  @ingroup l1_measurements
00865     def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
00866         if isinstance(src1, Mesh): src1 = src1.mesh
00867         if isinstance(src2, Mesh): src2 = src2.mesh
00868         if src2 is None and id2 != 0: src2 = src1
00869         if not hasattr(src1, "_narrow"): return None
00870         src1 = src1._narrow(SMESH.SMESH_IDSource)
00871         if not src1: return None
00872         if id1 != 0:
00873             m = src1.GetMesh()
00874             e = m.GetMeshEditor()
00875             if isElem1:
00876                 src1 = e.MakeIDSource([id1], SMESH.FACE)
00877             else:
00878                 src1 = e.MakeIDSource([id1], SMESH.NODE)
00879             pass
00880         if hasattr(src2, "_narrow"):
00881             src2 = src2._narrow(SMESH.SMESH_IDSource)
00882             if src2 and id2 != 0:
00883                 m = src2.GetMesh()
00884                 e = m.GetMeshEditor()
00885                 if isElem2:
00886                     src2 = e.MakeIDSource([id2], SMESH.FACE)
00887                 else:
00888                     src2 = e.MakeIDSource([id2], SMESH.NODE)
00889                 pass
00890             pass
00891         aMeasurements = self.CreateMeasurements()
00892         result = aMeasurements.MinDistance(src1, src2)
00893         aMeasurements.UnRegister()
00894         return result
00895 
00896     ## Get bounding box of the specified object(s)
00897     #  @param objects single source object or list of source objects
00898     #  @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
00899     #  @sa GetBoundingBox()
00900     #  @ingroup l1_measurements
00901     def BoundingBox(self, objects):
00902         result = self.GetBoundingBox(objects)
00903         if result is None:
00904             result = (0.0,)*6
00905         else:
00906             result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
00907         return result
00908 
00909     ## Get measure structure specifying bounding box data of the specified object(s)
00910     #  @param objects single source object or list of source objects
00911     #  @return Measure structure
00912     #  @sa BoundingBox()
00913     #  @ingroup l1_measurements
00914     def GetBoundingBox(self, objects):
00915         if isinstance(objects, tuple):
00916             objects = list(objects)
00917         if not isinstance(objects, list):
00918             objects = [objects]
00919         srclist = []
00920         for o in objects:
00921             if isinstance(o, Mesh):
00922                 srclist.append(o.mesh)
00923             elif hasattr(o, "_narrow"):
00924                 src = o._narrow(SMESH.SMESH_IDSource)
00925                 if src: srclist.append(src)
00926                 pass
00927             pass
00928         aMeasurements = self.CreateMeasurements()
00929         result = aMeasurements.BoundingBox(srclist)
00930         aMeasurements.UnRegister()
00931         return result
00932 
00933 import omniORB
00934 #Registering the new proxy for SMESH_Gen
00935 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
00936 
00937 
00938 # Public class: Mesh
00939 # ==================
00940 
00941 ## This class allows defining and managing a mesh.
00942 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
00943 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
00944 #  new nodes and elements and by changing the existing entities), to get information
00945 #  about a mesh and to export a mesh into different formats.
00946 class Mesh:
00947 
00948     geom = 0
00949     mesh = 0
00950     editor = 0
00951 
00952     ## Constructor
00953     #
00954     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
00955     #  sets the GUI name of this mesh to \a name.
00956     #  @param smeshpyD an instance of smeshDC class
00957     #  @param geompyD an instance of geompyDC class
00958     #  @param obj Shape to be meshed or SMESH_Mesh object
00959     #  @param name Study name of the mesh
00960     #  @ingroup l2_construct
00961     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
00962         self.smeshpyD=smeshpyD
00963         self.geompyD=geompyD
00964         if obj is None:
00965             obj = 0
00966         if obj != 0:
00967             objHasName = True
00968             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
00969                 self.geom = obj
00970                 # publish geom of mesh (issue 0021122)
00971                 if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
00972                     objHasName = False
00973                     studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
00974                     if studyID != geompyD.myStudyId:
00975                         geompyD.init_geom( smeshpyD.GetCurrentStudy())
00976                         pass
00977                     geo_name = "%s_%s_for_meshing"%(self.geom.GetShapeType(), id(self.geom)%100)
00978                     geompyD.addToStudy( self.geom, geo_name )
00979                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
00980 
00981             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
00982                 self.SetMesh(obj)
00983         else:
00984             self.mesh = self.smeshpyD.CreateEmptyMesh()
00985         if name != 0:
00986             self.smeshpyD.SetName(self.mesh, name)
00987         elif obj != 0 and objHasName:
00988             self.smeshpyD.SetName(self.mesh, GetName(obj))
00989 
00990         if not self.geom:
00991             self.geom = self.mesh.GetShapeToMesh()
00992 
00993         self.editor = self.mesh.GetMeshEditor()
00994 
00995         # set self to algoCreator's
00996         for attrName in dir(self):
00997             attr = getattr( self, attrName )
00998             if isinstance( attr, algoCreator ):
00999                 setattr( self, attrName, attr.copy( self ))
01000 
01001     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
01002     #  @param theMesh a SMESH_Mesh object
01003     #  @ingroup l2_construct
01004     def SetMesh(self, theMesh):
01005         self.mesh = theMesh
01006         self.geom = self.mesh.GetShapeToMesh()
01007 
01008     ## Returns the mesh, that is an instance of SMESH_Mesh interface
01009     #  @return a SMESH_Mesh object
01010     #  @ingroup l2_construct
01011     def GetMesh(self):
01012         return self.mesh
01013 
01014     ## Gets the name of the mesh
01015     #  @return the name of the mesh as a string
01016     #  @ingroup l2_construct
01017     def GetName(self):
01018         name = GetName(self.GetMesh())
01019         return name
01020 
01021     ## Sets a name to the mesh
01022     #  @param name a new name of the mesh
01023     #  @ingroup l2_construct
01024     def SetName(self, name):
01025         self.smeshpyD.SetName(self.GetMesh(), name)
01026 
01027     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
01028     #  The subMesh object gives access to the IDs of nodes and elements.
01029     #  @param geom a geometrical object (shape)
01030     #  @param name a name for the submesh
01031     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
01032     #  @ingroup l2_submeshes
01033     def GetSubMesh(self, geom, name):
01034         AssureGeomPublished( self, geom, name )
01035         submesh = self.mesh.GetSubMesh( geom, name )
01036         return submesh
01037 
01038     ## Returns the shape associated to the mesh
01039     #  @return a GEOM_Object
01040     #  @ingroup l2_construct
01041     def GetShape(self):
01042         return self.geom
01043 
01044     ## Associates the given shape to the mesh (entails the recreation of the mesh)
01045     #  @param geom the shape to be meshed (GEOM_Object)
01046     #  @ingroup l2_construct
01047     def SetShape(self, geom):
01048         self.mesh = self.smeshpyD.CreateMesh(geom)
01049 
01050     ## Loads mesh from the study after opening the study
01051     def Load(self):
01052         self.mesh.Load()
01053 
01054     ## Returns true if the hypotheses are defined well
01055     #  @param theSubObject a sub-shape of a mesh shape
01056     #  @return True or False
01057     #  @ingroup l2_construct
01058     def IsReadyToCompute(self, theSubObject):
01059         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
01060 
01061     ## Returns errors of hypotheses definition.
01062     #  The list of errors is empty if everything is OK.
01063     #  @param theSubObject a sub-shape of a mesh shape
01064     #  @return a list of errors
01065     #  @ingroup l2_construct
01066     def GetAlgoState(self, theSubObject):
01067         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
01068 
01069     ## Returns a geometrical object on which the given element was built.
01070     #  The returned geometrical object, if not nil, is either found in the
01071     #  study or published by this method with the given name
01072     #  @param theElementID the id of the mesh element
01073     #  @param theGeomName the user-defined name of the geometrical object
01074     #  @return GEOM::GEOM_Object instance
01075     #  @ingroup l2_construct
01076     def GetGeometryByMeshElement(self, theElementID, theGeomName):
01077         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
01078 
01079     ## Returns the mesh dimension depending on the dimension of the underlying shape
01080     #  @return mesh dimension as an integer value [0,3]
01081     #  @ingroup l1_auxiliary
01082     def MeshDimension(self):
01083         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
01084         if len( shells ) > 0 :
01085             return 3
01086         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
01087             return 2
01088         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
01089             return 1
01090         else:
01091             return 0;
01092         pass
01093 
01094     ## Evaluates size of prospective mesh on a shape
01095     #  @return a list where i-th element is a number of elements of i-th SMESH.EntityType
01096     #  To know predicted number of e.g. edges, inquire it this way
01097     #  Evaluate()[ EnumToLong( Entity_Edge )]
01098     def Evaluate(self, geom=0):
01099         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
01100             if self.geom == 0:
01101                 geom = self.mesh.GetShapeToMesh()
01102             else:
01103                 geom = self.geom
01104         return self.smeshpyD.Evaluate(self.mesh, geom)
01105 
01106 
01107     ## Computes the mesh and returns the status of the computation
01108     #  @param geom geomtrical shape on which mesh data should be computed
01109     #  @param discardModifs if True and the mesh has been edited since
01110     #         a last total re-compute and that may prevent successful partial re-compute,
01111     #         then the mesh is cleaned before Compute()
01112     #  @return True or False
01113     #  @ingroup l2_construct
01114     def Compute(self, geom=0, discardModifs=False):
01115         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
01116             if self.geom == 0:
01117                 geom = self.mesh.GetShapeToMesh()
01118             else:
01119                 geom = self.geom
01120         ok = False
01121         try:
01122             if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
01123                 self.mesh.Clear()
01124             ok = self.smeshpyD.Compute(self.mesh, geom)
01125         except SALOME.SALOME_Exception, ex:
01126             print "Mesh computation failed, exception caught:"
01127             print "    ", ex.details.text
01128         except:
01129             import traceback
01130             print "Mesh computation failed, exception caught:"
01131             traceback.print_exc()
01132         if True:#not ok:
01133             allReasons = ""
01134 
01135             # Treat compute errors
01136             computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
01137             for err in computeErrors:
01138                 shapeText = ""
01139                 if self.mesh.HasShapeToMesh():
01140                     try:
01141                         mainIOR  = salome.orb.object_to_string(geom)
01142                         for sname in salome.myStudyManager.GetOpenStudies():
01143                             s = salome.myStudyManager.GetStudyByName(sname)
01144                             if not s: continue
01145                             mainSO = s.FindObjectIOR(mainIOR)
01146                             if not mainSO: continue
01147                             if err.subShapeID == 1:
01148                                 shapeText = ' on "%s"' % mainSO.GetName()
01149                             subIt = s.NewChildIterator(mainSO)
01150                             while subIt.More():
01151                                 subSO = subIt.Value()
01152                                 subIt.Next()
01153                                 obj = subSO.GetObject()
01154                                 if not obj: continue
01155                                 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
01156                                 if not go: continue
01157                                 ids = go.GetSubShapeIndices()
01158                                 if len(ids) == 1 and ids[0] == err.subShapeID:
01159                                     shapeText = ' on "%s"' % subSO.GetName()
01160                                     break
01161                         if not shapeText:
01162                             shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
01163                             if shape:
01164                                 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
01165                             else:
01166                                 shapeText = " on subshape #%s" % (err.subShapeID)
01167                     except:
01168                         shapeText = " on subshape #%s" % (err.subShapeID)
01169                 errText = ""
01170                 stdErrors = ["OK",                 #COMPERR_OK
01171                              "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
01172                              "std::exception",     #COMPERR_STD_EXCEPTION
01173                              "OCC exception",      #COMPERR_OCC_EXCEPTION
01174                              "SALOME exception",   #COMPERR_SLM_EXCEPTION
01175                              "Unknown exception",  #COMPERR_EXCEPTION
01176                              "Memory allocation problem", #COMPERR_MEMORY_PB
01177                              "Algorithm failed",   #COMPERR_ALGO_FAILED
01178                              "Unexpected geometry"]#COMPERR_BAD_SHAPE
01179                 if err.code > 0:
01180                     if err.code < len(stdErrors): errText = stdErrors[err.code]
01181                 else:
01182                     errText = "code %s" % -err.code
01183                 if errText: errText += ". "
01184                 errText += err.comment
01185                 if allReasons != "":allReasons += "\n"
01186                 allReasons += '-  "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
01187                 pass
01188 
01189             # Treat hyp errors
01190             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
01191             for err in errors:
01192                 if err.isGlobalAlgo:
01193                     glob = "global"
01194                 else:
01195                     glob = "local"
01196                     pass
01197                 dim = err.algoDim
01198                 name = err.algoName
01199                 if len(name) == 0:
01200                     reason = '%s %sD algorithm is missing' % (glob, dim)
01201                 elif err.state == HYP_MISSING:
01202                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
01203                               % (glob, dim, name, dim))
01204                 elif err.state == HYP_NOTCONFORM:
01205                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
01206                 elif err.state == HYP_BAD_PARAMETER:
01207                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
01208                               % ( glob, dim, name ))
01209                 elif err.state == HYP_BAD_GEOMETRY:
01210                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
01211                               'geometry' % ( glob, dim, name ))
01212                 else:
01213                     reason = "For unknown reason."+\
01214                              " Revise Mesh.Compute() implementation in smeshDC.py!"
01215                     pass
01216                 if allReasons != "":allReasons += "\n"
01217                 allReasons += "-  " + reason
01218                 pass
01219             if not ok or allReasons != "":
01220                 msg = '"' + GetName(self.mesh) + '"'
01221                 if ok: msg += " has been computed with warnings"
01222                 else:  msg += " has not been computed"
01223                 if allReasons != "": msg += ":"
01224                 else:                msg += "."
01225                 print msg
01226                 print allReasons
01227             pass
01228         if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
01229             smeshgui = salome.ImportComponentGUI("SMESH")
01230             smeshgui.Init(self.mesh.GetStudyId())
01231             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
01232             salome.sg.updateObjBrowser(1)
01233             pass
01234         return ok
01235 
01236     ## Return submesh objects list in meshing order
01237     #  @return list of list of submesh objects
01238     #  @ingroup l2_construct
01239     def GetMeshOrder(self):
01240         return self.mesh.GetMeshOrder()
01241 
01242     ## Return submesh objects list in meshing order
01243     #  @return list of list of submesh objects
01244     #  @ingroup l2_construct
01245     def SetMeshOrder(self, submeshes):
01246         return self.mesh.SetMeshOrder(submeshes)
01247 
01248     ## Removes all nodes and elements
01249     #  @ingroup l2_construct
01250     def Clear(self):
01251         self.mesh.Clear()
01252         if salome.sg.hasDesktop():
01253             smeshgui = salome.ImportComponentGUI("SMESH")
01254             smeshgui.Init(self.mesh.GetStudyId())
01255             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
01256             salome.sg.updateObjBrowser(1)
01257 
01258     ## Removes all nodes and elements of indicated shape
01259     #  @ingroup l2_construct
01260     def ClearSubMesh(self, geomId):
01261         self.mesh.ClearSubMesh(geomId)
01262         if salome.sg.hasDesktop():
01263             smeshgui = salome.ImportComponentGUI("SMESH")
01264             smeshgui.Init(self.mesh.GetStudyId())
01265             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
01266             salome.sg.updateObjBrowser(1)
01267 
01268     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
01269     #  @param fineness [0.0,1.0] defines mesh fineness
01270     #  @return True or False
01271     #  @ingroup l3_algos_basic
01272     def AutomaticTetrahedralization(self, fineness=0):
01273         dim = self.MeshDimension()
01274         # assign hypotheses
01275         self.RemoveGlobalHypotheses()
01276         self.Segment().AutomaticLength(fineness)
01277         if dim > 1 :
01278             self.Triangle().LengthFromEdges()
01279             pass
01280         if dim > 2 :
01281             from NETGENPluginDC import NETGEN
01282             self.Tetrahedron(NETGEN)
01283             pass
01284         return self.Compute()
01285 
01286     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
01287     #  @param fineness [0.0, 1.0] defines mesh fineness
01288     #  @return True or False
01289     #  @ingroup l3_algos_basic
01290     def AutomaticHexahedralization(self, fineness=0):
01291         dim = self.MeshDimension()
01292         # assign the hypotheses
01293         self.RemoveGlobalHypotheses()
01294         self.Segment().AutomaticLength(fineness)
01295         if dim > 1 :
01296             self.Quadrangle()
01297             pass
01298         if dim > 2 :
01299             self.Hexahedron()
01300             pass
01301         return self.Compute()
01302 
01303     ## Assigns a hypothesis
01304     #  @param hyp a hypothesis to assign
01305     #  @param geom a subhape of mesh geometry
01306     #  @return SMESH.Hypothesis_Status
01307     #  @ingroup l2_hypotheses
01308     def AddHypothesis(self, hyp, geom=0):
01309         if isinstance( hyp, Mesh_Algorithm ):
01310             hyp = hyp.GetAlgorithm()
01311             pass
01312         if not geom:
01313             geom = self.geom
01314             if not geom:
01315                 geom = self.mesh.GetShapeToMesh()
01316             pass
01317         AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
01318         status = self.mesh.AddHypothesis(geom, hyp)
01319         isAlgo = hyp._narrow( SMESH_Algo )
01320         hyp_name = GetName( hyp )
01321         geom_name = ""
01322         if geom:
01323             geom_name = GetName( geom )
01324         TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
01325         return status
01326 
01327     ## Return True if an algorithm of hypothesis is assigned to a given shape
01328     #  @param hyp a hypothesis to check
01329     #  @param geom a subhape of mesh geometry
01330     #  @return True of False
01331     #  @ingroup l2_hypotheses
01332     def IsUsedHypothesis(self, hyp, geom):
01333         if not hyp or not geom:
01334             return False
01335         if isinstance( hyp, Mesh_Algorithm ):
01336             hyp = hyp.GetAlgorithm()
01337             pass
01338         hyps = self.GetHypothesisList(geom)
01339         for h in hyps:
01340             if h.GetId() == hyp.GetId():
01341                 return True
01342         return False
01343 
01344     ## Unassigns a hypothesis
01345     #  @param hyp a hypothesis to unassign
01346     #  @param geom a sub-shape of mesh geometry
01347     #  @return SMESH.Hypothesis_Status
01348     #  @ingroup l2_hypotheses
01349     def RemoveHypothesis(self, hyp, geom=0):
01350         if isinstance( hyp, Mesh_Algorithm ):
01351             hyp = hyp.GetAlgorithm()
01352             pass
01353         if not geom:
01354             geom = self.geom
01355             pass
01356         status = self.mesh.RemoveHypothesis(geom, hyp)
01357         return status
01358 
01359     ## Gets the list of hypotheses added on a geometry
01360     #  @param geom a sub-shape of mesh geometry
01361     #  @return the sequence of SMESH_Hypothesis
01362     #  @ingroup l2_hypotheses
01363     def GetHypothesisList(self, geom):
01364         return self.mesh.GetHypothesisList( geom )
01365 
01366     ## Removes all global hypotheses
01367     #  @ingroup l2_hypotheses
01368     def RemoveGlobalHypotheses(self):
01369         current_hyps = self.mesh.GetHypothesisList( self.geom )
01370         for hyp in current_hyps:
01371             self.mesh.RemoveHypothesis( self.geom, hyp )
01372             pass
01373         pass
01374 
01375     ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
01376     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
01377     ## allowing to overwrite the file if it exists or add the exported data to its contents
01378     #  @param f the file name
01379     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
01380     #  @param opt boolean parameter for creating/not creating
01381     #         the groups Group_On_All_Nodes, Group_On_All_Faces, ...
01382     #  @param overwrite boolean parameter for overwriting/not overwriting the file
01383     #  @ingroup l2_impexp
01384     def ExportToMED(self, f, version, opt=0, overwrite=1):
01385         self.mesh.ExportToMEDX(f, opt, version, overwrite)
01386 
01387     ## Exports the mesh in a file in MED format and chooses the \a version of MED format
01388     ## allowing to overwrite the file if it exists or add the exported data to its contents
01389     #  @param f is the file name
01390     #  @param auto_groups boolean parameter for creating/not creating
01391     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
01392     #  the typical use is auto_groups=false.
01393     #  @param version MED format version(MED_V2_1 or MED_V2_2)
01394     #  @param overwrite boolean parameter for overwriting/not overwriting the file
01395     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
01396     #  @ingroup l2_impexp
01397     def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
01398         if meshPart:
01399             if isinstance( meshPart, list ):
01400                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
01401             self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
01402         else:
01403             self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
01404 
01405     ## Exports the mesh in a file in SAUV format
01406     #  @param f is the file name
01407     #  @param auto_groups boolean parameter for creating/not creating
01408     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
01409     #  the typical use is auto_groups=false.
01410     #  @ingroup l2_impexp
01411     def ExportSAUV(self, f, auto_groups=0):
01412         self.mesh.ExportSAUV(f, auto_groups)
01413 
01414     ## Exports the mesh in a file in DAT format
01415     #  @param f the file name
01416     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
01417     #  @ingroup l2_impexp
01418     def ExportDAT(self, f, meshPart=None):
01419         if meshPart:
01420             if isinstance( meshPart, list ):
01421                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
01422             self.mesh.ExportPartToDAT( meshPart, f )
01423         else:
01424             self.mesh.ExportDAT(f)
01425 
01426     ## Exports the mesh in a file in UNV format
01427     #  @param f the file name
01428     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
01429     #  @ingroup l2_impexp
01430     def ExportUNV(self, f, meshPart=None):
01431         if meshPart:
01432             if isinstance( meshPart, list ):
01433                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
01434             self.mesh.ExportPartToUNV( meshPart, f )
01435         else:
01436             self.mesh.ExportUNV(f)
01437 
01438     ## Export the mesh in a file in STL format
01439     #  @param f the file name
01440     #  @param ascii defines the file encoding
01441     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
01442     #  @ingroup l2_impexp
01443     def ExportSTL(self, f, ascii=1, meshPart=None):
01444         if meshPart:
01445             if isinstance( meshPart, list ):
01446                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
01447             self.mesh.ExportPartToSTL( meshPart, f, ascii )
01448         else:
01449             self.mesh.ExportSTL(f, ascii)
01450 
01451     ## Exports the mesh in a file in CGNS format
01452     #  @param f is the file name
01453     #  @param overwrite boolean parameter for overwriting/not overwriting the file
01454     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
01455     #  @ingroup l2_impexp
01456     def ExportCGNS(self, f, overwrite=1, meshPart=None):
01457         if isinstance( meshPart, list ):
01458             meshPart = self.GetIDSource( meshPart, SMESH.ALL )
01459         if isinstance( meshPart, Mesh ):
01460             meshPart = meshPart.mesh
01461         elif not meshPart:
01462             meshPart = self.mesh
01463         self.mesh.ExportCGNS(meshPart, f, overwrite)
01464 
01465     # Operations with groups:
01466     # ----------------------
01467 
01468     ## Creates an empty mesh group
01469     #  @param elementType the type of elements in the group
01470     #  @param name the name of the mesh group
01471     #  @return SMESH_Group
01472     #  @ingroup l2_grps_create
01473     def CreateEmptyGroup(self, elementType, name):
01474         return self.mesh.CreateGroup(elementType, name)
01475 
01476     ## Creates a mesh group based on the geometric object \a grp
01477     #  and gives a \a name, \n if this parameter is not defined
01478     #  the name is the same as the geometric group name \n
01479     #  Note: Works like GroupOnGeom().
01480     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
01481     #  @param name the name of the mesh group
01482     #  @return SMESH_GroupOnGeom
01483     #  @ingroup l2_grps_create
01484     def Group(self, grp, name=""):
01485         return self.GroupOnGeom(grp, name)
01486 
01487     ## Creates a mesh group based on the geometrical object \a grp
01488     #  and gives a \a name, \n if this parameter is not defined
01489     #  the name is the same as the geometrical group name
01490     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
01491     #  @param name the name of the mesh group
01492     #  @param typ  the type of elements in the group. If not set, it is
01493     #              automatically detected by the type of the geometry
01494     #  @return SMESH_GroupOnGeom
01495     #  @ingroup l2_grps_create
01496     def GroupOnGeom(self, grp, name="", typ=None):
01497         AssureGeomPublished( self, grp, name )
01498         if name == "":
01499             name = grp.GetName()
01500         if not typ:
01501             typ = self._groupTypeFromShape( grp )
01502         return self.mesh.CreateGroupFromGEOM(typ, name, grp)
01503 
01504     ## Pivate method to get a type of group on geometry
01505     def _groupTypeFromShape( self, shape ):
01506         tgeo = str(shape.GetShapeType())
01507         if tgeo == "VERTEX":
01508             typ = NODE
01509         elif tgeo == "EDGE":
01510             typ = EDGE
01511         elif tgeo == "FACE" or tgeo == "SHELL":
01512             typ = FACE
01513         elif tgeo == "SOLID" or tgeo == "COMPSOLID":
01514             typ = VOLUME
01515         elif tgeo == "COMPOUND":
01516             sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
01517             if not sub:
01518                 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
01519             return self._groupTypeFromShape( sub[0] )
01520         else:
01521             raise ValueError, \
01522                   "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
01523         return typ
01524 
01525     ## Creates a mesh group with given \a name based on the \a filter which
01526     ## is a special type of group dynamically updating it's contents during
01527     ## mesh modification
01528     #  @param typ  the type of elements in the group
01529     #  @param name the name of the mesh group
01530     #  @param filter the filter defining group contents
01531     #  @return SMESH_GroupOnFilter
01532     #  @ingroup l2_grps_create
01533     def GroupOnFilter(self, typ, name, filter):
01534         return self.mesh.CreateGroupFromFilter(typ, name, filter)
01535 
01536     ## Creates a mesh group by the given ids of elements
01537     #  @param groupName the name of the mesh group
01538     #  @param elementType the type of elements in the group
01539     #  @param elemIDs the list of ids
01540     #  @return SMESH_Group
01541     #  @ingroup l2_grps_create
01542     def MakeGroupByIds(self, groupName, elementType, elemIDs):
01543         group = self.mesh.CreateGroup(elementType, groupName)
01544         group.Add(elemIDs)
01545         return group
01546 
01547     ## Creates a mesh group by the given conditions
01548     #  @param groupName the name of the mesh group
01549     #  @param elementType the type of elements in the group
01550     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
01551     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
01552     #  @param Threshold the threshold value (range of id ids as string, shape, numeric)
01553     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
01554     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
01555     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
01556     #  @return SMESH_Group
01557     #  @ingroup l2_grps_create
01558     def MakeGroup(self,
01559                   groupName,
01560                   elementType,
01561                   CritType=FT_Undefined,
01562                   Compare=FT_EqualTo,
01563                   Threshold="",
01564                   UnaryOp=FT_Undefined,
01565                   Tolerance=1e-07):
01566         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
01567         group = self.MakeGroupByCriterion(groupName, aCriterion)
01568         return group
01569 
01570     ## Creates a mesh group by the given criterion
01571     #  @param groupName the name of the mesh group
01572     #  @param Criterion the instance of Criterion class
01573     #  @return SMESH_Group
01574     #  @ingroup l2_grps_create
01575     def MakeGroupByCriterion(self, groupName, Criterion):
01576         aFilterMgr = self.smeshpyD.CreateFilterManager()
01577         aFilter = aFilterMgr.CreateFilter()
01578         aCriteria = []
01579         aCriteria.append(Criterion)
01580         aFilter.SetCriteria(aCriteria)
01581         group = self.MakeGroupByFilter(groupName, aFilter)
01582         aFilterMgr.UnRegister()
01583         return group
01584 
01585     ## Creates a mesh group by the given criteria (list of criteria)
01586     #  @param groupName the name of the mesh group
01587     #  @param theCriteria the list of criteria
01588     #  @return SMESH_Group
01589     #  @ingroup l2_grps_create
01590     def MakeGroupByCriteria(self, groupName, theCriteria):
01591         aFilterMgr = self.smeshpyD.CreateFilterManager()
01592         aFilter = aFilterMgr.CreateFilter()
01593         aFilter.SetCriteria(theCriteria)
01594         group = self.MakeGroupByFilter(groupName, aFilter)
01595         aFilterMgr.UnRegister()
01596         return group
01597 
01598     ## Creates a mesh group by the given filter
01599     #  @param groupName the name of the mesh group
01600     #  @param theFilter the instance of Filter class
01601     #  @return SMESH_Group
01602     #  @ingroup l2_grps_create
01603     def MakeGroupByFilter(self, groupName, theFilter):
01604         group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
01605         theFilter.SetMesh( self.mesh )
01606         group.AddFrom( theFilter )
01607         return group
01608 
01609     ## Passes mesh elements through the given filter and return IDs of fitting elements
01610     #  @param theFilter SMESH_Filter
01611     #  @return a list of ids
01612     #  @ingroup l1_controls
01613     def GetIdsFromFilter(self, theFilter):
01614         theFilter.SetMesh( self.mesh )
01615         return theFilter.GetIDs()
01616 
01617     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
01618     #  Returns a list of special structures (borders).
01619     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
01620     #  @ingroup l1_controls
01621     def GetFreeBorders(self):
01622         aFilterMgr = self.smeshpyD.CreateFilterManager()
01623         aPredicate = aFilterMgr.CreateFreeEdges()
01624         aPredicate.SetMesh(self.mesh)
01625         aBorders = aPredicate.GetBorders()
01626         aFilterMgr.UnRegister()
01627         return aBorders
01628 
01629     ## Removes a group
01630     #  @ingroup l2_grps_delete
01631     def RemoveGroup(self, group):
01632         self.mesh.RemoveGroup(group)
01633 
01634     ## Removes a group with its contents
01635     #  @ingroup l2_grps_delete
01636     def RemoveGroupWithContents(self, group):
01637         self.mesh.RemoveGroupWithContents(group)
01638 
01639     ## Gets the list of groups existing in the mesh
01640     #  @return a sequence of SMESH_GroupBase
01641     #  @ingroup l2_grps_create
01642     def GetGroups(self):
01643         return self.mesh.GetGroups()
01644 
01645     ## Gets the number of groups existing in the mesh
01646     #  @return the quantity of groups as an integer value
01647     #  @ingroup l2_grps_create
01648     def NbGroups(self):
01649         return self.mesh.NbGroups()
01650 
01651     ## Gets the list of names of groups existing in the mesh
01652     #  @return list of strings
01653     #  @ingroup l2_grps_create
01654     def GetGroupNames(self):
01655         groups = self.GetGroups()
01656         names = []
01657         for group in groups:
01658             names.append(group.GetName())
01659         return names
01660 
01661     ## Produces a union of two groups
01662     #  A new group is created. All mesh elements that are
01663     #  present in the initial groups are added to the new one
01664     #  @return an instance of SMESH_Group
01665     #  @ingroup l2_grps_operon
01666     def UnionGroups(self, group1, group2, name):
01667         return self.mesh.UnionGroups(group1, group2, name)
01668 
01669     ## Produces a union list of groups
01670     #  New group is created. All mesh elements that are present in
01671     #  initial groups are added to the new one
01672     #  @return an instance of SMESH_Group
01673     #  @ingroup l2_grps_operon
01674     def UnionListOfGroups(self, groups, name):
01675       return self.mesh.UnionListOfGroups(groups, name)
01676 
01677     ## Prodices an intersection of two groups
01678     #  A new group is created. All mesh elements that are common
01679     #  for the two initial groups are added to the new one.
01680     #  @return an instance of SMESH_Group
01681     #  @ingroup l2_grps_operon
01682     def IntersectGroups(self, group1, group2, name):
01683         return self.mesh.IntersectGroups(group1, group2, name)
01684 
01685     ## Produces an intersection of groups
01686     #  New group is created. All mesh elements that are present in all
01687     #  initial groups simultaneously are added to the new one
01688     #  @return an instance of SMESH_Group
01689     #  @ingroup l2_grps_operon
01690     def IntersectListOfGroups(self, groups, name):
01691       return self.mesh.IntersectListOfGroups(groups, name)
01692 
01693     ## Produces a cut of two groups
01694     #  A new group is created. All mesh elements that are present in
01695     #  the main group but are not present in the tool group are added to the new one
01696     #  @return an instance of SMESH_Group
01697     #  @ingroup l2_grps_operon
01698     def CutGroups(self, main_group, tool_group, name):
01699         return self.mesh.CutGroups(main_group, tool_group, name)
01700 
01701     ## Produces a cut of groups
01702     #  A new group is created. All mesh elements that are present in main groups
01703     #  but do not present in tool groups are added to the new one
01704     #  @return an instance of SMESH_Group
01705     #  @ingroup l2_grps_operon
01706     def CutListOfGroups(self, main_groups, tool_groups, name):
01707       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
01708 
01709     ## Produces a group of elements of specified type using list of existing groups
01710     #  A new group is created. System
01711     #  1) extracts all nodes on which groups elements are built
01712     #  2) combines all elements of specified dimension laying on these nodes
01713     #  @return an instance of SMESH_Group
01714     #  @ingroup l2_grps_operon
01715     def CreateDimGroup(self, groups, elem_type, name):
01716       return self.mesh.CreateDimGroup(groups, elem_type, name)
01717 
01718 
01719     ## Convert group on geom into standalone group
01720     #  @ingroup l2_grps_delete
01721     def ConvertToStandalone(self, group):
01722         return self.mesh.ConvertToStandalone(group)
01723 
01724     # Get some info about mesh:
01725     # ------------------------
01726 
01727     ## Returns the log of nodes and elements added or removed
01728     #  since the previous clear of the log.
01729     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
01730     #  @return list of log_block structures:
01731     #                                        commandType
01732     #                                        number
01733     #                                        coords
01734     #                                        indexes
01735     #  @ingroup l1_auxiliary
01736     def GetLog(self, clearAfterGet):
01737         return self.mesh.GetLog(clearAfterGet)
01738 
01739     ## Clears the log of nodes and elements added or removed since the previous
01740     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
01741     #  @ingroup l1_auxiliary
01742     def ClearLog(self):
01743         self.mesh.ClearLog()
01744 
01745     ## Toggles auto color mode on the object.
01746     #  @param theAutoColor the flag which toggles auto color mode.
01747     #  @ingroup l1_auxiliary
01748     def SetAutoColor(self, theAutoColor):
01749         self.mesh.SetAutoColor(theAutoColor)
01750 
01751     ## Gets flag of object auto color mode.
01752     #  @return True or False
01753     #  @ingroup l1_auxiliary
01754     def GetAutoColor(self):
01755         return self.mesh.GetAutoColor()
01756 
01757     ## Gets the internal ID
01758     #  @return integer value, which is the internal Id of the mesh
01759     #  @ingroup l1_auxiliary
01760     def GetId(self):
01761         return self.mesh.GetId()
01762 
01763     ## Get the study Id
01764     #  @return integer value, which is the study Id of the mesh
01765     #  @ingroup l1_auxiliary
01766     def GetStudyId(self):
01767         return self.mesh.GetStudyId()
01768 
01769     ## Checks the group names for duplications.
01770     #  Consider the maximum group name length stored in MED file.
01771     #  @return True or False
01772     #  @ingroup l1_auxiliary
01773     def HasDuplicatedGroupNamesMED(self):
01774         return self.mesh.HasDuplicatedGroupNamesMED()
01775 
01776     ## Obtains the mesh editor tool
01777     #  @return an instance of SMESH_MeshEditor
01778     #  @ingroup l1_modifying
01779     def GetMeshEditor(self):
01780         return self.mesh.GetMeshEditor()
01781 
01782     ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
01783     #  can be passed as argument to accepting mesh, group or sub-mesh
01784     #  @return an instance of SMESH_IDSource
01785     #  @ingroup l1_auxiliary
01786     def GetIDSource(self, ids, elemType):
01787         return self.GetMeshEditor().MakeIDSource(ids, elemType)
01788 
01789     ## Gets MED Mesh
01790     #  @return an instance of SALOME_MED::MESH
01791     #  @ingroup l1_auxiliary
01792     def GetMEDMesh(self):
01793         return self.mesh.GetMEDMesh()
01794 
01795 
01796     # Get informations about mesh contents:
01797     # ------------------------------------
01798 
01799     ## Gets the mesh stattistic
01800     #  @return dictionary type element - count of elements
01801     #  @ingroup l1_meshinfo
01802     def GetMeshInfo(self, obj = None):
01803         if not obj: obj = self.mesh
01804         return self.smeshpyD.GetMeshInfo(obj)
01805 
01806     ## Returns the number of nodes in the mesh
01807     #  @return an integer value
01808     #  @ingroup l1_meshinfo
01809     def NbNodes(self):
01810         return self.mesh.NbNodes()
01811 
01812     ## Returns the number of elements in the mesh
01813     #  @return an integer value
01814     #  @ingroup l1_meshinfo
01815     def NbElements(self):
01816         return self.mesh.NbElements()
01817 
01818     ## Returns the number of 0d elements in the mesh
01819     #  @return an integer value
01820     #  @ingroup l1_meshinfo
01821     def Nb0DElements(self):
01822         return self.mesh.Nb0DElements()
01823 
01824     ## Returns the number of edges in the mesh
01825     #  @return an integer value
01826     #  @ingroup l1_meshinfo
01827     def NbEdges(self):
01828         return self.mesh.NbEdges()
01829 
01830     ## Returns the number of edges with the given order in the mesh
01831     #  @param elementOrder the order of elements:
01832     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01833     #  @return an integer value
01834     #  @ingroup l1_meshinfo
01835     def NbEdgesOfOrder(self, elementOrder):
01836         return self.mesh.NbEdgesOfOrder(elementOrder)
01837 
01838     ## Returns the number of faces in the mesh
01839     #  @return an integer value
01840     #  @ingroup l1_meshinfo
01841     def NbFaces(self):
01842         return self.mesh.NbFaces()
01843 
01844     ## Returns the number of faces with the given order in the mesh
01845     #  @param elementOrder the order of elements:
01846     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01847     #  @return an integer value
01848     #  @ingroup l1_meshinfo
01849     def NbFacesOfOrder(self, elementOrder):
01850         return self.mesh.NbFacesOfOrder(elementOrder)
01851 
01852     ## Returns the number of triangles in the mesh
01853     #  @return an integer value
01854     #  @ingroup l1_meshinfo
01855     def NbTriangles(self):
01856         return self.mesh.NbTriangles()
01857 
01858     ## Returns the number of triangles with the given order in the mesh
01859     #  @param elementOrder is the order of elements:
01860     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01861     #  @return an integer value
01862     #  @ingroup l1_meshinfo
01863     def NbTrianglesOfOrder(self, elementOrder):
01864         return self.mesh.NbTrianglesOfOrder(elementOrder)
01865 
01866     ## Returns the number of quadrangles in the mesh
01867     #  @return an integer value
01868     #  @ingroup l1_meshinfo
01869     def NbQuadrangles(self):
01870         return self.mesh.NbQuadrangles()
01871 
01872     ## Returns the number of quadrangles with the given order in the mesh
01873     #  @param elementOrder the order of elements:
01874     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01875     #  @return an integer value
01876     #  @ingroup l1_meshinfo
01877     def NbQuadranglesOfOrder(self, elementOrder):
01878         return self.mesh.NbQuadranglesOfOrder(elementOrder)
01879 
01880     ## Returns the number of biquadratic quadrangles in the mesh
01881     #  @return an integer value
01882     #  @ingroup l1_meshinfo
01883     def NbBiQuadQuadrangles(self):
01884         return self.mesh.NbBiQuadQuadrangles()
01885 
01886     ## Returns the number of polygons in the mesh
01887     #  @return an integer value
01888     #  @ingroup l1_meshinfo
01889     def NbPolygons(self):
01890         return self.mesh.NbPolygons()
01891 
01892     ## Returns the number of volumes in the mesh
01893     #  @return an integer value
01894     #  @ingroup l1_meshinfo
01895     def NbVolumes(self):
01896         return self.mesh.NbVolumes()
01897 
01898     ## Returns the number of volumes with the given order in the mesh
01899     #  @param elementOrder  the order of elements:
01900     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01901     #  @return an integer value
01902     #  @ingroup l1_meshinfo
01903     def NbVolumesOfOrder(self, elementOrder):
01904         return self.mesh.NbVolumesOfOrder(elementOrder)
01905 
01906     ## Returns the number of tetrahedrons in the mesh
01907     #  @return an integer value
01908     #  @ingroup l1_meshinfo
01909     def NbTetras(self):
01910         return self.mesh.NbTetras()
01911 
01912     ## Returns the number of tetrahedrons with the given order in the mesh
01913     #  @param elementOrder  the order of elements:
01914     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01915     #  @return an integer value
01916     #  @ingroup l1_meshinfo
01917     def NbTetrasOfOrder(self, elementOrder):
01918         return self.mesh.NbTetrasOfOrder(elementOrder)
01919 
01920     ## Returns the number of hexahedrons in the mesh
01921     #  @return an integer value
01922     #  @ingroup l1_meshinfo
01923     def NbHexas(self):
01924         return self.mesh.NbHexas()
01925 
01926     ## Returns the number of hexahedrons with the given order in the mesh
01927     #  @param elementOrder  the order of elements:
01928     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01929     #  @return an integer value
01930     #  @ingroup l1_meshinfo
01931     def NbHexasOfOrder(self, elementOrder):
01932         return self.mesh.NbHexasOfOrder(elementOrder)
01933 
01934     ## Returns the number of triquadratic hexahedrons in the mesh
01935     #  @return an integer value
01936     #  @ingroup l1_meshinfo
01937     def NbTriQuadraticHexas(self):
01938         return self.mesh.NbTriQuadraticHexas()
01939 
01940     ## Returns the number of pyramids in the mesh
01941     #  @return an integer value
01942     #  @ingroup l1_meshinfo
01943     def NbPyramids(self):
01944         return self.mesh.NbPyramids()
01945 
01946     ## Returns the number of pyramids with the given order in the mesh
01947     #  @param elementOrder  the order of elements:
01948     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01949     #  @return an integer value
01950     #  @ingroup l1_meshinfo
01951     def NbPyramidsOfOrder(self, elementOrder):
01952         return self.mesh.NbPyramidsOfOrder(elementOrder)
01953 
01954     ## Returns the number of prisms in the mesh
01955     #  @return an integer value
01956     #  @ingroup l1_meshinfo
01957     def NbPrisms(self):
01958         return self.mesh.NbPrisms()
01959 
01960     ## Returns the number of prisms with the given order in the mesh
01961     #  @param elementOrder  the order of elements:
01962     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
01963     #  @return an integer value
01964     #  @ingroup l1_meshinfo
01965     def NbPrismsOfOrder(self, elementOrder):
01966         return self.mesh.NbPrismsOfOrder(elementOrder)
01967 
01968     ## Returns the number of hexagonal prisms in the mesh
01969     #  @return an integer value
01970     #  @ingroup l1_meshinfo
01971     def NbHexagonalPrisms(self):
01972         return self.mesh.NbHexagonalPrisms()
01973 
01974     ## Returns the number of polyhedrons in the mesh
01975     #  @return an integer value
01976     #  @ingroup l1_meshinfo
01977     def NbPolyhedrons(self):
01978         return self.mesh.NbPolyhedrons()
01979 
01980     ## Returns the number of submeshes in the mesh
01981     #  @return an integer value
01982     #  @ingroup l1_meshinfo
01983     def NbSubMesh(self):
01984         return self.mesh.NbSubMesh()
01985 
01986     ## Returns the list of mesh elements IDs
01987     #  @return the list of integer values
01988     #  @ingroup l1_meshinfo
01989     def GetElementsId(self):
01990         return self.mesh.GetElementsId()
01991 
01992     ## Returns the list of IDs of mesh elements with the given type
01993     #  @param elementType  the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
01994     #  @return list of integer values
01995     #  @ingroup l1_meshinfo
01996     def GetElementsByType(self, elementType):
01997         return self.mesh.GetElementsByType(elementType)
01998 
01999     ## Returns the list of mesh nodes IDs
02000     #  @return the list of integer values
02001     #  @ingroup l1_meshinfo
02002     def GetNodesId(self):
02003         return self.mesh.GetNodesId()
02004 
02005     # Get the information about mesh elements:
02006     # ------------------------------------
02007 
02008     ## Returns the type of mesh element
02009     #  @return the value from SMESH::ElementType enumeration
02010     #  @ingroup l1_meshinfo
02011     def GetElementType(self, id, iselem):
02012         return self.mesh.GetElementType(id, iselem)
02013 
02014     ## Returns the geometric type of mesh element
02015     #  @return the value from SMESH::EntityType enumeration
02016     #  @ingroup l1_meshinfo
02017     def GetElementGeomType(self, id):
02018         return self.mesh.GetElementGeomType(id)
02019 
02020     ## Returns the list of submesh elements IDs
02021     #  @param Shape a geom object(sub-shape) IOR
02022     #         Shape must be the sub-shape of a ShapeToMesh()
02023     #  @return the list of integer values
02024     #  @ingroup l1_meshinfo
02025     def GetSubMeshElementsId(self, Shape):
02026         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02027             ShapeID = Shape.GetSubShapeIndices()[0]
02028         else:
02029             ShapeID = Shape
02030         return self.mesh.GetSubMeshElementsId(ShapeID)
02031 
02032     ## Returns the list of submesh nodes IDs
02033     #  @param Shape a geom object(sub-shape) IOR
02034     #         Shape must be the sub-shape of a ShapeToMesh()
02035     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
02036     #  @return the list of integer values
02037     #  @ingroup l1_meshinfo
02038     def GetSubMeshNodesId(self, Shape, all):
02039         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02040             ShapeID = Shape.GetSubShapeIndices()[0]
02041         else:
02042             ShapeID = Shape
02043         return self.mesh.GetSubMeshNodesId(ShapeID, all)
02044 
02045     ## Returns type of elements on given shape
02046     #  @param Shape a geom object(sub-shape) IOR
02047     #         Shape must be a sub-shape of a ShapeToMesh()
02048     #  @return element type
02049     #  @ingroup l1_meshinfo
02050     def GetSubMeshElementType(self, Shape):
02051         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02052             ShapeID = Shape.GetSubShapeIndices()[0]
02053         else:
02054             ShapeID = Shape
02055         return self.mesh.GetSubMeshElementType(ShapeID)
02056 
02057     ## Gets the mesh description
02058     #  @return string value
02059     #  @ingroup l1_meshinfo
02060     def Dump(self):
02061         return self.mesh.Dump()
02062 
02063 
02064     # Get the information about nodes and elements of a mesh by its IDs:
02065     # -----------------------------------------------------------
02066 
02067     ## Gets XYZ coordinates of a node
02068     #  \n If there is no nodes for the given ID - returns an empty list
02069     #  @return a list of double precision values
02070     #  @ingroup l1_meshinfo
02071     def GetNodeXYZ(self, id):
02072         return self.mesh.GetNodeXYZ(id)
02073 
02074     ## Returns list of IDs of inverse elements for the given node
02075     #  \n If there is no node for the given ID - returns an empty list
02076     #  @return a list of integer values
02077     #  @ingroup l1_meshinfo
02078     def GetNodeInverseElements(self, id):
02079         return self.mesh.GetNodeInverseElements(id)
02080 
02081     ## @brief Returns the position of a node on the shape
02082     #  @return SMESH::NodePosition
02083     #  @ingroup l1_meshinfo
02084     def GetNodePosition(self,NodeID):
02085         return self.mesh.GetNodePosition(NodeID)
02086 
02087     ## If the given element is a node, returns the ID of shape
02088     #  \n If there is no node for the given ID - returns -1
02089     #  @return an integer value
02090     #  @ingroup l1_meshinfo
02091     def GetShapeID(self, id):
02092         return self.mesh.GetShapeID(id)
02093 
02094     ## Returns the ID of the result shape after
02095     #  FindShape() from SMESH_MeshEditor for the given element
02096     #  \n If there is no element for the given ID - returns -1
02097     #  @return an integer value
02098     #  @ingroup l1_meshinfo
02099     def GetShapeIDForElem(self,id):
02100         return self.mesh.GetShapeIDForElem(id)
02101 
02102     ## Returns the number of nodes for the given element
02103     #  \n If there is no element for the given ID - returns -1
02104     #  @return an integer value
02105     #  @ingroup l1_meshinfo
02106     def GetElemNbNodes(self, id):
02107         return self.mesh.GetElemNbNodes(id)
02108 
02109     ## Returns the node ID the given index for the given element
02110     #  \n If there is no element for the given ID - returns -1
02111     #  \n If there is no node for the given index - returns -2
02112     #  @return an integer value
02113     #  @ingroup l1_meshinfo
02114     def GetElemNode(self, id, index):
02115         return self.mesh.GetElemNode(id, index)
02116 
02117     ## Returns the IDs of nodes of the given element
02118     #  @return a list of integer values
02119     #  @ingroup l1_meshinfo
02120     def GetElemNodes(self, id):
02121         return self.mesh.GetElemNodes(id)
02122 
02123     ## Returns true if the given node is the medium node in the given quadratic element
02124     #  @ingroup l1_meshinfo
02125     def IsMediumNode(self, elementID, nodeID):
02126         return self.mesh.IsMediumNode(elementID, nodeID)
02127 
02128     ## Returns true if the given node is the medium node in one of quadratic elements
02129     #  @ingroup l1_meshinfo
02130     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
02131         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
02132 
02133     ## Returns the number of edges for the given element
02134     #  @ingroup l1_meshinfo
02135     def ElemNbEdges(self, id):
02136         return self.mesh.ElemNbEdges(id)
02137 
02138     ## Returns the number of faces for the given element
02139     #  @ingroup l1_meshinfo
02140     def ElemNbFaces(self, id):
02141         return self.mesh.ElemNbFaces(id)
02142 
02143     ## Returns nodes of given face (counted from zero) for given volumic element.
02144     #  @ingroup l1_meshinfo
02145     def GetElemFaceNodes(self,elemId, faceIndex):
02146         return self.mesh.GetElemFaceNodes(elemId, faceIndex)
02147 
02148     ## Returns an element based on all given nodes.
02149     #  @ingroup l1_meshinfo
02150     def FindElementByNodes(self,nodes):
02151         return self.mesh.FindElementByNodes(nodes)
02152 
02153     ## Returns true if the given element is a polygon
02154     #  @ingroup l1_meshinfo
02155     def IsPoly(self, id):
02156         return self.mesh.IsPoly(id)
02157 
02158     ## Returns true if the given element is quadratic
02159     #  @ingroup l1_meshinfo
02160     def IsQuadratic(self, id):
02161         return self.mesh.IsQuadratic(id)
02162 
02163     ## Returns XYZ coordinates of the barycenter of the given element
02164     #  \n If there is no element for the given ID - returns an empty list
02165     #  @return a list of three double values
02166     #  @ingroup l1_meshinfo
02167     def BaryCenter(self, id):
02168         return self.mesh.BaryCenter(id)
02169 
02170 
02171     # Get mesh measurements information:
02172     # ------------------------------------
02173 
02174     ## Get minimum distance between two nodes, elements or distance to the origin
02175     #  @param id1 first node/element id
02176     #  @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
02177     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
02178     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
02179     #  @return minimum distance value
02180     #  @sa GetMinDistance()
02181     def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
02182         aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
02183         return aMeasure.value
02184 
02185     ## Get measure structure specifying minimum distance data between two objects
02186     #  @param id1 first node/element id
02187     #  @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
02188     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
02189     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
02190     #  @return Measure structure
02191     #  @sa MinDistance()
02192     def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
02193         if isElem1:
02194             id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
02195         else:
02196             id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
02197         if id2 != 0:
02198             if isElem2:
02199                 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
02200             else:
02201                 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
02202             pass
02203         else:
02204             id2 = None
02205 
02206         aMeasurements = self.smeshpyD.CreateMeasurements()
02207         aMeasure = aMeasurements.MinDistance(id1, id2)
02208         aMeasurements.UnRegister()
02209         return aMeasure
02210 
02211     ## Get bounding box of the specified object(s)
02212     #  @param objects single source object or list of source objects or list of nodes/elements IDs
02213     #  @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
02214     #  @c False specifies that @a objects are nodes
02215     #  @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
02216     #  @sa GetBoundingBox()
02217     def BoundingBox(self, objects=None, isElem=False):
02218         result = self.GetBoundingBox(objects, isElem)
02219         if result is None:
02220             result = (0.0,)*6
02221         else:
02222             result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
02223         return result
02224 
02225     ## Get measure structure specifying bounding box data of the specified object(s)
02226     #  @param IDs single source object or list of source objects or list of nodes/elements IDs
02227     #  @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
02228     #  @c False specifies that @a objects are nodes
02229     #  @return Measure structure
02230     #  @sa BoundingBox()
02231     def GetBoundingBox(self, IDs=None, isElem=False):
02232         if IDs is None:
02233             IDs = [self.mesh]
02234         elif isinstance(IDs, tuple):
02235             IDs = list(IDs)
02236         if not isinstance(IDs, list):
02237             IDs = [IDs]
02238         if len(IDs) > 0 and isinstance(IDs[0], int):
02239             IDs = [IDs]
02240         srclist = []
02241         for o in IDs:
02242             if isinstance(o, Mesh):
02243                 srclist.append(o.mesh)
02244             elif hasattr(o, "_narrow"):
02245                 src = o._narrow(SMESH.SMESH_IDSource)
02246                 if src: srclist.append(src)
02247                 pass
02248             elif isinstance(o, list):
02249                 if isElem:
02250                     srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
02251                 else:
02252                     srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
02253                 pass
02254             pass
02255         aMeasurements = self.smeshpyD.CreateMeasurements()
02256         aMeasure = aMeasurements.BoundingBox(srclist)
02257         aMeasurements.UnRegister()
02258         return aMeasure
02259 
02260     # Mesh edition (SMESH_MeshEditor functionality):
02261     # ---------------------------------------------
02262 
02263     ## Removes the elements from the mesh by ids
02264     #  @param IDsOfElements is a list of ids of elements to remove
02265     #  @return True or False
02266     #  @ingroup l2_modif_del
02267     def RemoveElements(self, IDsOfElements):
02268         return self.editor.RemoveElements(IDsOfElements)
02269 
02270     ## Removes nodes from mesh by ids
02271     #  @param IDsOfNodes is a list of ids of nodes to remove
02272     #  @return True or False
02273     #  @ingroup l2_modif_del
02274     def RemoveNodes(self, IDsOfNodes):
02275         return self.editor.RemoveNodes(IDsOfNodes)
02276 
02277     ## Removes all orphan (free) nodes from mesh
02278     #  @return number of the removed nodes
02279     #  @ingroup l2_modif_del
02280     def RemoveOrphanNodes(self):
02281         return self.editor.RemoveOrphanNodes()
02282 
02283     ## Add a node to the mesh by coordinates
02284     #  @return Id of the new node
02285     #  @ingroup l2_modif_add
02286     def AddNode(self, x, y, z):
02287         x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
02288         if hasVars: self.mesh.SetParameters(Parameters)
02289         return self.editor.AddNode( x, y, z)
02290 
02291     ## Creates a 0D element on a node with given number.
02292     #  @param IDOfNode the ID of node for creation of the element.
02293     #  @return the Id of the new 0D element
02294     #  @ingroup l2_modif_add
02295     def Add0DElement(self, IDOfNode):
02296         return self.editor.Add0DElement(IDOfNode)
02297 
02298     ## Creates a linear or quadratic edge (this is determined
02299     #  by the number of given nodes).
02300     #  @param IDsOfNodes the list of node IDs for creation of the element.
02301     #  The order of nodes in this list should correspond to the description
02302     #  of MED. \n This description is located by the following link:
02303     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
02304     #  @return the Id of the new edge
02305     #  @ingroup l2_modif_add
02306     def AddEdge(self, IDsOfNodes):
02307         return self.editor.AddEdge(IDsOfNodes)
02308 
02309     ## Creates a linear or quadratic face (this is determined
02310     #  by the number of given nodes).
02311     #  @param IDsOfNodes the list of node IDs for creation of the element.
02312     #  The order of nodes in this list should correspond to the description
02313     #  of MED. \n This description is located by the following link:
02314     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
02315     #  @return the Id of the new face
02316     #  @ingroup l2_modif_add
02317     def AddFace(self, IDsOfNodes):
02318         return self.editor.AddFace(IDsOfNodes)
02319 
02320     ## Adds a polygonal face to the mesh by the list of node IDs
02321     #  @param IdsOfNodes the list of node IDs for creation of the element.
02322     #  @return the Id of the new face
02323     #  @ingroup l2_modif_add
02324     def AddPolygonalFace(self, IdsOfNodes):
02325         return self.editor.AddPolygonalFace(IdsOfNodes)
02326 
02327     ## Creates both simple and quadratic volume (this is determined
02328     #  by the number of given nodes).
02329     #  @param IDsOfNodes the list of node IDs for creation of the element.
02330     #  The order of nodes in this list should correspond to the description
02331     #  of MED. \n This description is located by the following link:
02332     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
02333     #  @return the Id of the new volumic element
02334     #  @ingroup l2_modif_add
02335     def AddVolume(self, IDsOfNodes):
02336         return self.editor.AddVolume(IDsOfNodes)
02337 
02338     ## Creates a volume of many faces, giving nodes for each face.
02339     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
02340     #  @param Quantities the list of integer values, Quantities[i]
02341     #         gives the quantity of nodes in face number i.
02342     #  @return the Id of the new volumic element
02343     #  @ingroup l2_modif_add
02344     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
02345         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
02346 
02347     ## Creates a volume of many faces, giving the IDs of the existing faces.
02348     #  @param IdsOfFaces the list of face IDs for volume creation.
02349     #
02350     #  Note:  The created volume will refer only to the nodes
02351     #         of the given faces, not to the faces themselves.
02352     #  @return the Id of the new volumic element
02353     #  @ingroup l2_modif_add
02354     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
02355         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
02356 
02357 
02358     ## @brief Binds a node to a vertex
02359     #  @param NodeID a node ID
02360     #  @param Vertex a vertex or vertex ID
02361     #  @return True if succeed else raises an exception
02362     #  @ingroup l2_modif_add
02363     def SetNodeOnVertex(self, NodeID, Vertex):
02364         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
02365             VertexID = Vertex.GetSubShapeIndices()[0]
02366         else:
02367             VertexID = Vertex
02368         try:
02369             self.editor.SetNodeOnVertex(NodeID, VertexID)
02370         except SALOME.SALOME_Exception, inst:
02371             raise ValueError, inst.details.text
02372         return True
02373 
02374 
02375     ## @brief Stores the node position on an edge
02376     #  @param NodeID a node ID
02377     #  @param Edge an edge or edge ID
02378     #  @param paramOnEdge a parameter on the edge where the node is located
02379     #  @return True if succeed else raises an exception
02380     #  @ingroup l2_modif_add
02381     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
02382         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
02383             EdgeID = Edge.GetSubShapeIndices()[0]
02384         else:
02385             EdgeID = Edge
02386         try:
02387             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
02388         except SALOME.SALOME_Exception, inst:
02389             raise ValueError, inst.details.text
02390         return True
02391 
02392     ## @brief Stores node position on a face
02393     #  @param NodeID a node ID
02394     #  @param Face a face or face ID
02395     #  @param u U parameter on the face where the node is located
02396     #  @param v V parameter on the face where the node is located
02397     #  @return True if succeed else raises an exception
02398     #  @ingroup l2_modif_add
02399     def SetNodeOnFace(self, NodeID, Face, u, v):
02400         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
02401             FaceID = Face.GetSubShapeIndices()[0]
02402         else:
02403             FaceID = Face
02404         try:
02405             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
02406         except SALOME.SALOME_Exception, inst:
02407             raise ValueError, inst.details.text
02408         return True
02409 
02410     ## @brief Binds a node to a solid
02411     #  @param NodeID a node ID
02412     #  @param Solid  a solid or solid ID
02413     #  @return True if succeed else raises an exception
02414     #  @ingroup l2_modif_add
02415     def SetNodeInVolume(self, NodeID, Solid):
02416         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
02417             SolidID = Solid.GetSubShapeIndices()[0]
02418         else:
02419             SolidID = Solid
02420         try:
02421             self.editor.SetNodeInVolume(NodeID, SolidID)
02422         except SALOME.SALOME_Exception, inst:
02423             raise ValueError, inst.details.text
02424         return True
02425 
02426     ## @brief Bind an element to a shape
02427     #  @param ElementID an element ID
02428     #  @param Shape a shape or shape ID
02429     #  @return True if succeed else raises an exception
02430     #  @ingroup l2_modif_add
02431     def SetMeshElementOnShape(self, ElementID, Shape):
02432         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02433             ShapeID = Shape.GetSubShapeIndices()[0]
02434         else:
02435             ShapeID = Shape
02436         try:
02437             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
02438         except SALOME.SALOME_Exception, inst:
02439             raise ValueError, inst.details.text
02440         return True
02441 
02442 
02443     ## Moves the node with the given id
02444     #  @param NodeID the id of the node
02445     #  @param x  a new X coordinate
02446     #  @param y  a new Y coordinate
02447     #  @param z  a new Z coordinate
02448     #  @return True if succeed else False
02449     #  @ingroup l2_modif_movenode
02450     def MoveNode(self, NodeID, x, y, z):
02451         x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
02452         if hasVars: self.mesh.SetParameters(Parameters)
02453         return self.editor.MoveNode(NodeID, x, y, z)
02454 
02455     ## Finds the node closest to a point and moves it to a point location
02456     #  @param x  the X coordinate of a point
02457     #  @param y  the Y coordinate of a point
02458     #  @param z  the Z coordinate of a point
02459     #  @param NodeID if specified (>0), the node with this ID is moved,
02460     #  otherwise, the node closest to point (@a x,@a y,@a z) is moved
02461     #  @return the ID of a node
02462     #  @ingroup l2_modif_throughp
02463     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
02464         x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
02465         if hasVars: self.mesh.SetParameters(Parameters)
02466         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
02467 
02468     ## Finds the node closest to a point
02469     #  @param x  the X coordinate of a point
02470     #  @param y  the Y coordinate of a point
02471     #  @param z  the Z coordinate of a point
02472     #  @return the ID of a node
02473     #  @ingroup l2_modif_throughp
02474     def FindNodeClosestTo(self, x, y, z):
02475         #preview = self.mesh.GetMeshEditPreviewer()
02476         #return preview.MoveClosestNodeToPoint(x, y, z, -1)
02477         return self.editor.FindNodeClosestTo(x, y, z)
02478 
02479     ## Finds the elements where a point lays IN or ON
02480     #  @param x  the X coordinate of a point
02481     #  @param y  the Y coordinate of a point
02482     #  @param z  the Z coordinate of a point
02483     #  @param elementType type of elements to find (SMESH.ALL type
02484     #         means elements of any type excluding nodes and 0D elements)
02485     #  @param meshPart a part of mesh (group, sub-mesh) to search within
02486     #  @return list of IDs of found elements
02487     #  @ingroup l2_modif_throughp
02488     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
02489         if meshPart:
02490             return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
02491         else:
02492             return self.editor.FindElementsByPoint(x, y, z, elementType)
02493 
02494     # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
02495     # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
02496 
02497     def GetPointState(self, x, y, z):
02498         return self.editor.GetPointState(x, y, z)
02499 
02500     ## Finds the node closest to a point and moves it to a point location
02501     #  @param x  the X coordinate of a point
02502     #  @param y  the Y coordinate of a point
02503     #  @param z  the Z coordinate of a point
02504     #  @return the ID of a moved node
02505     #  @ingroup l2_modif_throughp
02506     def MeshToPassThroughAPoint(self, x, y, z):
02507         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
02508 
02509     ## Replaces two neighbour triangles sharing Node1-Node2 link
02510     #  with the triangles built on the same 4 nodes but having other common link.
02511     #  @param NodeID1  the ID of the first node
02512     #  @param NodeID2  the ID of the second node
02513     #  @return false if proper faces were not found
02514     #  @ingroup l2_modif_invdiag
02515     def InverseDiag(self, NodeID1, NodeID2):
02516         return self.editor.InverseDiag(NodeID1, NodeID2)
02517 
02518     ## Replaces two neighbour triangles sharing Node1-Node2 link
02519     #  with a quadrangle built on the same 4 nodes.
02520     #  @param NodeID1  the ID of the first node
02521     #  @param NodeID2  the ID of the second node
02522     #  @return false if proper faces were not found
02523     #  @ingroup l2_modif_unitetri
02524     def DeleteDiag(self, NodeID1, NodeID2):
02525         return self.editor.DeleteDiag(NodeID1, NodeID2)
02526 
02527     ## Reorients elements by ids
02528     #  @param IDsOfElements if undefined reorients all mesh elements
02529     #  @return True if succeed else False
02530     #  @ingroup l2_modif_changori
02531     def Reorient(self, IDsOfElements=None):
02532         if IDsOfElements == None:
02533             IDsOfElements = self.GetElementsId()
02534         return self.editor.Reorient(IDsOfElements)
02535 
02536     ## Reorients all elements of the object
02537     #  @param theObject mesh, submesh or group
02538     #  @return True if succeed else False
02539     #  @ingroup l2_modif_changori
02540     def ReorientObject(self, theObject):
02541         if ( isinstance( theObject, Mesh )):
02542             theObject = theObject.GetMesh()
02543         return self.editor.ReorientObject(theObject)
02544 
02545     ## Fuses the neighbouring triangles into quadrangles.
02546     #  @param IDsOfElements The triangles to be fused,
02547     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
02548     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
02549     #                       is still performed; theMaxAngle is mesured in radians.
02550     #                       Also it could be a name of variable which defines angle in degrees.
02551     #  @return TRUE in case of success, FALSE otherwise.
02552     #  @ingroup l2_modif_unitetri
02553     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
02554         flag = False
02555         if isinstance(MaxAngle,str):
02556             flag = True
02557         MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
02558         self.mesh.SetParameters(Parameters)
02559         if not IDsOfElements:
02560             IDsOfElements = self.GetElementsId()
02561         Functor = 0
02562         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
02563             Functor = theCriterion
02564         else:
02565             Functor = self.smeshpyD.GetFunctor(theCriterion)
02566         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
02567 
02568     ## Fuses the neighbouring triangles of the object into quadrangles
02569     #  @param theObject is mesh, submesh or group
02570     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
02571     #  @param MaxAngle   a max angle between element normals at which the fusion
02572     #                   is still performed; theMaxAngle is mesured in radians.
02573     #  @return TRUE in case of success, FALSE otherwise.
02574     #  @ingroup l2_modif_unitetri
02575     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
02576         MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
02577         self.mesh.SetParameters(Parameters)
02578         if ( isinstance( theObject, Mesh )):
02579             theObject = theObject.GetMesh()
02580         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
02581 
02582     ## Splits quadrangles into triangles.
02583     #  @param IDsOfElements the faces to be splitted.
02584     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
02585     #  @return TRUE in case of success, FALSE otherwise.
02586     #  @ingroup l2_modif_cutquadr
02587     def QuadToTri (self, IDsOfElements, theCriterion):
02588         if IDsOfElements == []:
02589             IDsOfElements = self.GetElementsId()
02590         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
02591 
02592     ## Splits quadrangles into triangles.
02593     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
02594     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
02595     #  @return TRUE in case of success, FALSE otherwise.
02596     #  @ingroup l2_modif_cutquadr
02597     def QuadToTriObject (self, theObject, theCriterion):
02598         if ( isinstance( theObject, Mesh )):
02599             theObject = theObject.GetMesh()
02600         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
02601 
02602     ## Splits quadrangles into triangles.
02603     #  @param IDsOfElements the faces to be splitted
02604     #  @param Diag13        is used to choose a diagonal for splitting.
02605     #  @return TRUE in case of success, FALSE otherwise.
02606     #  @ingroup l2_modif_cutquadr
02607     def SplitQuad (self, IDsOfElements, Diag13):
02608         if IDsOfElements == []:
02609             IDsOfElements = self.GetElementsId()
02610         return self.editor.SplitQuad(IDsOfElements, Diag13)
02611 
02612     ## Splits quadrangles into triangles.
02613     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
02614     #  @param Diag13    is used to choose a diagonal for splitting.
02615     #  @return TRUE in case of success, FALSE otherwise.
02616     #  @ingroup l2_modif_cutquadr
02617     def SplitQuadObject (self, theObject, Diag13):
02618         if ( isinstance( theObject, Mesh )):
02619             theObject = theObject.GetMesh()
02620         return self.editor.SplitQuadObject(theObject, Diag13)
02621 
02622     ## Finds a better splitting of the given quadrangle.
02623     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
02624     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
02625     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
02626     #          diagonal is better, 0 if error occurs.
02627     #  @ingroup l2_modif_cutquadr
02628     def BestSplit (self, IDOfQuad, theCriterion):
02629         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
02630 
02631     ## Splits volumic elements into tetrahedrons
02632     #  @param elemIDs either list of elements or mesh or group or submesh
02633     #  @param method  flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
02634     #         Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
02635     #  @ingroup l2_modif_cutquadr
02636     def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
02637         if isinstance( elemIDs, Mesh ):
02638             elemIDs = elemIDs.GetMesh()
02639         if ( isinstance( elemIDs, list )):
02640             elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
02641         self.editor.SplitVolumesIntoTetra(elemIDs, method)
02642 
02643     ## Splits quadrangle faces near triangular facets of volumes
02644     #
02645     #  @ingroup l1_auxiliary
02646     def SplitQuadsNearTriangularFacets(self):
02647         faces_array = self.GetElementsByType(SMESH.FACE)
02648         for face_id in faces_array:
02649             if self.GetElemNbNodes(face_id) == 4: # quadrangle
02650                 quad_nodes = self.mesh.GetElemNodes(face_id)
02651                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
02652                 isVolumeFound = False
02653                 for node1_elem in node1_elems:
02654                     if not isVolumeFound:
02655                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
02656                             nb_nodes = self.GetElemNbNodes(node1_elem)
02657                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
02658                                 volume_elem = node1_elem
02659                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
02660                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
02661                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
02662                                         isVolumeFound = True
02663                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
02664                                             self.SplitQuad([face_id], False) # diagonal 2-4
02665                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
02666                                         isVolumeFound = True
02667                                         self.SplitQuad([face_id], True) # diagonal 1-3
02668                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
02669                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
02670                                         isVolumeFound = True
02671                                         self.SplitQuad([face_id], True) # diagonal 1-3
02672 
02673     ## @brief Splits hexahedrons into tetrahedrons.
02674     #
02675     #  This operation uses pattern mapping functionality for splitting.
02676     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
02677     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
02678     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
02679     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
02680     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
02681     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
02682     #  @return TRUE in case of success, FALSE otherwise.
02683     #  @ingroup l1_auxiliary
02684     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
02685         # Pattern:     5.---------.6
02686         #              /|#*      /|
02687         #             / | #*    / |
02688         #            /  |  # * /  |
02689         #           /   |   # /*  |
02690         # (0,0,1) 4.---------.7 * |
02691         #          |#*  |1   | # *|
02692         #          | # *.----|---#.2
02693         #          |  #/ *   |   /
02694         #          |  /#  *  |  /
02695         #          | /   # * | /
02696         #          |/      #*|/
02697         # (0,0,0) 0.---------.3
02698         pattern_tetra = "!!! Nb of points: \n 8 \n\
02699         !!! Points: \n\
02700         0 0 0  !- 0 \n\
02701         0 1 0  !- 1 \n\
02702         1 1 0  !- 2 \n\
02703         1 0 0  !- 3 \n\
02704         0 0 1  !- 4 \n\
02705         0 1 1  !- 5 \n\
02706         1 1 1  !- 6 \n\
02707         1 0 1  !- 7 \n\
02708         !!! Indices of points of 6 tetras: \n\
02709         0 3 4 1 \n\
02710         7 4 3 1 \n\
02711         4 7 5 1 \n\
02712         6 2 5 7 \n\
02713         1 5 2 7 \n\
02714         2 3 1 7 \n"
02715 
02716         pattern = self.smeshpyD.GetPattern()
02717         isDone  = pattern.LoadFromFile(pattern_tetra)
02718         if not isDone:
02719             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
02720             return isDone
02721 
02722         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
02723         isDone = pattern.MakeMesh(self.mesh, False, False)
02724         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
02725 
02726         # split quafrangle faces near triangular facets of volumes
02727         self.SplitQuadsNearTriangularFacets()
02728 
02729         return isDone
02730 
02731     ## @brief Split hexahedrons into prisms.
02732     #
02733     #  Uses the pattern mapping functionality for splitting.
02734     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
02735     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
02736     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
02737     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
02738     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
02739     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
02740     #  @return TRUE in case of success, FALSE otherwise.
02741     #  @ingroup l1_auxiliary
02742     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
02743         # Pattern:     5.---------.6
02744         #              /|#       /|
02745         #             / | #     / |
02746         #            /  |  #   /  |
02747         #           /   |   # /   |
02748         # (0,0,1) 4.---------.7   |
02749         #          |    |    |    |
02750         #          |   1.----|----.2
02751         #          |   / *   |   /
02752         #          |  /   *  |  /
02753         #          | /     * | /
02754         #          |/       *|/
02755         # (0,0,0) 0.---------.3
02756         pattern_prism = "!!! Nb of points: \n 8 \n\
02757         !!! Points: \n\
02758         0 0 0  !- 0 \n\
02759         0 1 0  !- 1 \n\
02760         1 1 0  !- 2 \n\
02761         1 0 0  !- 3 \n\
02762         0 0 1  !- 4 \n\
02763         0 1 1  !- 5 \n\
02764         1 1 1  !- 6 \n\
02765         1 0 1  !- 7 \n\
02766         !!! Indices of points of 2 prisms: \n\
02767         0 1 3 4 5 7 \n\
02768         2 3 1 6 7 5 \n"
02769 
02770         pattern = self.smeshpyD.GetPattern()
02771         isDone  = pattern.LoadFromFile(pattern_prism)
02772         if not isDone:
02773             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
02774             return isDone
02775 
02776         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
02777         isDone = pattern.MakeMesh(self.mesh, False, False)
02778         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
02779 
02780         # Splits quafrangle faces near triangular facets of volumes
02781         self.SplitQuadsNearTriangularFacets()
02782 
02783         return isDone
02784 
02785     ## Smoothes elements
02786     #  @param IDsOfElements the list if ids of elements to smooth
02787     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
02788     #  Note that nodes built on edges and boundary nodes are always fixed.
02789     #  @param MaxNbOfIterations the maximum number of iterations
02790     #  @param MaxAspectRatio varies in range [1.0, inf]
02791     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
02792     #  @return TRUE in case of success, FALSE otherwise.
02793     #  @ingroup l2_modif_smooth
02794     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
02795                MaxNbOfIterations, MaxAspectRatio, Method):
02796         if IDsOfElements == []:
02797             IDsOfElements = self.GetElementsId()
02798         MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
02799         self.mesh.SetParameters(Parameters)
02800         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
02801                                   MaxNbOfIterations, MaxAspectRatio, Method)
02802 
02803     ## Smoothes elements which belong to the given object
02804     #  @param theObject the object to smooth
02805     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
02806     #  Note that nodes built on edges and boundary nodes are always fixed.
02807     #  @param MaxNbOfIterations the maximum number of iterations
02808     #  @param MaxAspectRatio varies in range [1.0, inf]
02809     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
02810     #  @return TRUE in case of success, FALSE otherwise.
02811     #  @ingroup l2_modif_smooth
02812     def SmoothObject(self, theObject, IDsOfFixedNodes,
02813                      MaxNbOfIterations, MaxAspectRatio, Method):
02814         if ( isinstance( theObject, Mesh )):
02815             theObject = theObject.GetMesh()
02816         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
02817                                         MaxNbOfIterations, MaxAspectRatio, Method)
02818 
02819     ## Parametrically smoothes the given elements
02820     #  @param IDsOfElements the list if ids of elements to smooth
02821     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
02822     #  Note that nodes built on edges and boundary nodes are always fixed.
02823     #  @param MaxNbOfIterations the maximum number of iterations
02824     #  @param MaxAspectRatio varies in range [1.0, inf]
02825     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
02826     #  @return TRUE in case of success, FALSE otherwise.
02827     #  @ingroup l2_modif_smooth
02828     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
02829                          MaxNbOfIterations, MaxAspectRatio, Method):
02830         if IDsOfElements == []:
02831             IDsOfElements = self.GetElementsId()
02832         MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
02833         self.mesh.SetParameters(Parameters)
02834         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
02835                                             MaxNbOfIterations, MaxAspectRatio, Method)
02836 
02837     ## Parametrically smoothes the elements which belong to the given object
02838     #  @param theObject the object to smooth
02839     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
02840     #  Note that nodes built on edges and boundary nodes are always fixed.
02841     #  @param MaxNbOfIterations the maximum number of iterations
02842     #  @param MaxAspectRatio varies in range [1.0, inf]
02843     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
02844     #  @return TRUE in case of success, FALSE otherwise.
02845     #  @ingroup l2_modif_smooth
02846     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
02847                                MaxNbOfIterations, MaxAspectRatio, Method):
02848         if ( isinstance( theObject, Mesh )):
02849             theObject = theObject.GetMesh()
02850         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
02851                                                   MaxNbOfIterations, MaxAspectRatio, Method)
02852 
02853     ## Converts the mesh to quadratic, deletes old elements, replacing
02854     #  them with quadratic with the same id.
02855     #  @param theForce3d new node creation method:
02856     #         0 - the medium node lies at the geometrical entity from which the mesh element is built
02857     #         1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
02858     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
02859     #  @ingroup l2_modif_tofromqu
02860     def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
02861         if theSubMesh:
02862             self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
02863         else:
02864             self.editor.ConvertToQuadratic(theForce3d)
02865 
02866     ## Converts the mesh from quadratic to ordinary,
02867     #  deletes old quadratic elements, \n replacing
02868     #  them with ordinary mesh elements with the same id.
02869     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
02870     #  @ingroup l2_modif_tofromqu
02871     def ConvertFromQuadratic(self, theSubMesh=None):
02872         if theSubMesh:
02873             self.editor.ConvertFromQuadraticObject(theSubMesh)
02874         else:
02875             return self.editor.ConvertFromQuadratic()
02876 
02877     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
02878     #  @return TRUE if operation has been completed successfully, FALSE otherwise
02879     #  @ingroup l2_modif_edit
02880     def  Make2DMeshFrom3D(self):
02881         return self.editor. Make2DMeshFrom3D()
02882 
02883     ## Creates missing boundary elements
02884     #  @param elements - elements whose boundary is to be checked:
02885     #                    mesh, group, sub-mesh or list of elements
02886     #   if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
02887     #  @param dimension - defines type of boundary elements to create:
02888     #                     SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
02889     #    SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
02890     #  @param groupName - a name of group to store created boundary elements in,
02891     #                     "" means not to create the group
02892     #  @param meshName - a name of new mesh to store created boundary elements in,
02893     #                     "" means not to create the new mesh
02894     #  @param toCopyElements - if true, the checked elements will be copied into
02895     #     the new mesh else only boundary elements will be copied into the new mesh
02896     #  @param toCopyExistingBondary - if true, not only new but also pre-existing
02897     #     boundary elements will be copied into the new mesh
02898     #  @return tuple (mesh, group) where bondary elements were added to
02899     #  @ingroup l2_modif_edit
02900     def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
02901                          toCopyElements=False, toCopyExistingBondary=False):
02902         if isinstance( elements, Mesh ):
02903             elements = elements.GetMesh()
02904         if ( isinstance( elements, list )):
02905             elemType = SMESH.ALL
02906             if elements: elemType = self.GetElementType( elements[0], iselem=True)
02907             elements = self.editor.MakeIDSource(elements, elemType)
02908         mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
02909                                                    toCopyElements,toCopyExistingBondary)
02910         if mesh: mesh = self.smeshpyD.Mesh(mesh)
02911         return mesh, group
02912 
02913     ##
02914     # @brief Creates missing boundary elements around either the whole mesh or 
02915     #    groups of 2D elements
02916     #  @param dimension - defines type of boundary elements to create
02917     #  @param groupName - a name of group to store all boundary elements in,
02918     #    "" means not to create the group
02919     #  @param meshName - a name of a new mesh, which is a copy of the initial 
02920     #    mesh + created boundary elements; "" means not to create the new mesh
02921     #  @param toCopyAll - if true, the whole initial mesh will be copied into
02922     #    the new mesh else only boundary elements will be copied into the new mesh
02923     #  @param groups - groups of 2D elements to make boundary around
02924     #  @retval tuple( long, mesh, groups )
02925     #                 long - number of added boundary elements
02926     #                 mesh - the mesh where elements were added to
02927     #                 group - the group of boundary elements or None
02928     #
02929     def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
02930                              toCopyAll=False, groups=[]):
02931         nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
02932                                                            toCopyAll,groups)
02933         if mesh: mesh = self.smeshpyD.Mesh(mesh)
02934         return nb, mesh, group
02935 
02936     ## Renumber mesh nodes
02937     #  @ingroup l2_modif_renumber
02938     def RenumberNodes(self):
02939         self.editor.RenumberNodes()
02940 
02941     ## Renumber mesh elements
02942     #  @ingroup l2_modif_renumber
02943     def RenumberElements(self):
02944         self.editor.RenumberElements()
02945 
02946     ## Generates new elements by rotation of the elements around the axis
02947     #  @param IDsOfElements the list of ids of elements to sweep
02948     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
02949     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
02950     #  @param NbOfSteps the number of steps
02951     #  @param Tolerance tolerance
02952     #  @param MakeGroups forces the generation of new groups from existing ones
02953     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
02954     #                    of all steps, else - size of each step
02955     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
02956     #  @ingroup l2_modif_extrurev
02957     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
02958                       MakeGroups=False, TotalAngle=False):
02959         if IDsOfElements == []:
02960             IDsOfElements = self.GetElementsId()
02961         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
02962             Axis = self.smeshpyD.GetAxisStruct(Axis)
02963         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
02964         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
02965         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
02966         self.mesh.SetParameters(Parameters)
02967         if TotalAngle and NbOfSteps:
02968             AngleInRadians /= NbOfSteps
02969         if MakeGroups:
02970             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
02971                                                        AngleInRadians, NbOfSteps, Tolerance)
02972         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
02973         return []
02974 
02975     ## Generates new elements by rotation of the elements of object around the axis
02976     #  @param theObject object which elements should be sweeped.
02977     #                   It can be a mesh, a sub mesh or a group.
02978     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
02979     #  @param AngleInRadians the angle of Rotation
02980     #  @param NbOfSteps number of steps
02981     #  @param Tolerance tolerance
02982     #  @param MakeGroups forces the generation of new groups from existing ones
02983     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
02984     #                    of all steps, else - size of each step
02985     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
02986     #  @ingroup l2_modif_extrurev
02987     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
02988                             MakeGroups=False, TotalAngle=False):
02989         if ( isinstance( theObject, Mesh )):
02990             theObject = theObject.GetMesh()
02991         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
02992             Axis = self.smeshpyD.GetAxisStruct(Axis)
02993         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
02994         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
02995         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
02996         self.mesh.SetParameters(Parameters)
02997         if TotalAngle and NbOfSteps:
02998             AngleInRadians /= NbOfSteps
02999         if MakeGroups:
03000             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
03001                                                              NbOfSteps, Tolerance)
03002         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03003         return []
03004 
03005     ## Generates new elements by rotation of the elements of object around the axis
03006     #  @param theObject object which elements should be sweeped.
03007     #                   It can be a mesh, a sub mesh or a group.
03008     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
03009     #  @param AngleInRadians the angle of Rotation
03010     #  @param NbOfSteps number of steps
03011     #  @param Tolerance tolerance
03012     #  @param MakeGroups forces the generation of new groups from existing ones
03013     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
03014     #                    of all steps, else - size of each step
03015     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03016     #  @ingroup l2_modif_extrurev
03017     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03018                               MakeGroups=False, TotalAngle=False):
03019         if ( isinstance( theObject, Mesh )):
03020             theObject = theObject.GetMesh()
03021         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03022             Axis = self.smeshpyD.GetAxisStruct(Axis)
03023         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
03024         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
03025         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
03026         self.mesh.SetParameters(Parameters)
03027         if TotalAngle and NbOfSteps:
03028             AngleInRadians /= NbOfSteps
03029         if MakeGroups:
03030             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
03031                                                                NbOfSteps, Tolerance)
03032         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03033         return []
03034 
03035     ## Generates new elements by rotation of the elements of object around the axis
03036     #  @param theObject object which elements should be sweeped.
03037     #                   It can be a mesh, a sub mesh or a group.
03038     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
03039     #  @param AngleInRadians the angle of Rotation
03040     #  @param NbOfSteps number of steps
03041     #  @param Tolerance tolerance
03042     #  @param MakeGroups forces the generation of new groups from existing ones
03043     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
03044     #                    of all steps, else - size of each step
03045     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03046     #  @ingroup l2_modif_extrurev
03047     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03048                               MakeGroups=False, TotalAngle=False):
03049         if ( isinstance( theObject, Mesh )):
03050             theObject = theObject.GetMesh()
03051         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03052             Axis = self.smeshpyD.GetAxisStruct(Axis)
03053         AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
03054         NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
03055         Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
03056         self.mesh.SetParameters(Parameters)
03057         if TotalAngle and NbOfSteps:
03058             AngleInRadians /= NbOfSteps
03059         if MakeGroups:
03060             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
03061                                                              NbOfSteps, Tolerance)
03062         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03063         return []
03064 
03065     ## Generates new elements by extrusion of the elements with given ids
03066     #  @param IDsOfElements the list of elements ids for extrusion
03067     #  @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03068     #  @param NbOfSteps the number of steps
03069     #  @param MakeGroups forces the generation of new groups from existing ones
03070     #  @param IsNodes is True if elements with given ids are nodes
03071     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03072     #  @ingroup l2_modif_extrurev
03073     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
03074         if IDsOfElements == []:
03075             IDsOfElements = self.GetElementsId()
03076         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03077             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03078         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
03079         Parameters = StepVector.PS.parameters + var_separator + Parameters
03080         self.mesh.SetParameters(Parameters)
03081         if MakeGroups:
03082             if(IsNodes):
03083                 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
03084             else:
03085                 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
03086         if(IsNodes):
03087             self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
03088         else:
03089             self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
03090         return []
03091 
03092     ## Generates new elements by extrusion of the elements with given ids
03093     #  @param IDsOfElements is ids of elements
03094     #  @param StepVector vector, defining the direction and value of extrusion
03095     #  @param NbOfSteps the number of steps
03096     #  @param ExtrFlags sets flags for extrusion
03097     #  @param SewTolerance uses for comparing locations of nodes if flag
03098     #         EXTRUSION_FLAG_SEW is set
03099     #  @param MakeGroups forces the generation of new groups from existing ones
03100     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03101     #  @ingroup l2_modif_extrurev
03102     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
03103                           ExtrFlags, SewTolerance, MakeGroups=False):
03104         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03105             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03106         if MakeGroups:
03107             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
03108                                                            ExtrFlags, SewTolerance)
03109         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
03110                                       ExtrFlags, SewTolerance)
03111         return []
03112 
03113     ## Generates new elements by extrusion of the elements which belong to the object
03114     #  @param theObject the object which elements should be processed.
03115     #                   It can be a mesh, a sub mesh or a group.
03116     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03117     #  @param NbOfSteps the number of steps
03118     #  @param MakeGroups forces the generation of new groups from existing ones
03119     #  @param  IsNodes is True if elements which belong to the object are nodes
03120     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03121     #  @ingroup l2_modif_extrurev
03122     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
03123         if ( isinstance( theObject, Mesh )):
03124             theObject = theObject.GetMesh()
03125         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03126             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03127         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
03128         Parameters = StepVector.PS.parameters + var_separator + Parameters
03129         self.mesh.SetParameters(Parameters)
03130         if MakeGroups:
03131             if(IsNodes):
03132                 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
03133             else:
03134                 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
03135         if(IsNodes):
03136             self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
03137         else:
03138             self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
03139         return []
03140 
03141     ## Generates new elements by extrusion of the elements which belong to the object
03142     #  @param theObject object which elements should be processed.
03143     #                   It can be a mesh, a sub mesh or a group.
03144     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03145     #  @param NbOfSteps the number of steps
03146     #  @param MakeGroups to generate new groups from existing ones
03147     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03148     #  @ingroup l2_modif_extrurev
03149     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03150         if ( isinstance( theObject, Mesh )):
03151             theObject = theObject.GetMesh()
03152         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03153             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03154         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
03155         Parameters = StepVector.PS.parameters + var_separator + Parameters
03156         self.mesh.SetParameters(Parameters)
03157         if MakeGroups:
03158             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
03159         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
03160         return []
03161 
03162     ## Generates new elements by extrusion of the elements which belong to the object
03163     #  @param theObject object which elements should be processed.
03164     #                   It can be a mesh, a sub mesh or a group.
03165     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03166     #  @param NbOfSteps the number of steps
03167     #  @param MakeGroups forces the generation of new groups from existing ones
03168     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03169     #  @ingroup l2_modif_extrurev
03170     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03171         if ( isinstance( theObject, Mesh )):
03172             theObject = theObject.GetMesh()
03173         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03174             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03175         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
03176         Parameters = StepVector.PS.parameters + var_separator + Parameters
03177         self.mesh.SetParameters(Parameters)
03178         if MakeGroups:
03179             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
03180         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
03181         return []
03182 
03183 
03184 
03185     ## Generates new elements by extrusion of the given elements
03186     #  The path of extrusion must be a meshed edge.
03187     #  @param Base mesh or group, or submesh, or list of ids of elements for extrusion
03188     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
03189     #  @param NodeStart the start node from Path. Defines the direction of extrusion
03190     #  @param HasAngles allows the shape to be rotated around the path
03191     #                   to get the resulting mesh in a helical fashion
03192     #  @param Angles list of angles in radians
03193     #  @param LinearVariation forces the computation of rotation angles as linear
03194     #                         variation of the given Angles along path steps
03195     #  @param HasRefPoint allows using the reference point
03196     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03197     #         The User can specify any point as the Reference Point.
03198     #  @param MakeGroups forces the generation of new groups from existing ones
03199     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
03200     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03201     #          only SMESH::Extrusion_Error otherwise
03202     #  @ingroup l2_modif_extrurev
03203     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
03204                             HasAngles, Angles, LinearVariation,
03205                             HasRefPoint, RefPoint, MakeGroups, ElemType):
03206         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03207             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03208             pass
03209         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
03210         Parameters = AnglesParameters + var_separator + RefPoint.parameters
03211         self.mesh.SetParameters(Parameters)
03212 
03213         if (isinstance(Path, Mesh)): Path = Path.GetMesh()
03214 
03215         if isinstance(Base, list):
03216             IDsOfElements = []
03217             if Base == []: IDsOfElements = self.GetElementsId()
03218             else: IDsOfElements = Base
03219             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
03220                                                    HasAngles, Angles, LinearVariation,
03221                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
03222         else:
03223             if isinstance(Base, Mesh): Base = Base.GetMesh()
03224             if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
03225                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
03226                                                           HasAngles, Angles, LinearVariation,
03227                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
03228             else:
03229                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
03230 
03231 
03232     ## Generates new elements by extrusion of the given elements
03233     #  The path of extrusion must be a meshed edge.
03234     #  @param IDsOfElements ids of elements
03235     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
03236     #  @param PathShape shape(edge) defines the sub-mesh for the path
03237     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03238     #  @param HasAngles allows the shape to be rotated around the path
03239     #                   to get the resulting mesh in a helical fashion
03240     #  @param Angles list of angles in radians
03241     #  @param HasRefPoint allows using the reference point
03242     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03243     #         The User can specify any point as the Reference Point.
03244     #  @param MakeGroups forces the generation of new groups from existing ones
03245     #  @param LinearVariation forces the computation of rotation angles as linear
03246     #                         variation of the given Angles along path steps
03247     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03248     #          only SMESH::Extrusion_Error otherwise
03249     #  @ingroup l2_modif_extrurev
03250     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
03251                            HasAngles, Angles, HasRefPoint, RefPoint,
03252                            MakeGroups=False, LinearVariation=False):
03253         if IDsOfElements == []:
03254             IDsOfElements = self.GetElementsId()
03255         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03256             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03257             pass
03258         if ( isinstance( PathMesh, Mesh )):
03259             PathMesh = PathMesh.GetMesh()
03260         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
03261         Parameters = AnglesParameters + var_separator + RefPoint.parameters
03262         self.mesh.SetParameters(Parameters)
03263         if HasAngles and Angles and LinearVariation:
03264             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03265             pass
03266         if MakeGroups:
03267             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
03268                                                             PathShape, NodeStart, HasAngles,
03269                                                             Angles, HasRefPoint, RefPoint)
03270         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
03271                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
03272 
03273     ## Generates new elements by extrusion of the elements which belong to the object
03274     #  The path of extrusion must be a meshed edge.
03275     #  @param theObject the object which elements should be processed.
03276     #                   It can be a mesh, a sub mesh or a group.
03277     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
03278     #  @param PathShape shape(edge) defines the sub-mesh for the path
03279     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03280     #  @param HasAngles allows the shape to be rotated around the path
03281     #                   to get the resulting mesh in a helical fashion
03282     #  @param Angles list of angles
03283     #  @param HasRefPoint allows using the reference point
03284     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03285     #         The User can specify any point as the Reference Point.
03286     #  @param MakeGroups forces the generation of new groups from existing ones
03287     #  @param LinearVariation forces the computation of rotation angles as linear
03288     #                         variation of the given Angles along path steps
03289     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03290     #          only SMESH::Extrusion_Error otherwise
03291     #  @ingroup l2_modif_extrurev
03292     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
03293                                  HasAngles, Angles, HasRefPoint, RefPoint,
03294                                  MakeGroups=False, LinearVariation=False):
03295         if ( isinstance( theObject, Mesh )):
03296             theObject = theObject.GetMesh()
03297         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03298             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03299         if ( isinstance( PathMesh, Mesh )):
03300             PathMesh = PathMesh.GetMesh()
03301         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
03302         Parameters = AnglesParameters + var_separator + RefPoint.parameters
03303         self.mesh.SetParameters(Parameters)
03304         if HasAngles and Angles and LinearVariation:
03305             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03306             pass
03307         if MakeGroups:
03308             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
03309                                                                   PathShape, NodeStart, HasAngles,
03310                                                                   Angles, HasRefPoint, RefPoint)
03311         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
03312                                                     NodeStart, HasAngles, Angles, HasRefPoint,
03313                                                     RefPoint)
03314 
03315     ## Generates new elements by extrusion of the elements which belong to the object
03316     #  The path of extrusion must be a meshed edge.
03317     #  @param theObject the object which elements should be processed.
03318     #                   It can be a mesh, a sub mesh or a group.
03319     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
03320     #  @param PathShape shape(edge) defines the sub-mesh for the path
03321     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03322     #  @param HasAngles allows the shape to be rotated around the path
03323     #                   to get the resulting mesh in a helical fashion
03324     #  @param Angles list of angles
03325     #  @param HasRefPoint allows using the reference point
03326     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03327     #         The User can specify any point as the Reference Point.
03328     #  @param MakeGroups forces the generation of new groups from existing ones
03329     #  @param LinearVariation forces the computation of rotation angles as linear
03330     #                         variation of the given Angles along path steps
03331     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03332     #          only SMESH::Extrusion_Error otherwise
03333     #  @ingroup l2_modif_extrurev
03334     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
03335                                    HasAngles, Angles, HasRefPoint, RefPoint,
03336                                    MakeGroups=False, LinearVariation=False):
03337         if ( isinstance( theObject, Mesh )):
03338             theObject = theObject.GetMesh()
03339         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03340             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03341         if ( isinstance( PathMesh, Mesh )):
03342             PathMesh = PathMesh.GetMesh()
03343         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
03344         Parameters = AnglesParameters + var_separator + RefPoint.parameters
03345         self.mesh.SetParameters(Parameters)
03346         if HasAngles and Angles and LinearVariation:
03347             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03348             pass
03349         if MakeGroups:
03350             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
03351                                                                     PathShape, NodeStart, HasAngles,
03352                                                                     Angles, HasRefPoint, RefPoint)
03353         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
03354                                                       NodeStart, HasAngles, Angles, HasRefPoint,
03355                                                       RefPoint)
03356 
03357     ## Generates new elements by extrusion of the elements which belong to the object
03358     #  The path of extrusion must be a meshed edge.
03359     #  @param theObject the object which elements should be processed.
03360     #                   It can be a mesh, a sub mesh or a group.
03361     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
03362     #  @param PathShape shape(edge) defines the sub-mesh for the path
03363     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03364     #  @param HasAngles allows the shape to be rotated around the path
03365     #                   to get the resulting mesh in a helical fashion
03366     #  @param Angles list of angles
03367     #  @param HasRefPoint allows using the reference point
03368     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03369     #         The User can specify any point as the Reference Point.
03370     #  @param MakeGroups forces the generation of new groups from existing ones
03371     #  @param LinearVariation forces the computation of rotation angles as linear
03372     #                         variation of the given Angles along path steps
03373     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03374     #          only SMESH::Extrusion_Error otherwise
03375     #  @ingroup l2_modif_extrurev
03376     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
03377                                    HasAngles, Angles, HasRefPoint, RefPoint,
03378                                    MakeGroups=False, LinearVariation=False):
03379         if ( isinstance( theObject, Mesh )):
03380             theObject = theObject.GetMesh()
03381         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03382             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03383         if ( isinstance( PathMesh, Mesh )):
03384             PathMesh = PathMesh.GetMesh()
03385         Angles,AnglesParameters,hasVars = ParseAngles(Angles)
03386         Parameters = AnglesParameters + var_separator + RefPoint.parameters
03387         self.mesh.SetParameters(Parameters)
03388         if HasAngles and Angles and LinearVariation:
03389             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03390             pass
03391         if MakeGroups:
03392             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
03393                                                                     PathShape, NodeStart, HasAngles,
03394                                                                     Angles, HasRefPoint, RefPoint)
03395         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
03396                                                       NodeStart, HasAngles, Angles, HasRefPoint,
03397                                                       RefPoint)
03398 
03399     ## Creates a symmetrical copy of mesh elements
03400     #  @param IDsOfElements list of elements ids
03401     #  @param Mirror is AxisStruct or geom object(point, line, plane)
03402     #  @param theMirrorType is  POINT, AXIS or PLANE
03403     #  If the Mirror is a geom object this parameter is unnecessary
03404     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
03405     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03406     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03407     #  @ingroup l2_modif_trsf
03408     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
03409         if IDsOfElements == []:
03410             IDsOfElements = self.GetElementsId()
03411         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03412             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03413         self.mesh.SetParameters(Mirror.parameters)
03414         if Copy and MakeGroups:
03415             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
03416         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
03417         return []
03418 
03419     ## Creates a new mesh by a symmetrical copy of mesh elements
03420     #  @param IDsOfElements the list of elements ids
03421     #  @param Mirror is AxisStruct or geom object (point, line, plane)
03422     #  @param theMirrorType is  POINT, AXIS or PLANE
03423     #  If the Mirror is a geom object this parameter is unnecessary
03424     #  @param MakeGroups to generate new groups from existing ones
03425     #  @param NewMeshName a name of the new mesh to create
03426     #  @return instance of Mesh class
03427     #  @ingroup l2_modif_trsf
03428     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
03429         if IDsOfElements == []:
03430             IDsOfElements = self.GetElementsId()
03431         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03432             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03433         self.mesh.SetParameters(Mirror.parameters)
03434         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
03435                                           MakeGroups, NewMeshName)
03436         return Mesh(self.smeshpyD,self.geompyD,mesh)
03437 
03438     ## Creates a symmetrical copy of the object
03439     #  @param theObject mesh, submesh or group
03440     #  @param Mirror AxisStruct or geom object (point, line, plane)
03441     #  @param theMirrorType is  POINT, AXIS or PLANE
03442     #  If the Mirror is a geom object this parameter is unnecessary
03443     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
03444     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03445     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03446     #  @ingroup l2_modif_trsf
03447     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
03448         if ( isinstance( theObject, Mesh )):
03449             theObject = theObject.GetMesh()
03450         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03451             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03452         self.mesh.SetParameters(Mirror.parameters)
03453         if Copy and MakeGroups:
03454             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
03455         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
03456         return []
03457 
03458     ## Creates a new mesh by a symmetrical copy of the object
03459     #  @param theObject mesh, submesh or group
03460     #  @param Mirror AxisStruct or geom object (point, line, plane)
03461     #  @param theMirrorType POINT, AXIS or PLANE
03462     #  If the Mirror is a geom object this parameter is unnecessary
03463     #  @param MakeGroups forces the generation of new groups from existing ones
03464     #  @param NewMeshName the name of the new mesh to create
03465     #  @return instance of Mesh class
03466     #  @ingroup l2_modif_trsf
03467     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
03468         if ( isinstance( theObject, Mesh )):
03469             theObject = theObject.GetMesh()
03470         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03471             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03472         self.mesh.SetParameters(Mirror.parameters)
03473         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
03474                                                 MakeGroups, NewMeshName)
03475         return Mesh( self.smeshpyD,self.geompyD,mesh )
03476 
03477     ## Translates the elements
03478     #  @param IDsOfElements list of elements ids
03479     #  @param Vector the direction of translation (DirStruct or vector)
03480     #  @param Copy allows copying the translated elements
03481     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03482     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03483     #  @ingroup l2_modif_trsf
03484     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
03485         if IDsOfElements == []:
03486             IDsOfElements = self.GetElementsId()
03487         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03488             Vector = self.smeshpyD.GetDirStruct(Vector)
03489         self.mesh.SetParameters(Vector.PS.parameters)
03490         if Copy and MakeGroups:
03491             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
03492         self.editor.Translate(IDsOfElements, Vector, Copy)
03493         return []
03494 
03495     ## Creates a new mesh of translated elements
03496     #  @param IDsOfElements list of elements ids
03497     #  @param Vector the direction of translation (DirStruct or vector)
03498     #  @param MakeGroups forces the generation of new groups from existing ones
03499     #  @param NewMeshName the name of the newly created mesh
03500     #  @return instance of Mesh class
03501     #  @ingroup l2_modif_trsf
03502     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
03503         if IDsOfElements == []:
03504             IDsOfElements = self.GetElementsId()
03505         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03506             Vector = self.smeshpyD.GetDirStruct(Vector)
03507         self.mesh.SetParameters(Vector.PS.parameters)
03508         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
03509         return Mesh ( self.smeshpyD, self.geompyD, mesh )
03510 
03511     ## Translates the object
03512     #  @param theObject the object to translate (mesh, submesh, or group)
03513     #  @param Vector direction of translation (DirStruct or geom vector)
03514     #  @param Copy allows copying the translated elements
03515     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03516     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03517     #  @ingroup l2_modif_trsf
03518     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
03519         if ( isinstance( theObject, Mesh )):
03520             theObject = theObject.GetMesh()
03521         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03522             Vector = self.smeshpyD.GetDirStruct(Vector)
03523         self.mesh.SetParameters(Vector.PS.parameters)
03524         if Copy and MakeGroups:
03525             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
03526         self.editor.TranslateObject(theObject, Vector, Copy)
03527         return []
03528 
03529     ## Creates a new mesh from the translated object
03530     #  @param theObject the object to translate (mesh, submesh, or group)
03531     #  @param Vector the direction of translation (DirStruct or geom vector)
03532     #  @param MakeGroups forces the generation of new groups from existing ones
03533     #  @param NewMeshName the name of the newly created mesh
03534     #  @return instance of Mesh class
03535     #  @ingroup l2_modif_trsf
03536     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
03537         if (isinstance(theObject, Mesh)):
03538             theObject = theObject.GetMesh()
03539         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
03540             Vector = self.smeshpyD.GetDirStruct(Vector)
03541         self.mesh.SetParameters(Vector.PS.parameters)
03542         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
03543         return Mesh( self.smeshpyD, self.geompyD, mesh )
03544 
03545 
03546 
03547     ## Scales the object
03548     #  @param theObject - the object to translate (mesh, submesh, or group)
03549     #  @param thePoint - base point for scale
03550     #  @param theScaleFact - list of 1-3 scale factors for axises
03551     #  @param Copy - allows copying the translated elements
03552     #  @param MakeGroups - forces the generation of new groups from existing
03553     #                      ones (if Copy)
03554     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
03555     #          empty list otherwise
03556     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
03557         if ( isinstance( theObject, Mesh )):
03558             theObject = theObject.GetMesh()
03559         if ( isinstance( theObject, list )):
03560             theObject = self.GetIDSource(theObject, SMESH.ALL)
03561 
03562         self.mesh.SetParameters(thePoint.parameters)
03563 
03564         if Copy and MakeGroups:
03565             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
03566         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
03567         return []
03568 
03569     ## Creates a new mesh from the translated object
03570     #  @param theObject - the object to translate (mesh, submesh, or group)
03571     #  @param thePoint - base point for scale
03572     #  @param theScaleFact - list of 1-3 scale factors for axises
03573     #  @param MakeGroups - forces the generation of new groups from existing ones
03574     #  @param NewMeshName - the name of the newly created mesh
03575     #  @return instance of Mesh class
03576     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
03577         if (isinstance(theObject, Mesh)):
03578             theObject = theObject.GetMesh()
03579         if ( isinstance( theObject, list )):
03580             theObject = self.GetIDSource(theObject,SMESH.ALL)
03581 
03582         self.mesh.SetParameters(thePoint.parameters)
03583         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
03584                                          MakeGroups, NewMeshName)
03585         return Mesh( self.smeshpyD, self.geompyD, mesh )
03586 
03587 
03588 
03589     ## Rotates the elements
03590     #  @param IDsOfElements list of elements ids
03591     #  @param Axis the axis of rotation (AxisStruct or geom line)
03592     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
03593     #  @param Copy allows copying the rotated elements
03594     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03595     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03596     #  @ingroup l2_modif_trsf
03597     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
03598         if IDsOfElements == []:
03599             IDsOfElements = self.GetElementsId()
03600         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03601             Axis = self.smeshpyD.GetAxisStruct(Axis)
03602         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
03603         Parameters = Axis.parameters + var_separator + Parameters
03604         self.mesh.SetParameters(Parameters)
03605         if Copy and MakeGroups:
03606             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
03607         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
03608         return []
03609 
03610     ## Creates a new mesh of rotated elements
03611     #  @param IDsOfElements list of element ids
03612     #  @param Axis the axis of rotation (AxisStruct or geom line)
03613     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
03614     #  @param MakeGroups forces the generation of new groups from existing ones
03615     #  @param NewMeshName the name of the newly created mesh
03616     #  @return instance of Mesh class
03617     #  @ingroup l2_modif_trsf
03618     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
03619         if IDsOfElements == []:
03620             IDsOfElements = self.GetElementsId()
03621         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03622             Axis = self.smeshpyD.GetAxisStruct(Axis)
03623         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
03624         Parameters = Axis.parameters + var_separator + Parameters
03625         self.mesh.SetParameters(Parameters)
03626         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
03627                                           MakeGroups, NewMeshName)
03628         return Mesh( self.smeshpyD, self.geompyD, mesh )
03629 
03630     ## Rotates the object
03631     #  @param theObject the object to rotate( mesh, submesh, or group)
03632     #  @param Axis the axis of rotation (AxisStruct or geom line)
03633     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
03634     #  @param Copy allows copying the rotated elements
03635     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03636     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03637     #  @ingroup l2_modif_trsf
03638     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
03639         if (isinstance(theObject, Mesh)):
03640             theObject = theObject.GetMesh()
03641         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
03642             Axis = self.smeshpyD.GetAxisStruct(Axis)
03643         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
03644         Parameters = Axis.parameters + ":" + Parameters
03645         self.mesh.SetParameters(Parameters)
03646         if Copy and MakeGroups:
03647             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
03648         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
03649         return []
03650 
03651     ## Creates a new mesh from the rotated object
03652     #  @param theObject the object to rotate (mesh, submesh, or group)
03653     #  @param Axis the axis of rotation (AxisStruct or geom line)
03654     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
03655     #  @param MakeGroups forces the generation of new groups from existing ones
03656     #  @param NewMeshName the name of the newly created mesh
03657     #  @return instance of Mesh class
03658     #  @ingroup l2_modif_trsf
03659     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
03660         if (isinstance( theObject, Mesh )):
03661             theObject = theObject.GetMesh()
03662         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
03663             Axis = self.smeshpyD.GetAxisStruct(Axis)
03664         AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
03665         Parameters = Axis.parameters + ":" + Parameters
03666         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
03667                                                        MakeGroups, NewMeshName)
03668         self.mesh.SetParameters(Parameters)
03669         return Mesh( self.smeshpyD, self.geompyD, mesh )
03670 
03671     ## Finds groups of ajacent nodes within Tolerance.
03672     #  @param Tolerance the value of tolerance
03673     #  @return the list of groups of nodes
03674     #  @ingroup l2_modif_trsf
03675     def FindCoincidentNodes (self, Tolerance):
03676         return self.editor.FindCoincidentNodes(Tolerance)
03677 
03678     ## Finds groups of ajacent nodes within Tolerance.
03679     #  @param Tolerance the value of tolerance
03680     #  @param SubMeshOrGroup SubMesh or Group
03681     #  @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
03682     #  @return the list of groups of nodes
03683     #  @ingroup l2_modif_trsf
03684     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
03685         if (isinstance( SubMeshOrGroup, Mesh )):
03686             SubMeshOrGroup = SubMeshOrGroup.GetMesh()
03687         if not isinstance( exceptNodes, list):
03688             exceptNodes = [ exceptNodes ]
03689         if exceptNodes and isinstance( exceptNodes[0], int):
03690             exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
03691         return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
03692 
03693     ## Merges nodes
03694     #  @param GroupsOfNodes the list of groups of nodes
03695     #  @ingroup l2_modif_trsf
03696     def MergeNodes (self, GroupsOfNodes):
03697         self.editor.MergeNodes(GroupsOfNodes)
03698 
03699     ## Finds the elements built on the same nodes.
03700     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
03701     #  @return a list of groups of equal elements
03702     #  @ingroup l2_modif_trsf
03703     def FindEqualElements (self, MeshOrSubMeshOrGroup):
03704         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
03705             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
03706         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
03707 
03708     ## Merges elements in each given group.
03709     #  @param GroupsOfElementsID groups of elements for merging
03710     #  @ingroup l2_modif_trsf
03711     def MergeElements(self, GroupsOfElementsID):
03712         self.editor.MergeElements(GroupsOfElementsID)
03713 
03714     ## Leaves one element and removes all other elements built on the same nodes.
03715     #  @ingroup l2_modif_trsf
03716     def MergeEqualElements(self):
03717         self.editor.MergeEqualElements()
03718 
03719     ## Sews free borders
03720     #  @return SMESH::Sew_Error
03721     #  @ingroup l2_modif_trsf
03722     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
03723                         FirstNodeID2, SecondNodeID2, LastNodeID2,
03724                         CreatePolygons, CreatePolyedrs):
03725         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
03726                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
03727                                           CreatePolygons, CreatePolyedrs)
03728 
03729     ## Sews conform free borders
03730     #  @return SMESH::Sew_Error
03731     #  @ingroup l2_modif_trsf
03732     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
03733                                FirstNodeID2, SecondNodeID2):
03734         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
03735                                                  FirstNodeID2, SecondNodeID2)
03736 
03737     ## Sews border to side
03738     #  @return SMESH::Sew_Error
03739     #  @ingroup l2_modif_trsf
03740     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
03741                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
03742         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
03743                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
03744 
03745     ## Sews two sides of a mesh. The nodes belonging to Side1 are
03746     #  merged with the nodes of elements of Side2.
03747     #  The number of elements in theSide1 and in theSide2 must be
03748     #  equal and they should have similar nodal connectivity.
03749     #  The nodes to merge should belong to side borders and
03750     #  the first node should be linked to the second.
03751     #  @return SMESH::Sew_Error
03752     #  @ingroup l2_modif_trsf
03753     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
03754                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
03755                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
03756         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
03757                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
03758                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
03759 
03760     ## Sets new nodes for the given element.
03761     #  @param ide the element id
03762     #  @param newIDs nodes ids
03763     #  @return If the number of nodes does not correspond to the type of element - returns false
03764     #  @ingroup l2_modif_edit
03765     def ChangeElemNodes(self, ide, newIDs):
03766         return self.editor.ChangeElemNodes(ide, newIDs)
03767 
03768     ## If during the last operation of MeshEditor some nodes were
03769     #  created, this method returns the list of their IDs, \n
03770     #  if new nodes were not created - returns empty list
03771     #  @return the list of integer values (can be empty)
03772     #  @ingroup l1_auxiliary
03773     def GetLastCreatedNodes(self):
03774         return self.editor.GetLastCreatedNodes()
03775 
03776     ## If during the last operation of MeshEditor some elements were
03777     #  created this method returns the list of their IDs, \n
03778     #  if new elements were not created - returns empty list
03779     #  @return the list of integer values (can be empty)
03780     #  @ingroup l1_auxiliary
03781     def GetLastCreatedElems(self):
03782         return self.editor.GetLastCreatedElems()
03783 
03784      ## Creates a hole in a mesh by doubling the nodes of some particular elements
03785     #  @param theNodes identifiers of nodes to be doubled
03786     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled)
03787     #         nodes. If list of element identifiers is empty then nodes are doubled but
03788     #         they not assigned to elements
03789     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03790     #  @ingroup l2_modif_edit
03791     def DoubleNodes(self, theNodes, theModifiedElems):
03792         return self.editor.DoubleNodes(theNodes, theModifiedElems)
03793 
03794     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03795     #  This method provided for convenience works as DoubleNodes() described above.
03796     #  @param theNodeId identifiers of node to be doubled
03797     #  @param theModifiedElems identifiers of elements to be updated
03798     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03799     #  @ingroup l2_modif_edit
03800     def DoubleNode(self, theNodeId, theModifiedElems):
03801         return self.editor.DoubleNode(theNodeId, theModifiedElems)
03802 
03803     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03804     #  This method provided for convenience works as DoubleNodes() described above.
03805     #  @param theNodes group of nodes to be doubled
03806     #  @param theModifiedElems group of elements to be updated.
03807     #  @param theMakeGroup forces the generation of a group containing new nodes.
03808     #  @return TRUE or a created group if operation has been completed successfully,
03809     #          FALSE or None otherwise
03810     #  @ingroup l2_modif_edit
03811     def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
03812         if theMakeGroup:
03813             return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
03814         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
03815 
03816     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03817     #  This method provided for convenience works as DoubleNodes() described above.
03818     #  @param theNodes list of groups of nodes to be doubled
03819     #  @param theModifiedElems list of groups of elements to be updated.
03820     #  @param theMakeGroup forces the generation of a group containing new nodes.
03821     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03822     #  @ingroup l2_modif_edit
03823     def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
03824         if theMakeGroup:
03825             return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
03826         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
03827 
03828     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03829     #  @param theElems - the list of elements (edges or faces) to be replicated
03830     #         The nodes for duplication could be found from these elements
03831     #  @param theNodesNot - list of nodes to NOT replicate
03832     #  @param theAffectedElems - the list of elements (cells and edges) to which the
03833     #         replicated nodes should be associated to.
03834     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03835     #  @ingroup l2_modif_edit
03836     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
03837         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
03838 
03839     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03840     #  @param theElems - the list of elements (edges or faces) to be replicated
03841     #         The nodes for duplication could be found from these elements
03842     #  @param theNodesNot - list of nodes to NOT replicate
03843     #  @param theShape - shape to detect affected elements (element which geometric center
03844     #         located on or inside shape).
03845     #         The replicated nodes should be associated to affected elements.
03846     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03847     #  @ingroup l2_modif_edit
03848     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
03849         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
03850 
03851     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03852     #  This method provided for convenience works as DoubleNodes() described above.
03853     #  @param theElems - group of of elements (edges or faces) to be replicated
03854     #  @param theNodesNot - group of nodes not to replicated
03855     #  @param theAffectedElems - group of elements to which the replicated nodes
03856     #         should be associated to.
03857     #  @param theMakeGroup forces the generation of a group containing new elements.
03858     #  @param theMakeNodeGroup forces the generation of a group containing new nodes.
03859     #  @return TRUE or created groups (one or two) if operation has been completed successfully,
03860     #          FALSE or None otherwise
03861     #  @ingroup l2_modif_edit
03862     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems,
03863                              theMakeGroup=False, theMakeNodeGroup=False):
03864         if theMakeGroup or theMakeNodeGroup:
03865             twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot,
03866                                                             theAffectedElems,
03867                                                             theMakeGroup, theMakeNodeGroup)
03868             if theMakeGroup and theMakeNodeGroup:
03869                 return twoGroups
03870             else:
03871                 return twoGroups[ int(theMakeNodeGroup) ]
03872         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
03873 
03874     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03875     #  This method provided for convenience works as DoubleNodes() described above.
03876     #  @param theElems - group of of elements (edges or faces) to be replicated
03877     #  @param theNodesNot - group of nodes not to replicated
03878     #  @param theShape - shape to detect affected elements (element which geometric center
03879     #         located on or inside shape).
03880     #         The replicated nodes should be associated to affected elements.
03881     #  @ingroup l2_modif_edit
03882     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
03883         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
03884 
03885     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03886     #  This method provided for convenience works as DoubleNodes() described above.
03887     #  @param theElems - list of groups of elements (edges or faces) to be replicated
03888     #  @param theNodesNot - list of groups of nodes not to replicated
03889     #  @param theAffectedElems - group of elements to which the replicated nodes
03890     #         should be associated to.
03891     #  @param theMakeGroup forces the generation of a group containing new elements.
03892     #  @param theMakeNodeGroup forces the generation of a group containing new nodes.
03893     #  @return TRUE or created groups (one or two) if operation has been completed successfully,
03894     #          FALSE or None otherwise
03895     #  @ingroup l2_modif_edit
03896     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems,
03897                              theMakeGroup=False, theMakeNodeGroup=False):
03898         if theMakeGroup or theMakeNodeGroup:
03899             twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot,
03900                                                              theAffectedElems,
03901                                                              theMakeGroup, theMakeNodeGroup)
03902             if theMakeGroup and theMakeNodeGroup:
03903                 return twoGroups
03904             else:
03905                 return twoGroups[ int(theMakeNodeGroup) ]
03906         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
03907 
03908     ## Creates a hole in a mesh by doubling the nodes of some particular elements
03909     #  This method provided for convenience works as DoubleNodes() described above.
03910     #  @param theElems - list of groups of elements (edges or faces) to be replicated
03911     #  @param theNodesNot - list of groups of nodes not to replicated
03912     #  @param theShape - shape to detect affected elements (element which geometric center
03913     #         located on or inside shape).
03914     #         The replicated nodes should be associated to affected elements.
03915     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03916     #  @ingroup l2_modif_edit
03917     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
03918         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
03919 
03920     ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
03921     # The list of groups must describe a partition of the mesh volumes.
03922     # The nodes of the internal faces at the boundaries of the groups are doubled.
03923     # In option, the internal faces are replaced by flat elements.
03924     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
03925     # @param theDomains - list of groups of volumes
03926     # @param createJointElems - if TRUE, create the elements
03927     # @return TRUE if operation has been completed successfully, FALSE otherwise
03928     def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
03929        return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
03930 
03931     ## Double nodes on some external faces and create flat elements.
03932     # Flat elements are mainly used by some types of mechanic calculations.
03933     #
03934     # Each group of the list must be constituted of faces.
03935     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
03936     # @param theGroupsOfFaces - list of groups of faces
03937     # @return TRUE if operation has been completed successfully, FALSE otherwise
03938     def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
03939         return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
03940 
03941     def _valueFromFunctor(self, funcType, elemId):
03942         fn = self.smeshpyD.GetFunctor(funcType)
03943         fn.SetMesh(self.mesh)
03944         if fn.GetElementType() == self.GetElementType(elemId, True):
03945             val = fn.GetValue(elemId)
03946         else:
03947             val = 0
03948         return val
03949 
03950     ## Get length of 1D element.
03951     #  @param elemId mesh element ID
03952     #  @return element's length value
03953     #  @ingroup l1_measurements
03954     def GetLength(self, elemId):
03955         return self._valueFromFunctor(SMESH.FT_Length, elemId)
03956 
03957     ## Get area of 2D element.
03958     #  @param elemId mesh element ID
03959     #  @return element's area value
03960     #  @ingroup l1_measurements
03961     def GetArea(self, elemId):
03962         return self._valueFromFunctor(SMESH.FT_Area, elemId)
03963 
03964     ## Get volume of 3D element.
03965     #  @param elemId mesh element ID
03966     #  @return element's volume value
03967     #  @ingroup l1_measurements
03968     def GetVolume(self, elemId):
03969         return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
03970 
03971     ## Get maximum element length.
03972     #  @param elemId mesh element ID
03973     #  @return element's maximum length value
03974     #  @ingroup l1_measurements
03975     def GetMaxElementLength(self, elemId):
03976         if self.GetElementType(elemId, True) == SMESH.VOLUME:
03977             ftype = SMESH.FT_MaxElementLength3D
03978         else:
03979             ftype = SMESH.FT_MaxElementLength2D
03980         return self._valueFromFunctor(ftype, elemId)
03981 
03982     ## Get aspect ratio of 2D or 3D element.
03983     #  @param elemId mesh element ID
03984     #  @return element's aspect ratio value
03985     #  @ingroup l1_measurements
03986     def GetAspectRatio(self, elemId):
03987         if self.GetElementType(elemId, True) == SMESH.VOLUME:
03988             ftype = SMESH.FT_AspectRatio3D
03989         else:
03990             ftype = SMESH.FT_AspectRatio
03991         return self._valueFromFunctor(ftype, elemId)
03992 
03993     ## Get warping angle of 2D element.
03994     #  @param elemId mesh element ID
03995     #  @return element's warping angle value
03996     #  @ingroup l1_measurements
03997     def GetWarping(self, elemId):
03998         return self._valueFromFunctor(SMESH.FT_Warping, elemId)
03999 
04000     ## Get minimum angle of 2D element.
04001     #  @param elemId mesh element ID
04002     #  @return element's minimum angle value
04003     #  @ingroup l1_measurements
04004     def GetMinimumAngle(self, elemId):
04005         return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
04006 
04007     ## Get taper of 2D element.
04008     #  @param elemId mesh element ID
04009     #  @return element's taper value
04010     #  @ingroup l1_measurements
04011     def GetTaper(self, elemId):
04012         return self._valueFromFunctor(SMESH.FT_Taper, elemId)
04013 
04014     ## Get skew of 2D element.
04015     #  @param elemId mesh element ID
04016     #  @return element's skew value
04017     #  @ingroup l1_measurements
04018     def GetSkew(self, elemId):
04019         return self._valueFromFunctor(SMESH.FT_Skew, elemId)
04020 
04021 ## The mother class to define algorithm, it is not recommended to use it directly.
04022 #
04023 #  For each meshing algorithm, a python class inheriting from class Mesh_Algorithm
04024 #  should be defined. This descendant class sould have two attributes defining the way
04025 # it is created by class Mesh (see e.g. class StdMeshersDC_Segment in StdMeshersDC.py).
04026 # - meshMethod attribute defines name of method of class Mesh by calling which the
04027 #   python class of algorithm is created. E.g. if in class MyPlugin_Algorithm
04028 #   meshMethod = "MyAlgorithm", then an instance of MyPlugin_Algorithm is created
04029 #   by the following code: my_algo = mesh.MyAlgorithm()
04030 # - algoType defines name of algorithm type and is used mostly to discriminate
04031 #   algorithms that are created by the same method of class Mesh. E.g. if
04032 #   MyPlugin_Algorithm.algoType = "MyPLUGIN" then it's creation code can be:
04033 #   my_algo = mesh.MyAlgorithm(algo="MyPLUGIN")
04034 #  @ingroup l2_algorithms
04035 class Mesh_Algorithm:
04036     #  @class Mesh_Algorithm
04037     #  @brief Class Mesh_Algorithm
04038 
04039     #def __init__(self,smesh):
04040     #    self.smesh=smesh
04041     def __init__(self):
04042         self.mesh = None
04043         self.geom = None
04044         self.subm = None
04045         self.algo = None
04046 
04047     ## Finds a hypothesis in the study by its type name and parameters.
04048     #  Finds only the hypotheses created in smeshpyD engine.
04049     #  @return SMESH.SMESH_Hypothesis
04050     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
04051         study = smeshpyD.GetCurrentStudy()
04052         #to do: find component by smeshpyD object, not by its data type
04053         scomp = study.FindComponent(smeshpyD.ComponentDataType())
04054         if scomp is not None:
04055             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
04056             # Check if the root label of the hypotheses exists
04057             if res and hypRoot is not None:
04058                 iter = study.NewChildIterator(hypRoot)
04059                 # Check all published hypotheses
04060                 while iter.More():
04061                     hypo_so_i = iter.Value()
04062                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
04063                     if attr is not None:
04064                         anIOR = attr.Value()
04065                         hypo_o_i = salome.orb.string_to_object(anIOR)
04066                         if hypo_o_i is not None:
04067                             # Check if this is a hypothesis
04068                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
04069                             if hypo_i is not None:
04070                                 # Check if the hypothesis belongs to current engine
04071                                 if smeshpyD.GetObjectId(hypo_i) > 0:
04072                                     # Check if this is the required hypothesis
04073                                     if hypo_i.GetName() == hypname:
04074                                         # Check arguments
04075                                         if CompareMethod(hypo_i, args):
04076                                             # found!!!
04077                                             return hypo_i
04078                                         pass
04079                                     pass
04080                                 pass
04081                             pass
04082                         pass
04083                     iter.Next()
04084                     pass
04085                 pass
04086             pass
04087         return None
04088 
04089     ## Finds the algorithm in the study by its type name.
04090     #  Finds only the algorithms, which have been created in smeshpyD engine.
04091     #  @return SMESH.SMESH_Algo
04092     def FindAlgorithm (self, algoname, smeshpyD):
04093         study = smeshpyD.GetCurrentStudy()
04094         if not study: return None
04095         #to do: find component by smeshpyD object, not by its data type
04096         scomp = study.FindComponent(smeshpyD.ComponentDataType())
04097         if scomp is not None:
04098             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
04099             # Check if the root label of the algorithms exists
04100             if res and hypRoot is not None:
04101                 iter = study.NewChildIterator(hypRoot)
04102                 # Check all published algorithms
04103                 while iter.More():
04104                     algo_so_i = iter.Value()
04105                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
04106                     if attr is not None:
04107                         anIOR = attr.Value()
04108                         algo_o_i = salome.orb.string_to_object(anIOR)
04109                         if algo_o_i is not None:
04110                             # Check if this is an algorithm
04111                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
04112                             if algo_i is not None:
04113                                 # Checks if the algorithm belongs to the current engine
04114                                 if smeshpyD.GetObjectId(algo_i) > 0:
04115                                     # Check if this is the required algorithm
04116                                     if algo_i.GetName() == algoname:
04117                                         # found!!!
04118                                         return algo_i
04119                                     pass
04120                                 pass
04121                             pass
04122                         pass
04123                     iter.Next()
04124                     pass
04125                 pass
04126             pass
04127         return None
04128 
04129     ## If the algorithm is global, returns 0; \n
04130     #  else returns the submesh associated to this algorithm.
04131     def GetSubMesh(self):
04132         return self.subm
04133 
04134     ## Returns the wrapped mesher.
04135     def GetAlgorithm(self):
04136         return self.algo
04137 
04138     ## Gets the list of hypothesis that can be used with this algorithm
04139     def GetCompatibleHypothesis(self):
04140         mylist = []
04141         if self.algo:
04142             mylist = self.algo.GetCompatibleHypothesis()
04143         return mylist
04144 
04145     ## Gets the name of the algorithm
04146     def GetName(self):
04147         GetName(self.algo)
04148 
04149     ## Sets the name to the algorithm
04150     def SetName(self, name):
04151         self.mesh.smeshpyD.SetName(self.algo, name)
04152 
04153     ## Gets the id of the algorithm
04154     def GetId(self):
04155         return self.algo.GetId()
04156 
04157     ## Private method.
04158     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
04159         if geom is None:
04160             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
04161         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
04162         if algo is None:
04163             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
04164             pass
04165         self.Assign(algo, mesh, geom)
04166         return self.algo
04167 
04168     ## Private method
04169     def Assign(self, algo, mesh, geom):
04170         if geom is None:
04171             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
04172         self.mesh = mesh
04173         name = ""
04174         if not geom:
04175             self.geom = mesh.geom
04176         else:
04177             self.geom = geom
04178             AssureGeomPublished( mesh, geom )
04179             try:
04180                 name = GetName(geom)
04181                 pass
04182             except:
04183                 pass
04184             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
04185         self.algo = algo
04186         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
04187         TreatHypoStatus( status, algo.GetName(), name, True )
04188         return
04189 
04190     def CompareHyp (self, hyp, args):
04191         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
04192         return False
04193 
04194     def CompareEqualHyp (self, hyp, args):
04195         return True
04196 
04197     ## Private method
04198     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
04199                     UseExisting=0, CompareMethod=""):
04200         hypo = None
04201         if UseExisting:
04202             if CompareMethod == "": CompareMethod = self.CompareHyp
04203             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
04204             pass
04205         if hypo is None:
04206             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
04207             a = ""
04208             s = "="
04209             for arg in args:
04210                 argStr = str(arg)
04211                 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
04212                     argStr = arg.GetStudyEntry()
04213                     if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
04214                 if len( argStr ) > 10:
04215                     argStr = argStr[:7]+"..."
04216                     if argStr[0] == '[': argStr += ']'
04217                 a = a + s + argStr
04218                 s = ","
04219                 pass
04220             if len(a) > 50:
04221                 a = a[:47]+"..."
04222             self.mesh.smeshpyD.SetName(hypo, hyp + a)
04223             pass
04224         geomName=""
04225         if self.geom:
04226             geomName = GetName(self.geom)
04227         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
04228         TreatHypoStatus( status, GetName(hypo), geomName, 0 )
04229         return hypo
04230 
04231     ## Returns entry of the shape to mesh in the study
04232     def MainShapeEntry(self):
04233         if not self.mesh or not self.mesh.GetMesh(): return ""
04234         if not self.mesh.GetMesh().HasShapeToMesh(): return ""
04235         shape = self.mesh.GetShape()
04236         return shape.GetStudyEntry()
04237 
04238     ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
04239     #  near mesh boundary. This hypothesis can be used by several 3D algorithms:
04240     #  NETGEN 3D, GHS3D, Hexahedron(i,j,k)
04241     #  @param thickness total thickness of layers of prisms
04242     #  @param numberOfLayers number of layers of prisms
04243     #  @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
04244     #  @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
04245     #  @ingroup l3_hypos_additi
04246     def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
04247         if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
04248             raise TypeError, "ViscousLayers are supported by 3D algorithms only"
04249         if not "ViscousLayers" in self.GetCompatibleHypothesis():
04250             raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
04251         if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
04252             ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
04253         hyp = self.Hypothesis("ViscousLayers",
04254                               [thickness, numberOfLayers, stretchFactor, ignoreFaces])
04255         hyp.SetTotalThickness(thickness)
04256         hyp.SetNumberLayers(numberOfLayers)
04257         hyp.SetStretchFactor(stretchFactor)
04258         hyp.SetIgnoreFaces(ignoreFaces)
04259         return hyp
04260 
04261     ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
04262     #  into a list acceptable to SetReversedEdges() of some 1D hypotheses
04263     #  @ingroup l3_hypos_1dhyps
04264     def ReversedEdgeIndices(self, reverseList):
04265         resList = []
04266         geompy = self.mesh.geompyD
04267         for i in reverseList:
04268             if isinstance( i, int ):
04269                 s = geompy.SubShapes(self.mesh.geom, [i])[0]
04270                 if s.GetShapeType() != geompyDC.GEOM.EDGE:
04271                     raise TypeError, "Not EDGE index given"
04272                 resList.append( i )
04273             elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
04274                 if i.GetShapeType() != geompyDC.GEOM.EDGE:
04275                     raise TypeError, "Not an EDGE given"
04276                 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
04277             elif len( i ) > 1:
04278                 e = i[0]
04279                 v = i[1]
04280                 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
04281                    not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
04282                     raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
04283                 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
04284                    e.GetShapeType() == geompyDC.GEOM.VERTEX:
04285                     v,e = e,v
04286                 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
04287                    v.GetShapeType() != geompyDC.GEOM.VERTEX:
04288                     raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
04289                 vFirst = FirstVertexOnCurve( e )
04290                 tol    = geompy.Tolerance( vFirst )[-1]
04291                 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
04292                     resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
04293             else:
04294                 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
04295         return resList
04296 
04297 
04298 class Pattern(SMESH._objref_SMESH_Pattern):
04299 
04300     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
04301         decrFun = lambda i: i-1
04302         theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
04303         theMesh.SetParameters(Parameters)
04304         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
04305 
04306     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
04307         decrFun = lambda i: i-1
04308         theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
04309         theMesh.SetParameters(Parameters)
04310         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
04311 
04312 #Registering the new proxy for Pattern
04313 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
04314 
04315 
04316 
04317 
04318 
04319 ## Private class used to bind methods creating algorithms to the class Mesh
04320 #
04321 class algoCreator:
04322     def __init__(self):
04323         self.mesh = None
04324         self.defaultAlgoType = ""
04325         self.algoTypeToClass = {}
04326 
04327     # Stores a python class of algorithm
04328     def add(self, algoClass):
04329         if type( algoClass ).__name__ == 'classobj' and \
04330            hasattr( algoClass, "algoType"):
04331             self.algoTypeToClass[ algoClass.algoType ] = algoClass
04332             if not self.defaultAlgoType and \
04333                hasattr( algoClass, "isDefault") and algoClass.isDefault:
04334                 self.defaultAlgoType = algoClass.algoType
04335             #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
04336 
04337     # creates a copy of self and assign mesh to the copy
04338     def copy(self, mesh):
04339         other = algoCreator()
04340         other.defaultAlgoType = self.defaultAlgoType
04341         other.algoTypeToClass  = self.algoTypeToClass
04342         other.mesh = mesh
04343         return other
04344 
04345     # creates an instance of algorithm
04346     def __call__(self,algo="",geom=0,*args):
04347         algoType = self.defaultAlgoType
04348         for arg in args + (algo,geom):
04349             if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
04350                 geom = arg
04351             if isinstance( arg, str ) and arg:
04352                 algoType = arg
04353         if not algoType and self.algoTypeToClass:
04354             algoType = self.algoTypeToClass.keys()[0]
04355         if self.algoTypeToClass.has_key( algoType ):
04356             #print "Create algo",algoType
04357             return self.algoTypeToClass[ algoType ]( self.mesh, geom )
04358         raise RuntimeError, "No class found for algo type %s" % algoType
04359         return None
04360 
04361 # Private class used to substitute and store variable parameters of hypotheses.
04362 class hypMethodWrapper:
04363     def __init__(self, hyp, method):
04364         self.hyp    = hyp
04365         self.method = method
04366         #print "REBIND:", method.__name__
04367         return
04368 
04369     # call a method of hypothesis with calling SetVarParameter() before
04370     def __call__(self,*args):
04371         if not args:
04372             return self.method( self.hyp, *args ) # hypothesis method with no args
04373 
04374         #print "MethWrapper.__call__",self.method.__name__, args
04375         try:
04376             parsed = ParseParameters(*args)     # replace variables with their values
04377             self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
04378             result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
04379         except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
04380             # maybe there is a replaced string arg which is not variable
04381             result = self.method( self.hyp, *args )
04382         except ValueError, detail: # raised by ParseParameters()
04383             try:
04384                 result = self.method( self.hyp, *args )
04385             except omniORB.CORBA.BAD_PARAM:
04386                 raise ValueError, detail # wrong variable name
04387 
04388         return result