Salome HOME
Implemented [bos #35094] [EDF] (2023-T1) X,Y,Z to U,V.
[modules/geom.git] / src / GEOM_SWIG / geomBuilder.py
index e3b56a2282c547200e2961a97cf13b341e58ca7e..6b7947e0df628cf67fd72d857ec4ef8cb1f7b29a 100644 (file)
@@ -1,5 +1,5 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -52,7 +52,7 @@
 ## @code
 ## import salome
 ## from salome.geom import geomBuilder
-## geompy = geomBuilder.New(salome.myStudy)
+## geompy = geomBuilder.New()
 ## box = geompy.MakeBoxDXDYDZ(100, 100, 100) # box is not published in the study yet
 ## geompy.addToStudy(box, "box")             # explicit publishing
 ## @endcode
 ## @code
 ## import salome
 ## from salome.geom import geomBuilder
-## geompy = geomBuilder.New(salome.myStudy)
+## geompy = geomBuilder.New()
 ## geompy.addToStudyAuto() # enable automatic publication
 ## box = geompy.MakeBoxDXDYDZ(100, 100, 100)
 ## # the box is created and published in the study with default name
 ## @code
 ## import salome
 ## from salome.geom import geomBuilder
-## geompy = geomBuilder.New(salome.myStudy)
+## geompy = geomBuilder.New()
 ## box = geompy.MakeBoxDXDYDZ(100, 100, 100, "Box")
 ## # the box was created and published in the study
 ## folder = geompy.NewFolder("Primitives")
 ##   @}
 ##   @defgroup l2_measure       Using measurement tools
 ##   @defgroup l2_field         Field on Geometry
+##   @defgroup l2_testing       Testing
 
 ## @}
 
+import omniORB
+
 # initialize SALOME session in try/except block
 # to avoid problems in some cases, e.g. when generating documentation
 try:
@@ -257,12 +260,93 @@ import os
 import functools
 
 from salome.geom.gsketcher import Sketcher3D, Sketcher2D, Polyline2D
+from salome.geom.canonicalrecognition import CanonicalRecognition
+from salome.geom.conformity import CheckConformity
+from salome.geom.proximity import ShapeProximity
+
+# In case the omniORBpy EnumItem class does not fully support Python 3
+# (for instance in version 4.2.1-2), the comparison ordering methods must be
+# defined
+#
+try:
+    GEOM.COMPOUND < GEOM.SOLID
+except TypeError:
+    def enumitem_eq(self, other):
+        try:
+            if isinstance(other, omniORB.EnumItem):
+                if other._parent_id == self._parent_id:
+                    return self._v == other._v
+                else:
+                    return self._parent_id == other._parent_id
+            else:
+                return id(self) == id(other)
+        except:
+            return id(self) == id(other)
+
+    def enumitem_lt(self, other):
+        try:
+            if isinstance(other, omniORB.EnumItem):
+                if other._parent_id == self._parent_id:
+                    return self._v < other._v
+                else:
+                    return self._parent_id < other._parent_id
+            else:
+                return id(self) < id(other)
+        except:
+            return id(self) < id(other)
+
+    def enumitem_le(self, other):
+        try:
+            if isinstance(other, omniORB.EnumItem):
+                if other._parent_id == self._parent_id:
+                    return self._v <= other._v
+                else:
+                    return self._parent_id <= other._parent_id
+            else:
+                return id(self) <= id(other)
+        except:
+            return id(self) <= id(other)
+
+    def enumitem_gt(self, other):
+        try:
+            if isinstance(other, omniORB.EnumItem):
+                if other._parent_id == self._parent_id:
+                    return self._v > other._v
+                else:
+                    return self._parent_id > other._parent_id
+            else:
+                return id(self) > id(other)
+        except:
+            return id(self) > id(other)
+
+    def enumitem_ge(self, other):
+        try:
+            if isinstance(other, omniORB.EnumItem):
+                if other._parent_id == self._parent_id:
+                    return self._v >= other._v
+                else:
+                    return self._parent_id >= other._parent_id
+            else:
+                return id(self) >= id(other)
+        except:
+            return id(self) >= id(other)
+
+    GEOM.omniORB.EnumItem.__eq__ = enumitem_eq
+    GEOM.omniORB.EnumItem.__lt__ = enumitem_lt
+    GEOM.omniORB.EnumItem.__le__ = enumitem_le
+    GEOM.omniORB.EnumItem.__gt__ = enumitem_gt
+    GEOM.omniORB.EnumItem.__ge__ = enumitem_ge
+    omniORB.EnumItem.__eq__ = enumitem_eq
+    omniORB.EnumItem.__lt__ = enumitem_lt
+    omniORB.EnumItem.__le__ = enumitem_le
+    omniORB.EnumItem.__gt__ = enumitem_gt
+    omniORB.EnumItem.__ge__ = enumitem_ge
 
 # service function
 def _toListOfNames(_names, _size=-1):
     l = []
     import types
-    if type(_names) in [types.ListType, types.TupleType]:
+    if type(_names) in [list, tuple]:
         for i in _names: l.append(i)
     elif _names:
         l.append(_names)
@@ -296,7 +380,13 @@ def ManageTransactions(theOpeName):
 ## @ingroup l1_geomBuilder_auxiliary
 def RaiseIfFailed (Method_name, Operation):
     if not Operation.IsDone() and Operation.GetErrorCode() != "NOT_FOUND_ANY":
-        raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
+        raise RuntimeError(Method_name + " : " + Operation.GetErrorCode())
+
+def PrintOrRaise(message, raiseException=False):
+    if raiseException:
+        raise RuntimeError(message)
+    else:
+        print(message)
 
 ## Return list of variables value from salome notebook
 ## @ingroup l1_geomBuilder_auxiliary
@@ -316,7 +406,7 @@ def ParseParameters(*parameters):
                 if notebook.isVariable(parameter):
                     Result.append(notebook.get(parameter))
                 else:
-                    raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!"
+                    raise RuntimeError("Variable with name '" + parameter + "' doesn't exist!!!")
                 pass
             else:
                 Result.append(parameter)
@@ -365,7 +455,7 @@ def ParseSketcherCommand(command):
                     Result = Result + str(notebook.get(parameter)) + " "
                     pass
                 else:
-                    raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!"
+                    raise RuntimeError("Variable with name '" + parameter + "' doesn't exist!!!")
                     pass
                 pass
             else:
@@ -438,7 +528,7 @@ def PackData(data):
 ## For example,
 ## \code
 ## from salome.geom import geomBuilder
-## geompy = geomBuilder.New(salome.myStudy)
+## geompy = geomBuilder.New()
 ## texture = geompy.readtexture('mytexture.dat')
 ## texture = geompy.AddTexture(*texture)
 ## obj.SetMarkerTexture(texture)
@@ -464,7 +554,7 @@ def ReadTexture(fname):
 
     Example of usage:
         from salome.geom import geomBuilder
-        geompy = geomBuilder.New(salome.myStudy)
+        geompy = geomBuilder.New()
         texture = geompy.readtexture('mytexture.dat')
         texture = geompy.AddTexture(*texture)
         obj.SetMarkerTexture(texture)
@@ -554,7 +644,7 @@ engine = None
 doLcc = False
 created = False
 
-class geomBuilder(object, GEOM._objref_GEOM_Gen):
+class geomBuilder(GEOM._objref_GEOM_Gen):
 
         ## Enumeration ShapeType as a dictionary. \n
         ## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details.
@@ -605,7 +695,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #  @ingroup l1_geomBuilder_auxiliary
         kind = GEOM.GEOM_IKindOfShape
 
-        def __new__(cls):
+        def __new__(cls, *args):
             global engine
             global geom
             global doLcc
@@ -644,17 +734,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             #print "return geom 2 ", geom
             return geom
 
-        def __init__(self):
+        def __init__(self, *args):
             global created
             #print "-------- geomBuilder __init__ --- ", created, self
             if not created:
               created = True
-              GEOM._objref_GEOM_Gen.__init__(self)
+              GEOM._objref_GEOM_Gen.__init__(self, *args)
               self.myMaxNbSubShapesAllowed = 0 # auto-publishing is disabled by default
               self.myBuilder = None
-              self.myStudyId = 0
-              self.father    = None
-
               self.BasicOp  = None
               self.CurvesOp = None
               self.PrimOp   = None
@@ -668,6 +755,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
               self.BlocksOp = None
               self.GroupOp  = None
               self.FieldOp  = None
+              self.TestOp   = None
             pass
 
         ## Process object publication in the study, as follows:
@@ -686,10 +774,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             # ---
             def _item_name(_names, _defname, _idx=-1):
                 if not _names: _names = _defname
-                if type(_names) in [types.ListType, types.TupleType]:
+                if type(_names) in [list, tuple]:
                     if _idx >= 0:
                         if _idx >= len(_names) or not _names[_idx]:
-                            if type(_defname) not in [types.ListType, types.TupleType]:
+                            if type(_defname) not in [list, tuple]:
                                 _name = "%s_%d"%(_defname, _idx+1)
                             elif len(_defname) > 0 and _idx >= 0 and _idx < len(_defname):
                                 _name = _defname[_idx]
@@ -734,7 +822,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if not theName and not theDefaultName:
                 return # neither theName nor theDefaultName is given
             import types
-            if type(theObj) in [types.ListType, types.TupleType]:
+            if type(theObj) in [list, tuple]:
                 # list of objects is being published
                 idx = 0
                 for obj in theObj:
@@ -753,47 +841,35 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
 
         ## @addtogroup l1_geomBuilder_auxiliary
         ## @{
-        def init_geom(self,theStudy):
-            self.myStudy = theStudy
-            self.myStudyId = self.myStudy._get_StudyId()
+        def init_geom(self):
+            self.myStudy = salome.myStudy
             self.myBuilder = self.myStudy.NewBuilder()
-            self.father = self.myStudy.FindComponent("GEOM")
-            notebook.myStudy = theStudy
-            if self.father is None:
-                self.father = self.myBuilder.NewComponent("GEOM")
-                A1 = self.myBuilder.FindOrCreateAttribute(self.father, "AttributeName")
-                FName = A1._narrow(SALOMEDS.AttributeName)
-                FName.SetValue("Geometry")
-                A2 = self.myBuilder.FindOrCreateAttribute(self.father, "AttributePixMap")
-                aPixmap = A2._narrow(SALOMEDS.AttributePixMap)
-                aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry")
-                self.myBuilder.DefineComponentInstance(self.father,self)
-                pass
-            self.BasicOp  = self.GetIBasicOperations    (self.myStudyId)
-            self.CurvesOp = self.GetICurvesOperations   (self.myStudyId)
-            self.PrimOp   = self.GetI3DPrimOperations   (self.myStudyId)
-            self.ShapesOp = self.GetIShapesOperations   (self.myStudyId)
-            self.HealOp   = self.GetIHealingOperations  (self.myStudyId)
-            self.InsertOp = self.GetIInsertOperations   (self.myStudyId)
-            self.BoolOp   = self.GetIBooleanOperations  (self.myStudyId)
-            self.TrsfOp   = self.GetITransformOperations(self.myStudyId)
-            self.LocalOp  = self.GetILocalOperations    (self.myStudyId)
-            self.MeasuOp  = self.GetIMeasureOperations  (self.myStudyId)
-            self.BlocksOp = self.GetIBlocksOperations   (self.myStudyId)
-            self.GroupOp  = self.GetIGroupOperations    (self.myStudyId)
-            self.FieldOp  = self.GetIFieldOperations    (self.myStudyId)
-
-            # set GEOM as root in the use case tree
-            self.myUseCaseBuilder = self.myStudy.GetUseCaseBuilder()
-            self.myUseCaseBuilder.SetRootCurrent()
-            self.myUseCaseBuilder.Append(self.father)
 
             # load data from the study file, if necessary
-            self.myBuilder.LoadWith(self.father, self)
+            component = self.myStudy.FindComponent("GEOM")
+            if component:
+                self.myBuilder.LoadWith(component, self)
+
+            self.BasicOp  = self.GetIBasicOperations    ()
+            self.CurvesOp = self.GetICurvesOperations   ()
+            self.PrimOp   = self.GetI3DPrimOperations   ()
+            self.ShapesOp = self.GetIShapesOperations   ()
+            self.HealOp   = self.GetIHealingOperations  ()
+            self.InsertOp = self.GetIInsertOperations   ()
+            self.BoolOp   = self.GetIBooleanOperations  ()
+            self.TrsfOp   = self.GetITransformOperations()
+            self.LocalOp  = self.GetILocalOperations    ()
+            self.MeasuOp  = self.GetIMeasureOperations  ()
+            self.BlocksOp = self.GetIBlocksOperations   ()
+            self.GroupOp  = self.GetIGroupOperations    ()
+            self.FieldOp  = self.GetIFieldOperations    ()
+            self.TestOp   = self.GetITestOperations     ()
+
+            notebook.myStudy = self.myStudy
             pass
 
-        def GetPluginOperations(self, studyID, libraryName):
-            op = GEOM._objref_GEOM_Gen.GetPluginOperations(self, studyID, libraryName)
+        def GetPluginOperations(self, libraryName):
+            op = GEOM._objref_GEOM_Gen.GetPluginOperations(self, libraryName)
             return op
 
         ## Enable / disable results auto-publishing
@@ -833,12 +909,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
 
         ## Dump component to the Python script
         #  This method overrides IDL function to allow default values for the parameters.
-        def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
+        def DumpPython(self, theIsPublished=True, theIsMultiFile=True):
             """
             Dump component to the Python script
             This method overrides IDL function to allow default values for the parameters.
             """
-            return GEOM._objref_GEOM_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
+            return GEOM._objref_GEOM_Gen.DumpPython(self, theIsPublished, theIsMultiFile)
 
         ## Get name for sub-shape aSubObj of shape aMainObj
         #
@@ -893,13 +969,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             # Example: see GEOM_TestAll.py
             try:
-                aSObject = self.AddInStudy(self.myStudy, aShape, aName, None)
+                aSObject = self.AddInStudy(aShape, aName, None)
                 if aSObject and aName: aSObject.SetAttrString("AttributeName", aName)
                 if doRestoreSubShapes:
-                    self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs,
+                    self.RestoreSubShapesSO(aSObject, theArgs,
                                             theFindMethod, theInheritFirstArg, True )
             except:
-                print "addToStudy() failed"
+                print("addToStudy() failed")
                 return ""
             return aShape.GetStudyEntry()
 
@@ -926,10 +1002,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             # Example: see GEOM_TestAll.py
             try:
-                aSObject = self.AddInStudy(self.myStudy, aShape, aName, aFather)
+                aSObject = self.AddInStudy(aShape, aName, aFather)
                 if aSObject and aName: aSObject.SetAttrString("AttributeName", aName)
             except:
-                print "addToStudyInFather() failed"
+                print("addToStudyInFather() failed")
                 return ""
             return aShape.GetStudyEntry()
 
@@ -1012,7 +1088,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 list of published sub-shapes
             """
             # Example: see GEOM_TestAll.py
-            return self.RestoreSubShapesO(self.myStudy, theObject, theArgs,
+            return self.RestoreSubShapesO(theObject, theArgs,
                                           theFindMethod, theInheritFirstArg, theAddPrefix)
 
         ## Publish sub-shapes, standing for arguments and sub-shapes of arguments
@@ -1064,7 +1140,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 list of published sub-shapes
             """
             # Example: see GEOM_TestAll.py
-            return self.RestoreGivenSubShapesO(self.myStudy, theObject, theArgs,
+            return self.RestoreGivenSubShapesO(theObject, theArgs,
                                                theFindMethod, theInheritFirstArg, theAddPrefix)
 
         # end of l3_restore_ss
@@ -1368,7 +1444,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref swig_MakeVertexInsideFace "Example"
         @ManageTransactions("BasicOp")
-        def MakeVertexInsideFace (self, theFace, theName=None):
+        def MakeVertexInsideFace (self, theFace, theNumberOfPnts=1, theName=None):
             """
             Create a point, which lays on the given face.
             The point will lay in arbitrary place of the face.
@@ -1378,6 +1454,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
 
             Parameters:
                 theFace The referenced face.
+                theNumberOfPnts The number of points we want to get, 1 by default.
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
                         publication is switched on, default value is used for result name.
@@ -1389,7 +1466,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 p_on_face = geompy.MakeVertexInsideFace(Face)
             """
             # Example: see GEOM_TestAll.py
-            anObj = self.BasicOp.MakePointOnFace(theFace)
+            anObj = self.BasicOp.MakePointOnFace(theFace, theNumberOfPnts)
             RaiseIfFailed("MakeVertexInsideFace", self.BasicOp)
             self._autoPublish(anObj, theName, "vertex")
             return anObj
@@ -1694,7 +1771,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         ## Create a plane, passing through the three given points
         #  @param thePnt1 First of three points, defining the plane.
         #  @param thePnt2 Second of three points, defining the plane.
-        #  @param thePnt3 Fird of three points, defining the plane.
+        #  @param thePnt3 Third of three points, defining the plane.
         #  @param theTrimSize Half size of a side of quadrangle face, representing the plane.
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
@@ -1711,7 +1788,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             Parameters:
                 thePnt1 First of three points, defining the plane.
                 thePnt2 Second of three points, defining the plane.
-                thePnt3 Fird of three points, defining the plane.
+                thePnt3 Third of three points, defining the plane.
                 theTrimSize Half size of a side of quadrangle face, representing the plane.
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
@@ -3069,14 +3146,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if isinstance(theA,str):
                 flag = True
             theR,theH,theA,Parameters = ParseParameters(theR, theH, theA)
-           if flag:
+            if flag:
                 theA = theA*math.pi/180.
-           if theA<=0. or theA>=2*math.pi:
-             raise ValueError("The angle parameter should be strictly between 0 and 2*pi.")
-           anObj = self.PrimOp.MakeCylinderPntVecRHA(thePnt, theAxis, theR, theH, theA)
-           RaiseIfFailed("MakeCylinderPntVecRHA", self.PrimOp)
-           anObj.SetParameters(Parameters)
-           self._autoPublish(anObj, theName, "cylinder")
+            if theA<=0. or theA>=2*math.pi:
+                raise ValueError("The angle parameter should be strictly between 0 and 2*pi.")
+            anObj = self.PrimOp.MakeCylinderPntVecRHA(thePnt, theAxis, theR, theH, theA)
+            RaiseIfFailed("MakeCylinderPntVecRHA", self.PrimOp)
+            anObj.SetParameters(Parameters)
+            self._autoPublish(anObj, theName, "cylinder")
             return anObj
 
         ## Create a cylinder with given radius and height at
@@ -3155,7 +3232,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if flag:
                 theA = theA*math.pi/180.
             if theA<=0. or theA>=2*math.pi:
-             raise ValueError("The angle parameter should be strictly between 0 and 2*pi.")
+                raise ValueError("The angle parameter should be strictly between 0 and 2*pi.")
             anObj = self.PrimOp.MakeCylinderRHA(theR, theH, theA)
             RaiseIfFailed("MakeCylinderRHA", self.PrimOp)
             anObj.SetParameters(Parameters)
@@ -4212,11 +4289,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                                                               theWithContact, theWithCorrection,
                                                               IsGenerateGroups)
                 if self.PrimOp.IsDone() == 0:
-                    print "Problems with pipe creation between ",i," and ",i+1," sections"
+                    print("Problems with pipe creation between ",i," and ",i+1," sections")
                     RaiseIfFailed("MakePipeWithShellSections", self.PrimOp)
                     break
                 else:
-                    print "Pipe between ",i," and ",i+1," sections is OK"
+                    print("Pipe between ",i," and ",i+1," sections is OK")
                     res.append(aList[0])
                     pass
                 pass
@@ -4683,7 +4760,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_creation_face "Example"
         @ManageTransactions("ShapesOp")
-        def MakeFace(self, theWire, isPlanarWanted, theName=None):
+        def MakeFace(self, theWire, isPlanarWanted, theName=None, raiseException=False):
             """
             Create a face on the given wire.
 
@@ -4704,7 +4781,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             # Example: see GEOM_TestAll.py
             anObj = self.ShapesOp.MakeFace(theWire, isPlanarWanted)
             if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
-                print "WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built."
+                PrintOrRaise("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.",raiseException)
             else:
                 RaiseIfFailed("MakeFace", self.ShapesOp)
             self._autoPublish(anObj, theName, "face")
@@ -4725,7 +4802,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_creation_face "Example"
         @ManageTransactions("ShapesOp")
-        def MakeFaceWires(self, theWires, isPlanarWanted, theName=None):
+        def MakeFaceWires(self, theWires, isPlanarWanted, theName=None, raiseException=False):
             """
             Create a face on the given wires set.
 
@@ -4746,7 +4823,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             # Example: see GEOM_TestAll.py
             anObj = self.ShapesOp.MakeFaceWires(ToList(theWires), isPlanarWanted)
             if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG":
-                print "WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built."
+                PrintOrRaise("WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built.",raiseException)
             else:
                 RaiseIfFailed("MakeFaceWires", self.ShapesOp)
             self._autoPublish(anObj, theName, "face")
@@ -4893,7 +4970,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 #if len(descr) > 0:
                 #    raise RuntimeError, "MakeSolidShells : " + descr
                 if descr == "WRN_SHAPE_UNCLOSED":
-                    raise RuntimeError, "MakeSolidShells : Unable to create solid from unclosed shape"
+                    raise RuntimeError("MakeSolidShells : Unable to create solid from unclosed shape")
             anObj = self.ShapesOp.MakeSolidShells(theShells)
             RaiseIfFailed("MakeSolidShells", self.ShapesOp)
             self._autoPublish(anObj, theName, "solid")
@@ -5960,6 +6037,38 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "inplace")
             return anObj
 
+        ## A sort of GetInPlace functionality, returning IDs of sub-shapes.
+        #  For each sub-shape ID of @a theShapeWhat return a list of corresponding sub-shape
+        #  IDs of @a theShapeWhere.
+        #  For example, if theShapeWhat is a box and theShapeWhere is this box cut into 
+        #  two parts by a plane, then the result can be as this: 
+        #    len( result_list ) = 35,
+        #    result_list[ 1 ] = [ 2, 36 ], which means that the box  (ID 1) turned into two
+        #  solids with IDs 2 and 36 within theShapeWhere
+        #
+        #  @param theShapeWhere Shape to find sub-shapes of.
+        #  @param theShapeWhat Shape, specifying what to find.
+        #  @return List of lists of sub-shape IDS of theShapeWhere.
+        def GetInPlaceMap(self, theShapeWhere, theShapeWhat):
+            """
+            A sort of GetInPlace functionality, returning IDs of sub-shapes.
+            For each sub-shape ID of @a theShapeWhat return a list of corresponding sub-shape
+            IDs of @a theShapeWhere.
+            For example, if theShapeWhat is a box and theShapeWhere is this box cut into 
+            two parts by a plane, then the result can be as this: 
+              len( result_list ) = 35,
+              result_list[ 1 ] = [ 2, 36 ], which means that the box (ID 1) turned into two
+            solids with IDs 2 and 36 within theShapeWhere
+
+            Parameters:
+                theShapeWhere Shape to find sub-shapes of.
+                theShapeWhat Shape, specifying what to find.
+
+            Returns:
+                List of lists of sub-shape IDS of theShapeWhere.
+            """
+            return self.ShapesOp.GetInPlaceMap(theShapeWhere, theShapeWhat)
+
         ## Get sub-shape of theShapeWhere, which is
         #  equal to \a theShapeWhat.
         #  @param theShapeWhere Shape to find sub-shape of.
@@ -7441,7 +7550,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             theTolerance,Parameters = ParseParameters(theTolerance)
             anObj = self.ShapesOp.MakeGlueFaces(ToList(theShapes), theTolerance, doKeepNonSolids)
             if anObj is None:
-                raise RuntimeError, "MakeGlueFaces : " + self.ShapesOp.GetErrorCode()
+                raise RuntimeError("MakeGlueFaces : " + self.ShapesOp.GetErrorCode())
             anObj.SetParameters(Parameters)
             self._autoPublish(anObj, theName, "glueFaces")
             return anObj
@@ -7523,7 +7632,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             anObj = self.ShapesOp.MakeGlueFacesByList(ToList(theShapes), theTolerance, ToList(theFaces),
                                                       doKeepNonSolids, doGlueAllEdges)
             if anObj is None:
-                raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode()
+                raise RuntimeError("MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode())
             self._autoPublish(anObj, theName, "glueFaces")
             return anObj
 
@@ -7555,7 +7664,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             theTolerance,Parameters = ParseParameters(theTolerance)
             anObj = self.ShapesOp.MakeGlueEdges(ToList(theShapes), theTolerance)
             if anObj is None:
-                raise RuntimeError, "MakeGlueEdges : " + self.ShapesOp.GetErrorCode()
+                raise RuntimeError("MakeGlueEdges : " + self.ShapesOp.GetErrorCode())
             anObj.SetParameters(Parameters)
             self._autoPublish(anObj, theName, "glueEdges")
             return anObj
@@ -7625,7 +7734,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             anObj = self.ShapesOp.MakeGlueEdgesByList(ToList(theShapes), theTolerance, theEdges)
             if anObj is None:
-                raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode()
+                raise RuntimeError("MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode())
             self._autoPublish(anObj, theName, "glueEdges")
             return anObj
 
@@ -8145,7 +8254,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if Limit == self.ShapeType["AUTO"]:
                 # automatic detection of the most appropriate shape limit type
                 lim = GEOM.SHAPE
-                for s in ListShapes: lim = min( lim, s.GetMaxShapeType() )
+                for s in ListShapes: lim = min(lim, s.GetMaxShapeType())
                 Limit = EnumToLong(lim)
                 pass
             anObj = self.BoolOp.MakePartition(ListShapes, ListTools,
@@ -8218,7 +8327,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if Limit == self.ShapeType["AUTO"]:
                 # automatic detection of the most appropriate shape limit type
                 lim = GEOM.SHAPE
-                for s in ListShapes: lim = min( lim, s.GetMaxShapeType() )
+                for s in ListShapes: lim = min(lim, s.GetMaxShapeType())
                 Limit = EnumToLong(lim)
                 pass
             anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools,
@@ -9847,7 +9956,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             Deprecated method. Use MultiRotate1DNbTimes instead.
             """
-            print "The method MultiRotate1D is DEPRECATED. Use MultiRotate1DNbTimes instead."
+            print("The method MultiRotate1D is DEPRECATED. Use MultiRotate1DNbTimes instead.")
             return self.MultiRotate1DNbTimes(theObject, theAxis, theNbTimes, theName)
 
         ## The same, as MultiRotate2DByStep(), but theAngle is in degrees.
@@ -9861,7 +9970,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             Example of usage:
                 rot2d = geompy.MultiRotate2D(prism, vect, 60, 4, 50, 5)
             """
-            print "The method MultiRotate2D is DEPRECATED. Use MultiRotate2DByStep instead."
+            print("The method MultiRotate2D is DEPRECATED. Use MultiRotate2DByStep instead.")
             theAngle, theNbTimes1, theStep, theNbTimes2, Parameters = ParseParameters(theAngle, theNbTimes1, theStep, theNbTimes2)
             anObj = self.TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2)
             RaiseIfFailed("MultiRotate2D", self.TrsfOp)
@@ -9881,7 +9990,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 vy = geompy.MakeVectorDXDYDZ(0, 100, 0)
                 MultiRot1D = geompy.MakeMultiRotation1D(prism, vy, pz, 6)
             """
-            print "The method MakeMultiRotation1D is DEPRECATED. Use MakeMultiRotation1DNbTimes instead."
+            print("The method MakeMultiRotation1D is DEPRECATED. Use MakeMultiRotation1DNbTimes instead.")
             aVec = self.MakeLine(aPoint,aDir)
             # note: auto-publishing is done in self.MultiRotate1D()
             anObj = self.MultiRotate1D(aShape, aVec, aNbTimes, theName)
@@ -9899,7 +10008,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 vy = geompy.MakeVectorDXDYDZ(0, 100, 0)
                 MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3)
             """
-            print "The method MakeMultiRotation2D is DEPRECATED. Use MakeMultiRotation2DByStep instead."
+            print("The method MakeMultiRotation2D is DEPRECATED. Use MakeMultiRotation2DByStep instead.")
             aVec = self.MakeLine(aPoint,aDir)
             # note: auto-publishing is done in self.MultiRotate2D()
             anObj = self.MultiRotate2D(aShape, aVec, anAngle, nbtimes1, aStep, nbtimes2, theName)
@@ -11073,6 +11182,124 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             return aSurf
         ## @}
 
+        ## Measure curvature radius of surface in the given point along the given direction.
+        #  @param theSurf the given face.
+        #  @param thePoint given point.
+        #  @param theDirection given direction.
+        #  @param theName Object name; when specified, this parameter is used
+        #         for result publication in the study. Otherwise, if automatic
+        #         publication is switched on, default value is used for result name.
+        #
+        #  @return New GEOM.GEOM_Object, containing vector of curvature of theSurf.
+        #          The returned vector is codirectional with the normal to the face
+        #          in the given point in case of positive curvature value
+        #          and opposite to the normal in case of negative curvature.
+        #          The normal of the returned vector is equal to the
+        #          absolute value of the curvature radius.
+        #          Null shape is returned in case of infinite radius
+        #          (zero curvature), for example, in case of flat face.
+        #
+        ## @ref swig_CurvatureOnFace "Example"
+        @ManageTransactions("MeasuOp")
+        def CurvatureOnFace(self, theSurf, thePoint, theDirection, theName=None):
+            """
+            Measure curvature radius of surface in the given point along the given direction.
+
+            Parameters:
+                theSurf the given face.
+                thePoint given point.
+                theDirection given direction.
+                theName Object name; when specified, this parameter is used
+                        for result publication in the study. Otherwise, if automatic
+                        publication is switched on, default value is used for result name.
+
+            Returns:
+                New GEOM.GEOM_Object, containing vector of curvature of theSurf.
+                The returned vector is codirectional with the normal to the face
+                in the given point in case of positive curvature value
+                and opposite to the normal in case of negative curvature.
+                The normal of the returned vector is equal to the
+                absolute value of the curvature radius.
+                Null shape is returned in case of infinite radius
+                (zero curvature), for example, in case of flat face.
+
+            Example of usage:
+                curvature_1 = geompy.CurvatureOnFace(Face_1, Vertex_1, OX)
+            """
+            aVec = self.MeasuOp.SurfaceCurvatureByPointAndDirection(theSurf,thePoint,theDirection)
+            if self.MeasuOp.GetErrorCode() != "ZERO_CURVATURE":
+                RaiseIfFailed("CurvatureOnFace", self.MeasuOp)
+                self._autoPublish(aVec, theName, "curvature")
+            return aVec
+
+        ## Convert X,Y,Z points coordinates to UV parameters on the given surface.
+        #  @param theSurf the given face. It can be also a shell or a compound with one face.
+        #  @param theXYZlist float list of size 3*N where N is the number of points
+        #                    for which we want their U,V coordinates.
+        #                    If the user enters a list of size not divisible by 3
+        #                    an exception will be thrown.
+        #  @param theIsNormalized if True, the returned parameters will be in range [0, 1].
+        #
+        #  @return list of float of size 2*N.
+        #
+        #  @ref tui_xyz_to_uv_page "Example"
+        @ManageTransactions("MeasuOp")
+        def XYZtoUV(self, theSurf, theXYZlist, theIsNormalized = True):
+            """
+            Convert X,Y,Z points coordinates to UV parameters on the given surface.
+
+            Parameters:
+                theSurf the given face. It can be also a shell or a compound with one face.
+                theXYZlist float list of size 3*N where N is the number of points
+                           for which we want their U,V coordinates.
+                           If the user enters a list of size not divisible by 3
+                           an exception will be thrown.
+                theIsNormalized if True, the returned parameters will be in range [0, 1].
+
+            Returns:
+                list of float of size 2*N.
+
+            Example of usage:
+                [u1,v1, u2,v2] = geompy.XYZtoUV(Face_1, [0,0,0, 0,10,10])
+            """
+            aUVlist = self.MeasuOp.XYZtoUV(theSurf, theXYZlist, theIsNormalized)
+            RaiseIfFailed("XYZtoUV", self.MeasuOp)
+            return aUVlist
+
+        ## Convert UV parameters on the given surface to 3D points coordinates.
+        #  @param theSurf the given face. It can be also a shell or a compound with one face.
+        #  @param theUVlist float list of size 2*N where N is the number of points
+        #                   for which we want their X,Y,Z coordinates.
+        #                   If the user enters a list of non-even size
+        #                   an exception will be thrown.
+        #  @param theIsNormalized if True, the input parameters are expected to be in range [0, 1].
+        #
+        #  @return list of float of size 3*N.
+        #
+        #  @ref tui_xyz_to_uv_page "Example"
+        @ManageTransactions("MeasuOp")
+        def UVtoXYZ(self, theSurf, theUVlist, theIsNormalized = True):
+            """
+            Convert UV parameters on the given surface to 3D points coordinates.
+
+            Parameters:
+                theSurf the given face. It can be also a shell or a compound with one face.
+                theUVlist float list of size 2*N where N is the number of points
+                          for which we want their X,Y,Z coordinates.
+                          If the user enters a list of non-even size
+                          an exception will be thrown.
+                theIsNormalized if True, the input parameters are expected to be in range [0, 1].
+
+            Returns:
+                list of float of size 3*N.
+
+            Example of usage:
+                [x1,y1,z1, x2,y2,z2] = geompy.UVtoXYZ(Face_1, [0,0, 10,10])
+            """
+            aXYZlist = self.MeasuOp.UVtoXYZ(theSurf, theUVlist, theIsNormalized)
+            RaiseIfFailed("UVtoXYZ", self.MeasuOp)
+            return aXYZlist
+
         ## Get min and max tolerances of sub-shapes of theShape
         #  @param theShape Shape, to get tolerances of.
         #  @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax]\n
@@ -11215,9 +11442,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "centerOfMass")
             return anObj
 
-        ## Get a vertex sub-shape by index depended with orientation.
+        ## Get a vertex sub-shape by index.
         #  @param theShape Shape to find sub-shape.
         #  @param theIndex Index to find vertex by this index (starting from zero)
+        #  @param theUseOri To consider edge/wire orientation or not
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
         #         publication is switched on, default value is used for result name.
@@ -11226,13 +11454,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_measurement_tools_page "Example"
         @ManageTransactions("MeasuOp")
-        def GetVertexByIndex(self, theShape, theIndex, theName=None):
+        def GetVertexByIndex(self, theShape, theIndex, theUseOri=True, theName=None):
             """
-            Get a vertex sub-shape by index depended with orientation.
+            Get a vertex sub-shape by index.
 
             Parameters:
                 theShape Shape to find sub-shape.
                 theIndex Index to find vertex by this index (starting from zero)
+                theUseOri To consider edge/wire orientation or not
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
                         publication is switched on, default value is used for result name.
@@ -11241,7 +11470,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 New GEOM.GEOM_Object, containing the created vertex.
             """
             # Example: see GEOM_TestMeasures.py
-            anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex)
+            if isinstance( theUseOri, str ): # theUseOri was inserted before theName
+                theUseOri, theName = True, theUseOri
+            anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex, theUseOri)
             RaiseIfFailed("GetVertexByIndex", self.MeasuOp)
             self._autoPublish(anObj, theName, "vertex")
             return anObj
@@ -11270,7 +11501,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             # Example: see GEOM_TestMeasures.py
             # note: auto-publishing is done in self.GetVertexByIndex()
-            return self.GetVertexByIndex(theShape, 0, theName)
+            return self.GetVertexByIndex(theShape, 0, True, theName)
 
         ## Get the last vertex of wire/edge depended orientation.
         #  @param theShape Shape to find last vertex.
@@ -11297,7 +11528,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             # Example: see GEOM_TestMeasures.py
             nb_vert =  self.NumberOfSubShapes(theShape, self.ShapeType["VERTEX"])
             # note: auto-publishing is done in self.GetVertexByIndex()
-            return self.GetVertexByIndex(theShape, (nb_vert-1), theName)
+            return self.GetVertexByIndex(theShape, (nb_vert-1), True, theName)
 
         ## Get a normale to the given face. If the point is not given,
         #  the normale is calculated at the center of mass.
@@ -11360,7 +11591,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             Descr = self.MeasuOp.PrintShapeErrors(theShape, theShapeErrors)
             if theReturnStatus == 1:
                 return Descr
-            print Descr
+            print(Descr)
             pass
 
         ## Check a topology of the given shape.
@@ -11415,7 +11646,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if IsValid == 0:
                 if theReturnStatus == 0:
                     Descr = self.MeasuOp.PrintShapeErrors(theShape, ShapeErrors)
-                    print Descr
+                    print(Descr)
             if theReturnStatus == 1:
               Descr = self.MeasuOp.PrintShapeErrors(theShape, ShapeErrors)
               return (IsValid, Descr)
@@ -11624,6 +11855,39 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
 
             return aKindTuple
 
+        ## The function takes a single face with holes and returns a list of faces,
+        #  first of them is the original face without holes, and the other faces are placed
+        #  on the same surface as the original face but bounded by each hole wire.
+        #  If the original face has no holes, it will be returned as an output
+        #  @param theShape Face to perform operation on.
+        #
+        #  @return GEOM.ListOfGO, list created faces, where first of them is the original face without holes
+        @ManageTransactions("MeasuOp")
+        def PatchFace(self, theShape):
+            """
+            The function takes a single face with holes and returns a list of faces,
+            first of them is the original face without holes, and the other faces are placed
+            on the same surface as the original face but bounded by each hole wire.
+            If the original face has no holes, it will be returned as an output
+
+            Parameters:
+                theShape  Face to perform operation on.
+
+            Returns:
+                GEOM.ListOfGO, list created faces, where first of them is the original face without holes
+
+            Example of usage:
+                Circle_1 = geompy.MakeCircle(None, None, 190)
+                Circle_2 = geompy.MakeCircle(None, None, 100)
+                Face_1 = geompy.MakeFaceWires([Circle_1], 1)
+                Face_2 = geompy.MakeFaceWires([Circle_2], 1)
+                Cut_1 = geompy.MakeCutList(Face_1, [Face_2], True)
+                faces = geompy.PatchFace(Cut_1)
+            """
+            aList = self.MeasuOp.PatchFace(theShape)
+            RaiseIfFailed("PatchFace", self.MeasuOp)
+            return aList
+
         ## Returns the string that describes if the shell is good for solid.
         #  This is a support method for MakeSolid.
         #
@@ -11646,6 +11910,22 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             aDescr = self.MeasuOp.IsGoodForSolid(theShell)
             return aDescr
 
+        ## Obtain a canonical recognition interface.
+        #  @return An instance of
+        #          @ref canonicalrecognition.CanonicalRecognition "CanonicalRecognition" interface
+        #
+        #  @ref tui_3dsketcher_page "Example"
+        def CanonicalRecognition (self):
+            """
+            Obtain a canonical recognition interface.
+
+            Example of usage:
+                cr = geompy.CanonicalRecognition()
+                cr.isLine(aLine, tolerance)
+            """
+            cr = CanonicalRecognition (self)
+            return cr
+
         # end of l2_measure
         ## @}
 
@@ -11706,10 +11986,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 material groups are not automatically published.
             """
             # Example: see GEOM_TestOthers.py
-            print """
+            print("""
             WARNING: Function ImportFile is deprecated, use Import<FormatName> instead,
             where <FormatName> is a name of desirable format for importing.
-            """
+            """)
             aListObj = self.InsertOp.ImportFile(theFileName, theFormatName)
             RaiseIfFailed("ImportFile", self.InsertOp)
             aNbObj = len(aListObj)
@@ -11765,7 +12045,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if not theStream:
                 # this is the workaround to ignore invalid case when data stream is empty
                 if int(os.getenv("GEOM_IGNORE_RESTORE_SHAPE", "0")) > 0:
-                    print "WARNING: Result of RestoreShape is a NULL shape!"
+                    print("WARNING: Result of RestoreShape is a NULL shape!")
                     return None
             anObj = self.InsertOp.RestoreShape(theStream)
             RaiseIfFailed("RestoreShape", self.InsertOp)
@@ -11800,13 +12080,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                               geompy.InsertOp.ExportTranslators()[0] method.
             """
             # Example: see GEOM_TestOthers.py
-            print """
+            print("""
             WARNING: Function Export is deprecated, use Export<FormatName> instead,
             where <FormatName> is a name of desirable format for exporting.
-            """
+            """)
             self.InsertOp.Export(theObject, theFileName, theFormatName)
             if self.InsertOp.IsDone() == 0:
-                raise RuntimeError,  "Export : " + self.InsertOp.GetErrorCode()
+                raise RuntimeError("Export : " + self.InsertOp.GetErrorCode())
                 pass
             pass
 
@@ -12409,7 +12689,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             RaiseIfFailed("CheckCompoundOfBlocks", self.BlocksOp)
             if IsValid == 0:
                 Descr = self.BlocksOp.PrintBCErrors(theCompound, BCErrors)
-                print Descr
+                print(Descr)
             return IsValid
 
         ## Retrieve all non blocks solids and faces from \a theShape.
@@ -12936,7 +13216,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             RaiseIfFailed("RemoveObject", self.GroupOp)
             pass
 
-        ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
+        ## Adds to the group all the given shapes. No errors, if some shapes are already included.
         #  @param theGroup is a GEOM group to which the new sub-shapes are added.
         #  @param theSubShapes is a list of sub-shapes to be added.
         #
@@ -12944,7 +13224,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         @ManageTransactions("GroupOp")
         def UnionList (self,theGroup, theSubShapes):
             """
-            Adds to the group all the given shapes. No errors, if some shapes are alredy included.
+            Adds to the group all the given shapes. No errors, if some shapes are already included.
 
             Parameters:
                 theGroup is a GEOM group to which the new sub-shapes are added.
@@ -12955,7 +13235,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             RaiseIfFailed("UnionList", self.GroupOp)
             pass
 
-        ## Adds to the group all the given shapes. No errors, if some shapes are alredy included.
+        ## Adds to the group all the given shapes. No errors, if some shapes are already included.
         #  @param theGroup is a GEOM group to which the new sub-shapes are added.
         #  @param theSubShapes is a list of indices of sub-shapes to be added.
         #
@@ -12963,7 +13243,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         @ManageTransactions("GroupOp")
         def UnionIDs(self,theGroup, theSubShapes):
             """
-            Adds to the group all the given shapes. No errors, if some shapes are alredy included.
+            Adds to the group all the given shapes. No errors, if some shapes are already included.
 
             Parameters:
                 theGroup is a GEOM group to which the new sub-shapes are added.
@@ -13433,7 +13713,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                             edges_in_range.append(edge)
 
             if len(edges_in_range) <= 0:
-                print "No edges found by given criteria"
+                print("No edges found by given criteria")
                 return None
 
             # note: auto-publishing is done in self.CreateGroup()
@@ -13466,10 +13746,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             nb_selected = sg.SelectedCount()
             if nb_selected < 1:
-                print "Select a shape before calling this function, please."
+                print("Select a shape before calling this function, please.")
                 return 0
             if nb_selected > 1:
-                print "Only one shape must be selected"
+                print("Only one shape must be selected")
                 return 0
 
             id_shape = sg.getSelected(0)
@@ -13482,10 +13762,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             if include_min: left_str  = " <= "
             if include_max: right_str  = " <= "
 
-            self.addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length`
-                                    + left_str + "length" + right_str + `max_length`)
+            self.addToStudyInFather(shape, group_edges, "Group of edges with " + repr(min_length)
+                                    + left_str + "length" + right_str + repr(max_length))
 
-            sg.updateObjBrowser(True)
+            sg.updateObjBrowser()
 
             return group_edges
 
@@ -13688,7 +13968,6 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             Returns:
                 a new created folder
             """
-            if not Father: Father = self.father
             return self.CreateFolder(Name, Father)
 
         ## Move object to the specified folder
@@ -13750,7 +14029,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             """
             if isinstance( type, int ):
                 if type < 0 or type > 3:
-                    raise RuntimeError, "CreateField : Error: data type must be within [0-3] range"
+                    raise RuntimeError("CreateField : Error: data type must be within [0-3] range")
                 type = [GEOM.FDT_Bool,GEOM.FDT_Int,GEOM.FDT_Double,GEOM.FDT_String][type]
 
             f = self.FieldOp.CreateField( shape, name, type, dimension, componentNames)
@@ -13769,7 +14048,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             elif isinstance( field, geomField ):
                 geom.RemoveObject( field.field )
             else:
-                raise RuntimeError, "RemoveField() : the object is not a field"
+                raise RuntimeError("RemoveField() : the object is not a field")
             return
 
         ## Returns number of fields on a shape
@@ -13799,8 +14078,72 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         # end of l2_field
         ## @}
 
+        ## @addtogroup l2_testing
+        ## @{
+
+        ## Build a mesh on the given shape.
+        # @param shape the source shape
+        # @param linear_deflection linear deflection coefficient
+        # @param is_relative says if given value of deflection is relative to shape's bounding box
+        # @param angular_deflection angular deflection for edges in degrees
+        # @return True in case of success; otherwise False.
+        @ManageTransactions("TestOp")
+        def Tesselate(self, shape, linear_deflection=0, is_relative=True, angular_deflection=0):
+            """Build a mesh on the given shape.
+
+            Parameters:
+                shape the source shape
+                linear_deflection linear deflection coefficient
+                is_relative says if given value of deflection is relative to shape's bounding box
+                angular_deflection angular deflection for edges in degrees
+
+            Returns:
+                True in case of success; otherwise False.
+            """
+            if angular_deflection > 0:
+                angular_deflection = angular_deflection * math.pi / 180.
+            r = self.TestOp.Tesselate(shape, linear_deflection, is_relative, angular_deflection)
+            RaiseIfFailed("Tesselate", self.TestOp)
+            return r
+
+        ## Obtain a shape checker
+        #  @return An instance of @ref conformity.CheckConformity "CheckConformity" interface
+        #
+        #  @ref tui_conformity_page "Example"
+        def CheckConformity (self, shape):
+            """
+            Obtain a shape checker.
+
+            Example of usage:
+                conf = geompy.CheckConformity(shape)
+                valid = conf.isValid()
+                si2d = conf.selfIntersected2D()
+                dist = conf.distantShapes()
+                small = conf.smallEdges()
+                interfer = cc.interferingSubshapes()
+            """
+            conf = CheckConformity (shape, self)
+            return conf
+
+        ## Obtain a shape proximity calculator
+        #  @return An instance of @ref proximity.ShapeProximity "ShapeProximity" interface
+        #
+        #  @ref tui_proximity_page "Example"
+        def ShapeProximity (self):
+            """
+            Obtain a shape proximity calculator.
+
+            Example of usage:
+                prox = geompy.ShapeProximity()
+                value = prox.proximity(shape1, shape2)
+            """
+            prox = ShapeProximity (self)
+            return prox
+
+        # end of l2_testing
+        ## @}
+
 
-import omniORB
 # Register the new proxy for GEOM_Gen
 omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)
 
@@ -13809,8 +14152,8 @@ omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)
 #  @ingroup l2_field
 class geomField( GEOM._objref_GEOM_Field ):
 
-    def __init__(self):
-        GEOM._objref_GEOM_Field.__init__(self)
+    def __init__(self, *args):
+        GEOM._objref_GEOM_Field.__init__(self, *args)
         self.field = GEOM._objref_GEOM_Field
         return
 
@@ -13827,7 +14170,7 @@ class geomField( GEOM._objref_GEOM_Field ):
     ## Returns type of field data as integer [0-3]
     def getType(self):
         "Returns type of field data"
-        return self.field.GetDataType(self)._v
+        return EnumToLong(self.field.GetDataType(self))
 
     ## Returns type of field data:
     #  one of GEOM.FDT_Bool, GEOM.FDT_Int, GEOM.FDT_Double, GEOM.FDT_String
@@ -13855,8 +14198,7 @@ class geomField( GEOM._objref_GEOM_Field ):
         "Adds a time step to the field"
         stp = self.field.AddStep( self, step, stamp )
         if not stp:
-            raise RuntimeError, \
-                  "Field.addStep() : Error: step %s already exists in this field"%step
+            raise RuntimeError("Field.addStep() : Error: step %s already exists in this field"%step)
         global geom
         geom._autoPublish( stp, "", "Step %s, %s"%(step,stamp))
         self.setValues( step, values )
@@ -13894,7 +14236,7 @@ class geomField( GEOM._objref_GEOM_Field ):
         "Returns a time step by its ID"
         stp = self.field.GetStep(self, step)
         if not stp:
-            raise RuntimeError, "Step %s is missing from this field"%step
+            raise RuntimeError("Step %s is missing from this field"%step)
         return stp
 
     ## Returns the time of the field step
@@ -13919,19 +14261,19 @@ class geomField( GEOM._objref_GEOM_Field ):
         errBeg = "Field.setValues(values) : Error: "
         try:
             ok = stp.SetValues( values )
-        except Exception, e:
+        except Exception as e:
             excStr = str(e)
             if excStr.find("WrongPythonType") > 0:
-                raise RuntimeErrorerrBeg +\
-                      "wrong type of values, %s values are expected"%str(self.getTypeEnum())[4:]
-            raise RuntimeError, errBeg + str(e)
+                raise RuntimeError(errBeg +\
+                      "wrong type of values, %s values are expected"%str(self.getTypeEnum())[4:])
+            raise RuntimeError(errBeg + str(e))
         if not ok:
             nbOK = self.field.GetArraySize(self)
             nbKO = len(values)
             if nbOK != nbKO:
-                raise RuntimeError, errBeg + "len(values) must be %s but not %s"%(nbOK,nbKO)
+                raise RuntimeError(errBeg + "len(values) must be %s but not %s"%(nbOK,nbKO))
             else:
-                raise RuntimeError, errBeg + "failed"
+                raise RuntimeError(errBeg + "failed")
         return
 
     pass # end of class geomField
@@ -13948,12 +14290,11 @@ omniORB.registerObjref(GEOM._objref_GEOM_Field._NP_RepositoryId, geomField)
 #    import salome
 #    salome.salome_init()
 #    from salome.geom import geomBuilder
-#    geompy = geomBuilder.New(salome.myStudy)
+#    geompy = geomBuilder.New()
 #  \endcode
-#  @param  study     SALOME study, generally obtained by salome.myStudy.
 #  @param  instance  CORBA proxy of GEOM Engine. If None, the default Engine is used.
 #  @return geomBuilder instance
-def New( study, instance=None):
+def New( instance=None):
     """
     Create a new geomBuilder instance.The geomBuilder class provides the Python
     interface to GEOM operations.
@@ -13962,10 +14303,9 @@ def New( study, instance=None):
         import salome
         salome.salome_init()
         from salome.geom import geomBuilder
-        geompy = geomBuilder.New(salome.myStudy)
+        geompy = geomBuilder.New()
 
     Parameters:
-        study     SALOME study, generally obtained by salome.myStudy.
         instance  CORBA proxy of GEOM Engine. If None, the default Engine is used.
     Returns:
         geomBuilder instance
@@ -13974,12 +14314,16 @@ def New( study, instance=None):
     global engine
     global geom
     global doLcc
+    if instance and isinstance( instance, SALOMEDS._objref_Study ):
+        import sys
+        sys.stderr.write("Warning: 'study' argument is no more needed in geomBuilder.New(). Consider updating your script!!!\n\n")
+        instance = None
     engine = instance
     if engine is None:
       doLcc = True
     geom = geomBuilder()
     assert isinstance(geom,geomBuilder), "Geom engine class is %s but should be geomBuilder.geomBuilder. Import geomBuilder before creating the instance."%geom.__class__
-    geom.init_geom(study)
+    geom.init_geom()
     return geom
 
 
@@ -13989,15 +14333,15 @@ plugins_var = os.environ.get( "GEOM_PluginsList" )
 plugins = None
 if plugins_var is not None:
     plugins = plugins_var.split( ":" )
-    plugins=filter(lambda x: len(x)>0, plugins)
+    plugins=[x for x in plugins if len(x)>0]
 if plugins is not None:
     for pluginName in plugins:
         pluginBuilderName = pluginName + "Builder"
         try:
             exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName))
-        except Exception, e:
+        except Exception as e:
             from salome_utils import verbose
-            print "Exception while loading %s: %s" % ( pluginBuilderName, e )
+            print("Exception while loading %s: %s" % ( pluginBuilderName, e ))
             continue
         exec( "from salome.%s import %s" % (pluginName, pluginBuilderName))
         plugin = eval( pluginBuilderName )