2013-04-25 14:49:48 +00:00
|
|
|
// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2013-02-04 12:57:57 +00: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
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
|
|
|
|
#include <Standard_Stream.hxx>
|
|
|
|
|
|
|
|
#include "GEOM_IImportExportOperations_i.hh"
|
|
|
|
|
|
|
|
#include <utilities.h>
|
|
|
|
#include <OpUtil.hxx>
|
|
|
|
#include <Utils_ExceptHandlers.hxx>
|
|
|
|
|
|
|
|
#include "GEOM_Engine.hxx"
|
|
|
|
#include "GEOM_Object.hxx"
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* constructor:
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-04-11 15:50:20 +00:00
|
|
|
GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i(PortableServer::POA_ptr thePOA,
|
|
|
|
GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IImportExportOperations* theImpl)
|
|
|
|
:
|
|
|
|
GEOM_IOperations_i(thePOA, theEngine, theImpl)
|
2013-02-04 12:57:57 +00:00
|
|
|
{
|
2013-04-11 15:50:20 +00:00
|
|
|
MESSAGE("GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i");
|
2013-02-04 12:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOM_IImportExportOperations_i::~GEOM_IImportExportOperations_i()
|
|
|
|
{
|
2013-04-11 15:50:20 +00:00
|
|
|
MESSAGE("GEOM_IImportExportOperations_i::~GEOM_IImportExportOperations_i");
|
2013-02-04 12:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
2013-04-25 14:49:48 +00:00
|
|
|
* Export a shape to XAO format
|
2013-04-11 15:50:20 +00:00
|
|
|
* \param shape The shape to export
|
|
|
|
* \param groups The list of groups to export
|
|
|
|
* \param fields The list of fields to export
|
2013-04-25 14:49:48 +00:00
|
|
|
* \param author The author of the export
|
|
|
|
* \param fileName The name of the exported file
|
2013-04-11 15:50:20 +00:00
|
|
|
* \return boolean indicating if export was succeful.
|
2013-02-04 12:57:57 +00:00
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-04-12 15:43:32 +00:00
|
|
|
CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
|
2013-04-25 14:49:48 +00:00
|
|
|
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
|
|
|
|
const char* author, const char* fileName)
|
2013-02-04 12:57:57 +00:00
|
|
|
{
|
2013-04-11 15:50:20 +00:00
|
|
|
bool isGood = false;
|
2013-04-12 15:43:32 +00:00
|
|
|
// Set a not done flag
|
2013-04-11 15:50:20 +00:00
|
|
|
GetOperations()->SetNotDone();
|
2013-02-04 12:57:57 +00:00
|
|
|
|
2013-04-11 15:50:20 +00:00
|
|
|
// Get the reference shape
|
|
|
|
Handle(GEOM_Object) reference = GetObjectImpl(shape);
|
|
|
|
|
2013-04-12 15:43:32 +00:00
|
|
|
// Get the reference groups
|
2013-04-11 15:50:20 +00:00
|
|
|
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-04-12 15:43:32 +00:00
|
|
|
// Get the reference fields
|
2013-04-11 15:50:20 +00:00
|
|
|
ind = 0;
|
|
|
|
std::list<Handle(GEOM_Object)> fieldsObj;
|
|
|
|
for (; ind < fields.length(); ind++)
|
|
|
|
{
|
|
|
|
Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]);
|
|
|
|
if (fobj.IsNull()) return false;
|
|
|
|
fieldsObj.push_back(fobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!reference.IsNull())
|
|
|
|
{
|
|
|
|
// Export XAO
|
2013-04-25 14:49:48 +00:00
|
|
|
isGood = GetOperations()->ExportXAO(reference, groupsObj, fieldsObj, author, fileName);
|
2013-04-11 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return isGood;
|
2013-02-04 12:57:57 +00:00
|
|
|
}
|
|
|
|
|
2013-04-11 15:50:20 +00:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
2013-04-25 14:49:48 +00:00
|
|
|
* Import a shape from XAO format
|
|
|
|
* \param fileName The name of the file to import
|
2013-04-11 15:50:20 +00:00
|
|
|
* \param shape The imported shape
|
|
|
|
* \param groups The list of imported groups
|
|
|
|
* \param fields The list of imported fields
|
|
|
|
* \return boolean indicating if import was succeful.
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-04-25 14:49:48 +00:00
|
|
|
CORBA::Boolean GEOM_IImportExportOperations_i::ImportXAO(const char* fileName,
|
|
|
|
GEOM::GEOM_Object_out shape,
|
|
|
|
GEOM::ListOfGO_out groups,
|
|
|
|
GEOM::ListOfGO_out fields)
|
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var vshape;
|
|
|
|
shape = vshape._retn();
|
|
|
|
|
|
|
|
groups = new GEOM::ListOfGO;
|
|
|
|
fields = new GEOM::ListOfGO;
|
|
|
|
|
|
|
|
// Set a not done flag
|
|
|
|
GetOperations()->SetNotDone();
|
|
|
|
|
|
|
|
Handle(TColStd_HSequenceOfTransient) importedGroups = new TColStd_HSequenceOfTransient();
|
|
|
|
Handle(TColStd_HSequenceOfTransient) importedFields = new TColStd_HSequenceOfTransient();
|
|
|
|
Handle(GEOM_Object) hshape;
|
|
|
|
bool res = GetOperations()->ImportXAO(fileName, hshape, importedGroups, importedFields);
|
|
|
|
|
|
|
|
if (!GetOperations()->IsDone() || !res)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// parse groups
|
|
|
|
int 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++)
|
|
|
|
{
|
|
|
|
(*fields)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedFields->Value(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
shape = GetObject(hshape);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2013-04-11 15:50:20 +00:00
|
|
|
|
2013-02-04 12:57:57 +00:00
|
|
|
/*@@ insert new functions before this line @@ do not remove this line @@*/
|