mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-15 17:51:27 +05:00
IDL, modifications on engine level
This commit is contained in:
parent
33eddb946d
commit
f4b55b9e7f
@ -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
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -3936,6 +3940,40 @@ module GEOM
|
||||
*/
|
||||
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:
|
||||
|
@ -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
|
||||
|
82
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
Executable file → Normal file
82
src/GEOMImpl/GEOMImpl_IInsertOperations.cxx
Executable file → Normal file
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
56
src/GEOMImpl/GEOMImpl_ITransferData.hxx
Normal file
56
src/GEOMImpl/GEOMImpl_ITransferData.hxx
Normal file
@ -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;
|
||||
};
|
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -67,6 +67,12 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
|
||||
|
||||
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(); }
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user