2005-12-05 21:23:52 +05:00
|
|
|
// Copyright (C) 2005 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.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2006-06-01 17:32:40 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <Standard_Stream.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <GEOMImpl_IInsertOperations.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
#include "utilities.h"
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <OpUtil.hxx>
|
|
|
|
#include <Utils_ExceptHandlers.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
#include <TFunction_DriverTable.hxx>
|
|
|
|
#include <TFunction_Driver.hxx>
|
|
|
|
#include <TFunction_Logbook.hxx>
|
|
|
|
#include <TDF_Tool.hxx>
|
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <GEOM_Function.hxx>
|
|
|
|
#include <GEOM_PythonDump.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <GEOMImpl_CopyDriver.hxx>
|
|
|
|
#include <GEOMImpl_ExportDriver.hxx>
|
|
|
|
#include <GEOMImpl_ImportDriver.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <GEOMImpl_ICopy.hxx>
|
|
|
|
#include <GEOMImpl_IImportExport.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <GEOMImpl_Types.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <Standard_Failure.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* constructor:
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
|
|
|
|
: GEOM_IOperations(theEngine, theDocID)
|
|
|
|
{
|
|
|
|
MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
|
|
|
|
{
|
|
|
|
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* MakeCopy
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
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);
|
|
|
|
|
|
|
|
//Add a Copy function for creation a copy object
|
|
|
|
Handle(GEOM_Function) aFunction = aCopy->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITH_REF);
|
|
|
|
|
|
|
|
//Check if the function is set correctly
|
|
|
|
if(aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) return NULL;
|
|
|
|
|
|
|
|
GEOMImpl_ICopy aCI(aFunction);
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction();
|
|
|
|
if (aRefFunction.IsNull()) return NULL;
|
|
|
|
|
|
|
|
aCI.SetOriginal(aRefFunction);
|
|
|
|
|
|
|
|
//Compute the Copy value
|
|
|
|
try {
|
2008-03-07 12:45:34 +05:00
|
|
|
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
|
|
|
OCC_CATCH_SIGNALS;
|
|
|
|
#endif
|
2004-12-01 15:39:14 +05:00
|
|
|
if (!GetSolver()->ComputeFunction(aFunction)) {
|
|
|
|
SetErrorCode("Copy driver failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Standard_Failure) {
|
|
|
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
|
|
|
SetErrorCode(aFail->GetMessageString());
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Make a Python command
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeCopy(" << theOriginal << ")";
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return aCopy;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Export
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOMImpl_IInsertOperations::Export
|
2005-08-19 15:11:52 +06:00
|
|
|
(const Handle(GEOM_Object) theOriginal,
|
|
|
|
const TCollection_AsciiString& theFileName,
|
|
|
|
const TCollection_AsciiString& theFormatName)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
//Check if the function is set correctly
|
|
|
|
if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return;
|
|
|
|
|
|
|
|
Handle(TCollection_HAsciiString) aHLibName;
|
2005-08-19 15:11:52 +06:00
|
|
|
if (!IsSupported(Standard_False, theFormatName, aHLibName)) {
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
TCollection_AsciiString aLibName = aHLibName->String();
|
2006-05-06 14:44:32 +06:00
|
|
|
|
|
|
|
//Set parameters
|
|
|
|
GEOMImpl_IImportExport aCI (aFunction);
|
|
|
|
aCI.SetOriginal(aRefFunction);
|
|
|
|
aCI.SetFileName(theFileName);
|
|
|
|
aCI.SetFormatName(theFormatName);
|
2004-12-01 15:39:14 +05:00
|
|
|
aCI.SetPluginName(aLibName);
|
|
|
|
|
|
|
|
//Perform the Export
|
|
|
|
try {
|
2008-03-07 12:45:34 +05:00
|
|
|
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
|
|
|
OCC_CATCH_SIGNALS;
|
|
|
|
#endif
|
2004-12-01 15:39:14 +05:00
|
|
|
if (!GetSolver()->ComputeFunction(aFunction)) {
|
|
|
|
SetErrorCode("Export driver failed");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Standard_Failure) {
|
|
|
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
|
|
|
SetErrorCode(aFail->GetMessageString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Make a Python command
|
2005-08-19 15:11:52 +06:00
|
|
|
GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal << ", \""
|
|
|
|
<< theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Import
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
2005-08-19 15:11:52 +06:00
|
|
|
(const TCollection_AsciiString& theFileName,
|
|
|
|
const TCollection_AsciiString& theFormatName)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
|
2005-08-19 15:11:52 +06:00
|
|
|
if (theFileName.IsEmpty() || theFormatName.IsEmpty()) return NULL;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
//Add a new result object
|
|
|
|
Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
|
|
|
|
|
|
|
|
//Add an Import function
|
|
|
|
Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_ImportDriver::GetID(), IMPORT_SHAPE);
|
|
|
|
if (aFunction.IsNull()) return result;
|
|
|
|
|
|
|
|
//Check if the function is set correctly
|
|
|
|
if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
|
|
|
|
|
|
|
|
Handle(TCollection_HAsciiString) aHLibName;
|
2005-08-19 15:11:52 +06:00
|
|
|
if (!IsSupported(Standard_True, theFormatName, aHLibName)) {
|
2004-12-01 15:39:14 +05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
TCollection_AsciiString aLibName = aHLibName->String();
|
2006-05-06 14:44:32 +06:00
|
|
|
|
|
|
|
//Set parameters
|
|
|
|
GEOMImpl_IImportExport aCI (aFunction);
|
|
|
|
aCI.SetFileName(theFileName);
|
|
|
|
aCI.SetFormatName(theFormatName);
|
2004-12-01 15:39:14 +05:00
|
|
|
aCI.SetPluginName(aLibName);
|
|
|
|
|
|
|
|
//Perform the Import
|
|
|
|
try {
|
2008-03-07 12:45:34 +05:00
|
|
|
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
|
|
|
OCC_CATCH_SIGNALS;
|
|
|
|
#endif
|
2004-12-01 15:39:14 +05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Make a Python command
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
|
2005-08-19 15:11:52 +06:00
|
|
|
<< theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* ImportTranslators
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
|
|
|
|
(Handle(TColStd_HSequenceOfAsciiString)& theFormats,
|
|
|
|
Handle(TColStd_HSequenceOfAsciiString)& thePatterns)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Read Import formats list from install directory
|
2004-12-01 15:39:14 +05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Read Import formats from user directory
|
|
|
|
if (myResMgrUser->Find("Import")) {
|
|
|
|
TCollection_AsciiString aFormats (myResMgrUser->Value("Import"));
|
|
|
|
TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
|
|
|
|
int i = 1;
|
|
|
|
for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
|
|
|
|
int aLenFormats = theFormats->Length();
|
|
|
|
bool isFound = false;
|
|
|
|
for(int aInd=1;aInd<=aLenFormats;aInd++){
|
|
|
|
if( theFormats->Value(aInd) == aToken){
|
|
|
|
isFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!isFound)
|
|
|
|
theFormats->Append(aToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// Read Patterns for each supported format
|
|
|
|
int j = 1, len = theFormats->Length();
|
|
|
|
for (; j <= len; j++) {
|
2006-05-06 14:44:32 +06:00
|
|
|
TCollection_AsciiString aKey, aPattern;
|
|
|
|
aKey = theFormats->Value(j) + ".ImportPattern";
|
2004-12-01 15:39:14 +05:00
|
|
|
if (myResMgr->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgr->Value(aKey.ToCString());
|
2008-03-07 12:45:34 +05:00
|
|
|
else if(myResMgrUser->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgrUser->Value(aKey.ToCString());
|
2004-12-01 15:39:14 +05:00
|
|
|
else {
|
2006-05-06 14:44:32 +06:00
|
|
|
aKey = theFormats->Value(j) + ".Pattern";
|
|
|
|
if (myResMgr->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgr->Value(aKey.ToCString());
|
2008-03-07 12:45:34 +05:00
|
|
|
else if(myResMgrUser->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgrUser->Value(aKey.ToCString());
|
2006-05-06 14:44:32 +06:00
|
|
|
else {
|
|
|
|
aPattern = theFormats->Value(j);
|
|
|
|
aPattern += " Files ( *.* )";
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
thePatterns->Append(aPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (!theFormats->IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* ExportTranslators
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
|
|
|
|
(Handle(TColStd_HSequenceOfAsciiString)& theFormats,
|
|
|
|
Handle(TColStd_HSequenceOfAsciiString)& thePatterns)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Read Export formats list from install directory
|
2004-12-01 15:39:14 +05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Read Export formats list from user directory
|
|
|
|
if (myResMgrUser->Find("Export")) {
|
|
|
|
TCollection_AsciiString aFormats (myResMgrUser->Value("Export"));
|
|
|
|
TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
|
|
|
|
int i = 1;
|
|
|
|
for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
|
|
|
|
int aLenFormats = theFormats->Length();
|
|
|
|
bool isFound = false;
|
|
|
|
for(int aInd=1;aInd<=aLenFormats;aInd++){
|
|
|
|
if( theFormats->Value(aInd) == aToken){
|
|
|
|
isFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!isFound)
|
|
|
|
theFormats->Append(aToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// Read Patterns for each supported format
|
|
|
|
int j = 1, len = theFormats->Length();
|
|
|
|
for (; j <= len; j++) {
|
2006-05-06 14:44:32 +06:00
|
|
|
TCollection_AsciiString aKey, aPattern;
|
|
|
|
aKey = theFormats->Value(j) + ".ExportPattern";
|
2004-12-01 15:39:14 +05:00
|
|
|
if (myResMgr->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgr->Value(aKey.ToCString());
|
2008-03-07 12:45:34 +05:00
|
|
|
else if (myResMgrUser->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgrUser->Value(aKey.ToCString());
|
2004-12-01 15:39:14 +05:00
|
|
|
else {
|
2006-05-06 14:44:32 +06:00
|
|
|
aKey = theFormats->Value(j) + ".Pattern";
|
|
|
|
if (myResMgr->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgr->Value(aKey.ToCString());
|
2008-03-07 12:45:34 +05:00
|
|
|
else if (myResMgrUser->Find(aKey.ToCString()))
|
|
|
|
aPattern = myResMgrUser->Value(aKey.ToCString());
|
2006-05-06 14:44:32 +06:00
|
|
|
else {
|
|
|
|
aPattern = theFormats->Value(j);
|
|
|
|
aPattern += " Files ( *.* )";
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
thePatterns->Append(aPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (!theFormats->IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* IsSupported
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
|
|
|
|
(const Standard_Boolean isImport,
|
2005-08-19 15:11:52 +06:00
|
|
|
const TCollection_AsciiString& theFormat,
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(TCollection_HAsciiString)& theLibName)
|
|
|
|
{
|
|
|
|
if (!InitResMgr()) return Standard_False;
|
|
|
|
|
|
|
|
// Import/Export mode
|
2005-08-19 15:11:52 +06:00
|
|
|
TCollection_AsciiString aMode;
|
|
|
|
//Standard_CString aMode;
|
2004-12-01 15:39:14 +05:00
|
|
|
if (isImport) aMode = "Import";
|
|
|
|
else aMode = "Export";
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
// Read supported formats for the certain mode from install directory
|
2005-08-19 15:11:52 +06:00
|
|
|
if (myResMgr->Find(aMode.ToCString())) {
|
|
|
|
TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
|
2004-12-01 15:39:14 +05:00
|
|
|
if (aFormats.Search(theFormat) > -1) {
|
|
|
|
// Read library name for the supported format
|
|
|
|
TCollection_AsciiString aKey (theFormat);
|
|
|
|
aKey += ".";
|
|
|
|
aKey += aMode;
|
|
|
|
if (myResMgr->Find(aKey.ToCString())) {
|
2008-03-07 12:45:34 +05:00
|
|
|
TCollection_AsciiString aLibName (myResMgr->Value(aKey.ToCString()));
|
|
|
|
#ifndef WNT
|
|
|
|
aLibName += ".so";
|
|
|
|
#else
|
|
|
|
aLibName += ".dll";
|
|
|
|
#endif
|
2004-12-01 15:39:14 +05:00
|
|
|
theLibName = new TCollection_HAsciiString (aLibName);
|
|
|
|
return Standard_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
// Read supported formats for the certain mode from user directory
|
|
|
|
if (myResMgrUser->Find(aMode.ToCString())) {
|
|
|
|
TCollection_AsciiString aFormats (myResMgrUser->Value(aMode.ToCString()));
|
|
|
|
if (aFormats.Search(theFormat) > -1) {
|
|
|
|
// Read library name for the supported format
|
|
|
|
TCollection_AsciiString aKey (theFormat);
|
|
|
|
aKey += ".";
|
|
|
|
aKey += aMode;
|
|
|
|
if (myResMgrUser->Find(aKey.ToCString())) {
|
|
|
|
TCollection_AsciiString aLibName (myResMgrUser->Value(aKey.ToCString()));
|
|
|
|
theLibName = new TCollection_HAsciiString (aLibName);
|
|
|
|
return Standard_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
return Standard_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* InitResMgr
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
bool isResourceFound = false;
|
|
|
|
bool isResourceFoundUser = false;
|
|
|
|
TCollection_AsciiString aUserResDir,aResDir;
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if (myResMgr.IsNull()) {
|
|
|
|
// Initialize the Resource Manager
|
2008-03-07 12:45:34 +05:00
|
|
|
TCollection_AsciiString aNull;
|
|
|
|
aResDir = TCollection_AsciiString(getenv("GEOM_ROOT_DIR"));
|
2004-12-01 15:39:14 +05:00
|
|
|
#ifdef WNT
|
2008-03-07 12:45:34 +05:00
|
|
|
aResDir += "\\share\\salome\\resources\\geom";
|
2004-12-01 15:39:14 +05:00
|
|
|
#else
|
2008-03-07 12:45:34 +05:00
|
|
|
aResDir += "/share/salome/resources/geom";
|
2004-12-01 15:39:14 +05:00
|
|
|
#endif
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
myResMgr = new Resource_Manager ("ImportExport", aResDir, aNull, Standard_False);
|
|
|
|
|
|
|
|
isResourceFound = true;
|
|
|
|
if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {
|
|
|
|
// instead of complains in Resource_Manager
|
|
|
|
isResourceFound = false;
|
|
|
|
INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString());
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
isResourceFound = true;
|
|
|
|
|
|
|
|
if (myResMgrUser.IsNull()) {
|
2005-08-30 18:50:44 +06:00
|
|
|
char * dir = getenv("GEOM_ENGINE_RESOURCES_DIR");
|
2008-03-07 12:45:34 +05:00
|
|
|
TCollection_AsciiString aNull;
|
2005-08-30 18:50:44 +06:00
|
|
|
if ( dir )
|
|
|
|
{
|
|
|
|
aUserResDir = dir;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aUserResDir = getenv("HOME");
|
2004-12-01 15:39:14 +05:00
|
|
|
#ifdef WNT
|
2005-08-30 18:50:44 +06:00
|
|
|
aUserResDir += "\\.salome\\resources";
|
2004-12-01 15:39:14 +05:00
|
|
|
#else
|
2005-08-30 18:50:44 +06:00
|
|
|
aUserResDir += "/.salome/resources";
|
2004-12-01 15:39:14 +05:00
|
|
|
#endif
|
2005-08-30 18:50:44 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
myResMgrUser = new Resource_Manager ("ImportExport", aNull, aUserResDir, Standard_False);
|
|
|
|
|
|
|
|
isResourceFoundUser = true;
|
|
|
|
|
|
|
|
if (!myResMgrUser->Find("Import") && !myResMgrUser->Find("Export")) {
|
2005-06-15 11:54:44 +06:00
|
|
|
// instead of complains in Resource_Manager
|
2008-03-07 12:45:34 +05:00
|
|
|
isResourceFoundUser = false;
|
2005-06-15 11:54:44 +06:00
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
} else
|
|
|
|
isResourceFoundUser = true;
|
|
|
|
|
|
|
|
if(!isResourceFound && !isResourceFoundUser){
|
|
|
|
INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString());
|
|
|
|
INFOS("No valid file \"ImportExport\" found in " << aUserResDir.ToCString() );
|
2005-06-15 11:54:44 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
return ( myResMgr->Find("Import") || myResMgr->Find("Export") ||
|
|
|
|
myResMgrUser->Find("Import") || myResMgrUser->Find("Export"));
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|