Salome HOME
Implemented [bos #35094] [EDF] (2023-T1) X,Y,Z to U,V.
[modules/geom.git] / src / GEOM_I / GEOM_IInsertOperations_i.cc
index ab79c87b68bc66e78e6f735cbdb68f93d5619f6c..762c0954761ef1026016765f3382c71e24afa87f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  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
 
 #include "GEOM_Engine.hxx"
 #include "GEOM_BaseObject.hxx"
-
-#include <Basics_OCCTVersion.hxx>
+#include "GEOMImpl_Types.hxx"
 
 #include <TColStd_HSequenceOfAsciiString.hxx>
-
 #include <TColStd_HArray1OfByte.hxx>
 
 //=============================================================================
@@ -78,11 +76,11 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::MakeCopy(GEOM::GEOM_Object_ptr t
   GetOperations()->SetNotDone();
 
   //Get the reference shape
-  Handle(GEOM_Object) anOriginal = GetObjectImpl(theOriginal);
+  Handle(::GEOM_Object) anOriginal = GetObjectImpl(theOriginal);
   if (anOriginal.IsNull()) return aGEOMObject._retn();
 
   //Create the copy
-  Handle(GEOM_Object) anObject = GetOperations()->MakeCopy(anOriginal);
+  Handle(::GEOM_Object) anObject = GetOperations()->MakeCopy(anOriginal);
 
   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
 
@@ -105,7 +103,7 @@ void GEOM_IInsertOperations_i::Export
   GetOperations()->SetNotDone();
 
   //Get the reference shape
-  Handle(GEOM_Object) anOriginal = GetObjectImpl(theOriginal);
+  Handle(::GEOM_Object) anOriginal = GetObjectImpl(theOriginal);
   if (anOriginal.IsNull()) return;
 
   //Export the shape to the file
@@ -138,7 +136,7 @@ GEOM::ListOfGBO* GEOM_IInsertOperations_i::ImportFile
 
   aSeq->length(aLength);
   for (Standard_Integer i = 1; i <= aLength; i++)
-    aSeq[i-1] = GetBaseObject(Handle(GEOM_BaseObject)::DownCast(aHSeq->Value(i)));
+    aSeq[i-1] = GetBaseObject(Handle(::GEOM_BaseObject)::DownCast(aHSeq->Value(i)));
 
   return aSeq._retn();
 }
@@ -179,7 +177,7 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::RestoreShape (const SALOMEDS::TM
   char* buf = (char*)theStream.NP_data();
   std::istringstream aStream (buf);
 
-  Handle(GEOM_Object) anObject = GetOperations()->RestoreShape(aStream);
+  Handle(::GEOM_Object) anObject = GetOperations()->RestoreShape(aStream);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
@@ -212,7 +210,7 @@ CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Lo
   if ( theTexture.length() > 0 ) {
     aTexture = new TColStd_HArray1OfByte (1, theTexture.length());
 
-    for ( int i = 0; i < theTexture.length(); i++ )
+    for ( CORBA::ULong i = 0; i < theTexture.length(); i++ )
       aTexture->SetValue( i+1, (Standard_Byte)theTexture[i] );
   }
   return GetOperations()->AddTexture( theWidth, theHeight, aTexture );
@@ -259,4 +257,83 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
   return anIDs._retn();
 }
 
+//=============================================================================
+/*!
+ *  TransferData
+ */
+//=============================================================================
+CORBA::Boolean GEOM_IInsertOperations_i::TransferData
+        (GEOM::GEOM_Object_ptr                                 theObjectFrom,
+         GEOM::GEOM_Object_ptr                                 theObjectTo,
+         GEOM::find_shape_method                               theFindMethod,
+         GEOM::GEOM_IInsertOperations::ListOfTransferDatum_out theResult)
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (CORBA::is_nil(theObjectFrom) || CORBA::is_nil(theObjectTo))
+  {
+    return false;
+  }
 
+  //Get the reference shape
+  Handle(::GEOM_Object) aShapeFrom = GetObjectImpl(theObjectFrom);
+  Handle(::GEOM_Object) aShapeTo   = GetObjectImpl(theObjectTo);
+
+  if (aShapeFrom.IsNull() || aShapeTo.IsNull())
+  {
+    return false;
+  }
+
+  bool isOk = false;
+  std::list<GEOMImpl_IInsertOperations::TransferDatum> aData;
+  int aFindMethod = -1;
+
+  switch (theFindMethod) {
+  case GEOM::FSM_GetInPlace:
+    aFindMethod = TD_GET_IN_PLACE;
+    break;
+  case GEOM::FSM_GetInPlaceByHistory:
+    aFindMethod = TD_GET_IN_PLACE_BY_HISTORY;
+    break;
+  case GEOM::FSM_GetInPlace_Old:
+    aFindMethod = TD_GET_IN_PLACE_OLD;
+    break;
+  default:
+    break;
+  }
+
+  // Transfer data.
+  if (aFindMethod > 0) {
+    isOk = GetOperations()->TransferData
+      (aShapeFrom, aShapeTo, aFindMethod, aData);
+  }
+
+  if (isOk) {
+    // Copy results.
+    const int aNbDatum = aData.size();
+    GEOM::GEOM_IInsertOperations::ListOfTransferDatum_var aResult =
+      new GEOM::GEOM_IInsertOperations::ListOfTransferDatum;
+
+    aResult->length(aNbDatum);
+
+    // fill the local CORBA array with values from lists
+    std::list<GEOMImpl_IInsertOperations::TransferDatum>::const_iterator
+      anIt = aData.begin();
+    int i = 0;
+
+    for (; anIt != aData.end(); i++, anIt++) {
+      GEOM::GEOM_IInsertOperations::TransferDatum_var aDatum =
+        new GEOM::GEOM_IInsertOperations::TransferDatum;
+
+      aDatum->myName      = CORBA::string_dup(anIt->myName.ToCString());
+      aDatum->myNumber    = anIt->myNumber;
+      aDatum->myMaxNumber = anIt->myMaxNumber;
+      aResult[i]          = aDatum;
+    }
+
+    theResult = aResult._retn();
+  }
+
+  return isOk;
+}