Salome HOME
0023312: [CEA 1928] GEOM: Create group from second shape
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IShapesOperations.cxx
index 34db98229f27a306da5e6ff8aca241c385860ba9..75b41d6e77cf20fcefaaefa4206101304b3e444d 100644 (file)
@@ -123,9 +123,9 @@ namespace {
     else {
       TopoDS_Iterator It(S, Standard_True, Standard_True);
       for (; It.More(); It.Next()) {
-       TopoDS_Shape SS = It.Value();
-       if (M.Add(SS))
-         AddFlatSubShapes(SS, L, M);
+        TopoDS_Shape SS = It.Value();
+        if (M.Add(SS))
+          AddFlatSubShapes(SS, L, M);
       }
     }
   }
@@ -139,7 +139,7 @@ namespace
    * \brief Returns the vertex from theWhere shape that is coincident with
    * theVertex.
    *
-   * \param theWhere the shape where the coinsident vertex is searched.
+   * \param theWhere the shape where the coincident vertex is searched.
    * \param theVertex the vertex to be searched.
    * \return the coincident vertex if it is found. Otherwise null object.
    */
@@ -176,8 +176,8 @@ namespace
  *   constructor:
  */
 //=============================================================================
-GEOMImpl_IShapesOperations::GEOMImpl_IShapesOperations (GEOM_Engine* theEngine, int theDocID)
-: GEOM_IOperations(theEngine, theDocID)
+GEOMImpl_IShapesOperations::GEOMImpl_IShapesOperations (GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
 {
   MESSAGE("GEOMImpl_IShapesOperations::GEOMImpl_IShapesOperations");
 }
@@ -205,7 +205,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge
   if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
 
   //Add a new Edge object
-  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE);
+  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GEOM_EDGE);
 
   //Add a new Vector function
   Handle(GEOM_Function) aFunction =
@@ -231,9 +231,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -260,7 +259,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeOnCurveByLength
   if (theRefCurve.IsNull()) return NULL;
 
   //Add a new Edge object
-  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE);
+  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GEOM_EDGE);
 
   //Add a new Vector function
   Handle(GEOM_Function) aFunction =
@@ -290,9 +289,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeOnCurveByLength
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -319,7 +317,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeWire
   if (theWire.IsNull()) return NULL;
 
   //Add a new Edge object
-  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE);
+  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GEOM_EDGE);
 
   //Add a new Vector function
   Handle(GEOM_Function) aFunction =
@@ -346,9 +344,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeWire
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -385,7 +382,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire
   SetErrorCode(KO);
 
   //Add a new object
-  Handle(GEOM_Object) aWire = GetEngine()->AddObject(GetDocID(), GEOM_WIRE);
+  Handle(GEOM_Object) aWire = GetEngine()->AddObject(GEOM_WIRE);
 
   //Add a new function
   Handle(GEOM_Function) aFunction =
@@ -420,9 +417,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -457,7 +453,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
   if (theWire.IsNull()) return NULL;
 
   //Add a new Face object
-  Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
+  Handle(GEOM_Object) aFace = GetEngine()->AddObject(GEOM_FACE);
 
   //Add a new Shape function for creation of a face from a wire
   Handle(GEOM_Function) aFunction =
@@ -485,9 +481,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -517,7 +512,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   SetErrorCode(KO);
 
   //Add a new object
-  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
+  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GEOM_FACE);
 
   //Add a new function
   Handle(GEOM_Function) aFunction =
@@ -554,9 +549,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -596,7 +590,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceFromSurface
   SetErrorCode(KO);
 
   //Add a new object
-  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
+  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GEOM_FACE);
 
   //Add a new function
   Handle(GEOM_Function) aFunction =
@@ -640,9 +634,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceFromSurface
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -666,7 +659,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWithConstraints
   SetErrorCode(KO);
 
   //Add a new object
-  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
+  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GEOM_FILLING);
 
   //Add a new function
   Handle(GEOM_Function) aFunction =
@@ -728,9 +721,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWithConstraints
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -807,7 +799,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
   SetErrorCode(KO);
 
   //Add a new object
-  Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), theObjectType);
+  Handle(GEOM_Object) aShape = GetEngine()->AddObject(theObjectType);
 
   //Add a new function
   Handle(GEOM_Function) aFunction =
@@ -841,9 +833,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -877,7 +868,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSolidFromConnectedFaces
   SetErrorCode(KO);
 
   //Add a new object
-  Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
+  Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GEOM_SOLID);
 
   //Add a new function
   Handle(GEOM_Function) aFunction =
@@ -912,9 +903,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSolidFromConnectedFaces
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -955,7 +945,7 @@ GEOMImpl_IShapesOperations::MakeGlueFaces (std::list< Handle(GEOM_Object) >& the
   }
 
   //Add a new Glued object
-  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
+  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GEOM_GLUED);
 
   //Add a new Glue function
   Handle(GEOM_Function) aFunction;
@@ -980,9 +970,8 @@ GEOMImpl_IShapesOperations::MakeGlueFaces (std::list< Handle(GEOM_Object) >& the
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -1103,7 +1092,7 @@ GEOMImpl_IShapesOperations::MakeGlueFacesByList(std::list< Handle(GEOM_Object) >
   }
 
   //Add a new Glued object
-  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
+  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GEOM_GLUED);
 
   //Add a new Glue function
   Handle(GEOM_Function) aFunction;
@@ -1130,9 +1119,8 @@ GEOMImpl_IShapesOperations::MakeGlueFacesByList(std::list< Handle(GEOM_Object) >
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -1171,7 +1159,7 @@ GEOMImpl_IShapesOperations::MakeGlueEdges (std::list< Handle(GEOM_Object) >& the
   }
 
   //Add a new Glued object
-  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
+  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GEOM_GLUED);
 
   //Add a new Glue function
   Handle(GEOM_Function) aFunction;
@@ -1196,9 +1184,8 @@ GEOMImpl_IShapesOperations::MakeGlueEdges (std::list< Handle(GEOM_Object) >& the
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -1352,7 +1339,7 @@ GEOMImpl_IShapesOperations::MakeGlueEdgesByList (std::list< Handle(GEOM_Object)
     return NULL;
   }
   //Add a new Glued object
-  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED);
+  Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GEOM_GLUED);
 
   //Add a new Glue function
   Handle(GEOM_Function) aFunction;
@@ -1378,9 +1365,8 @@ GEOMImpl_IShapesOperations::MakeGlueEdgesByList (std::list< Handle(GEOM_Object)
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     // to provide warning
     if (!aFunction->GetValue().IsNull()) {
       isWarning = Standard_True;
@@ -1460,16 +1446,15 @@ GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object)    theShap
     Standard_Integer aStrLen = anEntry.LengthOfCString();
     char* anEntryStr = new char[aStrLen+1];
     anEntry.ToUTF8CString(anEntryStr);
-    Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(GetDocID(), anEntryStr, false);
+    Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(anEntryStr, false);
     if (!anObj.IsNull() ) {
       bool isGroup    = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() == GEOM_GROUP;
       bool isSubShape = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() != GEOM_GROUP;
       bool isField    = anObj->IsKind(STANDARD_TYPE(GEOM_Field));
-      if (theTypes & Groups    && isGroup ||
-          theTypes & SubShapes && isSubShape ||
-          theTypes & Fields    && isField) {
+      if ((theTypes & Groups    && isGroup    ) ||
+          (theTypes & SubShapes && isSubShape ) ||
+          (theTypes & Fields    && isField    ))
         aSeq->Append(anObj);
-      }
     }
     delete [] anEntryStr;
   }
@@ -1515,11 +1500,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
     for (; It.More(); It.Next()) {
       TopoDS_Shape SS = It.Value();
       if (mapShape.Add(SS)) {
-       if (theShapeType == TopAbs_FLAT) {
+        if (theShapeType == TopAbs_FLAT) {
           AddFlatSubShapes(SS, listShape, mapShape);
-       }
+        }
         else if (theShapeType == TopAbs_SHAPE || theShapeType == SS.ShapeType()) {
-         listShape.Append(SS);
+          listShape.Append(SS);
         }
         // VSR: for EXPLODE_NEW_INCLUDE_MAIN and EXPLODE_OLD_INCLUDE_MAIN:
         // it seems it is necessary to add top-level shape if theShapeType == TopAbs_COMPOUND
@@ -1561,7 +1546,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
 
     //anObj = GetEngine()->AddSubShape(theShape, anArray);
     {
-      anObj = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+      anObj = GetEngine()->AddObject(GEOM_SUBSHAPE);
       Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
       if (aFunction.IsNull()) return aSeq;
 
@@ -1641,9 +1626,9 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs
     for (; It.More(); It.Next()) {
       TopoDS_Shape SS = It.Value();
       if (mapShape.Add(SS)) {
-       if (theShapeType == TopAbs_FLAT) {
+        if (theShapeType == TopAbs_FLAT) {
           AddFlatSubShapes(SS, listShape, mapShape);
-       }
+        }
         else if (theShapeType == TopAbs_SHAPE || theShapeType == SS.ShapeType()) {
           listShape.Append(SS);
         }
@@ -1777,7 +1762,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeSubShapes
       anArray = new TColStd_HArray1OfInteger(1,1);
       anArray->SetValue(1, id);
 
-      anObj = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+      anObj = GetEngine()->AddObject(GEOM_SUBSHAPE);
       if (!anObj.IsNull()) {
         Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
         if (aFunction.IsNull()) return aSeq;
@@ -2143,9 +2128,8 @@ Standard_Integer GEOMImpl_IShapesOperations::NumberOfSubShapes
         nbShapes = nbTypes[theShapeType];
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return -1;
   }
 
@@ -2166,7 +2150,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object)
 
   /*
   //Add a new reversed object
-  Handle(GEOM_Object) aReversed = GetEngine()->AddObject(GetDocID(), theShape->GetType());
+  Handle(GEOM_Object) aReversed = GetEngine()->AddObject(theShape->GetType());
 
   //Add a new Revese function
   Handle(GEOM_Function) aFunction;
@@ -2191,9 +2175,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object)
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -2212,7 +2195,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object)
 
   if (aGen) {
     GEOMImpl_IHealingOperations* anIHealingOperations =
-      aGen->GetIHealingOperations(GetDocID());
+      aGen->GetIHealingOperations();
     aReversed = anIHealingOperations->ChangeOrientationCopy(theShape);
     SetErrorCode(anIHealingOperations->GetErrorCode());
   }
@@ -2452,7 +2435,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
       for (; itSel.More(); itSel.Next()) {
         const TopoDS_Shape& aSS = itSel.Value();
         if (mapShape.Add(aSS) )
-         aShared.Append(aSS);
+          aShared.Append(aSS);
       }
     }
   }
@@ -2661,7 +2644,7 @@ Handle(TColStd_HSequenceOfInteger)
   aFinder.SetState(theState);
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -2853,7 +2836,7 @@ Handle(TColStd_HSequenceOfInteger)
   aFinder.SetState(theState);
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -3020,7 +3003,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnShapeAsCompound
   }
 
   //Add a new result object
-  Handle(GEOM_Object) aRes = GetEngine()->AddObject(GetDocID(), GEOM_SHAPES_ON_SHAPE);
+  Handle(GEOM_Object) aRes = GetEngine()->AddObject(GEOM_SHAPES_ON_SHAPE);
   Handle(GEOM_Function) aFunction =
     aRes->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPES_ON_SHAPE);
   aFunction->SetValue(aCompound);
@@ -3202,7 +3185,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeExtraction
 
   //Add a new Result object
   Handle(GEOM_Object) aResult =
-              GetEngine()->AddObject(GetDocID(), GEOM_EXTRACTION);
+              GetEngine()->AddObject(GEOM_EXTRACTION);
 
   //Add a new Extraction function
   Handle(GEOM_Function) aFunction =
@@ -3233,9 +3216,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeExtraction
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
 
     return NULL;
   }
@@ -3323,9 +3305,8 @@ Handle(TColStd_HSequenceOfInteger)
         VertMax = T;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return aSeqOfIDs;
   }
   // END: Mantis issue 0020961
@@ -3347,14 +3328,14 @@ Handle(TColStd_HSequenceOfInteger)
   // Default value=3
   aFinder.SetNbPntsMin(3);
   // Sets the maximal number of inner points for edges or faces.
-  // It is usefull for the cases when this number is very big (e.g =2000) to improve
+  // It is useful for the cases when this number is very big (e.g =2000) to improve
   // the performance. If this value =0, all inner points will be taken into account.
   // Default value=0
   aFinder.SetNbPntsMax(100);
 
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -4198,9 +4179,9 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnSphere
     * \param theShape - the shape to explore
     * \param theShapeType - type of sub-shape of theShape
     * \param theTopLeftPoint - top left quadrangle corner
-    * \param theTopRigthPoint - top right quadrangle corner
+    * \param theTopRightPoint - top right quadrangle corner
     * \param theBottomLeftPoint - bottom left quadrangle corner
-    * \param theBottomRigthPoint - bottom right quadrangle corner
+    * \param theBottomRightPoint - bottom right quadrangle corner
     * \param theState - required state
     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
@@ -4209,25 +4190,25 @@ Handle(TColStd_HSequenceOfInteger)
   GEOMImpl_IShapesOperations::getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
                                                         const Standard_Integer     theShapeType,
                                                         const Handle(GEOM_Object)& theTopLeftPoint,
-                                                        const Handle(GEOM_Object)& theTopRigthPoint,
+                                                        const Handle(GEOM_Object)& theTopRightPoint,
                                                         const Handle(GEOM_Object)& theBottomLeftPoint,
-                                                        const Handle(GEOM_Object)& theBottomRigthPoint,
+                                                        const Handle(GEOM_Object)& theBottomRightPoint,
                                                         const GEOMAlgo_State       theState)
 {
   SetErrorCode(KO);
 
   if ( theShape.IsNull() ||
        theTopLeftPoint.IsNull() ||
-       theTopRigthPoint.IsNull() ||
+       theTopRightPoint.IsNull() ||
        theBottomLeftPoint.IsNull() ||
-       theBottomRigthPoint.IsNull() )
+       theBottomRightPoint.IsNull() )
     return NULL;
 
   TopoDS_Shape aShape = theShape->GetValue();
   TopoDS_Shape aTL = theTopLeftPoint->GetValue();
-  TopoDS_Shape aTR = theTopRigthPoint->GetValue();
+  TopoDS_Shape aTR = theTopRightPoint->GetValue();
   TopoDS_Shape aBL = theBottomLeftPoint->GetValue();
-  TopoDS_Shape aBR = theBottomRigthPoint->GetValue();
+  TopoDS_Shape aBR = theBottomRightPoint->GetValue();
 
   if (aShape.IsNull() ||
       aTL.IsNull() ||
@@ -4275,14 +4256,14 @@ Handle(TColStd_HSequenceOfInteger)
   // Default value=3
   aFinder.SetNbPntsMin(3);
   // Sets the maximal number of inner points for edges or faces.
-  // It is usefull for the cases when this number is very big (e.g =2000) to improve
+  // It is useful for the cases when this number is very big (e.g =2000) to improve
   // the performance. If this value =0, all inner points will be taken into account.
   // Default value=0
   aFinder.SetNbPntsMax(100);
 
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -4327,9 +4308,9 @@ Handle(TColStd_HSequenceOfInteger)
     * \param theShape - the shape to explore
     * \param theShapeType - type of sub-shape of theShape
     * \param theTopLeftPoint - top left quadrangle corner
-    * \param theTopRigthPoint - top right quadrangle corner
+    * \param theTopRightPoint - top right quadrangle corner
     * \param theBottomLeftPoint - bottom left quadrangle corner
-    * \param theBottomRigthPoint - bottom right quadrangle corner
+    * \param theBottomRightPoint - bottom right quadrangle corner
     * \param theState - required state
     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
@@ -4338,9 +4319,9 @@ Handle(TColStd_HSequenceOfTransient)
     GEOMImpl_IShapesOperations::GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
                                                        const Standard_Integer     theShapeType,
                                                        const Handle(GEOM_Object)& theTopLeftPoint,
-                                                       const Handle(GEOM_Object)& theTopRigthPoint,
+                                                       const Handle(GEOM_Object)& theTopRightPoint,
                                                        const Handle(GEOM_Object)& theBottomLeftPoint,
-                                                       const Handle(GEOM_Object)& theBottomRigthPoint,
+                                                       const Handle(GEOM_Object)& theBottomRightPoint,
                                                        const GEOMAlgo_State       theState)
 {
   // Find indices
@@ -4348,9 +4329,9 @@ Handle(TColStd_HSequenceOfTransient)
     getShapesOnQuadrangleIDs( theShape,
                               theShapeType,
                               theTopLeftPoint,
-                              theTopRigthPoint,
+                              theTopRightPoint,
                               theBottomLeftPoint,
-                              theBottomRigthPoint,
+                              theBottomRightPoint,
                               theState);
   if ( aSeqOfIDs.IsNull() || aSeqOfIDs->IsEmpty() )
     return NULL;
@@ -4372,9 +4353,9 @@ Handle(TColStd_HSequenceOfTransient)
     << theShape << ", "
     << TopAbs_ShapeEnum(theShapeType) << ", "
     << theTopLeftPoint << ", "
-    << theTopRigthPoint << ", "
+    << theTopRightPoint << ", "
     << theBottomLeftPoint << ", "
-    << theBottomRigthPoint << ", "
+    << theBottomRightPoint << ", "
     << theState << ")";
 
   SetErrorCode(OK);
@@ -4388,9 +4369,9 @@ Handle(TColStd_HSequenceOfTransient)
     * \param theShape - the shape to explore
     * \param theShapeType - type of sub-shape of theShape
     * \param theTopLeftPoint - top left quadrangle corner
-    * \param theTopRigthPoint - top right quadrangle corner
+    * \param theTopRightPoint - top right quadrangle corner
     * \param theBottomLeftPoint - bottom left quadrangle corner
-    * \param theBottomRigthPoint - bottom right quadrangle corner
+    * \param theBottomRightPoint - bottom right quadrangle corner
     * \param theState - required state
     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
@@ -4399,9 +4380,9 @@ Handle(TColStd_HSequenceOfInteger)
   GEOMImpl_IShapesOperations::GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
                                                         const Standard_Integer     theShapeType,
                                                         const Handle(GEOM_Object)& theTopLeftPoint,
-                                                        const Handle(GEOM_Object)& theTopRigthPoint,
+                                                        const Handle(GEOM_Object)& theTopRightPoint,
                                                         const Handle(GEOM_Object)& theBottomLeftPoint,
-                                                        const Handle(GEOM_Object)& theBottomRigthPoint,
+                                                        const Handle(GEOM_Object)& theBottomRightPoint,
                                                         const GEOMAlgo_State       theState)
 {
   // Find indices
@@ -4409,9 +4390,9 @@ Handle(TColStd_HSequenceOfInteger)
     getShapesOnQuadrangleIDs( theShape,
                               theShapeType,
                               theTopLeftPoint,
-                              theTopRigthPoint,
+                              theTopRightPoint,
                               theBottomLeftPoint,
-                              theBottomRigthPoint,
+                              theBottomRightPoint,
                               theState);
   if ( aSeqOfIDs.IsNull() || aSeqOfIDs->IsEmpty() )
     return NULL;
@@ -4420,8 +4401,8 @@ Handle(TColStd_HSequenceOfInteger)
 
   // The GetShapesOnCylinder() doesn't change object so no new function is required.
   Handle(GEOM_BaseObject) lastObj = GEOM::GetCreatedLast(theShape,theTopLeftPoint);
-  lastObj = GEOM::GetCreatedLast(lastObj,theTopRigthPoint);
-  lastObj = GEOM::GetCreatedLast(lastObj,theBottomRigthPoint);
+  lastObj = GEOM::GetCreatedLast(lastObj,theTopRightPoint);
+  lastObj = GEOM::GetCreatedLast(lastObj,theBottomRightPoint);
   lastObj = GEOM::GetCreatedLast(lastObj,theBottomLeftPoint);
   Handle(GEOM_Function) aFunction = lastObj->GetLastFunction();
 
@@ -4432,9 +4413,9 @@ Handle(TColStd_HSequenceOfInteger)
     << theShape << ", "
     << TopAbs_ShapeEnum(theShapeType) << ", "
     << theTopLeftPoint << ", "
-    << theTopRigthPoint << ", "
+    << theTopRightPoint << ", "
     << theBottomLeftPoint << ", "
-    << theBottomRigthPoint << ", "
+    << theBottomRightPoint << ", "
     << theState << ")";
 #endif // DUMP_SUBSHAPE_IDS
 
@@ -4482,7 +4463,6 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
 
   if (aShapeResult.IsNull() == Standard_False) {
     TopoDS_Iterator  anIt(aShapeResult);
-    Standard_Boolean isFirst = Standard_True;
 
     for (; anIt.More(); anIt.Next()) {
       const TopoDS_Shape &aPart = anIt.Value();
@@ -4735,6 +4715,42 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
   return aResult;
 }
 
+//=======================================================================
+//function : GetInPlaceMap
+//purpose  :
+//=======================================================================
+void GEOMImpl_IShapesOperations::GetInPlaceMap (Handle(GEOM_Object) theShapeWhere,
+                                                Handle(GEOM_Object) theShapeWhat,
+                                                std::vector< std::vector< int > > & theResVec)
+{
+  SetErrorCode(KO);
+
+  if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return;
+
+  TopoDS_Shape aWhere = theShapeWhere->GetValue();
+  TopoDS_Shape aWhat  = theShapeWhat->GetValue();
+
+  if (aWhere.IsNull() || aWhat.IsNull()) return;
+
+  Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction();
+  if (aWhereFunction.IsNull()) return;
+
+  bool isFound = GEOMAlgo_GetInPlaceAPI::GetInPlaceMap( aWhereFunction, aWhat, theResVec );
+
+  if ( isFound )
+    SetErrorCode(OK);
+
+  Handle(GEOM_Function) aFunction =
+    GEOM::GetCreatedLast(theShapeWhere,theShapeWhat)->GetLastFunction();
+
+  GEOM::TPythonDump(aFunction, /*append=*/true)
+    << "resultList = geompy.GetInPlaceMap( "
+    << theShapeWhere << ", "
+    << theShapeWhat << ")";
+
+  return;
+}
+
 //=======================================================================
 //function : isSameEdge
 //purpose  : Returns True if two edges coincide
@@ -4778,6 +4794,10 @@ static bool isSameEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2)
   gp_Pnt P2 = C1->Value(U);     //Compute a point on two thirds of the edge's length
 
   C2 = new Geom_TrimmedCurve(C2, U21, U22);
+  // vsr 04/10/2018: 0023312 - As curve may be periodic, its parameters may be normalized
+  // so, we re-take them from trimmed curve
+  U21 = C2->FirstParameter();
+  U22 = C2->LastParameter();
 
   if(!GeomLib_Tool::Parameter(C2, P1, MAX_TOLERANCE, U) ||  U < U21 || U > U22)
     return false;
@@ -5181,7 +5201,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ExtendEdge
   }
 
   //Add a new Edge object
-  Handle(GEOM_Object) aResEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE);
+  Handle(GEOM_Object) aResEdge = GetEngine()->AddObject(GEOM_EDGE);
 
   //Add a new Vector function
   Handle(GEOM_Function) aFunction =
@@ -5213,9 +5233,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ExtendEdge
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
 
     return NULL;
   }
@@ -5248,7 +5267,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ExtendFace
   }
 
   //Add a new Face object
-  Handle(GEOM_Object) aResFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
+  Handle(GEOM_Object) aResFace = GetEngine()->AddObject(GEOM_FACE);
 
   //Add a new Vector function
   Handle(GEOM_Function) aFunction =
@@ -5282,9 +5301,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ExtendFace
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
 
     return NULL;
   }
@@ -5314,7 +5332,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSurfaceFromFace
   }
 
   //Add a new Face object
-  Handle(GEOM_Object) aResFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
+  Handle(GEOM_Object) aResFace = GetEngine()->AddObject(GEOM_FACE);
 
   //Add a new Vector function
   Handle(GEOM_Function) aFunction =
@@ -5344,9 +5362,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSurfaceFromFace
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
 
     return NULL;
   }