From: skv Date: Thu, 27 Nov 2014 13:09:06 +0000 (+0300) Subject: IDL, modifications on engine level X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f4b55b9e7fe4624a7fe27a4a70e87404370ed35e;p=modules%2Fgeom.git IDL, modifications on engine level --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 83faa46bb..ed6b6992b 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -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 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: diff --git a/src/GEOMImpl/CMakeLists.txt b/src/GEOMImpl/CMakeLists.txt index 3822d2912..3828848e5 100755 --- a/src/GEOMImpl/CMakeLists.txt +++ b/src/GEOMImpl/CMakeLists.txt @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx old mode 100755 new mode 100644 index e5f5a1f94..925e547aa --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "GEOMImpl_IShapesOperations.hxx" #include "GEOMImpl_IGroupOperations.hxx" @@ -340,3 +341,84 @@ std::list 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 &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; +} diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx index 9341c2b8d..f9694ea4e 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx @@ -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 GetAllTextures(); + Standard_EXPORT bool TransferData + (const Handle(GEOM_Object) &theObjectFrom, + const Handle(GEOM_Object) &theObjectTo, + const int theFindMethod, + std::list &theResult); + private: std::vector myResMgrList; GEOMImpl_IShapesOperations* myShapesOperations; diff --git a/src/GEOMImpl/GEOMImpl_ITransferData.hxx b/src/GEOMImpl/GEOMImpl_ITransferData.hxx new file mode 100644 index 000000000..2e7e55eed --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ITransferData.hxx @@ -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; +}; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index f7f329ebb..94aa63ba5 100644 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -117,10 +117,13 @@ #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 @@ -378,6 +381,10 @@ #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" diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.cc b/src/GEOM_I/GEOM_IInsertOperations_i.cc index ab79c87b6..334000f23 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.cc +++ b/src/GEOM_I/GEOM_IInsertOperations_i.cc @@ -34,6 +34,7 @@ #include "GEOM_Engine.hxx" #include "GEOM_BaseObject.hxx" +#include "GEOMImpl_Types.hxx" #include @@ -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 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::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; +} diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.hh b/src/GEOM_I/GEOM_IInsertOperations_i.hh index 4a2b4f2cc..26bfa4d88 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.hh +++ b/src/GEOM_I/GEOM_IInsertOperations_i.hh @@ -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(); } };