2014-02-18 12:44:41 +06:00
|
|
|
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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
|
2014-02-18 12:44:41 +06:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2013-04-01 18:25:01 +06:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-10-17 20:53:21 +06:00
|
|
|
#ifdef WIN32
|
2005-08-11 10:14:22 +06:00
|
|
|
#pragma warning( disable:4786 )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Standard_Stream.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
#include "GEOM_IInsertOperations_i.hh"
|
|
|
|
|
|
|
|
#include "utilities.h"
|
|
|
|
#include "OpUtil.hxx"
|
|
|
|
#include "Utils_ExceptHandlers.hxx"
|
|
|
|
|
|
|
|
#include "GEOM_Engine.hxx"
|
|
|
|
#include "GEOM_Object.hxx"
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <Basics_OCCTVersion.hxx>
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TColStd_HSequenceOfAsciiString.hxx>
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
|
|
|
|
#include <TColStd_HArray1OfByte.hxx>
|
|
|
|
#else
|
|
|
|
#include <TDataStd_HArray1OfByte.hxx>
|
|
|
|
#endif
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
2012-10-08 17:16:36 +06:00
|
|
|
* constructor
|
2004-12-01 15:39:14 +05:00
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOM_IInsertOperations_i::GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA,
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::GEOM_Gen_ptr theEngine,
|
|
|
|
::GEOMImpl_IInsertOperations* theImpl)
|
2004-12-01 15:39:14 +05:00
|
|
|
:GEOM_IOperations_i(thePOA, theEngine, theImpl)
|
|
|
|
{
|
|
|
|
MESSAGE("GEOM_IInsertOperations_i::GEOM_IInsertOperations_i");
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOM_IInsertOperations_i::~GEOM_IInsertOperations_i()
|
|
|
|
{
|
|
|
|
MESSAGE("GEOM_IInsertOperations_i::~GEOM_IInsertOperations_i");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* MakeCopy
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::MakeCopy(GEOM::GEOM_Object_ptr theOriginal)
|
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var aGEOMObject;
|
|
|
|
|
|
|
|
//Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
//Get the reference shape
|
2012-08-09 13:58:02 +06:00
|
|
|
Handle(GEOM_Object) anOriginal = GetObjectImpl(theOriginal);
|
2004-12-01 15:39:14 +05:00
|
|
|
if (anOriginal.IsNull()) return aGEOMObject._retn();
|
|
|
|
|
|
|
|
//Create the copy
|
|
|
|
Handle(GEOM_Object) anObject = GetOperations()->MakeCopy(anOriginal);
|
|
|
|
|
|
|
|
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
|
|
|
|
|
|
|
|
return GetObject(anObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Export
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOM_IInsertOperations_i::Export
|
|
|
|
(GEOM::GEOM_Object_ptr theOriginal,
|
2012-08-09 13:58:02 +06:00
|
|
|
const char* theFileName,
|
|
|
|
const char* theFormatName)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theOriginal);
|
|
|
|
|
|
|
|
//Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
//Get the reference shape
|
2012-08-09 13:58:02 +06:00
|
|
|
Handle(GEOM_Object) anOriginal = GetObjectImpl(theOriginal);
|
2004-12-01 15:39:14 +05:00
|
|
|
if (anOriginal.IsNull()) return;
|
|
|
|
|
|
|
|
//Export the shape to the file
|
|
|
|
char* aFileName = strdup(theFileName);
|
|
|
|
char* aFormatName = strdup(theFormatName);
|
|
|
|
GetOperations()->Export(anOriginal, aFileName, aFormatName);
|
|
|
|
free(aFileName);
|
|
|
|
free(aFormatName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
2012-08-09 13:58:02 +06:00
|
|
|
* ImportFile
|
2004-12-01 15:39:14 +05:00
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::ImportFile
|
2004-12-01 15:39:14 +05:00
|
|
|
(const char* theFileName,
|
2012-08-09 13:58:02 +06:00
|
|
|
const char* theFormatName)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var aGEOMObject;
|
|
|
|
|
|
|
|
//Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
//Import the shape from the file
|
|
|
|
char* aFileName = strdup(theFileName);
|
|
|
|
char* aFormatName = strdup(theFormatName);
|
|
|
|
Handle(GEOM_Object) anObject = GetOperations()->Import(aFileName, aFormatName);
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
if( strcmp(aFormatName,"IGES_UNIT")==0 && !anObject.IsNull() ) {
|
|
|
|
free(aFileName);
|
|
|
|
free(aFormatName);
|
|
|
|
return GetObject(anObject);
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
free(aFileName);
|
|
|
|
free(aFormatName);
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!GetOperations()->IsDone() || anObject.IsNull()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
return aGEOMObject._retn();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
return GetObject(anObject);
|
|
|
|
}
|
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* ReadValue
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
char* GEOM_IInsertOperations_i::ReadValue(const char* theFileName,
|
|
|
|
const char* theFormatName,
|
|
|
|
const char* theParameterName)
|
|
|
|
{
|
|
|
|
//Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
char* aFileName = strdup(theFileName);
|
|
|
|
char* aFormatName = strdup(theFormatName);
|
|
|
|
char* aParameterName = strdup(theParameterName);
|
|
|
|
|
|
|
|
TCollection_AsciiString aUnits = GetOperations()->ReadValue
|
|
|
|
(aFileName, aFormatName, aParameterName);
|
|
|
|
|
|
|
|
free(aFileName);
|
|
|
|
free(aFormatName);
|
|
|
|
free(aParameterName);
|
|
|
|
|
|
|
|
return CORBA::string_dup(aUnits.ToCString());
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* ImportTranslators
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOM_IInsertOperations_i::ImportTranslators
|
|
|
|
(GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns)
|
|
|
|
{
|
|
|
|
// allocate the CORBA arrays
|
|
|
|
GEOM::string_array_var aFormatsArray = new GEOM::string_array();
|
|
|
|
GEOM::string_array_var aPatternsArray = new GEOM::string_array();
|
2005-09-13 17:09:57 +06:00
|
|
|
|
|
|
|
// Get sequences of available formats
|
|
|
|
Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
|
|
|
|
Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
|
|
|
|
if (GetOperations()->ImportTranslators(aFormats, aPatterns)) {
|
|
|
|
const int formSize = aFormats->Length();
|
|
|
|
if (formSize == aPatterns->Length()) {
|
|
|
|
aFormatsArray->length(formSize);
|
|
|
|
aPatternsArray->length(formSize);
|
|
|
|
|
|
|
|
// fill the local CORBA arrays with values from sequences
|
|
|
|
CORBA::Long i = 1;
|
|
|
|
for (; i <= formSize; i++) {
|
2012-08-09 13:58:02 +06:00
|
|
|
aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
|
|
|
|
aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
|
2005-09-13 17:09:57 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// initialize out-parameters with local arrays
|
2005-09-13 17:09:57 +06:00
|
|
|
theFormats = aFormatsArray._retn();
|
2004-12-01 15:39:14 +05:00
|
|
|
thePatterns = aPatternsArray._retn();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* ExportTranslators
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOM_IInsertOperations_i::ExportTranslators
|
|
|
|
(GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns)
|
|
|
|
{
|
|
|
|
// allocate the CORBA arrays
|
|
|
|
GEOM::string_array_var aFormatsArray = new GEOM::string_array();
|
|
|
|
GEOM::string_array_var aPatternsArray = new GEOM::string_array();
|
2005-09-13 17:09:57 +06:00
|
|
|
|
|
|
|
// Get sequences of available formats
|
|
|
|
Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
|
|
|
|
Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
|
|
|
|
if (GetOperations()->ExportTranslators(aFormats, aPatterns)) {
|
|
|
|
const int formSize = aFormats->Length();
|
|
|
|
if (formSize == aPatterns->Length()) {
|
|
|
|
aFormatsArray->length(formSize);
|
|
|
|
aPatternsArray->length(formSize);
|
|
|
|
|
|
|
|
// fill the local CORBA arrays with values from sequences
|
|
|
|
CORBA::Long i = 1;
|
|
|
|
for (; i <= formSize; i++) {
|
2012-08-09 13:58:02 +06:00
|
|
|
aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
|
|
|
|
aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
|
2005-09-13 17:09:57 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// initialize out-parameters with local arrays
|
2005-09-13 17:09:57 +06:00
|
|
|
theFormats = aFormatsArray._retn();
|
2004-12-01 15:39:14 +05:00
|
|
|
thePatterns = aPatternsArray._retn();
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* RestoreShape
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::RestoreShape (const SALOMEDS::TMPFile& theStream)
|
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var aGEOMObject;
|
|
|
|
|
|
|
|
//Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
if (theStream.length() < 1)
|
|
|
|
return aGEOMObject._retn();
|
|
|
|
|
|
|
|
char* buf = (char*)theStream.NP_data();
|
|
|
|
std::istringstream aStream (buf);
|
|
|
|
|
|
|
|
Handle(GEOM_Object) anObject = GetOperations()->RestoreShape(aStream);
|
|
|
|
if (!GetOperations()->IsDone() || anObject.IsNull())
|
|
|
|
return aGEOMObject._retn();
|
|
|
|
|
|
|
|
return GetObject(anObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* LoadTexture
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
CORBA::Long GEOM_IInsertOperations_i::LoadTexture(const char* theTextureFile)
|
|
|
|
{
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
return GetOperations()->LoadTexture( theTextureFile );
|
|
|
|
}
|
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* AddTexture
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
|
|
|
|
const SALOMEDS::TMPFile& theTexture)
|
|
|
|
{
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
|
|
|
|
Handle(TColStd_HArray1OfByte) aTexture;
|
|
|
|
#else
|
|
|
|
Handle(TDataStd_HArray1OfByte) aTexture;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ( theTexture.length() > 0 ) {
|
|
|
|
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
|
|
|
|
aTexture = new TColStd_HArray1OfByte (1, theTexture.length());
|
|
|
|
#else
|
|
|
|
aTexture = new TDataStd_HArray1OfByte (1, theTexture.length());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for ( int i = 0; i < theTexture.length(); i++ )
|
|
|
|
aTexture->SetValue( i+1, (Standard_Byte)theTexture[i] );
|
|
|
|
}
|
|
|
|
return GetOperations()->AddTexture( theWidth, theHeight, aTexture );
|
|
|
|
}
|
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetTexture
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID,
|
|
|
|
CORBA::Long& theWidth,
|
|
|
|
CORBA::Long& theHeight)
|
|
|
|
{
|
|
|
|
int aWidth, aHeight;
|
|
|
|
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
|
|
|
|
Handle(TColStd_HArray1OfByte) aTextureImpl =
|
|
|
|
#else
|
|
|
|
Handle(TDataStd_HArray1OfByte) aTextureImpl =
|
|
|
|
#endif
|
|
|
|
GetOperations()->GetTexture(theID, aWidth, aHeight);
|
|
|
|
theWidth = aWidth;
|
|
|
|
theHeight = aHeight;
|
|
|
|
SALOMEDS::TMPFile_var aTexture;
|
|
|
|
if ( !aTextureImpl.IsNull() ) {
|
|
|
|
aTexture = new SALOMEDS::TMPFile;
|
|
|
|
aTexture->length( aTextureImpl->Length() );
|
|
|
|
for ( int i = aTextureImpl->Lower(); i <= aTextureImpl->Upper(); i++ )
|
|
|
|
aTexture[i-aTextureImpl->Lower()] = aTextureImpl->Value( i );
|
|
|
|
}
|
|
|
|
return aTexture._retn();
|
|
|
|
}
|
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetAllTextures
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
|
|
|
|
{
|
|
|
|
std::list<int> localIDs = GetOperations()->GetAllTextures();
|
|
|
|
GEOM::ListOfLong_var anIDs = new GEOM::ListOfLong(localIDs.size());
|
|
|
|
anIDs->length(localIDs.size());
|
|
|
|
std::list<int>::const_iterator anIt;
|
|
|
|
int i = 0;
|
|
|
|
for( anIt = localIDs.begin(); anIt != localIDs.end(); ++anIt, i++)
|
|
|
|
anIDs[i] = *anIt;
|
|
|
|
return anIDs._retn();
|
|
|
|
}
|
2013-10-02 19:13:33 +06:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Export a shape to XAO format
|
|
|
|
* \param shape The shape to export
|
|
|
|
* \param groups The list of groups to export
|
|
|
|
* \param fields The list of fields to export
|
|
|
|
* \param author The author of the export
|
|
|
|
* \param fileName The name of the exported file
|
|
|
|
* \return boolean indicating if export was succeful.
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
|
2013-11-12 22:32:55 +06:00
|
|
|
const GEOM::ListOfGO& groups,
|
|
|
|
const GEOM::ListOfFields& fields,
|
|
|
|
const char* author,
|
|
|
|
const char* fileName)
|
2013-10-02 19:13:33 +06:00
|
|
|
{
|
|
|
|
bool isGood = false;
|
|
|
|
// Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
// Get the reference shape
|
|
|
|
Handle(GEOM_Object) reference = GetObjectImpl(shape);
|
|
|
|
|
|
|
|
// Get the reference groups
|
|
|
|
int ind = 0;
|
|
|
|
std::list<Handle(GEOM_Object)> groupsObj;
|
|
|
|
for (; ind < groups.length(); ind++)
|
|
|
|
{
|
|
|
|
Handle(GEOM_Object) gobj = GetObjectImpl(groups[ind]);
|
|
|
|
if (gobj.IsNull()) return false;
|
|
|
|
groupsObj.push_back(gobj);
|
|
|
|
}
|
2013-11-12 22:32:55 +06:00
|
|
|
|
2013-10-02 19:13:33 +06:00
|
|
|
// Get the reference fields
|
|
|
|
ind = 0;
|
2013-11-12 22:32:55 +06:00
|
|
|
std::list<Handle(GEOM_Field)> fieldsObj;
|
2013-10-02 19:13:33 +06:00
|
|
|
for (; ind < fields.length(); ind++)
|
|
|
|
{
|
2013-11-12 22:32:55 +06:00
|
|
|
Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind]));
|
2013-10-02 19:13:33 +06:00
|
|
|
if (fobj.IsNull()) return false;
|
|
|
|
fieldsObj.push_back(fobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!reference.IsNull())
|
|
|
|
{
|
|
|
|
// Export XAO
|
|
|
|
isGood = GetOperations()->ExportXAO(reference, groupsObj, fieldsObj, author, fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return isGood;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Import a shape from XAO format
|
|
|
|
* \param fileName The name of the file to import
|
|
|
|
* \param shape The imported shape
|
|
|
|
* \param subShapes The list of imported subShapes
|
|
|
|
* \param groups The list of imported groups
|
|
|
|
* \param fields The list of imported fields
|
|
|
|
* \return boolean indicating if import was succeful.
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
|
2013-11-12 22:32:55 +06:00
|
|
|
GEOM::GEOM_Object_out shape,
|
|
|
|
GEOM::ListOfGO_out subShapes,
|
|
|
|
GEOM::ListOfGO_out groups,
|
|
|
|
GEOM::ListOfFields_out fields)
|
2013-10-02 19:13:33 +06:00
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var vshape;
|
|
|
|
shape = vshape._retn();
|
|
|
|
|
|
|
|
subShapes = new GEOM::ListOfGO;
|
|
|
|
groups = new GEOM::ListOfGO;
|
2013-11-12 22:32:55 +06:00
|
|
|
fields = new GEOM::ListOfFields;
|
2013-10-02 19:13:33 +06:00
|
|
|
|
|
|
|
// Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
Handle(TColStd_HSequenceOfTransient) importedSubShapes = new TColStd_HSequenceOfTransient();
|
|
|
|
Handle(TColStd_HSequenceOfTransient) importedGroups = new TColStd_HSequenceOfTransient();
|
|
|
|
Handle(TColStd_HSequenceOfTransient) importedFields = new TColStd_HSequenceOfTransient();
|
|
|
|
Handle(GEOM_Object) hshape;
|
|
|
|
bool res = GetOperations()->ImportXAO(fileName, hshape, importedSubShapes, importedGroups, importedFields);
|
|
|
|
|
|
|
|
if (!GetOperations()->IsDone() || !res)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// parse fields
|
|
|
|
int n = importedSubShapes->Length();
|
|
|
|
subShapes->length(n);
|
|
|
|
for (int i = 1; i <= n; i++)
|
|
|
|
{
|
|
|
|
(*subShapes)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedSubShapes->Value(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse groups
|
|
|
|
n = importedGroups->Length();
|
|
|
|
groups->length(n);
|
|
|
|
for (int i = 1; i <= n; i++)
|
|
|
|
{
|
|
|
|
(*groups)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedGroups->Value(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse fields
|
|
|
|
n = importedFields->Length();
|
|
|
|
fields->length(n);
|
|
|
|
for (int i = 1; i <= n; i++)
|
|
|
|
{
|
2013-11-14 20:11:58 +06:00
|
|
|
(*fields)[i - 1] = GEOM::GEOM_Field::_narrow(
|
|
|
|
GetBaseObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i))));
|
2013-10-02 19:13:33 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
shape = GetObject(hshape);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|