]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
IDL, modifications on engine level
authorskv <skv@opencascade.com>
Thu, 27 Nov 2014 13:09:06 +0000 (16:09 +0300)
committerskv <skv@opencascade.com>
Thu, 27 Nov 2014 13:09:06 +0000 (16:09 +0300)
idl/GEOM_Gen.idl
src/GEOMImpl/CMakeLists.txt
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx [changed mode: 0755->0644]
src/GEOMImpl/GEOMImpl_IInsertOperations.hxx
src/GEOMImpl/GEOMImpl_ITransferData.hxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_IInsertOperations_i.cc
src/GEOM_I/GEOM_IInsertOperations_i.hh

index 83faa46bb4cdf7783fe6d5a471be272331de08c6..ed6b6992b023b2f7c8296a98fca4e08dee0c601a 100644 (file)
@@ -115,7 +115,8 @@ module GEOM
    *  \brief Kind of method to find inside one main shape some sub-shapes,
    *  corresponding to other given shape (its argument)
    *
-   *  Is used in functions GEOM_Gen.RestoreSubShapesO(), GEOM_Gen.RestoreSubShapesSO()
+   *  Is used in functions GEOM_Gen.RestoreSubShapesO(), GEOM_Gen.RestoreSubShapesSO(),
+   *  TransferNames()
    */
   enum find_shape_method
   {
@@ -139,7 +140,10 @@ module GEOM
     /*! To be used only for multi-transformation result.
      *  Only this method can be used after multi-transformation.
      */
-    FSM_MultiTransformed
+    FSM_MultiTransformed,
+
+    /*! Use old GetInPlace functionality. */
+    FSM_GetInPlace_Old
   };
 
   /*!
@@ -3935,7 +3939,41 @@ module GEOM
      * \return list of all texture IDs avaiable for the current study
      */
     ListOfLong GetAllTextures();
-    
+
+    /*!
+     *  \brief Non-topological information transfer datum.
+     */
+    struct TransferDatum
+    {
+      string myName;
+      long   myNumber;
+      long   myMaxNumber;
+    };
+
+    /*!
+     *  \brief Sequence of non-topological information tranfer data.
+     */
+    typedef sequence<TransferDatum> ListOfTransferDatum;
+
+    /*!
+     *  \brief Transfer non-topological data from one object to another
+     *  \param theObjectFrom the source object of non-topological data
+     *  \param theObjectTo the destination object of non-topological data
+     *  \param theFindMethod method to search sub-shapes of theObjectFrom
+     *         in shape theObjectTo. Possible values are: GEOM::FSM_GetInPlace,
+     *         GEOM::FSM_GetInPlaceByHistory and GEOM::FSM_GetInPlace_Old.
+     *         Other values of GEOM::find_shape_method are not supported.
+     *  \param theResult statistics of the operation. Output parameter. It
+     *         represents a sequence of Transfer Datum. A datum has the type
+     *         (string code), the total number of items of this type and
+     *         the number of transfered items.
+     *  \return true in case of success; otherwise false.
+     */
+    boolean TransferData(in  GEOM_Object         theObjectFrom,
+                         in  GEOM_Object         theObjectTo,
+                         in  find_shape_method   theFindMethod,
+                         out ListOfTransferDatum theResult);
+
   };
 
  // # GEOM_IKindOfShape:
index 3822d2912c5c4508080c9baec1221610d294cccb..3828848e5d088bf5fa083afd8930f09f06348330 100755 (executable)
@@ -110,6 +110,7 @@ SET(GEOMImpl_HEADERS
   GEOMImpl_ICone.hxx
   GEOMImpl_ISphere.hxx
   GEOMImpl_ITorus.hxx
+  GEOMImpl_ITransferData.hxx
   GEOMImpl_IPrism.hxx
   GEOMImpl_IPipe.hxx
   GEOMImpl_IPipePath.hxx
old mode 100755 (executable)
new mode 100644 (file)
index e5f5a1f..925e547
@@ -29,6 +29,7 @@
 #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"
@@ -340,3 +341,84 @@ std::list<int> GEOMImpl_IInsertOperations::GetAllTextures()
   SetErrorCode(OK);
   return id_list;
 }
+
+//=============================================================================
+/*!
+ *  TransferData
+ */
+//=============================================================================
+bool GEOMImpl_IInsertOperations::TransferData
+                          (const Handle(GEOM_Object)      &theObjectFrom,
+                           const Handle(GEOM_Object)      &theObjectTo,
+                           const int                       theFindMethod,
+                                 std::list<TransferDatum> &theResult)
+{
+  SetErrorCode(KO);
+
+  if (theObjectFrom.IsNull() || theObjectTo.IsNull()) {
+    return false;
+  }
+
+  //Add a new Transfer Data object object
+  Handle(GEOM_Object) aTDObj =
+    GetEngine()->AddObject(GetDocID(), 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) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return false;
+  }
+
+  //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;
+}
index 9341c2b8da8a4edf542cb3feb123b85e79bea207..f9694ea4e1a58c5b67e617251ed8e72fb3c9dc9a 100644 (file)
@@ -49,6 +49,14 @@ class Handle_TColStd_HArray1OfByte;
 
 class GEOMImpl_IInsertOperations : public GEOM_IOperations {
  public:
+
+  struct TransferDatum
+  {
+    TCollection_AsciiString myName;
+    long                    myNumber;
+    long                    myMaxNumber;
+  };
+
   Standard_EXPORT GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID);
   Standard_EXPORT ~GEOMImpl_IInsertOperations();
 
@@ -79,6 +87,12 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
 
   Standard_EXPORT std::list<int> GetAllTextures();
 
+  Standard_EXPORT bool TransferData
+                          (const Handle(GEOM_Object)      &theObjectFrom,
+                           const Handle(GEOM_Object)      &theObjectTo,
+                           const int                       theFindMethod,
+                                 std::list<TransferDatum> &theResult);
+
  private:
   std::vector<Handle(Resource_Manager)> myResMgrList;
   GEOMImpl_IShapesOperations* myShapesOperations;
diff --git a/src/GEOMImpl/GEOMImpl_ITransferData.hxx b/src/GEOMImpl/GEOMImpl_ITransferData.hxx
new file mode 100644 (file)
index 0000000..2e7e55e
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2007-2014  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
+//
+
+//NOTE: This is an intreface to a function for the Transfer Data functionality.
+//
+#include "GEOM_Function.hxx"
+
+#define TD_ARG_REF1   1
+#define TD_ARG_REF2   2
+#define TD_ARG_METHOD 3
+
+class GEOMImpl_ITransferData
+{
+ public:
+
+  GEOMImpl_ITransferData(const Handle(GEOM_Function) &theFunction)
+    : _func(theFunction) {}
+
+  void SetRef1(const Handle(GEOM_Function) &theRefPoint1)
+  { _func->SetReference(TD_ARG_REF1, theRefPoint1); }
+
+  Handle(GEOM_Function) GetRef1() { return _func->GetReference(TD_ARG_REF1); }
+
+  void SetRef2(const Handle(GEOM_Function) &theRefPoint2)
+  { _func->SetReference(TD_ARG_REF2, theRefPoint2); }
+
+  Handle(GEOM_Function) GetRef2() { return _func->GetReference(TD_ARG_REF2); }
+
+  void SetFindMethod(const int theFindMethod)
+  { _func->SetInteger(TD_ARG_METHOD, theFindMethod); }
+
+  int GetFindMethod() { return _func->GetInteger(TD_ARG_METHOD); }
+
+ private:
+
+  Handle(GEOM_Function) _func;
+};
index f7f329ebb88fab67f7487150783f9bcbf5d3300c..94aa63ba5f964538d0447275ce8c66a2de468e4e 100644 (file)
 
 #define GEOM_POLYLINE2D 56
 
+#define GEOM_TRANSFER_DATA 57
+
 //GEOM_Function types
 
 #define COPY_WITH_REF    1
 #define COPY_WITHOUT_REF 2
+#define TRANSFER_DATA    3
 
 #define IMPORT_SHAPE 1
 #define EXPORT_SHAPE 2
 #define USER_TYPE 200     // Base type for GEOM advanced shapes
 #define USER_TYPE_EX 1000 // Base type for GEOM plugins
 
+// Transfer data method type
+#define TD_GET_IN_PLACE            1
+#define TD_GET_IN_PLACE_OLD        2
+#define TD_GET_IN_PLACE_BY_HISTORY 3
 
 // Plugins specified constants
 #define PLUGIN_NAME "Plugin Name"
index ab79c87b68bc66e78e6f735cbdb68f93d5619f6c..334000f236120773216e5120de679e377225cdc3 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "GEOM_Engine.hxx"
 #include "GEOM_BaseObject.hxx"
+#include "GEOMImpl_Types.hxx"
 
 #include <Basics_OCCTVersion.hxx>
 
@@ -259,4 +260,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;
+}
index 4a2b4f2ccccd00f86ae6dc33752d50569e73de0b..26bfa4d88584424c1e54436cd308459833406d84 100644 (file)
@@ -66,7 +66,13 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
                                 CORBA::Long& theHeight);
 
   GEOM::ListOfLong* GetAllTextures();
-  
+
+  CORBA::Boolean TransferData
+        (GEOM::GEOM_Object_ptr                                 theObjectFrom,
+         GEOM::GEOM_Object_ptr                                 theObjectTo,
+         GEOM::find_shape_method                               theFindMethod,
+         GEOM::GEOM_IInsertOperations::ListOfTransferDatum_out theResult);
+
   ::GEOMImpl_IInsertOperations* GetOperations()
   { return (::GEOMImpl_IInsertOperations*)GetImpl(); }
 };