Salome HOME
Copyright update 2022
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
index 16eb765751e2bfcdc362d7410d3b071454be57a9..751c8839cde7b2f703ca07df7752d33902810a66 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include <Standard_Stream.hxx>
 
 #include "GEOM_IShapesOperations_i.hh"
 #include "GEOM_Engine.hxx"
 #include "GEOM_Object.hxx"
 
+#include <TopAbs.hxx>
 #include <TColStd_HSequenceOfTransient.hxx>
 #include <TColStd_HArray1OfInteger.hxx>
 
+#include <vector>
+
+/**
+ * This function converts GEOM::comparison_condition type into
+ * GEOMUtils::ComparisonCondition type.
+ *
+ * \param theCondition the condition of GEOM::comparison_condition type
+ * \return the condition of GEOMUtils::ComparisonCondition type.
+ */
+static GEOMUtils::ComparisonCondition ComparisonCondition
+                    (const GEOM::comparison_condition theCondition)
+{
+  GEOMUtils::ComparisonCondition aResult = GEOMUtils::CC_GT;
+
+  switch (theCondition) {
+  case GEOM::CC_GE:
+    aResult = GEOMUtils::CC_GE;
+    break;
+  case GEOM::CC_LT:
+    aResult = GEOMUtils::CC_LT;
+    break;
+  case GEOM::CC_LE:
+    aResult = GEOMUtils::CC_LE;
+    break;
+  default:
+    break;
+  }
+
+  return aResult;
+}
+
 //=============================================================================
 /*!
  *   constructor:
  */
 //=============================================================================
 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
-                                                   GEOM::GEOM_Gen_ptr theEngine,
-                                                   ::GEOMImpl_IShapesOperations* theImpl)
+                                                    GEOM::GEOM_Gen_ptr theEngine,
+                                                    ::GEOMImpl_IShapesOperations* theImpl)
 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
 {
   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
@@ -70,18 +103,76 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
-
   //Get the reference points
-  Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
-    (thePnt1->GetStudyID(), thePnt1->GetEntry());
-  Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
-    (thePnt2->GetStudyID(), thePnt2->GetEntry());
+  Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
+  Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
 
   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
 
   //Create the Edge
-  Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
+  Handle(::GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeEdgeOnCurveByLength
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
+                  (GEOM::GEOM_Object_ptr theCurve,
+                   CORBA::Double         theLength,
+                   GEOM::GEOM_Object_ptr theStartPoint)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference curve
+  Handle(::GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
+  if (aRefCurve.IsNull()) return aGEOMObject._retn();
+
+  //Get the reference point (can be NULL)
+  Handle(::GEOM_Object) aRefPoint;
+  if (!CORBA::is_nil(theStartPoint)) {
+    aRefPoint = GetObjectImpl(theStartPoint);
+  }
+
+  //Create the point
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeEdgeWire
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
+                      (GEOM::GEOM_Object_ptr theWire,
+                       const CORBA::Double theLinearTolerance,
+                       const CORBA::Double theAngularTolerance)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the source wire
+  Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
+
+  if (aWire.IsNull()) return aGEOMObject._retn();
+
+  //Create the Edge
+  Handle(::GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
@@ -94,7 +185,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
  */
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
-                                      (const GEOM::ListOfGO& theEdgesAndWires)
+                           (const GEOM::ListOfGO& theEdgesAndWires,
+                            const CORBA::Double   theTolerance)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -102,21 +194,19 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
   GetOperations()->SetNotDone();
 
   int ind, aLen;
-  list<Handle(GEOM_Object)> aShapes;
+  std::list<Handle(::GEOM_Object)> aShapes;
 
   //Get the shapes
   aLen = theEdgesAndWires.length();
   for (ind = 0; ind < aLen; ind++) {
-    if (theEdgesAndWires[ind] == NULL) return aGEOMObject._retn();
-    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
-      (theEdgesAndWires[ind]->GetStudyID(), theEdgesAndWires[ind]->GetEntry());
+    Handle(::GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
     if (aSh.IsNull()) return aGEOMObject._retn();
     aShapes.push_back(aSh);
   }
 
   // Make Solid
-  Handle(GEOM_Object) anObject =
-    GetOperations()->MakeWire(aShapes);
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeWire(aShapes, theTolerance);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
@@ -130,24 +220,22 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
                       (GEOM::GEOM_Object_ptr theWire,
-                      const CORBA::Boolean  isPlanarWanted)
+                       const CORBA::Boolean  isPlanarWanted)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theWire == NULL) return aGEOMObject._retn();
-
   //Get the reference wire
-  Handle(GEOM_Object) aWire = GetOperations()->GetEngine()->GetObject
-    (theWire->GetStudyID(), theWire->GetEntry());
-
+  Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
   if (aWire.IsNull()) return aGEOMObject._retn();
 
   //Create the Face
-  Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
-  if (!GetOperations()->IsDone() || anObject.IsNull())
+  Handle(::GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
+  //if (!GetOperations()->IsDone() || anObject.IsNull())
+  // enable warning status
+  if (anObject.IsNull())
     return aGEOMObject._retn();
 
   return GetObject(anObject);
@@ -160,7 +248,7 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
                                          (const GEOM::ListOfGO& theWires,
-                                         const CORBA::Boolean  isPlanarWanted)
+                                          const CORBA::Boolean  isPlanarWanted)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -168,22 +256,86 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
   GetOperations()->SetNotDone();
 
   int ind, aLen;
-  list<Handle(GEOM_Object)> aShapes;
+  std::list<Handle(::GEOM_Object)> aShapes;
 
   //Get the shapes
   aLen = theWires.length();
   for (ind = 0; ind < aLen; ind++) {
-    if (theWires[ind] == NULL) return aGEOMObject._retn();
-    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
-      (theWires[ind]->GetStudyID(), theWires[ind]->GetEntry());
+    Handle(::GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
     if (aSh.IsNull()) return aGEOMObject._retn();
     aShapes.push_back(aSh);
   }
 
   // Make Face
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
-  if (!GetOperations()->IsDone() || anObject.IsNull())
+  //if (!GetOperations()->IsDone() || anObject.IsNull())
+  // enable warning status
+  if (anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeFaceFromSurface
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceFromSurface
+                                  (GEOM::GEOM_Object_ptr theFace,
+                                   GEOM::GEOM_Object_ptr theWire)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference face and wire
+  Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
+  Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
+
+  if (aFace.IsNull() || aWire.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  //Create the Face
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeFaceFromSurface(aFace, aWire);
+
+  if (anObject.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeFaceWithConstraints
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWithConstraints
+                                                (const GEOM::ListOfGO& theConstraints)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the shapes
+  std::list<Handle(::GEOM_Object)> aConstraints;
+  for( CORBA::ULong ind = 0; ind < theConstraints.length(); ind++ ) {
+    Handle(::GEOM_Object) anObject = GetObjectImpl( theConstraints[ind] );
+    aConstraints.push_back(anObject);
+  }
+
+  // Make Face
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeFaceWithConstraints( aConstraints );
+
+  // enable warning status
+  if (anObject.IsNull())
     return aGEOMObject._retn();
 
   return GetObject(anObject);
@@ -203,20 +355,18 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
   GetOperations()->SetNotDone();
 
   int ind, aLen;
-  list<Handle(GEOM_Object)> aShapes;
+  std::list<Handle(::GEOM_Object)> aShapes;
 
   //Get the shapes
   aLen = theFacesAndShells.length();
   for (ind = 0; ind < aLen; ind++) {
-    if (theFacesAndShells[ind] == NULL) return aGEOMObject._retn();
-    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
-      (theFacesAndShells[ind]->GetStudyID(), theFacesAndShells[ind]->GetEntry());
+    Handle(::GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
     if (aSh.IsNull()) return aGEOMObject._retn();
     aShapes.push_back(aSh);
   }
 
   // Make Solid
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->MakeShell(aShapes);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
@@ -237,16 +387,15 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShell == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShell = GetOperations()->GetEngine()->GetObject
-    (theShell->GetStudyID(), theShell->GetEntry());
-
+  Handle(::GEOM_Object) aShell = GetObjectImpl(theShell);
   if (aShell.IsNull()) return aGEOMObject._retn();
 
+  std::list<Handle(::GEOM_Object)> aShapes;
+  aShapes.push_back(aShell);
+
   //Create the Solid
-  Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
+  Handle(::GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
@@ -267,20 +416,18 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
   GetOperations()->SetNotDone();
 
   int ind, aLen;
-  list<Handle(GEOM_Object)> aShapes;
+  std::list<Handle(::GEOM_Object)> aShapes;
 
   //Get the shapes
   aLen = theShells.length();
   for (ind = 0; ind < aLen; ind++) {
-    if (theShells[ind] == NULL) return aGEOMObject._retn();
-    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
-      (theShells[ind]->GetStudyID(), theShells[ind]->GetEntry());
+    Handle(::GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
     if (aSh.IsNull()) return aGEOMObject._retn();
     aShapes.push_back(aSh);
   }
 
   // Make Solid
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->MakeSolidShells(aShapes);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
@@ -293,8 +440,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
  *  MakeCompound
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
-                                      (const GEOM::ListOfGO& theShapes)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -302,20 +449,18 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
   GetOperations()->SetNotDone();
 
   int ind, aLen;
-  list<Handle(GEOM_Object)> aShapes;
+  std::list<Handle(::GEOM_Object)> aShapes;
 
   //Get the shapes
   aLen = theShapes.length();
   for (ind = 0; ind < aLen; ind++) {
-    if (theShapes[ind] == NULL) return aGEOMObject._retn();
-    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
-      (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
+    Handle(::GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
     if (aSh.IsNull()) return aGEOMObject._retn();
     aShapes.push_back(aSh);
   }
 
   // Make Solid
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->MakeCompound(aShapes);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
@@ -325,30 +470,61 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
 
 //=============================================================================
 /*!
- *  MakeGlueFaces
+ *  MakeSolidFromConnectedFaces
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
-                                           (GEOM::GEOM_Object_ptr theShape,
-                                           CORBA::Double   theTolerance,
-                                           CORBA::Boolean  doKeepNonSolids)
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidFromConnectedFaces
+                                      (const GEOM::ListOfGO& theFacesOrShells,
+                                       const CORBA::Boolean  isIntersect)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL) return aGEOMObject._retn();
+  int ind, aLen;
+  std::list<Handle(::GEOM_Object)> aShapes;
 
-  //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+  //Get the shapes
+  aLen = theFacesOrShells.length();
+  for (ind = 0; ind < aLen; ind++) {
+    ::Handle(::GEOM_Object) aSh = GetObjectImpl(theFacesOrShells[ind]);
+    if (aSh.IsNull()) return aGEOMObject._retn();
+    aShapes.push_back(aSh);
+  }
 
-  if (aShape.IsNull()) return aGEOMObject._retn();
+  // Make Solid
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeSolidFromConnectedFaces(aShapes, isIntersect);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeGlueFaces
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
+                                         CORBA::Double         theTolerance,
+                                         CORBA::Boolean  doKeepNonSolids)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  std::list< Handle(::GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aGEOMObject._retn();
 
   //Perform the gluing
-  Handle(GEOM_Object) anObject =
-    GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
   //if (!GetOperations()->IsDone() || anObject.IsNull())
   // to allow warning
   if (anObject.IsNull())
@@ -357,30 +533,27 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
   return GetObject(anObject);
 }
 
-
 //=============================================================================
 /*!
  *  GetGlueFaces
  */
 //=============================================================================
-GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
-                                           (GEOM::GEOM_Object_ptr theShape,
-                                           const CORBA::Double   theTolerance)
+GEOM::ListOfGO*
+GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
+                                        const CORBA::Double   theTolerance)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  if (aShape.IsNull()) return aSeq._retn();
+  std::list< Handle(::GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aSeq._retn();
 
   Handle(TColStd_HSequenceOfTransient) aHSeq =
-    GetOperations()->GetGlueFaces(aShape, theTolerance);
+    GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
 
   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
   // to allow warning
@@ -390,51 +563,42 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
 
-
 //=============================================================================
 /*!
  *  MakeGlueFacesByList
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
-                                           (GEOM::GEOM_Object_ptr theShape,
-                                           CORBA::Double   theTolerance,
-                                           const GEOM::ListOfGO& theFaces,
-                                           CORBA::Boolean  doKeepNonSolids)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
+                                               CORBA::Double         theTolerance,
+                                               const GEOM::ListOfGO& theFaces,
+                                               CORBA::Boolean        doKeepNonSolids,
+                                               CORBA::Boolean        doGlueAllEdges)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-
-  if (aShape.IsNull()) return aGEOMObject._retn();
+  std::list< Handle(::GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aGEOMObject._retn();
 
-  int ind, aLen;
-  list<Handle(GEOM_Object)> aFaces;
   //Get the shapes
-  aLen = theFaces.length();
-  for (ind = 0; ind < aLen; ind++) {
-    if (theFaces[ind] == NULL) return aGEOMObject._retn();
-    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
-      (theFaces[ind]->GetStudyID(), theFaces[ind]->GetEntry());
-    if (aSh.IsNull()) return aGEOMObject._retn();
-    aFaces.push_back(aSh);
-  }
+  std::list<Handle(::GEOM_Object)> aFaces;
+  if (! GetListOfObjectsImpl( theFaces, aFaces ))
+    return aGEOMObject._retn();
 
   //Perform the gluing
-  Handle(GEOM_Object) anObject =
-    GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
+                                         doKeepNonSolids, doGlueAllEdges);
   //if (!GetOperations()->IsDone() || anObject.IsNull())
   // to allow warning
   if (anObject.IsNull())
@@ -443,86 +607,102 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
   return GetObject(anObject);
 }
 
-
 //=============================================================================
 /*!
- *  MakeExplode
+ *  MakeGlueEdges
  */
 //=============================================================================
-GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
-                                                      const CORBA::Long     theShapeType,
-                                                      const CORBA::Boolean  isSorted)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
+                                         CORBA::Double         theTolerance)
 {
-  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
-  if (theShape == NULL) return aSeq._retn();
+  GEOM::GEOM_Object_var aGEOMObject;
 
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+  //Set a not done flag
+  GetOperations()->SetNotDone();
 
-  Handle(TColStd_HSequenceOfTransient) aHSeq =
-    GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
-  if (!GetOperations()->IsDone() || aHSeq.IsNull())
-    return aSeq._retn();
+  //Get the reference objects
+  std::list< Handle(::GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aGEOMObject._retn();
 
-  Standard_Integer aLength = aHSeq->Length();
-  aSeq->length(aLength);
-  for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+  //Perform the gluing
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeGlueEdges(aShapes, theTolerance);
+  //if (!GetOperations()->IsDone() || anObject.IsNull())
+  // to allow warning
+  if (anObject.IsNull())
+    return aGEOMObject._retn();
 
-  return aSeq._retn();
+  return GetObject(anObject);
 }
 
 //=============================================================================
 /*!
- *  SubShapeAllIDs
+ *  GetGlueEdges
  */
 //=============================================================================
-GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
-                                                           const CORBA::Long     theShapeType,
-                                                           const CORBA::Boolean  isSorted)
+GEOM::ListOfGO*
+GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
+                                        const CORBA::Double   theTolerance)
 {
-  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
-  if (theShape == NULL) return aSeq._retn();
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+  //Set a not done flag
+  GetOperations()->SetNotDone();
 
-  Handle(TColStd_HSequenceOfInteger) aHSeq =
-    GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
-  if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
+  //Get the reference objects
+  std::list< Handle(::GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aSeq._retn();
+
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+    GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
+
+  //if (!GetOperations()->IsDone() || aHSeq.IsNull())
+  // to allow warning
+  if (aHSeq.IsNull())
+    return aSeq._retn();
 
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = aHSeq->Value(i);
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
 
 //=============================================================================
 /*!
- *  GetSubShape
+ *  MakeGlueEdgesByList
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
-                                           (GEOM::GEOM_Object_ptr theMainShape,
-                                           const CORBA::Long     theID)
+GEOM::GEOM_Object_ptr
+GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
+                                               CORBA::Double         theTolerance,
+                                               const GEOM::ListOfGO& theEdges)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theMainShape == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theMainShape->GetStudyID(), theMainShape->GetEntry());
+  std::list< Handle(::GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aGEOMObject._retn();
 
-  if (aShape.IsNull()) return aGEOMObject._retn();
+  //Get the shapes
+  std::list<Handle(::GEOM_Object)> anEdges;
+  if (! GetListOfObjectsImpl( theEdges, anEdges ))
+    return aGEOMObject._retn();
 
-  Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
-  if (!GetOperations()->IsDone() || anObject.IsNull())
+  //Perform the gluing
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
+  //if (!GetOperations()->IsDone() || anObject.IsNull())
+  // to allow warning
+  if (anObject.IsNull())
     return aGEOMObject._retn();
 
   return GetObject(anObject);
@@ -530,90 +710,360 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
 
 //=============================================================================
 /*!
- *  GetSubShapeIndex
+ *  GetExistingSubObjects
  */
 //=============================================================================
-CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
-  (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
+GEOM::ListOfGO*
+GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
+                                                 CORBA::Boolean        theGroupsOnly)
 {
-  if (theMainShape == NULL || theSubShape == NULL) return -1;
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
-  //Get the reference shapes
-  Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject
-    (theMainShape->GetStudyID(), theMainShape->GetEntry());
-  Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
-    (theSubShape->GetStudyID(), theSubShape->GetEntry());
-  if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
 
-  //Get the unique ID of <theSubShape> inside <theMainShape>
-  CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
-  if (!GetOperations()->IsDone())
-    return -1;
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+    GetOperations()->GetExistingSubObjects(aShape, (Standard_Boolean)theGroupsOnly);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
 
-  return anID;
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
 }
 
 //=============================================================================
 /*!
- *  GetTopologyIndex
+ *  MakeExplode (including theShape itself, bad sorting)
  */
 //=============================================================================
-CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
-  (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
+GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
+                                                       const CORBA::Long     theShapeType,
+                                                       const CORBA::Boolean  isSorted)
 {
-  if (theMainShape == NULL || theSubShape == NULL) return -1;
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
-  //Get the reference shapes
-  Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject
-    (theMainShape->GetStudyID(), theMainShape->GetEntry());
-  Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
-    (theSubShape->GetStudyID(), theSubShape->GetEntry());
-  if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
 
-  //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
-  CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
-  if (!GetOperations()->IsDone())
-    return -1;
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+    GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
+                                 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
 
-  return anID;
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
 }
 
 //=============================================================================
 /*!
- *  GetShapeTypeString
+ *  MakeAllSubShapes (including theShape itself, good sorting)
  */
 //=============================================================================
-char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
+GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
+                                                            const CORBA::Long     theShapeType,
+                                                            const CORBA::Boolean  isSorted)
 {
-  if (theShape == NULL) return NULL;
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
-  //Get the reference shape
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
 
-  if (aShape.IsNull()) return NULL;
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+    GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
+                                 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
 
-  // Get shape parameters
-  TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
-  return CORBA::string_dup(aDescription.ToCString());
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
 }
 
 //=============================================================================
 /*!
- *  NumberOfFaces
+ *  ExtractSubShapes (excluding theShape itself, good sorting)
  */
 //=============================================================================
-CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
+GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
+                                                            const CORBA::Long     theShapeType,
+                                                            const CORBA::Boolean  isSorted)
 {
-  if (theShape == NULL) return -1;
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
 
-  CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
-  if (!GetOperations()->IsDone()) return -1;
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+    // TODO: enum instead of bool for the last argument
+    GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
+                                 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
 
-  return aNb;
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  SubShapeAllIDs
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
+                                                            const CORBA::Long     theShapeType,
+                                                            const CORBA::Boolean  isSorted)
+{
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
+
+  Handle(TColStd_HSequenceOfInteger) aHSeq =
+    GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
+                                    GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetAllSubShapesIDs
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
+                                                                const CORBA::Long     theShapeType,
+                                                                const CORBA::Boolean  isSorted)
+{
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
+
+  Handle(TColStd_HSequenceOfInteger) aHSeq =
+    GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
+                                    GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetSubShape
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
+                                           (GEOM::GEOM_Object_ptr theMainShape,
+                                            const CORBA::Long     theID)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theMainShape);
+  if (aShape.IsNull()) return aGEOMObject._retn();
+
+  Handle(::GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeSubShapes
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
+                                                         const GEOM::ListOfLong& theIndices)
+{
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theIndices.length() < 1)
+    return aSeq._retn();
+
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theMainShape);
+  if (aShape.IsNull()) return aSeq._retn();
+
+  Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
+  for (CORBA::ULong i = 0; i < theIndices.length(); i++)
+    anArray->SetValue(i+1, theIndices[i]);
+
+  Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (int i = 0; i < aLength; i++)
+    aSeq[i] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i+1)));
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetSubShapeIndex
+ */
+//=============================================================================
+CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
+  (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
+{
+  //Get the reference shapes
+  Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
+  Handle(::GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
+
+  if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
+
+  //Get the unique ID of <theSubShape> inside <theMainShape>
+  CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
+  if (!GetOperations()->IsDone())
+    return -1;
+
+  return anID;
+}
+
+//=============================================================================
+/*!
+ *  GetSubShapesIndices
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
+  (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
+{
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+  
+  //Get the reference main shape
+  Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
+  if (aMainShapeRef.IsNull()) return aSeq._retn();
+      
+  //Get the subshapes
+  std::list<Handle(::GEOM_Object)> aShapes;
+  int aLen = theSubShapes.length();
+  for (int ind = 0; ind < aLen; ind++) {
+    Handle(::GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
+    if (aSh.IsNull())
+    {
+      MESSAGE("NULL shape")
+      return aSeq._retn();
+    }
+    aShapes.push_back(aSh);
+  }
+
+  //Get the IDs of <theSubShapes> inside <theMainShape>
+  Handle(TColStd_HSequenceOfInteger) aHSeq = 
+  GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
+  
+  if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
+
+//=============================================================================
+/*!
+ *  GetTopologyIndex
+ */
+//=============================================================================
+CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
+  (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
+{
+  //Get the reference shapes
+  Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
+  Handle(::GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
+
+  if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
+
+  //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
+  CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
+  if (!GetOperations()->IsDone())
+    return -1;
+
+  return anID;
+}
+
+//=============================================================================
+/*!
+ *  GetShapeTypeString
+ */
+//=============================================================================
+char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
+{
+  //Get the reference shape
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return NULL;
+
+  // Get shape parameters
+  TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
+  return CORBA::string_dup(aDescription.ToCString());
+}
+
+//=============================================================================
+/*!
+ *  IsSubShapeBelongsTo
+ */
+//=============================================================================
+CORBA::Boolean GEOM_IShapesOperations_i::IsSubShapeBelongsTo( GEOM::GEOM_Object_ptr theSubObject,
+                                                              const CORBA::Long theSubObjectIndex,
+                                                              GEOM::GEOM_Object_ptr theObject,
+                                                              const CORBA::Long theObjectIndex)
+{
+  Handle(::GEOM_Object) aSubObject = GetObjectImpl( theSubObject );
+  Handle(::GEOM_Object) anObject = GetObjectImpl( theObject );
+  if( anObject.IsNull() || aSubObject.IsNull() )
+    return false;
+
+  // Get parameters
+  return GetOperations()->IsSubShapeBelongsTo( aSubObject, theSubObjectIndex, anObject, theObjectIndex );
+}
+
+//=============================================================================
+/*!
+ *  NumberOfFaces
+ */
+//=============================================================================
+CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
+{
+  return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
 }
 
 //=============================================================================
@@ -623,12 +1073,21 @@ CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theSh
 //=============================================================================
 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
 {
-  if (theShape == NULL) return -1;
+  return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
+}
 
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+//=============================================================================
+/*!
+ *  NumberOfSubShapes
+ */
+//=============================================================================
+CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
+                                                         const CORBA::Long     theShapeType)
+{
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return -1;
 
-  CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
+  CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
   if (!GetOperations()->IsDone()) return -1;
 
   return aNb;
@@ -647,16 +1106,12 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
   if (aShape.IsNull()) return aGEOMObject._retn();
 
   //Create the Solid
-  Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
+  Handle(::GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
@@ -674,10 +1129,9 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_p
   GetOperations()->SetNotDone();
 
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
-  if (theShape == NULL) return aSeq._retn();
 
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aSeq._retn();
 
   Handle(TColStd_HSequenceOfInteger) aHSeq =
     GetOperations()->GetFreeFacesIDs(aShape);
@@ -698,23 +1152,18 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_p
 //=============================================================================
 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
                                           (GEOM::GEOM_Object_ptr theShape1,
-                                          GEOM::GEOM_Object_ptr theShape2,
-                                          const CORBA::Long     theShapeType)
+                                           GEOM::GEOM_Object_ptr theShape2,
+                                           const CORBA::Long     theShapeType)
 {
   //Set a not done flag
   GetOperations()->SetNotDone();
 
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
-  if (theShape1 == NULL ||
-      theShape2 == NULL) return aSeq._retn();
 
-  Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
-    (theShape1->GetStudyID(), theShape1->GetEntry());
-  Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
-    (theShape2->GetStudyID(), theShape2->GetEntry());
+  Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
+  Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
 
-  if (aShape1.IsNull() ||
-      aShape2.IsNull()) return aSeq._retn();
+  if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
 
   Handle(TColStd_HSequenceOfTransient) aHSeq =
     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
@@ -724,7 +1173,40 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetSharedShapesMulti
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
+                                          (const GEOM::ListOfGO& theShapes,
+                                           const CORBA::Long     theShapeType,
+                                           CORBA::Boolean        theMultiShare)
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Get the shapes
+  std::list<Handle(::GEOM_Object)> aShapes;
+  if (! GetListOfObjectsImpl( theShapes, aShapes ))
+    return aSeq._retn();
+
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+    GetOperations()->GetSharedShapes(aShapes, theShapeType, theMultiShare);
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -763,22 +1245,18 @@ static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
 //=============================================================================
 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theAx1,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAx1,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
-    (theAx1->GetStudyID(), theAx1->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
 
   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
 
@@ -791,7 +1269,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -803,25 +1281,20 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
 //=============================================================================
 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theAx1,
-                                                GEOM::GEOM_Object_ptr   thePnt,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAx1,
+                                                 GEOM::GEOM_Object_ptr   thePnt,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theAx1 == NULL || thePnt == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
-    (theAx1->GetStudyID(), theAx1->GetEntry());
-  Handle(GEOM_Object) anPnt = GetOperations()->GetEngine()->GetObject
-    (thePnt->GetStudyID(), thePnt->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
+  Handle(::GEOM_Object) anPnt = GetObjectImpl(thePnt);
 
   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
 
@@ -834,7 +1307,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -846,23 +1319,19 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
 //=============================================================================
 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theAxis,
-                                                const CORBA::Double     theRadius,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAxis,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theAxis == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
-    (theAxis->GetStudyID(), theAxis->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
 
   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
 
@@ -875,7 +1344,46 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetShapesOnCylinderWithLocation
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
+                                                (GEOM::GEOM_Object_ptr   theShape,
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAxis,
+                                                 GEOM::GEOM_Object_ptr   thePnt,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
+{
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
+  Handle(::GEOM_Object) aPnt   = GetObjectImpl(thePnt);
+
+  if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
+
+  //Get Shapes On Cylinder
+  Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
+    (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -887,23 +1395,19 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
 //=============================================================================
 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theCenter,
-                                                const CORBA::Double     theRadius,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theCenter,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theCenter == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
-    (theCenter->GetStudyID(), theCenter->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aCenter = GetObjectImpl(theCenter);
 
   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
 
@@ -916,7 +1420,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -930,9 +1434,9 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
                                                 (GEOM::GEOM_Object_ptr theShape,
                                                  CORBA::Long           theShapeType,
                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
-                                                 GEOM::GEOM_Object_ptr theTopRigthPoint,
+                                                 GEOM::GEOM_Object_ptr theTopRightPoint,
                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
-                                                 GEOM::GEOM_Object_ptr theBottomRigthPoint,
+                                                 GEOM::GEOM_Object_ptr theBottomRightPoint,
                                                  GEOM::shape_state     theState)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
@@ -940,36 +1444,24 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape            == NULL ||
-      theTopLeftPoint     == NULL ||   
-      theTopRigthPoint    == NULL || 
-      theBottomLeftPoint  == NULL ||
-      theBottomRigthPoint == NULL )
-    return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
-  Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
-  Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
-  Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
+  Handle(::GEOM_Object) aTopRightPoint = GetObjectImpl(theTopRightPoint);
+  Handle(::GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
+  Handle(::GEOM_Object) aBottomRightPoint = GetObjectImpl(theBottomRightPoint);
 
   if (aShape.IsNull() ||
       aTopLeftPoint.IsNull() ||
-      aTopRigthPoint.IsNull() ||
+      aTopRightPoint.IsNull() ||
       aBottomLeftPoint.IsNull() ||
-      aBottomRigthPoint.IsNull() )
+      aBottomRightPoint.IsNull())
     return aSeq._retn();
 
   //Get Shapes On Quadrangle
   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
     (aShape, theShapeType,
-     aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
+     aTopLeftPoint, aTopRightPoint, aBottomLeftPoint, aBottomRightPoint,
      ShapeState(theState));
   if (!GetOperations()->IsDone() || aHSeq.IsNull())
     return aSeq._retn();
@@ -977,7 +1469,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -989,28 +1481,63 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
 //=============================================================================
 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theAx1,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAx1,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
+  //Get the reference objects
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
+
+  if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
+
+  //Get Shapes On Plane
+  Handle(TColStd_HSequenceOfInteger) aHSeq =
+    GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetShapesOnPlaneWithLocationIDs
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
+                                                (GEOM::GEOM_Object_ptr   theShape,
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAx1,
+                                                 GEOM::GEOM_Object_ptr   thePnt,
+                                                 const GEOM::shape_state theState)
+{
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
 
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
-    (theAx1->GetStudyID(), theAx1->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
+  Handle(::GEOM_Object) anPnt = GetObjectImpl(thePnt);
 
-  if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
+  if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
 
   //Get Shapes On Plane
   Handle(TColStd_HSequenceOfInteger) aHSeq =
-    GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
+    GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
+                                                     anAx1, anPnt, ShapeState(theState));
   if (!GetOperations()->IsDone() || aHSeq.IsNull())
     return aSeq._retn();
 
@@ -1024,36 +1551,30 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
 
 //=============================================================================
 /*!
- *  GetShapesOnPlaneWithLocationIDs
+ *  GetShapesOnCylinderIDs
  */
 //=============================================================================
-GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theAx1,
-                                                GEOM::GEOM_Object_ptr   thePnt,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAxis,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theAx1 == NULL || thePnt == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
-    (theAx1->GetStudyID(), theAx1->GetEntry());
-  Handle(GEOM_Object) anPnt = GetOperations()->GetEngine()->GetObject
-    (thePnt->GetStudyID(), thePnt->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
 
-  if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
+  if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
 
-  //Get Shapes On Plane
-  Handle(TColStd_HSequenceOfInteger) aHSeq =
-    GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
+  //Get Shapes On Cylinder
+  Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
+    (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
   if (!GetOperations()->IsDone() || aHSeq.IsNull())
     return aSeq._retn();
 
@@ -1067,34 +1588,32 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
 
 //=============================================================================
 /*!
- *  GetShapesOnCylinderIDs
+ *  GetShapesOnCylinderWithLocationIDs
  */
 //=============================================================================
-GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theAxis,
-                                                const CORBA::Double     theRadius,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAxis,
+                                                 GEOM::GEOM_Object_ptr   thePnt,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theAxis == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
-    (theAxis->GetStudyID(), theAxis->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
+  Handle(::GEOM_Object) aPnt   = GetObjectImpl(thePnt);
 
-  if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
+  if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
 
   //Get Shapes On Cylinder
-  Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
-    (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
+  Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
+    (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
   if (!GetOperations()->IsDone() || aHSeq.IsNull())
     return aSeq._retn();
 
@@ -1113,23 +1632,19 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
 //=============================================================================
 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
                                                 (GEOM::GEOM_Object_ptr   theShape,
-                                                const CORBA::Long       theShapeType,
-                                                GEOM::GEOM_Object_ptr   theCenter,
-                                                const CORBA::Double     theRadius,
-                                                const GEOM::shape_state theState)
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theCenter,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
 {
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape == NULL || theCenter == NULL) return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
-    (theCenter->GetStudyID(), theCenter->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aCenter = GetObjectImpl(theCenter);
 
   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
 
@@ -1156,9 +1671,9 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
                                                 (GEOM::GEOM_Object_ptr theShape,
                                                  CORBA::Long           theShapeType,
                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
-                                                 GEOM::GEOM_Object_ptr theTopRigthPoint,
+                                                 GEOM::GEOM_Object_ptr theTopRightPoint,
                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
-                                                 GEOM::GEOM_Object_ptr theBottomRigthPoint,
+                                                 GEOM::GEOM_Object_ptr theBottomRightPoint,
                                                  GEOM::shape_state     theState)
 {
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
@@ -1166,36 +1681,24 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShape            == NULL ||
-      theTopLeftPoint     == NULL ||   
-      theTopRigthPoint    == NULL || 
-      theBottomLeftPoint  == NULL ||
-      theBottomRigthPoint == NULL )
-    return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
-  Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
-  Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
-  Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
+  Handle(::GEOM_Object) aTopRightPoint = GetObjectImpl(theTopRightPoint);
+  Handle(::GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
+  Handle(::GEOM_Object) aBottomRightPoint = GetObjectImpl(theBottomRightPoint);
 
   if (aShape.IsNull() ||
       aTopLeftPoint.IsNull() ||
-      aTopRigthPoint.IsNull() ||
+      aTopRightPoint.IsNull() ||
       aBottomLeftPoint.IsNull() ||
-      aBottomRigthPoint.IsNull() )
+      aBottomRightPoint.IsNull() )
     return aSeq._retn();
 
   //Get Shapes On Quadrangle
   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
     (aShape, theShapeType,
-     aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
+     aTopLeftPoint, aTopRightPoint, aBottomLeftPoint, aBottomRightPoint,
      ShapeState(theState));
   if (!GetOperations()->IsDone() || aHSeq.IsNull())
     return aSeq._retn();
@@ -1224,14 +1727,9 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if ( theShape == NULL ||  theBox == NULL )
-    return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aBox = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theBox->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aBox = GetObjectImpl(theBox);
 
   if (aShape.IsNull() || aBox.IsNull() )
     return aSeq._retn();
@@ -1245,7 +1743,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -1257,7 +1755,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
 //=============================================================================
 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
                                                 (GEOM::GEOM_Object_ptr theBox,
-                                                GEOM::GEOM_Object_ptr theShape,
+                                                 GEOM::GEOM_Object_ptr theShape,
                                                  CORBA::Long           theShapeType,
                                                  GEOM::shape_state     theState)
 {
@@ -1266,14 +1764,9 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if ( theShape == NULL ||  theBox == NULL )
-    return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aBox = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theBox->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aBox = GetObjectImpl(theBox);
 
   if (aShape.IsNull() || aBox.IsNull() )
     return aSeq._retn();
@@ -1300,23 +1793,18 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
 //=============================================================================
 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
                                            (GEOM::GEOM_Object_ptr theCheckShape,
-                                           GEOM::GEOM_Object_ptr theShape,
-                                           CORBA::Short          theShapeType,
-                                           GEOM::shape_state     theState)
+                                            GEOM::GEOM_Object_ptr theShape,
+                                            CORBA::Short          theShapeType,
+                                            GEOM::shape_state     theState)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if ( theShape == NULL ||  theCheckShape == NULL )
-    return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aCheckShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theCheckShape->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
 
   if (aShape.IsNull() || aCheckShape.IsNull() )
     return aSeq._retn();
@@ -1331,7 +1819,7 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
   Standard_Integer aLength = aHSeq->Length();
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -1344,29 +1832,24 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
                                            (GEOM::GEOM_Object_ptr theCheckShape,
-                                           GEOM::GEOM_Object_ptr theShape,
-                                           CORBA::Short          theShapeType,
-                                           GEOM::shape_state     theState)
+                                            GEOM::GEOM_Object_ptr theShape,
+                                            CORBA::Short          theShapeType,
+                                            GEOM::shape_state     theState)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if ( theShape == NULL ||  theCheckShape == NULL )
-    return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aCheckShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theCheckShape->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
 
   if (aShape.IsNull() || aCheckShape.IsNull() )
     return aGEOMObject._retn();
 
   //Get Shapes On Shape
-  Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
+  Handle(::GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
     (aCheckShape,aShape, theShapeType,ShapeState(theState));
 
   if (anObject.IsNull())
@@ -1383,23 +1866,18 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
 //=============================================================================
 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
                                            (GEOM::GEOM_Object_ptr theCheckShape,
-                                           GEOM::GEOM_Object_ptr theShape,
-                                           CORBA::Short          theShapeType,
-                                           GEOM::shape_state     theState)
+                                            GEOM::GEOM_Object_ptr theShape,
+                                            CORBA::Short          theShapeType,
+                                            GEOM::shape_state     theState)
 {
   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if ( theShape == NULL ||  theCheckShape == NULL )
-    return aSeq._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theShape->GetEntry());
-  Handle(GEOM_Object) aCheckShape = GetOperations()->GetEngine()->GetObject
-    (theShape->GetStudyID(), theCheckShape->GetEntry());
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
 
   if (aShape.IsNull() || aCheckShape.IsNull() )
     return aSeq._retn();
@@ -1426,27 +1904,22 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
                                           (GEOM::GEOM_Object_ptr theShapeWhere,
-                                          GEOM::GEOM_Object_ptr theShapeWhat)
+                                           GEOM::GEOM_Object_ptr theShapeWhat)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShapeWhere == NULL ||
-      theShapeWhat == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
-    (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
-  Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
-    (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
+  Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
+  Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
 
   if (aShapeWhere.IsNull() ||
       aShapeWhat.IsNull()) return aGEOMObject._retn();
 
   //Get Shapes in place of aShapeWhat
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
@@ -1454,6 +1927,36 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  GetInPlaceOld
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
+                                          (GEOM::GEOM_Object_ptr theShapeWhere,
+                                           GEOM::GEOM_Object_ptr theShapeWhat)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
+  Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
+
+  if (aShapeWhere.IsNull() ||
+      aShapeWhat.IsNull()) return aGEOMObject._retn();
+
+  //Get Shapes in place of aShapeWhat
+  Handle(::GEOM_Object) anObject =
+    GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  GetInPlaceByHistory
@@ -1461,27 +1964,22 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
                                           (GEOM::GEOM_Object_ptr theShapeWhere,
-                                          GEOM::GEOM_Object_ptr theShapeWhat)
+                                           GEOM::GEOM_Object_ptr theShapeWhat)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShapeWhere == NULL ||
-      theShapeWhat == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
-    (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
-  Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
-    (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
+  Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
+  Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
 
   if (aShapeWhere.IsNull() ||
       aShapeWhat.IsNull()) return aGEOMObject._retn();
 
   //Get Shapes in place of aShapeWhat
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
@@ -1489,6 +1987,39 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  GetInPlaceMap
+ */
+//=============================================================================
+GEOM::ListOfListOfLong*
+GEOM_IShapesOperations_i::GetInPlaceMap (GEOM::GEOM_Object_ptr theShapeWhere,
+                                         GEOM::GEOM_Object_ptr theShapeWhat)
+{
+  GEOM::ListOfListOfLong_var aResult = new GEOM::ListOfListOfLong();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
+  Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
+
+  if (!aShapeWhere.IsNull() &&
+      !aShapeWhat.IsNull())
+  {
+    std::vector< std::vector< int > > resVec;
+    GetOperations()->GetInPlaceMap(aShapeWhere, aShapeWhat, resVec);
+
+    aResult->length( resVec.size() );
+    for ( size_t i = 0; i < resVec.size(); ++i )
+    {
+      //if ( !resVec[i].empty() )
+      aResult[i].length( resVec[i].size() );
+      for ( size_t j = 0; j < resVec[i].size(); ++j )
+        aResult[i][j] = resVec[i][j];
+    }
+  }
+  return aResult._retn();
+}
+
 //=============================================================================
 /*!
  *  GetSame
@@ -1496,27 +2027,22 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
 //=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
                                           (GEOM::GEOM_Object_ptr theShapeWhere,
-                                          GEOM::GEOM_Object_ptr theShapeWhat)
+                                           GEOM::GEOM_Object_ptr theShapeWhat)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   //Set a not done flag
   GetOperations()->SetNotDone();
 
-  if (theShapeWhere == NULL ||
-      theShapeWhat == NULL) return aGEOMObject._retn();
-
   //Get the reference objects
-  Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
-    (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
-  Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
-    (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
+  Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
+  Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
 
   if (aShapeWhere.IsNull() ||
       aShapeWhat.IsNull()) return aGEOMObject._retn();
 
   //Get Shapes in place of aShapeWhat
-  Handle(GEOM_Object) anObject =
+  Handle(::GEOM_Object) anObject =
     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
@@ -1524,3 +2050,312 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  GetSameIDs
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
+                                          (GEOM::GEOM_Object_ptr theShapeWhere,
+                                           GEOM::GEOM_Object_ptr theShapeWhat) {
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
+  Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
+
+  if (aShapeWhere.IsNull() ||
+      aShapeWhat.IsNull()) return aSeq._retn();
+
+
+  Handle(TColStd_HSequenceOfInteger) aHSeq =
+    GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
+
+  if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  ExtendEdge
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendEdge
+                                  (GEOM::GEOM_Object_ptr theEdge,
+                                   CORBA::Double         theMin,
+                                   CORBA::Double         theMax)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) anEdge = GetObjectImpl(theEdge);
+
+  if (anEdge.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  //Get Shapes in place of aShapeWhat
+  Handle(::GEOM_Object) aNewEdge =
+    GetOperations()->ExtendEdge(anEdge, theMin, theMax);
+
+  if (!GetOperations()->IsDone() || aNewEdge.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  return GetObject(aNewEdge);
+}
+
+//=============================================================================
+/*!
+ *  ExtendFace
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
+                                  (GEOM::GEOM_Object_ptr theFace,
+                                   CORBA::Double         theUMin,
+                                   CORBA::Double         theUMax,
+                                   CORBA::Double         theVMin,
+                                   CORBA::Double         theVMax)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
+
+  if (aFace.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  //Get Shapes in place of aShapeWhat
+  Handle(::GEOM_Object) aNewFace =
+    GetOperations()->ExtendFace(aFace, theUMin, theUMax, theVMin, theVMax);
+
+  if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  return GetObject(aNewFace);
+}
+
+//=============================================================================
+/*!
+ *  MakeSurfaceFromFace
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
+                                  (GEOM::GEOM_Object_ptr theFace)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference object
+  Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
+
+  if (aFace.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  //Get Shapes in place of aShapeWhat
+  Handle(::GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
+
+  if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  return GetObject(aNewFace);
+}
+
+//=============================================================================
+/*!
+ *  GetSubShapeEdgeSorted
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapeEdgeSorted
+                                        (GEOM::GEOM_Object_ptr theShape,
+                                         GEOM::GEOM_Object_ptr theStartPoint)
+{
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShape      = GetObjectImpl(theShape);
+  Handle(::GEOM_Object) aStartPoint = GetObjectImpl(theStartPoint);
+
+  if (aShape.IsNull() || aStartPoint.IsNull()) {
+    return aSeq._retn();
+  }
+
+  //Get Shapes On Shape
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+      GetOperations()->GetSubShapeEdgeSorted(aShape, aStartPoint);
+
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  const Standard_Integer aLength = aHSeq->Length();
+  Standard_Integer       i;
+
+  aSeq->length(aLength);
+
+  for (i = 1; i <= aLength; i++) {
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+  }
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetSubShapesWithTolerance
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapesWithTolerance
+                     (GEOM::GEOM_Object_ptr      theShape,
+                      CORBA::Short               theShapeType,
+                      GEOM::comparison_condition theCondition,
+                      CORBA::Double              theTolerance)
+{
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+
+  if (aShape.IsNull()) {
+    return aSeq._retn();
+  }
+
+  //Get Shapes On Shape
+  const GEOMUtils::ComparisonCondition aCondition =
+                ComparisonCondition(theCondition);
+  Handle(TColStd_HSequenceOfTransient) aHSeq      =
+      GetOperations()->GetSubShapesWithTolerance
+                (aShape, theShapeType, aCondition, theTolerance);
+
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  const Standard_Integer aLength = aHSeq->Length();
+  Standard_Integer       i;
+
+  aSeq->length(aLength);
+
+  for (i = 1; i <= aLength; i++) {
+    aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
+  }
+
+  return aSeq._retn();
+}
+
+//=============================================================================
+/*!
+ *  MakeExtraction
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
+         (GEOM::GEOM_Object_ptr                              theShape,
+          const GEOM::ListOfLong                            &theSubShapeIDs,
+          GEOM::GEOM_IShapesOperations::ExtractionStats_out  theStats)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  theStats = new GEOM::GEOM_IShapesOperations::ExtractionStats;
+  GetOperations()->SetNotDone();
+
+  //Get the reference object
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+
+  if (aShape.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  const int aNbIDs = theSubShapeIDs.length();
+
+  if (aNbIDs == 0) {
+    return aGEOMObject._retn();
+  }
+
+  int                              i;
+  Handle(TColStd_HArray1OfInteger) anArray =
+    new TColStd_HArray1OfInteger (1, aNbIDs);
+
+  for (i = 0; i < aNbIDs; i++) {
+    anArray->SetValue(i + 1, theSubShapeIDs[i]);
+  }
+
+  //Get Shapes in place of aShapeWhat
+  std::list<GEOMImpl_IShapesOperations::ExtractionStat> aStats;
+  Handle(GEOM_Object)                                   aResult =
+          GetOperations()->MakeExtraction(aShape, anArray, aStats);
+
+  if (!GetOperations()->IsDone() || aResult.IsNull()) {
+    return aGEOMObject._retn();
+  }
+
+  // Convert statistics.
+  const int aNbStats = aStats.size();
+
+  theStats->length(aNbStats);
+
+  // fill the local CORBA array with values from lists
+  std::list<GEOMImpl_IShapesOperations::ExtractionStat>::const_iterator
+    anIt = aStats.begin();
+
+  for (i = 0; anIt != aStats.end(); i++, anIt++) {
+    GEOM::GEOM_IShapesOperations::ExtractionStat_var aResStat =
+      new GEOM::GEOM_IShapesOperations::ExtractionStat;
+
+    // Copy type
+    switch (anIt->type) {
+    case GEOMImpl_IShapesOperations::EST_Removed:
+      aResStat->type = GEOM::GEOM_IShapesOperations::EST_Removed;
+      break;
+    case GEOMImpl_IShapesOperations::EST_Modified:
+      aResStat->type = GEOM::GEOM_IShapesOperations::EST_Modified;
+      break;
+    case GEOMImpl_IShapesOperations::EST_Added:
+      aResStat->type = GEOM::GEOM_IShapesOperations::EST_Added;
+      break;
+    default:
+      break;
+    }
+
+    // Copy the list of IDs
+    std::list<Standard_Integer> aIDList    = anIt->indices;
+    GEOM::ListOfLong_var        aResIDList = new GEOM::ListOfLong;
+
+    aResIDList->length(aIDList.size());
+
+    std::list<Standard_Integer>::iterator anIDIt = aIDList.begin();
+    int j = 0;
+
+    for (; anIDIt != aIDList.end(); j++, anIDIt++) {
+      aResIDList[j] = *anIDIt;
+    }
+
+    aResStat->indices = aResIDList;
+
+    theStats[(_CORBA_ULong)i] = aResStat;
+  }
+
+  return GetObject(aResult);
+}