Salome HOME
Remove unnecessary includes
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IInsertOperations.cxx
index 11ec04762fdd77179271e04d7e5948dd8cf28853..cc09d461388588f4d8ffdf31787afe6349a8cec9 100644 (file)
@@ -1,40 +1,82 @@
-using namespace std;
-
-#include "GEOMImpl_IInsertOperations.hxx"
+// Copyright (C) 2007-2021  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
+//
+// 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.
+//
+// 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
+//
+
+#include <Standard_Stream.hxx>
+
+#include <GEOMImpl_IInsertOperations.hxx>
+
+#include <GEOMImpl_CopyDriver.hxx>
+#include <GEOMImpl_ExportDriver.hxx>
+#include <GEOMImpl_ImportDriver.hxx>
+#include <GEOMImpl_ICopy.hxx>
+#include <GEOMImpl_IImportExport.hxx>
+#include <GEOMImpl_ITransferData.hxx>
+#include <GEOMImpl_Types.hxx>
+#include "GEOMImpl_IShapesOperations.hxx"
+#include "GEOMImpl_IGroupOperations.hxx"
+#include "GEOMImpl_IFieldOperations.hxx"
+#include "GEOMImpl_IECallBack.hxx"
+
+#include <GEOM_Function.hxx>
+#include <GEOM_PythonDump.hxx>
+#include "GEOM_ISubShape.hxx"
 
 #include "utilities.h"
-#include "OpUtil.hxx"
-#include "Utils_ExceptHandlers.hxx"
+#include <Utils_ExceptHandlers.hxx>
 
 #include <TFunction_DriverTable.hxx>
 #include <TFunction_Driver.hxx>
-#include <TFunction_Logbook.hxx>
+#include <TDF_ChildIDIterator.hxx>
 #include <TDF_Tool.hxx>
-
-#include "GEOM_Function.hxx"
-#include "GEOM_PythonDump.hxx"
-
-#include "GEOMImpl_CopyDriver.hxx"
-#include "GEOMImpl_ExportDriver.hxx"
-#include "GEOMImpl_ImportDriver.hxx"
-
-#include "GEOMImpl_ICopy.hxx"
-#include "GEOMImpl_IImportExport.hxx"
-
-#include "GEOMImpl_Types.hxx"
-
+#include <TDataStd_Integer.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TDataStd_Comment.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+#include <gp_Pnt.hxx>
+
+#include <TColStd_HArray1OfReal.hxx>
+
+#include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
 
 //=============================================================================
 /*!
- *   constructor:
+ *  constructor
  */
 //=============================================================================
-
-GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
-: GEOM_IOperations(theEngine, theDocID)
+GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
 {
   MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
+  myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine());
+  myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine());
+  myFieldOperations = new GEOMImpl_IFieldOperations(GetEngine());
 }
 
 //=============================================================================
@@ -42,27 +84,27 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
  *  destructor
  */
 //=============================================================================
-
 GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
 {
   MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
+  delete myShapesOperations;
+  delete myGroupOperations;
+  delete myFieldOperations;
 }
 
-
-
 //=============================================================================
 /*!
  *  MakeCopy
  */
 //=============================================================================
-Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) theOriginal)
+Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy (Handle(GEOM_Object) theOriginal)
 {
   SetErrorCode(KO);
 
   if (theOriginal.IsNull()) return NULL;
 
   //Add a new Copy object
-  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
+  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
 
   //Add a Copy function for creation a copy object
   Handle(GEOM_Function) aFunction = aCopy->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITH_REF);
@@ -79,14 +121,14 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) the
 
   //Compute the Copy value
   try {
+    OCC_CATCH_SIGNALS;
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Copy driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -103,278 +145,303 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) the
  */
 //=============================================================================
 void GEOMImpl_IInsertOperations::Export
-                     (const Handle(GEOM_Object) theOriginal,
-                     const char*               theFileName,
-                     const char*               theFormatName)
+                     (const Handle(GEOM_Object)      theOriginal,
+                      const TCollection_AsciiString& theFileName,
+                      const TCollection_AsciiString& theFormatName)
 {
   SetErrorCode(KO);
 
   if (theOriginal.IsNull()) return;
 
-  Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction();
-  if (aRefFunction.IsNull()) return;  //There is no function which creates an object to be exported
-
-  //Add an Export function
-  Handle(GEOM_Function) aFunction = theOriginal->AddFunction(GEOMImpl_ExportDriver::GetID(), EXPORT_SHAPE);
-  if (aFunction.IsNull()) return;
+  if ( !GEOMImpl_IECallBack::GetCallBack( theFormatName )->Export( theOriginal, theFileName, theFormatName ) )
+    return;
+  SetErrorCode(OK);
+}
 
-  //Check if the function is set correctly
-  if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return;
+//=============================================================================
+/*!
+ *  Import
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOMImpl_IInsertOperations::Import
+                                 (const TCollection_AsciiString& theFileName,
+                                  const TCollection_AsciiString& theFormatName)
+{
+  SetErrorCode(KO);
 
-  //Set parameters
-  GEOMImpl_IImportExport aCI (aFunction);
-  aCI.SetOriginal(aRefFunction);
-  char* aFileName = (char*)theFileName;
-  aCI.SetFileName(aFileName);
+  if (theFileName.IsEmpty() || theFormatName.IsEmpty()) return NULL;
 
-  char* aFormatName = (char*)theFormatName;
-  Handle(TCollection_HAsciiString) aHLibName;
-  if (!IsSupported(Standard_False, aFormatName, aHLibName)) {
-    return;
-  }
-  TCollection_AsciiString aLibName = aHLibName->String();
-  aCI.SetPluginName(aLibName);
+  Handle(TColStd_HSequenceOfTransient) aSeq =
+    GEOMImpl_IECallBack::GetCallBack( theFormatName )->Import( theFormatName, theFileName );
+  SetErrorCode(OK);
+  return aSeq;
+}
 
-  //Perform the Export
-  try {
-    if (!GetSolver()->ComputeFunction(aFunction)) {
-      SetErrorCode("Export driver failed");
-      return;
-    }
-  }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
-    return;
-  }
+//=============================================================================
+/*!
+ *  ReadValue
+ */
+//=============================================================================
+TCollection_AsciiString GEOMImpl_IInsertOperations::ReadValue
+                                 (const TCollection_AsciiString& theFileName,
+                                  const TCollection_AsciiString& theFormatName,
+                                  const TCollection_AsciiString& theParameterName)
+{
+  SetErrorCode(KO);
+  TCollection_AsciiString aValue;
+  if (theFileName.IsEmpty() || theFormatName.IsEmpty() || theParameterName.IsEmpty()) return aValue;
 
-  //Make a Python command
-  GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal
-    << ", \"" << theFileName << "\", \"" << theFormatName << "\")";
+  aValue = GEOMImpl_IECallBack::GetCallBack( theFormatName )->ReadValue( theFileName, theFormatName, theParameterName );
 
   SetErrorCode(OK);
+  return aValue;
 }
 
 //=============================================================================
 /*!
- *  Import
+ *  RestoreShape
  */
 //=============================================================================
-Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
-                     (const char* theFileName,
-                     const char* theFormatName)
+Handle(GEOM_Object) GEOMImpl_IInsertOperations::RestoreShape (std::istringstream& theStream)
 {
   SetErrorCode(KO);
 
-  if (!theFileName || !theFormatName) return NULL;
-
   //Add a new result object
-  Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
+  Handle(GEOM_Object) result = GetEngine()->AddObject(GEOM_COPY);
 
-  //Add an Import function
-  Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_ImportDriver::GetID(), IMPORT_SHAPE);
-  if (aFunction.IsNull()) return result;
+  //Add a Copy function
+  Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
+  if (aFunction.IsNull()) return NULL;
 
   //Check if the function is set correctly
-  if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
+  if (aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) return NULL;
+
+  //Read a shape from the stream
+  TopoDS_Shape aShape;
+  BRep_Builder B;
+  BRepTools::Read(aShape, theStream, B);
+  if (aShape.IsNull()) {
+    SetErrorCode("RestoreShape error: BREP reading failed");
+  }
 
-  //Set parameters
-  GEOMImpl_IImportExport aCI (aFunction);
-  char* aFileName = (char*)theFileName;
-  aCI.SetFileName(aFileName);
+  //Set function value
+  aFunction->SetValue(aShape);
 
-  char* aFormatName = (char*)theFormatName;
-  Handle(TCollection_HAsciiString) aHLibName;
-  if (!IsSupported(Standard_True, aFormatName, aHLibName)) {
-    return result;
-  }
-  TCollection_AsciiString aLibName = aHLibName->String();
-  aCI.SetPluginName(aLibName);
+  //Special dump to avoid restored shapes publication.
+  //See correcponding code in GEOM_Engine.cxx (method ProcessFunction)
+  //GEOM::TPythonDump(aFunction) << "#";
 
-  //Perform the Import
-  try {
-    if (!GetSolver()->ComputeFunction(aFunction)) {
-      SetErrorCode("Import driver failed");
-      return NULL;
-    }
-  }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
-    return NULL;
-  }
+  bool ignore = false;
 
-  //Make a Python command
-  GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
-    << theFileName << "\", \"" << theFormatName << "\")";
+  if ( const char* env_var = getenv( "GEOM_IGNORE_RESTORE_SHAPE" ) )
+    ignore = atoi( env_var ) > 1;
+
+  if ( !ignore ) {
+    GEOM::TPythonDump(aFunction) << result
+    << " = geompy.RestoreShape(\"\") # the shape string has not been dump for performance reason";
+  }
 
   SetErrorCode(OK);
+
   return result;
 }
 
-//=============================================================================
-/*!
- *  ImportTranslators
- */
-//=============================================================================
-Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
-                     (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
-                     Handle(TColStd_HSequenceOfAsciiString)& thePatterns)
+int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTextureFile)
 {
-  if (theFormats.IsNull())
-    theFormats = new TColStd_HSequenceOfAsciiString;
-  else
-    theFormats->Clear();
-
-  if (thePatterns.IsNull())
-    thePatterns = new TColStd_HSequenceOfAsciiString;
-  else
-    thePatterns->Clear();
-
-  if (!InitResMgr()) return Standard_False;
-
-  // Read Import formats list
-  if (myResMgr->Find("Import")) {
-    TCollection_AsciiString aFormats (myResMgr->Value("Import"));
-    TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
-    int i = 1;
-    for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
-      theFormats->Append(aToken);
-    }
+  SetErrorCode(KO);
+
+  if (theTextureFile.IsEmpty()) return 0;
+
+  Handle(TColStd_HArray1OfByte) aTexture;
+
+  FILE* fp = fopen(theTextureFile.ToCString(), "r");
+  if (!fp) return 0;
+
+  std::list<std::string> lines;
+  char buffer[4096];
+  int maxlen = 0;
+  while (!feof(fp)) {
+    if ((fgets(buffer, 4096, fp)) == NULL) break;
+    int aLen = strlen(buffer);
+    if (buffer[aLen-1] == '\n') buffer[aLen-1] = '\0';
+    lines.push_back(buffer);
+    maxlen = std::max(maxlen, (int)strlen(buffer));
   }
 
-  // Read Patterns for each supported format
-  int j = 1, len = theFormats->Length();
-  for (; j <= len; j++) {
-    TCollection_AsciiString aPattern;
-    TCollection_AsciiString aKey (theFormats->Value(j));
-    aKey += ".Pattern";
-    if (myResMgr->Find(aKey.ToCString()))
-      aPattern = myResMgr->Value(aKey.ToCString());
-    else {
-      aPattern = theFormats->Value(j);
-      aPattern += " Files ( *.* )";
+  fclose(fp);
+
+  int lenbytes = maxlen/8;
+  if (maxlen%8) lenbytes++;
+
+  if (lenbytes == 0 || lines.empty())
+    return 0;
+
+  std::list<unsigned char> bytedata;
+  std::list<std::string>::const_iterator it;
+  for (it = lines.begin(); it != lines.end(); ++it) {
+    std::string line = *it;
+    size_t lenline = (line.size()/8 + (line.size()%8 ? 1 : 0)) * 8;
+    for (size_t i = 0; i < lenline/8; i++) {
+      unsigned char byte = 0;
+      for (int j = 0; j < 8; j++)
+        byte = (byte << 1) + ( i*8+j < line.size() && line[i*8+j] != '0' ? 1 : 0 );
+      bytedata.push_back(byte);
     }
-    thePatterns->Append(aPattern);
+    for (int i = lenline/8; i < lenbytes; i++)
+      bytedata.push_back((unsigned char)0);
   }
 
-  return (!theFormats->IsEmpty());
+  if (bytedata.empty() || bytedata.size() != lines.size()*lenbytes)
+    return 0;
+
+  aTexture = new TColStd_HArray1OfByte (1, lines.size()*lenbytes);
+
+  std::list<unsigned char>::iterator bdit;
+  int i;
+  for (i = 1, bdit = bytedata.begin(); bdit != bytedata.end(); ++bdit, ++i)
+    aTexture->SetValue(i, (Standard_Byte)(*bdit));
+
+  int aTextureId = GetEngine()->addTexture(lenbytes*8, lines.size(), aTexture, theTextureFile);
+  if (aTextureId > 0) SetErrorCode(OK);
+  return aTextureId;
+}
+  
+int GEOMImpl_IInsertOperations::AddTexture(int theWidth, int theHeight, 
+                                           const Handle(TColStd_HArray1OfByte)& theTexture)
+{
+  SetErrorCode(KO);
+  int aTextureId = GetEngine()->addTexture(theWidth, theHeight, theTexture);
+  if (aTextureId > 0) SetErrorCode(OK);
+  return aTextureId;
 }
 
-//=============================================================================
-/*!
- *  ExportTranslators
- */
-//=============================================================================
-Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
-                     (Handle(TColStd_HSequenceOfAsciiString)& theFormats,
-                     Handle(TColStd_HSequenceOfAsciiString)& thePatterns)
+Handle(TColStd_HArray1OfByte) GEOMImpl_IInsertOperations::GetTexture(int theTextureId,
+                                                                     int& theWidth, int& theHeight)
 {
-  if (theFormats.IsNull())
-    theFormats = new TColStd_HSequenceOfAsciiString;
-  else
-    theFormats->Clear();
-
-  if (thePatterns.IsNull())
-    thePatterns = new TColStd_HSequenceOfAsciiString;
-  else
-    thePatterns->Clear();
-
-  if (!InitResMgr()) return Standard_False;
-
-  // Read Export formats list
-  if (myResMgr->Find("Export")) {
-    TCollection_AsciiString aFormats (myResMgr->Value("Export"));
-    TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
-    int i = 1;
-    for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
-      theFormats->Append(aToken);
-    }
-  }
+  SetErrorCode(KO);
+  
+  Handle(TColStd_HArray1OfByte) aTexture;
 
-  // Read Patterns for each supported format
-  int j = 1, len = theFormats->Length();
-  for (; j <= len; j++) {
-    TCollection_AsciiString aPattern;
-    TCollection_AsciiString aKey (theFormats->Value(j));
-    aKey += ".Pattern";
-    if (myResMgr->Find(aKey.ToCString()))
-      aPattern = myResMgr->Value(aKey.ToCString());
-    else {
-      aPattern = theFormats->Value(j);
-      aPattern += " Files ( *.* )";
-    }
-    thePatterns->Append(aPattern);
-  }
+  theWidth = theHeight = 0;
+  TCollection_AsciiString aFileName;
+
+  if (theTextureId <= 0)
+    return aTexture;
+
+  aTexture = GetEngine()->getTexture(theTextureId, theWidth, theHeight, aFileName);
+
+  if (theWidth > 0 && theHeight > 0 && aTexture->Length() > 0) SetErrorCode(OK);
 
-  return (!theFormats->IsEmpty());
+  return aTexture;
+}
+
+std::list<int> GEOMImpl_IInsertOperations::GetAllTextures()
+{
+  SetErrorCode(KO);
+  std::list<int> id_list = GetEngine()->getAllTextures();
+  SetErrorCode(OK);
+  return id_list;
 }
 
 //=============================================================================
 /*!
- *  IsSupported
+ *  TransferData
  */
 //=============================================================================
-Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
-                            (const Standard_Boolean isImport,
-                             const TCollection_AsciiString theFormat,
-                             Handle(TCollection_HAsciiString)& theLibName)
+bool GEOMImpl_IInsertOperations::TransferData
+                          (const Handle(GEOM_Object)      &theObjectFrom,
+                           const Handle(GEOM_Object)      &theObjectTo,
+                           const int                       theFindMethod,
+                                 std::list<TransferDatum> &theResult)
 {
-  if (!InitResMgr()) return Standard_False;
-
-  // Import/Export mode
-  Standard_CString aMode;
-  if (isImport) aMode = "Import";
-  else aMode = "Export";
-
-  // Read supported formats for the certain mode
-  if (myResMgr->Find(aMode)) {
-    TCollection_AsciiString aFormats (myResMgr->Value(aMode));
-    if (aFormats.Search(theFormat) > -1) {
-      // Read library name for the supported format
-      TCollection_AsciiString aKey (theFormat);
-      aKey += ".";
-      aKey += aMode;
-      if (myResMgr->Find(aKey.ToCString())) {
-        TCollection_AsciiString aLibName (myResMgr->Value(aKey.ToCString()));
-        theLibName = new TCollection_HAsciiString (aLibName);
-        return Standard_True;
-      }
+  SetErrorCode(KO);
+
+  if (theObjectFrom.IsNull() || theObjectTo.IsNull()) {
+    return false;
+  }
+
+  //Add a new Transfer Data object object
+  Handle(GEOM_Object) aTDObj =
+    GetEngine()->AddObject(GEOM_TRANSFER_DATA);
+
+  //Add a Transfer Data function for created object
+  Handle(GEOM_Function) aFunction =
+    aTDObj->AddFunction(GEOMImpl_CopyDriver::GetID(), TRANSFER_DATA);
+
+  //Check if the function is set correctly
+  if(aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) {
+    return false;
+  }
+
+  Handle(GEOM_Function) aFunctionFrom = theObjectFrom->GetLastFunction();
+  Handle(GEOM_Function) aFunctionTo   = theObjectTo->GetLastFunction();
+
+  if (aFunctionFrom.IsNull() || aFunctionTo.IsNull()) {
+    return false;
+  }
+
+  GEOMImpl_ITransferData aTD(aFunction);
+
+  aTD.SetRef1(aFunctionFrom);
+  aTD.SetRef2(aFunctionTo);
+  aTD.SetFindMethod(theFindMethod);
+
+  // Transfer data
+  try {
+    OCC_CATCH_SIGNALS;
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Transfer data failed");
+      return false;
     }
   }
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
+    return false;
+  }
 
-  return Standard_False;
-}
+  // Fill result list of data.
+  theResult.clear();
 
-//=============================================================================
-/*!
- *  InitResMgr
- */
-//=============================================================================
-Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
-{
-  if (myResMgr.IsNull()) {
-    // Initialize the Resource Manager
-    TCollection_AsciiString aResDir (getenv("GEOM_ROOT_DIR"));
-#ifdef WNT
-    aResDir += "\\share\\salome\\resources";
-#else
-    aResDir += "/share/salome/resources";
-#endif
-    TCollection_AsciiString aUserResDir (getenv("HOME"));
-#ifdef WNT
-    aUserResDir += "\\.salome\\resources";
-#else
-    aUserResDir += "/.salome/resources";
-#endif
-    myResMgr = new Resource_Manager ("ImportExport", aResDir, aUserResDir, Standard_False);
-
-    if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {
-      // instead of complains in Resource_Manager
-      INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString() <<
-            " and in " << aUserResDir.ToCString() );
+  Handle(TColStd_HArray1OfExtendedString) aDatumName   = aTD.GetDatumName();
+  Handle(TColStd_HArray1OfInteger)        aDatumMaxVal = aTD.GetDatumMaxVal();
+  Handle(TColStd_HArray1OfInteger)        aDatumVal    = aTD.GetDatumVal();
+
+  if (!aDatumName.IsNull() && !aDatumMaxVal.IsNull() && !aDatumVal.IsNull()) {
+    Standard_Integer i;
+    Standard_Integer aNbDatum = aDatumName->Length();
+
+    for (i = 1; i <= aNbDatum; ++i) {
+      if (aDatumMaxVal->Value(i) > 0) {
+        TransferDatum aDatum;
+
+        aDatum.myName      = TCollection_AsciiString(aDatumName->Value(i));
+        aDatum.myNumber    = aDatumVal->Value(i);
+        aDatum.myMaxNumber = aDatumMaxVal->Value(i);
+        theResult.push_back(aDatum);
+      }
     }
   }
 
-  return ( myResMgr->Find("Import") || myResMgr->Find("Export") );
+  //Make a Python command
+  GEOM::TPythonDump pd (aFunction);
+  pd << "geompy.TransferData(" << theObjectFrom << ", " << theObjectTo;
+  pd << ", GEOM.";
+
+  switch (theFindMethod) {
+  case TD_GET_IN_PLACE:
+    pd << "FSM_GetInPlace";
+    break;
+  case TD_GET_IN_PLACE_OLD:
+    pd << "FSM_GetInPlace_Old";
+    break;
+  case TD_GET_IN_PLACE_BY_HISTORY:
+  default:
+    pd << "FSM_GetInPlaceByHistory";
+    break;
+  }
+  pd << ")";
+
+  SetErrorCode(OK);
+
+  return true;
 }