Salome HOME
Merge from V6_3_BR branch (Windows porting) 27/10/2011
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index 5f3bfd6c4755eb03e7dae16f9b0c4e97f3f0e04c..29b6c39fdd41dac1032feb1efd16e8267b54e51d 100644 (file)
@@ -188,10 +188,10 @@ None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization
 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
 
 # Topology treatment way of BLSURF
-FromCAD, PreProcess, PreProcessPlus = 0,1,2
+FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
 
 # Element size flag of BLSURF
-DefaultSize, DefaultGeom, Custom = 0,0,1
+DefaultSize, DefaultGeom, BLSURF_Custom, SizeMap = 0,0,1,2
 
 PrecisionConfusion = 1e-07
 
@@ -509,6 +509,26 @@ def AssureGeomPublished(mesh, geom, name=''):
         mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
     return
 
+## Return the first vertex of a geomertical edge by ignoring orienation
+def FirstVertexOnCurve(edge):
+    from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
+    vv = SubShapeAll( edge, ShapeType["VERTEX"])
+    if not vv:
+        raise TypeError, "Given object has no vertices"
+    if len( vv ) == 1: return vv[0]
+    info = KindOfShape(edge)
+    xyz = info[1:4] # coords of the first vertex
+    xyz1  = PointCoordinates( vv[0] )
+    xyz2  = PointCoordinates( vv[1] )
+    dist1, dist2 = 0,0
+    for i in range(3):
+        dist1 += abs( xyz[i] - xyz1[i] )
+        dist2 += abs( xyz[i] - xyz2[i] )
+    if dist1 < dist2:
+        return vv[0]
+    else:
+        return vv[1]
+
 # end of l1_auxiliary
 ## @}
 
@@ -677,6 +697,17 @@ class smeshDC(SMESH._objref_SMESH_Gen):
             aMeshes.append(aMesh)
         return aMeshes, aStatus
 
+    ## Creates a Mesh object(s) importing data from the given SAUV file
+    #  @return a list of Mesh class instances
+    #  @ingroup l2_impexp
+    def CreateMeshesFromSAUV( self,theFileName ):
+        aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
+        aMeshes = []
+        for iMesh in range(len(aSmeshMeshes)) :
+            aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
+            aMeshes.append(aMesh)
+        return aMeshes, aStatus
+
     ## Creates a Mesh object importing data from the given STL file
     #  @return an instance of Mesh class
     #  @ingroup l2_impexp
@@ -685,6 +716,17 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
         return aMesh
 
+    ## Creates Mesh objects importing data from the given CGNS file
+    #  @return an instance of Mesh class
+    #  @ingroup l2_impexp
+    def CreateMeshesFromCGNS( self, theFileName ):
+        aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
+        aMeshes = []
+        for iMesh in range(len(aSmeshMeshes)) :
+            aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
+            aMeshes.append(aMesh)
+        return aMeshes, aStatus
+
     ## Concatenate the given meshes into one mesh.
     #  @return an instance of Mesh class
     #  @param meshes the meshes to combine into one mesh
@@ -785,6 +827,8 @@ class smeshDC(SMESH._objref_SMESH_Gen):
                      UnaryOp=FT_Undefined,
                      BinaryOp=FT_Undefined,
                      Tolerance=1e-07):
+        if not CritType in SMESH.FunctorType._items:
+            raise TypeError, "CritType should be of SMESH.FunctorType"
         aCriterion = self.GetEmptyCriterion()
         aCriterion.TypeOfElement = elementType
         aCriterion.Type = self.EnumToLong(CritType)
@@ -840,6 +884,7 @@ class smeshDC(SMESH._objref_SMESH_Gen):
             # Checks the treshold
             try:
                 aCriterion.Threshold = self.EnumToLong(aTreshold)
+                assert( aTreshold in SMESH.GeometryType._items )
             except:
                 if isinstance(aTreshold, int):
                     aCriterion.Threshold = aTreshold
@@ -1379,6 +1424,15 @@ class Mesh:
     def Projection1D(self, geom=0):
         return Mesh_Projection1D(self,  geom)
 
+    ## Creates a projection 1D-2D algorithm for faces.
+    #  If the optional \a geom parameter is not set, this algorithm is global.
+    #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
+    #  @param geom If defined, the subshape to be meshed
+    #  @return an instance of Mesh_Projection2D algorithm
+    #  @ingroup l3_algos_proj
+    def Projection1D2D(self, geom=0):
+        return Mesh_Projection2D(self,  geom, "Projection_1D2D")
+
     ## Creates a projection 2D algorithm for faces.
     #  If the optional \a geom parameter is not set, this algorithm is global.
     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
@@ -1386,7 +1440,7 @@ class Mesh:
     #  @return an instance of Mesh_Projection2D algorithm
     #  @ingroup l3_algos_proj
     def Projection2D(self, geom=0):
-        return Mesh_Projection2D(self,  geom)
+        return Mesh_Projection2D(self,  geom, "Projection_2D")
 
     ## Creates a projection 3D algorithm for solids.
     #  If the optional \a geom parameter is not set, this algorithm is global.
@@ -1704,6 +1758,15 @@ class Mesh:
         else:
             self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
 
+    ## Exports the mesh in a file in SAUV format
+    #  @param f is the file name
+    #  @param auto_groups boolean parameter for creating/not creating
+    #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
+    #  the typical use is auto_groups=false.
+    #  @ingroup l2_impexp
+    def ExportSAUV(self, f, auto_groups=0):
+        self.mesh.ExportSAUV(f, auto_groups)
+
     ## Exports the mesh in a file in DAT format
     #  @param f the file name
     #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
@@ -1741,6 +1804,19 @@ class Mesh:
         else:
             self.mesh.ExportSTL(f, ascii)
 
+    ## Exports the mesh in a file in CGNS format
+    #  @param f is the file name
+    #  @param overwrite boolean parameter for overwriting/not overwriting the file
+    #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
+    #  @ingroup l2_impexp
+    def ExportCGNS(self, f, overwrite=1, meshPart=None):
+        if isinstance( meshPart, list ):
+            meshPart = self.GetIDSource( meshPart, SMESH.ALL )
+        if isinstance( meshPart, Mesh ):
+            meshPart = meshPart.mesh
+        elif not meshPart:
+            meshPart = self.mesh
+        self.mesh.ExportCGNS(meshPart, f, overwrite)
 
     # Operations with groups:
     # ----------------------
@@ -4544,6 +4620,42 @@ class Mesh_Algorithm:
         hyp.SetIgnoreFaces(ignoreFaces)
         return hyp
 
+    ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
+    #  into a list acceptable to SetReversedEdges() of some 1D hypotheses
+    #  @ingroupl3_hypos_1dhyps
+    def ReversedEdgeIndices(self, reverseList):
+        resList = []
+        geompy = self.mesh.geompyD
+        for i in reverseList:
+            if isinstance( i, int ):
+                s = geompy.SubShapes(self.mesh.geom, [i])[0]
+                if s.GetShapeType() != geompyDC.GEOM.EDGE:
+                    raise TypeError, "Not EDGE index given"
+                resList.append( i )
+            elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
+                if i.GetShapeType() != geompyDC.GEOM.EDGE:
+                    raise TypeError, "Not an EDGE given"
+                resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
+            elif len( i ) > 1:
+                e = i[0]
+                v = i[1]
+                if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
+                   not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
+                    raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
+                if v.GetShapeType() == geompyDC.GEOM.EDGE and \
+                   e.GetShapeType() == geompyDC.GEOM.VERTEX:
+                    v,e = e,v
+                if e.GetShapeType() != geompyDC.GEOM.EDGE or \
+                   v.GetShapeType() != geompyDC.GEOM.VERTEX:
+                    raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
+                vFirst = FirstVertexOnCurve( e )
+                tol    = geompy.Tolerance( vFirst )[-1]
+                if geompy.MinDistance( v, vFirst ) > 1.5*tol:
+                    resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
+            else:
+                raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
+        return resList
+
 # Public class: Mesh_Segment
 # --------------------------
 
@@ -4616,7 +4728,8 @@ class Mesh_Segment(Mesh_Algorithm):
     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
     #  @param n for the number of segments that cut an edge
     #  @param s for the scale factor (optional)
-    #  @param reversedEdges is a list of edges to mesh using reversed orientation
+    #  @param reversedEdges is a list of edges to mesh using reversed orientation.
+    #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
     #  @param UseExisting if ==true - searches for an existing hypothesis created with
     #                     the same parameters, else (default) - create a new one
     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
@@ -4625,20 +4738,19 @@ class Mesh_Segment(Mesh_Algorithm):
         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
             reversedEdges, UseExisting = [], reversedEdges
         entry = self.MainShapeEntry()
-        if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
-            reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
+        reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
         if s == []:
-            hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
+            hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
                                   UseExisting=UseExisting,
                                   CompareMethod=self.CompareNumberOfSegments)
         else:
-            hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
+            hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
                                   UseExisting=UseExisting,
                                   CompareMethod=self.CompareNumberOfSegments)
             hyp.SetDistrType( 1 )
             hyp.SetScaleFactor(s)
         hyp.SetNumberOfSegments(n)
-        hyp.SetReversedEdges( reversedEdges )
+        hyp.SetReversedEdges( reversedEdgeInd )
         hyp.SetObjectEntry( entry )
         return hyp
 
@@ -4661,7 +4773,8 @@ class Mesh_Segment(Mesh_Algorithm):
     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
     #  @param start defines the length of the first segment
     #  @param end   defines the length of the last  segment
-    #  @param reversedEdges is a list of edges to mesh using reversed orientation
+    #  @param reversedEdges is a list of edges to mesh using reversed orientation.
+    #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
     #  @param UseExisting if ==true - searches for an existing hypothesis created with
     #                     the same parameters, else (default) - creates a new one
     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
@@ -4669,15 +4782,14 @@ class Mesh_Segment(Mesh_Algorithm):
     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
             reversedEdges, UseExisting = [], reversedEdges
-        if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
-            reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
+        reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
         entry = self.MainShapeEntry()
-        hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
+        hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
                               UseExisting=UseExisting,
                               CompareMethod=self.CompareArithmetic1D)
         hyp.SetStartLength(start)
         hyp.SetEndLength(end)
-        hyp.SetReversedEdges( reversedEdges )
+        hyp.SetReversedEdges( reversedEdgeInd )
         hyp.SetObjectEntry( entry )
         return hyp
 
@@ -4699,7 +4811,8 @@ class Mesh_Segment(Mesh_Algorithm):
     # values are equals 1
     #  @param points defines the list of parameters on curve
     #  @param nbSegs defines the list of numbers of segments
-    #  @param reversedEdges is a list of edges to mesh using reversed orientation
+    #  @param reversedEdges is a list of edges to mesh using reversed orientation.
+    #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
     #  @param UseExisting if ==true - searches for an existing hypothesis created with
     #                     the same parameters, else (default) - creates a new one
     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
@@ -4707,15 +4820,14 @@ class Mesh_Segment(Mesh_Algorithm):
     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
             reversedEdges, UseExisting = [], reversedEdges
-        if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
-            reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
+        reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
         entry = self.MainShapeEntry()
-        hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
+        hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
                               UseExisting=UseExisting,
                               CompareMethod=self.CompareFixedPoints1D)
         hyp.SetPoints(points)
         hyp.SetNbSegments(nbSegs)
-        hyp.SetReversedEdges(reversedEdges)
+        hyp.SetReversedEdges(reversedEdgeInd)
         hyp.SetObjectEntry(entry)
         return hyp
 
@@ -4735,7 +4847,8 @@ class Mesh_Segment(Mesh_Algorithm):
     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
     #  @param start defines the length of the first segment
     #  @param end   defines the length of the last  segment
-    #  @param reversedEdges is a list of edges to mesh using reversed orientation
+    #  @param reversedEdges is a list of edges to mesh using reversed orientation.
+    #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
     #  @param UseExisting if ==true - searches for an existing hypothesis created with
     #                     the same parameters, else (default) - creates a new one
     #  @return an instance of StdMeshers_StartEndLength hypothesis
@@ -4743,15 +4856,14 @@ class Mesh_Segment(Mesh_Algorithm):
     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
             reversedEdges, UseExisting = [], reversedEdges
-        if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
-            reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
+        reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
         entry = self.MainShapeEntry()
-        hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
+        hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
                               UseExisting=UseExisting,
                               CompareMethod=self.CompareStartEndLength)
         hyp.SetStartLength(start)
         hyp.SetEndLength(end)
-        hyp.SetReversedEdges( reversedEdges )
+        hyp.SetReversedEdges( reversedEdgeInd )
         hyp.SetObjectEntry( entry )
         return hyp
 
@@ -4921,7 +5033,6 @@ class Mesh_Triangle(Mesh_Algorithm):
     def __init__(self, mesh, algoType, geom=0):
         Mesh_Algorithm.__init__(self)
 
-        self.algoType = algoType
         if algoType == MEFISTO:
             self.Create(mesh, geom, "MEFISTO_2D")
             pass
@@ -4938,6 +5049,8 @@ class Mesh_Triangle(Mesh_Algorithm):
             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
             pass
 
+        self.algoType = algoType
+
     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
     #  @param area for the maximum area of each triangle
     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
@@ -4973,98 +5086,276 @@ class Mesh_Triangle(Mesh_Algorithm):
             return hyp
 
     ## Sets a way to define size of mesh elements to generate.
-    #  @param thePhysicalMesh is: DefaultSize or Custom.
+    #  @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
     #  @ingroup l3_hypos_blsurf
     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
-        # Parameter of BLSURF algo
-        self.Parameters().SetPhysicalMesh(thePhysicalMesh)
+        if self.Parameters():
+            # Parameter of BLSURF algo
+            self.params.SetPhysicalMesh(thePhysicalMesh)
 
     ## Sets size of mesh elements to generate.
     #  @ingroup l3_hypos_blsurf
     def SetPhySize(self, theVal):
-        # Parameter of BLSURF algo
-        self.SetPhysicalMesh(1) #Custom - else why to set the size?
-        self.Parameters().SetPhySize(theVal)
+        if self.Parameters():
+            # Parameter of BLSURF algo
+            self.params.SetPhySize(theVal)
 
     ## Sets lower boundary of mesh element size (PhySize).
     #  @ingroup l3_hypos_blsurf
     def SetPhyMin(self, theVal=-1):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetPhyMin(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPhyMin(theVal)
 
     ## Sets upper boundary of mesh element size (PhySize).
     #  @ingroup l3_hypos_blsurf
     def SetPhyMax(self, theVal=-1):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetPhyMax(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPhyMax(theVal)
 
     ## Sets a way to define maximum angular deflection of mesh from CAD model.
     #  @param theGeometricMesh is: 0 (None) or 1 (Custom)
     #  @ingroup l3_hypos_blsurf
     def SetGeometricMesh(self, theGeometricMesh=0):
-        #  Parameter of BLSURF algo
-        if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
-        self.params.SetGeometricMesh(theGeometricMesh)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
+            self.params.SetGeometricMesh(theGeometricMesh)
 
     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
     #  @ingroup l3_hypos_blsurf
     def SetAngleMeshS(self, theVal=_angleMeshS):
-        #  Parameter of BLSURF algo
-        if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
-        self.params.SetAngleMeshS(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
+            self.params.SetAngleMeshS(theVal)
 
     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
     #  @ingroup l3_hypos_blsurf
     def SetAngleMeshC(self, theVal=_angleMeshS):
-        #  Parameter of BLSURF algo
-        if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
-        self.params.SetAngleMeshC(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
+            self.params.SetAngleMeshC(theVal)
 
     ## Sets lower boundary of mesh element size computed to respect angular deflection.
     #  @ingroup l3_hypos_blsurf
     def SetGeoMin(self, theVal=-1):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetGeoMin(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetGeoMin(theVal)
 
     ## Sets upper boundary of mesh element size computed to respect angular deflection.
     #  @ingroup l3_hypos_blsurf
     def SetGeoMax(self, theVal=-1):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetGeoMax(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetGeoMax(theVal)
 
     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
     #  @ingroup l3_hypos_blsurf
     def SetGradation(self, theVal=_gradation):
-        #  Parameter of BLSURF algo
-        if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
-        self.params.SetGradation(theVal)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            if self.params.GetGeometricMesh() == 0: theVal = self._gradation
+            self.params.SetGradation(theVal)
 
     ## Sets topology usage way.
     # @param way defines how mesh conformity is assured <ul>
     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
+    # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
     #  @ingroup l3_hypos_blsurf
     def SetTopology(self, way):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetTopology(way)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetTopology(way)
 
     ## To respect geometrical edges or not.
     #  @ingroup l3_hypos_blsurf
     def SetDecimesh(self, toIgnoreEdges=False):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetDecimesh(toIgnoreEdges)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetDecimesh(toIgnoreEdges)
 
     ## Sets verbosity level in the range 0 to 100.
     #  @ingroup l3_hypos_blsurf
     def SetVerbosity(self, level):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetVerbosity(level)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetVerbosity(level)
+
+    ## To optimize merges edges.
+    #  @ingroup l3_hypos_blsurf
+    def SetPreCADMergeEdges(self, toMergeEdges=False):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPreCADMergeEdges(toMergeEdges)
+
+    ## To remove nano edges.
+    #  @ingroup l3_hypos_blsurf
+    def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPreCADRemoveNanoEdges(toRemoveNanoEdges)
+
+    ## To compute topology from scratch
+    #  @ingroup l3_hypos_blsurf
+    def SetPreCADDiscardInput(self, toDiscardInput=False):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPreCADDiscardInput(toDiscardInput)
+
+    ## Sets the length below which an edge is considered as nano 
+    #  for the topology processing.
+    #  @ingroup l3_hypos_blsurf
+    def SetPreCADEpsNano(self, epsNano):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPreCADEpsNano(epsNano)
 
     ## Sets advanced option value.
     #  @ingroup l3_hypos_blsurf
     def SetOptionValue(self, optionName, level):
-        #  Parameter of BLSURF algo
-        self.Parameters().SetOptionValue(optionName,level)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetOptionValue(optionName,level)
+
+    ## Sets advanced PreCAD option value.
+    #  Keyword arguments:
+    #  optionName: name of the option
+    #  optionValue: value of the option
+    #  @ingroup l3_hypos_blsurf
+    def SetPreCADOptionValue(self, optionName, optionValue):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetPreCADOptionValue(optionName,optionValue)
+
+    ## Sets GMF file for export at computation
+    #  @ingroup l3_hypos_blsurf
+    def SetGMFFile(self, fileName):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            self.params.SetGMFFile(fileName)
+
+    ## Enforced vertices (BLSURF)
+
+    ## To get all the enforced vertices
+    #  @ingroup l3_hypos_blsurf
+    def GetAllEnforcedVertices(self):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            return self.params.GetAllEnforcedVertices()
+
+    ## To get all the enforced vertices sorted by face (or group, compound)
+    #  @ingroup l3_hypos_blsurf
+    def GetAllEnforcedVerticesByFace(self):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            return self.params.GetAllEnforcedVerticesByFace()
+
+    ## To get all the enforced vertices sorted by coords of input vertices
+    #  @ingroup l3_hypos_blsurf
+    def GetAllEnforcedVerticesByCoords(self):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            return self.params.GetAllEnforcedVerticesByCoords()
+
+    ## To get all the coords of input vertices sorted by face (or group, compound)
+    #  @ingroup l3_hypos_blsurf
+    def GetAllCoordsByFace(self):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            return self.params.GetAllCoordsByFace()
+
+    ## To get all the enforced vertices on a face (or group, compound)
+    #  @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
+    #  @ingroup l3_hypos_blsurf
+    def GetEnforcedVertices(self, theFace):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            return self.params.GetEnforcedVertices(theFace)
+
+    ## To clear all the enforced vertices
+    #  @ingroup l3_hypos_blsurf
+    def ClearAllEnforcedVertices(self):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            return self.params.ClearAllEnforcedVertices()
+
+    ## To set an enforced vertex on a face (or group, compound) given the coordinates of a point. If the point is not on the face, it will projected on it. If there is no projection, no enforced vertex is created.
+    #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
+    #  @param x            : x coordinate
+    #  @param y            : y coordinate
+    #  @param z            : z coordinate
+    #  @param vertexName   : name of the enforced vertex
+    #  @param groupName    : name of the group
+    #  @ingroup l3_hypos_blsurf
+    def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            if vertexName == "":
+              if groupName == "":
+                return self.params.SetEnforcedVertex(theFace, x, y, z)
+              else:
+                return self.params.SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
+            else:
+              if groupName == "":
+                return self.params.SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
+              else:
+                return self.params.SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
+
+    ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
+    #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
+    #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
+    #  @param groupName    : name of the group
+    #  @ingroup l3_hypos_blsurf
+    def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            AssureGeomPublished( self.mesh, theVertex )
+            if groupName == "":
+              return self.params.SetEnforcedVertexGeom(theFace, theVertex)
+            else:
+              return self.params.SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
+
+    ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
+    #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
+    #  @param x            : x coordinate
+    #  @param y            : y coordinate
+    #  @param z            : z coordinate
+    #  @ingroup l3_hypos_blsurf
+    def UnsetEnforcedVertex(self, theFace, x, y, z):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            return self.params.UnsetEnforcedVertex(theFace, x, y, z)
+
+    ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
+    #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
+    #  @param theVertex    : GEOM vertex (or group, compound) to remove.
+    #  @ingroup l3_hypos_blsurf
+    def UnsetEnforcedVertexGeom(self, theFace, theVertex):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            AssureGeomPublished( self.mesh, theVertex )
+            return self.params.UnsetEnforcedVertexGeom(theFace, theVertex)
+
+    ## To remove all enforced vertices on a given face.
+    #  @param theFace      : face (or group/compound of faces) on which to remove all enforced vertices
+    #  @ingroup l3_hypos_blsurf
+    def UnsetEnforcedVertices(self, theFace):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            return self.params.UnsetEnforcedVertices(theFace)
+
+    ## Attractors (BLSURF)
 
     ## Sets an attractor on the chosen face. The mesh size will decrease exponentially with the distance from theAttractor, following the rule h(d) = theEndSize - (theEndSize - theStartSize) * exp [ - ( d / theInfluenceDistance ) ^ 2 ] 
     #  @param theFace      : face on which the attractor will be defined
@@ -5075,18 +5366,52 @@ class Mesh_Triangle(Mesh_Algorithm):
     #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace                                                      
     #  @ingroup l3_hypos_blsurf
     def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
-        AssureGeomPublished( self.mesh, theFace )
-        AssureGeomPublished( self.mesh, theAttractor )
-        #  Parameter of BLSURF algo
-        self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
-        
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            AssureGeomPublished( self.mesh, theAttractor )
+            self.params.SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
+
     ## Unsets an attractor on the chosen face. 
     #  @param theFace      : face on which the attractor has to be removed                               
     #  @ingroup l3_hypos_blsurf
     def UnsetAttractorGeom(self, theFace):
-        AssureGeomPublished( self.mesh, theFace )
-        #  Parameter of BLSURF algo
-        self.Parameters().SetAttractorGeom(theFace)
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theFace )
+            self.params.SetAttractorGeom(theFace)
+
+    ## Size maps (BLSURF)
+
+    ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
+    #  If theObject is a face, the function can be: def f(u,v): return u+v
+    #  If theObject is an edge, the function can be: def f(t): return t/2
+    #  If theObject is a vertex, the function can be: def f(): return 10
+    #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
+    #  @param theSizeMap  : Size map defined as a string
+    #  @ingroup l3_hypos_blsurf
+    def SetSizeMap(self, theObject, theSizeMap):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theObject )
+            return self.params.SetSizeMap(theObject, theSizeMap)
+
+    ## To remove a size map defined on a face, edge or vertex (or group, compound)
+    #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
+    #  @ingroup l3_hypos_blsurf
+    def UnsetSizeMap(self, theObject):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            AssureGeomPublished( self.mesh, theObject )
+            return self.params.UnsetSizeMap(theObject)
+
+    ## To remove all the size maps
+    #  @ingroup l3_hypos_blsurf
+    def ClearSizeMaps(self):
+        if self.Parameters():
+            #  Parameter of BLSURF algo
+            return self.params.ClearSizeMaps()
+
 
     ## Sets QuadAllowed flag.
     #  Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
@@ -5484,7 +5809,8 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     #  @ingroup l3_hypos_ghs3dh
     def SetToMeshHoles(self, toMesh):
         #  Parameter of GHS3D
-        self.Parameters().SetToMeshHoles(toMesh)
+        if self.Parameters():
+            self.params.SetToMeshHoles(toMesh)
 
     ## Set Optimization level:
     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
@@ -5493,32 +5819,37 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     #  @ingroup l3_hypos_ghs3dh
     def SetOptimizationLevel(self, level):
         #  Parameter of GHS3D
-        self.Parameters().SetOptimizationLevel(level)
+        if self.Parameters():
+            self.params.SetOptimizationLevel(level)
 
     ## Maximal size of memory to be used by the algorithm (in Megabytes).
     #  @ingroup l3_hypos_ghs3dh
     def SetMaximumMemory(self, MB):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetMaximumMemory(MB)
+        if self.Parameters():
+            self.params.SetMaximumMemory(MB)
 
     ## Initial size of memory to be used by the algorithm (in Megabytes) in
     #  automatic memory adjustment mode.
     #  @ingroup l3_hypos_ghs3dh
     def SetInitialMemory(self, MB):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetInitialMemory(MB)
+        if self.Parameters():
+            self.params.SetInitialMemory(MB)
 
     ## Path to working directory.
     #  @ingroup l3_hypos_ghs3dh
     def SetWorkingDirectory(self, path):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetWorkingDirectory(path)
+        if self.Parameters():
+            self.params.SetWorkingDirectory(path)
 
     ## To keep working files or remove them. Log file remains in case of errors anyway.
     #  @ingroup l3_hypos_ghs3dh
     def SetKeepFiles(self, toKeep):
         #  Advanced parameter of GHS3D and GHS3DPRL
-        self.Parameters().SetKeepFiles(toKeep)
+        if self.Parameters():
+            self.params.SetKeepFiles(toKeep)
 
     ## To set verbose level [0-10]. <ul>
     #<li> 0 - no standard output,
@@ -5531,20 +5862,23 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     #  @ingroup l3_hypos_ghs3dh
     def SetVerboseLevel(self, level):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetVerboseLevel(level)
+        if self.Parameters():
+            self.params.SetVerboseLevel(level)
 
     ## To create new nodes.
     #  @ingroup l3_hypos_ghs3dh
     def SetToCreateNewNodes(self, toCreate):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetToCreateNewNodes(toCreate)
+        if self.Parameters():
+            self.params.SetToCreateNewNodes(toCreate)
 
     ## To use boundary recovery version which tries to create mesh on a very poor
     #  quality surface mesh.
     #  @ingroup l3_hypos_ghs3dh
     def SetToUseBoundaryRecoveryVersion(self, toUse):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
+        if self.Parameters():
+            self.params.SetToUseBoundaryRecoveryVersion(toUse)
 
     ## Applies finite-element correction by replacing overconstrained elements where
     #  it is possible. The process is cutting first the overconstrained edges and
@@ -5553,97 +5887,112 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     #  @ingroup l3_hypos_ghs3dh
     def SetFEMCorrection(self, toUseFem):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetFEMCorrection(toUseFem)
+        if self.Parameters():
+            self.params.SetFEMCorrection(toUseFem)
 
     ## To removes initial central point.
     #  @ingroup l3_hypos_ghs3dh
     def SetToRemoveCentralPoint(self, toRemove):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetToRemoveCentralPoint(toRemove)
+        if self.Parameters():
+            self.params.SetToRemoveCentralPoint(toRemove)
 
     ## To set an enforced vertex.
+    #  @param x            : x coordinate
+    #  @param y            : y coordinate
+    #  @param z            : z coordinate
+    #  @param size         : size of 1D element around enforced vertex
+    #  @param vertexName   : name of the enforced vertex
+    #  @param groupName    : name of the group
     #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedVertex(self, x, y, z, size):
-        #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedVertex(x, y, z, size)
-
-    ## To set an enforced vertex and add it in the group "groupName".
-    #  Only on meshes w/o geometry
-    #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
-        #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
-
-    ## To remove an enforced vertex.
-    #  @ingroup l3_hypos_ghs3dh
-    def RemoveEnforcedVertex(self, x, y, z):
+    def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
         #  Advanced parameter of GHS3D
-        return self.Parameters().RemoveEnforcedVertex(x, y, z)
+        if self.Parameters():
+          if vertexName == "":
+            if groupName == "":
+              return self.params.SetEnforcedVertex(x, y, z, size)
+            else:
+              return self.params.SetEnforcedVertexWithGroup(x, y, z, size, groupName)
+          else:
+            if groupName == "":
+              return self.params.SetEnforcedVertexNamed(x, y, z, size, vertexName)
+            else:
+              return self.params.SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
 
     ## To set an enforced vertex given a GEOM vertex, group or compound.
+    #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
+    #  @param size         : size of 1D element around enforced vertex
+    #  @param groupName    : name of the group
     #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedVertexGeom(self, theVertex, size):
+    def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
         AssureGeomPublished( self.mesh, theVertex )
         #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
+        if self.Parameters():
+          if groupName == "":
+            return self.params.SetEnforcedVertexGeom(theVertex, size)
+          else:
+            return self.params.SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
 
-    ## To set an enforced vertex given a GEOM vertex, group or compound
-    #  and add it in the group "groupName".
-    #  Only on meshes w/o geometry
+    ## To remove an enforced vertex.
+    #  @param x            : x coordinate
+    #  @param y            : y coordinate
+    #  @param z            : z coordinate
     #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
-        AssureGeomPublished( self.mesh, theVertex )
+    def RemoveEnforcedVertex(self, x, y, z):
         #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
+        if self.Parameters():
+          return self.params.RemoveEnforcedVertex(x, y, z)
 
     ## To remove an enforced vertex given a GEOM vertex, group or compound.
+    #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
     #  @ingroup l3_hypos_ghs3dh
     def RemoveEnforcedVertexGeom(self, theVertex):
         AssureGeomPublished( self.mesh, theVertex )
         #  Advanced parameter of GHS3D
-        return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
-
-    ## To set an enforced mesh.
-    #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedMesh(self, theSource, elementType):
-        #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedMesh(theSource, elementType)
-
-    ## To set an enforced mesh and add the enforced elements in the group "groupName".
-    #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
-        #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
-
-    ## To set an enforced mesh with given size.
-    #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedMeshSize(self, theSource, elementType, size):
-        #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
+        if self.Parameters():
+          return self.params.RemoveEnforcedVertexGeom(theVertex)
 
     ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
+    #  @param theSource    : source mesh which provides constraint elements/nodes
+    #  @param elementType  : SMESH.ElementType (NODE, EDGE or FACE)
+    #  @param size         : size of elements around enforced elements. Unused if -1.
+    #  @param groupName    : group in which enforced elements will be added. Unused if "".
     #  @ingroup l3_hypos_ghs3dh
-    def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
+    def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
         #  Advanced parameter of GHS3D
-        return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
+        if self.Parameters():
+          if size >= 0:
+            if groupName != "":
+              return self.params.SetEnforcedMesh(theSource, elementType)
+            else:
+              return self.params.SetEnforcedMeshWithGroup(theSource, elementType, groupName)
+          else:
+            if groupName != "":
+              return self.params.SetEnforcedMeshSize(theSource, elementType, size)
+            else:
+              return self.params.SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
 
     ## Sets command line option as text.
     #  @ingroup l3_hypos_ghs3dh
     def SetTextOption(self, option):
         #  Advanced parameter of GHS3D
-        self.Parameters().SetTextOption(option)
+        if self.Parameters():
+            self.params.SetTextOption(option)
 
     ## Sets MED files name and path.
     def SetMEDName(self, value):
-        self.Parameters().SetMEDName(value)
+        if self.Parameters():
+            self.params.SetMEDName(value)
 
     ## Sets the number of partition of the initial mesh
     def SetNbPart(self, value):
-        self.Parameters().SetNbPart(value)
+        if self.Parameters():
+            self.params.SetNbPart(value)
 
     ## When big mesh, start tepal in background
     def SetBackground(self, value):
-        self.Parameters().SetBackground(value)
+        if self.Parameters():
+            self.params.SetBackground(value)
 
 # Public class: Mesh_Hexahedron
 # ------------------------------
@@ -5773,9 +6122,9 @@ class Mesh_Projection1D(Mesh_Algorithm):
 class Mesh_Projection2D(Mesh_Algorithm):
 
     ## Private constructor.
-    def __init__(self, mesh, geom=0):
+    def __init__(self, mesh, geom=0, algoName="Projection_2D"):
         Mesh_Algorithm.__init__(self)
-        self.Create(mesh, geom, "Projection_2D")
+        self.Create(mesh, geom, algoName)
 
     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
     #  a mesh pattern is taken, and, optionally, the association of vertices
@@ -6101,7 +6450,7 @@ class Mesh_UseExistingElements(Mesh_Algorithm):
     #  @param UseExisting if ==true - searches for the existing hypothesis created with
     #                     the same parameters, else (default) - creates a new one
     def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
-        if self.algo.GetName() == "Import_2D":
+        if self.algo.GetName() != "Import_1D":
             raise ValueError, "algoritm dimension mismatch"
         for group in groups:
             AssureGeomPublished( self.mesh, group )