Salome HOME
EDF 2281 : small fixes
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IShapesOperations.cxx
index 5ca5029fb3ee5031309cc5f5dcc666f34af0282f..b81b261ce0e0a7c62376ca50427225407460d986 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
@@ -18,6 +18,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 //  File      : GEOMImpl_IShapesOperations.cxx
 //  Created   :
@@ -40,6 +41,9 @@
 #include "GEOMImpl_IGlue.hxx"
 
 #include "GEOMImpl_Block6Explorer.hxx"
+#include "GEOMImpl_IHealingOperations.hxx"
+
+#include <GEOMImpl_Gen.hxx>
 
 #include "GEOM_Function.hxx"
 #include "GEOM_ISubShape.hxx"
@@ -80,7 +84,6 @@
 #include <BRepAdaptor_Curve.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepBndLib.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepMesh_IncrementalMesh.hxx>
 
 #include <TopAbs.hxx>
@@ -455,6 +458,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
   aCI.SetIsPlanar(isPlanarWanted);
 
   //Compute the Face value
+  Standard_Boolean isWarning = Standard_False;
   try {
 #if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
@@ -467,14 +471,20 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
   catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     SetErrorCode(aFail->GetMessageString());
-    return NULL;
+    // to provide warning
+    if (!aFunction->GetValue().IsNull()) {
+      isWarning = Standard_True;
+    } else {
+      return NULL;
+    }
   }
 
   //Make a Python command
   GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFace("
     << theWire << ", " << (int)isPlanarWanted << ")";
 
-  SetErrorCode(OK);
+  // to provide warning
+  if (!isWarning) SetErrorCode(OK);
   return aFace;
 }
 
@@ -519,6 +529,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   aCI.SetIsPlanar(isPlanarWanted);
 
   //Compute the shape
+  Standard_Boolean isWarning = Standard_False;
   try {
 #if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
@@ -531,7 +542,12 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     SetErrorCode(aFail->GetMessageString());
-    return NULL;
+    // to provide warning
+    if (!aFunction->GetValue().IsNull()) {
+      isWarning = Standard_True;
+    } else {
+      return NULL;
+    }
   }
 
   //Make a Python command
@@ -548,7 +564,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
   }
   pd << "], " << (int)isPlanarWanted << ")";
 
-  SetErrorCode(OK);
+  // to provide warning
+  if (!isWarning) SetErrorCode(OK);
   return aShape;
 }
 
@@ -1282,7 +1299,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
       // on the main shape for each being calculated sub-shape separately.
       aFunction->SetValue(aValue);
 
-      // Put this subshape in the list of subshapes of theMainShape
+      // Put this subshape in the list of sub-shapes of theMainShape
       aMainShape->AddSubShapeReference(aFunction);
     }
 
@@ -1496,7 +1513,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeSubShapes
         // on the main shape for each being calculated sub-shape separately.
         aFunction->SetValue(aValue);
 
-        // Put this subshape in the list of subshapes of theMainShape
+        // Put this sub-shape in the list of sub-shapes of theMainShape
         aMainShape->AddSubShapeReference(aFunction);
 
         aSeq->Append(anObj);
@@ -1774,6 +1791,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object)
 
   if (theShape.IsNull()) return NULL;
 
+  /*
   //Add a new reversed object
   Handle(GEOM_Object) aReversed = GetEngine()->AddObject(GetDocID(), theShape->GetType());
 
@@ -1813,6 +1831,21 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object)
     << " = geompy.ChangeOrientation(" << theShape << ")";
 
   SetErrorCode(OK);
+  */
+
+  Handle(GEOM_Object) aReversed;
+
+  GEOM_Engine* anEngine = GetEngine();
+  //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
+  GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
+
+  if (aGen) {
+    GEOMImpl_IHealingOperations* anIHealingOperations =
+      aGen->GetIHealingOperations(GetDocID());
+    aReversed = anIHealingOperations->ChangeOrientationCopy(theShape);
+    SetErrorCode(anIHealingOperations->GetErrorCode());
+  }
+
   return aReversed;
 }
 
@@ -2019,7 +2052,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
   // Make a Python command
   anAsciiList.Trunc(anAsciiList.Length() - 1);
 
-  GEOM::TPythonDump pd (aMainShape, /*append=*/true);
+  // IPAL22904: TC6.5.0: order of python commands is wrong after dump study
+  Handle(TColStd_HSequenceOfTransient) anObjects = new TColStd_HSequenceOfTransient;
+  for( it = theShapes.begin(); it != theShapes.end(); it++ )
+  {
+    Handle(GEOM_Object) anObj = *it;
+    if( !anObj.IsNull() )
+      anObjects->Append( anObj );
+  }
+
+  // Get the function of the latest published object
+  Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast( anObjects )->GetLastFunction();
+  if( aFunction.IsNull() ) // just in case
+    aFunction = aMainShape;
+
+  GEOM::TPythonDump pd (aFunction, /*append=*/true);
   pd << "[" << anAsciiList.ToCString()
      << "] = geompy.GetSharedShapesMulti([";
 
@@ -2151,12 +2198,12 @@ Handle(Geom_Surface) GEOMImpl_IShapesOperations::makeCylinder(const TopoDS_Shape
 //=======================================================================
 //function : getShapesOnBoxIDs
   /*!
-   * \brief Find IDs of subshapes complying with given status about surface
-    * \param theBox - the box to check state of subshapes against
+   * \brief Find IDs of sub-shapes complying with given status about surface
+    * \param theBox - the box to check state of sub-shapes against
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -2232,12 +2279,12 @@ Handle(TColStd_HSequenceOfInteger)
 //=======================================================================
 //function : GetShapesOnBoxIDs
 /*!
-   * \brief Find subshapes complying with given status about surface
-    * \param theBox - the box to check state of subshapes against
+   * \brief Find sub-shapes complying with given status about surface
+    * \param theBox - the box to check state of sub-shapes against
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
  */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -2246,7 +2293,7 @@ Handle(TColStd_HSequenceOfInteger)
                                                   const Standard_Integer theShapeType,
                                                   GEOMAlgo_State theState)
 {
-  // Find subshapes ids
+  // Find sub-shapes ids
   Handle(TColStd_HSequenceOfInteger) aSeqOfIDs =
     getShapesOnBoxIDs (theBox, theShape, theShapeType, theState);
   if ( aSeqOfIDs.IsNull()  || aSeqOfIDs->Length() == 0 )
@@ -2270,12 +2317,12 @@ Handle(TColStd_HSequenceOfInteger)
 //=======================================================================
 //function : GetShapesOnBox
 /*!
-   * \brief Find subshapes complying with given status about surface
-    * \param theBox - the box to check state of subshapes against
+   * \brief Find sub-shapes complying with given status about surface
+    * \param theBox - the box to check state of sub-shapes against
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfTransient) - found subshapes
+    * \retval Handle(TColStd_HSequenceOfTransient) - found sub-shapes
  */
 //=======================================================================
 Handle(TColStd_HSequenceOfTransient)
@@ -2284,7 +2331,7 @@ Handle(TColStd_HSequenceOfTransient)
                                                const Standard_Integer theShapeType,
                                                GEOMAlgo_State theState)
 {
-  // Find subshapes ids
+  // Find sub-shapes ids
   Handle(TColStd_HSequenceOfInteger) aSeqOfIDs =
     getShapesOnBoxIDs (theBox, theShape, theShapeType, theState);
   if ( aSeqOfIDs.IsNull()  || aSeqOfIDs->Length() == 0 )
@@ -2316,12 +2363,12 @@ Handle(TColStd_HSequenceOfTransient)
 //=======================================================================
 //function : getShapesOnShapeIDs
 /*!
- * \brief Find IDs of subshapes complying with given status about surface
- * \param theCheckShape - the shape to check state of subshapes against
+ * \brief Find IDs of sub-shapes complying with given status about surface
+ * \param theCheckShape - the shape to check state of sub-shapes against
  * \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
  * \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
  */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -2403,12 +2450,12 @@ Handle(TColStd_HSequenceOfInteger)
 //=======================================================================
 //function : GetShapesOnShapeIDs
 /*!
- * \brief Find subshapes complying with given status about surface
- * \param theCheckShape - the shape to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theCheckShape - the shape to check state of sub-shapes against
  * \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
  * \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
  */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -2443,12 +2490,12 @@ Handle(TColStd_HSequenceOfInteger)
 //=======================================================================
 //function : GetShapesOnShape
 /*!
- * \brief Find subshapes complying with given status about surface
- * \param theCheckShape - the shape to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theCheckShape - the shape to check state of sub-shapes against
  * \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
  * \param theState - required state
- * \retval Handle(TColStd_HSequenceOfTransient) - found subshapes
+ * \retval Handle(TColStd_HSequenceOfTransient) - found sub-shapes
  */
 //=======================================================================
 Handle(TColStd_HSequenceOfTransient)
@@ -2541,12 +2588,12 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnShapeAsCompound
 //=======================================================================
 //function : getShapesOnSurfaceIDs
   /*!
-   * \brief Find IDs of subshapes complying with given status about surface
-    * \param theSurface - the surface to check state of subshapes against
+   * \brief Find IDs of sub-shapes complying with given status about surface
+    * \param theSurface - the surface to check state of sub-shapes against
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -2684,13 +2731,13 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::
 //=======================================================================
 //function : getShapesOnSurface
 /*!
-   * \brief Find subshapes complying with given status about surface
-    * \param theSurface - the surface to check state of subshapes against
+   * \brief Find sub-shapes complying with given status about surface
+    * \param theSurface - the surface to check state of sub-shapes against
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theState - required state
     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
  */
 //=======================================================================
 Handle(TColStd_HSequenceOfTransient)
@@ -2700,7 +2747,7 @@ Handle(TColStd_HSequenceOfTransient)
                                                    GEOMAlgo_State              theState,
                                                    TCollection_AsciiString &   theShapeEntries)
 {
-  // Find subshapes ids
+  // Find sub-shapes ids
   Handle(TColStd_HSequenceOfInteger) aSeqOfIDs =
     getShapesOnSurfaceIDs (theSurface, theShape->GetValue(), theShapeType, theState);
   if ( aSeqOfIDs.IsNull()  || aSeqOfIDs->Length() == 0 )
@@ -3286,15 +3333,15 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnSphere
 //=======================================================================
 //function : getShapesOnQuadrangleIDs
   /*!
-   * \brief Find IDs of subshapes complying with given status about quadrangle
+   * \brief Find IDs of sub-shapes complying with given status about quadrangle
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theTopLeftPoint - top left quadrangle corner
     * \param theTopRigthPoint - top right quadrangle corner
     * \param theBottomLeftPoint - bottom left quadrangle corner
     * \param theBottomRigthPoint - bottom right quadrangle corner
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -3412,15 +3459,15 @@ Handle(TColStd_HSequenceOfInteger)
 //=======================================================================
 //function : GetShapesOnQuadrangle
   /*!
-   * \brief Find subshapes complying with given status about quadrangle
+   * \brief Find sub-shapes complying with given status about quadrangle
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theTopLeftPoint - top left quadrangle corner
     * \param theTopRigthPoint - top right quadrangle corner
     * \param theBottomLeftPoint - bottom left quadrangle corner
     * \param theBottomRigthPoint - bottom right quadrangle corner
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
 //=======================================================================
 Handle(TColStd_HSequenceOfTransient)
@@ -3473,15 +3520,15 @@ Handle(TColStd_HSequenceOfTransient)
 //=======================================================================
 //function : GetShapesOnQuadrangleIDs
   /*!
-   * \brief Find IDs of subshapes complying with given status about quadrangle
+   * \brief Find IDs of sub-shapes complying with given status about quadrangle
     * \param theShape - the shape to explore
-    * \param theShapeType - type of subshape of theShape
+    * \param theShapeType - type of sub-shape of theShape
     * \param theTopLeftPoint - top left quadrangle corner
     * \param theTopRigthPoint - top right quadrangle corner
     * \param theBottomLeftPoint - bottom left quadrangle corner
     * \param theBottomRigthPoint - bottom right quadrangle corner
     * \param theState - required state
-    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
    */
 //=======================================================================
 Handle(TColStd_HSequenceOfInteger)
@@ -3732,7 +3779,7 @@ namespace {
 
 //================================================================================
 /*!
- * \brief Return type of shape for explode. In case of compound it will be a type of sub shape.
+ * \brief Return type of shape for explode. In case of compound it will be a type of sub-shape.
  */
 //================================================================================
 TopAbs_ShapeEnum GEOMImpl_IShapesOperations::GetTypeOfSimplePart (const TopoDS_Shape& theShape)
@@ -3889,7 +3936,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
       aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value()));
     }
     else {
-      SetErrorCode("Error: wrong sub shape returned");
+      SetErrorCode("Error: wrong sub-shape returned");
       return NULL;
     }
   }
@@ -3901,11 +3948,11 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
     return NULL;
   }
 
-  if (aModifiedArray->Length() > 1) {
+  if (aModifiedArray->Length() > 1 || theShapeWhat->GetType() == GEOM_GROUP) {
     //Set a GROUP type
     aResult->SetType(GEOM_GROUP);
 
-    //Set a sub shape type
+    //Set a sub-shape type
     TopoDS_Shape aFirstFound = aLSA.First();
     TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType();
 
@@ -4090,7 +4137,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Objec
             if ( isFound && iType == TopAbs_FACE )
             {
               // check normals at pOnWhat and pOnWhere
-              const double angleTol = PI/180.;
+              const double angleTol = M_PI/180.;
               gp_Vec normToWhat  = GetNormal( TopoDS::Face(Exp_aWhat.Current()), aWhatDistance);
               gp_Vec normToWhere = GetNormal( TopoDS::Face(Exp_aWhere.Current()), aWhereDistance);
               if ( normToWhat * normToWhere < 0 )
@@ -4129,11 +4176,11 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Objec
     return NULL;
   }
 
-  if (aModifiedArray->Length() > 1) {
+  if (aModifiedArray->Length() > 1 || theShapeWhat->GetType() == GEOM_GROUP) {
     //Set a GROUP type
     aResult->SetType(GEOM_GROUP);
 
-    //Set a sub shape type
+    //Set a sub-shape type
     TopoDS_Shape aFirstFound = aWhereIndices.FindKey(aModifiedArray->Value(1));
     TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType();
 
@@ -4202,7 +4249,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
     //Set a GROUP type
     aResult->SetType(GEOM_GROUP);
 
-    //Set a sub shape type
+    //Set a sub-shape type
     TopoDS_Shape aFirstFound = aWhereIndices.FindKey(aModifiedArray->Value(1));
     TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType();
 
@@ -4867,3 +4914,109 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSame(const Handle(GEOM_Object
 
   return aResult;
 }
+
+
+//=======================================================================
+//function : GetSameIDs
+//purpose  :
+//=======================================================================
+Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
+                                                        const Handle(GEOM_Object)& theShapeWhat)
+{
+  SetErrorCode(KO);
+  if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return NULL;
+
+  TopoDS_Shape aWhere = theShapeWhere->GetValue();
+  TopoDS_Shape aWhat  = theShapeWhat->GetValue();
+
+  if (aWhere.IsNull() || aWhat.IsNull()) return NULL;
+
+  int anIndex = -1;
+  bool isFound = false;
+  TopTools_ListOfShape listShape;
+  TopTools_MapOfShape aMap;
+
+  if (aWhat.ShapeType() == TopAbs_COMPOUND || aWhat.ShapeType() == TopAbs_COMPSOLID) {
+    TopoDS_Iterator It (aWhat, Standard_True, Standard_True);
+    if (It.More()) aWhat = It.Value();
+    It.Next();
+    if (It.More()) {
+      SetErrorCode("Compounds of two or more shapes are not allowed for aWhat argument");
+      return NULL;
+    }
+  }
+
+  switch (aWhat.ShapeType()) {
+    case TopAbs_VERTEX: {
+      gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aWhat));
+      TopExp_Explorer E(aWhere, TopAbs_VERTEX);
+      for(; E.More(); E.Next()) {
+        if(!aMap.Add(E.Current())) continue;
+        gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(E.Current()));
+        if(P.Distance(P2) <= MAX_TOLERANCE) {
+          listShape.Append(E.Current());
+        }
+      }
+      break;
+                        }
+    case TopAbs_EDGE: {
+      TopoDS_Edge anEdge = TopoDS::Edge(aWhat);
+      TopExp_Explorer E(aWhere, TopAbs_EDGE);
+      for(; E.More(); E.Next()) {
+        if(!aMap.Add(E.Current())) continue;
+        if(isSameEdge(anEdge, TopoDS::Edge(E.Current()))) {
+          listShape.Append(E.Current());
+        }
+      }
+      break;
+                      }
+    case TopAbs_FACE: {
+      TopoDS_Face aFace = TopoDS::Face(aWhat);
+      TopExp_Explorer E(aWhere, TopAbs_FACE);
+      for(; E.More(); E.Next()) {
+        if(!aMap.Add(E.Current())) continue;
+        if(isSameFace(aFace, TopoDS::Face(E.Current()))) {
+          listShape.Append(E.Current());
+        }
+      }
+      break;
+                      }
+    case TopAbs_SOLID: {
+      TopoDS_Solid aSolid = TopoDS::Solid(aWhat);
+      TopExp_Explorer E(aWhere, TopAbs_SOLID);
+      for(; E.More(); E.Next()) {
+        if(!aMap.Add(E.Current())) continue;
+        if(isSameSolid(aSolid, TopoDS::Solid(E.Current()))) {
+          listShape.Append(E.Current());
+        }
+      }
+      break;
+                       }
+    default:
+      return NULL;
+  }
+
+  if ( !listShape.IsEmpty() ) {
+    TopTools_IndexedMapOfShape anIndices;
+    TopExp::MapShapes(aWhere, anIndices);
+    TopTools_ListIteratorOfListOfShape itSub (listShape);
+    Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+    for (; itSub.More(); itSub.Next()) {
+      if (anIndices.Contains(itSub.Value()))
+        aSeq->Append(anIndices.FindIndex(itSub.Value()));
+    }
+    SetErrorCode(OK);
+    // The GetSameIDs() doesn't change object so no new function is required.
+    Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShapeWhere,theShapeWhat)->GetLastFunction();
+
+  // Make a Python command
+  GEOM::TPythonDump(aFunction)
+    << "listSameIDs = geompy.GetSameIDs("
+    << theShapeWhere << ", "
+    << theShapeWhat << ")";
+    return aSeq;
+  } else {
+    SetErrorCode(NOT_FOUND_ANY);
+    return NULL; 
+  }
+}