From 926f7982e5b13ac2efe4f4455b1d5c36d968dc28 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Thu, 15 Dec 2016 16:36:42 +0100 Subject: [PATCH] Export XAO with the shape in a seperated BREP file. This allows to avoid too big xml files. --- idl/GEOM_Superv.idl | 3 +- idl/XAOPlugin.idl | 4 +- src/GEOM_I_Superv/GEOM_Superv_i.cc | 6 +- src/GEOM_I_Superv/GEOM_Superv_i.hh | 3 +- src/GEOM_SWIG/XAOPluginBuilder.py | 5 +- src/XAO/XAO_BrepGeometry.cxx | 19 +++++++ src/XAO/XAO_BrepGeometry.hxx | 12 ++++ src/XAO/XAO_Geometry.hxx | 2 + src/XAO/XAO_Xao.cxx | 4 +- src/XAO/XAO_Xao.hxx | 3 +- src/XAO/XAO_XaoExporter.cxx | 72 +++++++++++++++++------- src/XAO/XAO_XaoExporter.hxx | 3 +- src/XAO/tests/ImportExportTest.cxx | 4 +- src/XAOPlugin/XAOPlugin_ExportDlg.cxx | 20 ++++++- src/XAOPlugin/XAOPlugin_ExportDlg.h | 2 + src/XAOPlugin/XAOPlugin_IECallBack.cxx | 9 +-- src/XAOPlugin/XAOPlugin_IECallBack.hxx | 7 ++- src/XAOPlugin/XAOPlugin_IOperations.cxx | 7 ++- src/XAOPlugin/XAOPlugin_IOperations.hxx | 3 +- src/XAOPlugin/XAOPlugin_IOperations_i.cc | 12 ++-- src/XAOPlugin/XAOPlugin_IOperations_i.hh | 3 +- src/XAOPlugin/XAOPlugin_msg_en.ts | 4 ++ src/XAOPlugin/XAOPlugin_msg_fr.ts | 4 ++ 23 files changed, 158 insertions(+), 53 deletions(-) diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index c12b0104c..003c8210b 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -668,7 +668,8 @@ module GEOM in ListOfGO groups, in ListOfFields fields, in string author, - in string fileName ); + in string fileName, + in string shapeFileName ); boolean ImportXAO( in string fileName, out GEOM_Object shape, out ListOfGO subShapes, diff --git a/idl/XAOPlugin.idl b/idl/XAOPlugin.idl index 16a470802..d8e2ebb7f 100644 --- a/idl/XAOPlugin.idl +++ b/idl/XAOPlugin.idl @@ -36,13 +36,15 @@ module GEOM * \param fields The list of fields to export * \param author The author of the export * \param fileName The name of the file to export + * \param shapeFileName The name of the file to export the shape in an external file * \return boolean indicating if export was successful. */ boolean ExportXAO( in GEOM::GEOM_Object shape, in GEOM::ListOfGO groups, in GEOM::ListOfFields fields, in string author, - in string fileName ); + in string fileName, + in string shapeFileName ); /*! * Import a shape from XAO format diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 2984de3af..1ba007067 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -3633,12 +3633,14 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportIGES( const char* theFileName, CORBA::Boolean GEOM_Superv_i::ExportXAO( GEOM::GEOM_Object_ptr shape, const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields, - const char* author, const char* fileName ) + const char* author, + const char* fileName, + const char* shapeFileName ) { beginService( " GEOM_Superv_i::ExportXAO" ); MESSAGE("GEOM_Superv_i::ExportXAO"); getXAOPluginOp(); - CORBA::Boolean isGood = myXAOOp->ExportXAO( shape, groups, fields, author, fileName ); + CORBA::Boolean isGood = myXAOOp->ExportXAO( shape, groups, fields, author, fileName, shapeFileName ); endService( " GEOM_Superv_i::ExportXAO" ); return isGood; } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 594215cc4..8d712acde 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -744,7 +744,8 @@ public: const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields, const char* author, - const char* fileName); + const char* fileName, + const char* shapeFileName); CORBA::Boolean ImportXAO( const char* fileName, GEOM::GEOM_Object_out shape, GEOM::ListOfGO_out subShapes, diff --git a/src/GEOM_SWIG/XAOPluginBuilder.py b/src/GEOM_SWIG/XAOPluginBuilder.py index aeffc075e..84a0945d6 100644 --- a/src/GEOM_SWIG/XAOPluginBuilder.py +++ b/src/GEOM_SWIG/XAOPluginBuilder.py @@ -33,10 +33,11 @@ def GetXAOPluginOperations(self): # @param fields The list of fields to export # @param author The author of the file # @param fileName The name of the file to export +# @param shapeFileName The name of the BRep file to export # @return True if operation is successful or False otherwise # # @ingroup l2_import_export -def ExportXAO(self, shape, groups, fields, author, fileName): +def ExportXAO(self, shape, groups, fields, author, fileName, shapeFileName = ""): """ Export a shape to XAO format @@ -52,7 +53,7 @@ def ExportXAO(self, shape, groups, fields, author, fileName): """ from salome.geom.geomBuilder import RaiseIfFailed anOp = GetXAOPluginOperations(self) - res = anOp.ExportXAO(shape, groups, fields, author, fileName) + res = anOp.ExportXAO(shape, groups, fields, author, fileName, shapeFileName) RaiseIfFailed("ExportXAO", anOp) return res diff --git a/src/XAO/XAO_BrepGeometry.cxx b/src/XAO/XAO_BrepGeometry.cxx index fb59e2cd5..db3c162b0 100644 --- a/src/XAO/XAO_BrepGeometry.cxx +++ b/src/XAO/XAO_BrepGeometry.cxx @@ -65,6 +65,25 @@ void BrepGeometry::setShapeString(const std::string& shape) initIds(); } +void BrepGeometry::writeShapeFile(const std::string& fileName) +throw (XAO_Exception) +{ + bool res = BRepTools::Write(m_shape, fileName.c_str()); + if (!res) + throw XAO_Exception(MsgBuilder() << "Cannot write BRep file: " << fileName); +} + +void BrepGeometry::readShapeFile(const std::string& fileName) +throw (XAO_Exception) + { + BRep_Builder builder; + bool res = BRepTools::Read(m_shape, fileName.c_str(), builder); + if (!res) + throw XAO_Exception(MsgBuilder() << "Cannot read BRep file: " << fileName); + + initIds(); +} + TopoDS_Shape BrepGeometry::getTopoDS_Shape() { return m_shape; diff --git a/src/XAO/XAO_BrepGeometry.hxx b/src/XAO/XAO_BrepGeometry.hxx index 59d19ba54..e57823384 100644 --- a/src/XAO/XAO_BrepGeometry.hxx +++ b/src/XAO/XAO_BrepGeometry.hxx @@ -75,6 +75,18 @@ namespace XAO */ virtual void setShapeString(const std::string& shape); + /** + * Writes shape to a file + * @param fileName the path to the file + */ + virtual void writeShapeFile(const std::string& fileName) throw (XAO_Exception); + + /** + * Reads shape from a file + * @param fileName the path to the file + */ + virtual void readShapeFile(const std::string& fileName) throw (XAO_Exception); + #ifdef SWIG %pythoncode %{ def setShape(self, shape): diff --git a/src/XAO/XAO_Geometry.hxx b/src/XAO/XAO_Geometry.hxx index 698843c9e..34760ca34 100644 --- a/src/XAO/XAO_Geometry.hxx +++ b/src/XAO/XAO_Geometry.hxx @@ -94,6 +94,8 @@ namespace XAO virtual const std::string getShapeString() = 0; virtual void setShapeString(const std::string& shape) = 0; + virtual void writeShapeFile(const std::string& fileName) = 0; + virtual void readShapeFile(const std::string& fileName) = 0; const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception); const int countVertices() const { return m_vertices.getSize(); } diff --git a/src/XAO/XAO_Xao.cxx b/src/XAO/XAO_Xao.cxx index 4e9652a26..1ec749b35 100644 --- a/src/XAO/XAO_Xao.cxx +++ b/src/XAO/XAO_Xao.cxx @@ -241,9 +241,9 @@ bool Xao::removeField(Field* field) return res; } -const bool Xao::exportXAO(const std::string& fileName) +const bool Xao::exportXAO(const std::string& fileName, const std::string& shapeFileName) { - return XaoExporter::saveToFile(this, fileName); + return XaoExporter::saveToFile(this, fileName, shapeFileName); } const std::string Xao::getXML() diff --git a/src/XAO/XAO_Xao.hxx b/src/XAO/XAO_Xao.hxx index 82c891b82..c7d839c3f 100644 --- a/src/XAO/XAO_Xao.hxx +++ b/src/XAO/XAO_Xao.hxx @@ -215,9 +215,10 @@ namespace XAO /** * Exports this XAO object to a file. * \param fileName the name of the file to create. + * \param shapeFileName if not empty, export the shape to this external file. * \return true is the export is successful. */ - const bool exportXAO(const std::string& fileName); + const bool exportXAO(const std::string& fileName, const std::string& shapeFileName); /** * Gets the XML corresponding to this XAO. * \return the XML as a string. diff --git a/src/XAO/XAO_XaoExporter.cxx b/src/XAO/XAO_XaoExporter.cxx index f0ca278fe..fd13841b8 100644 --- a/src/XAO/XAO_XaoExporter.cxx +++ b/src/XAO/XAO_XaoExporter.cxx @@ -28,6 +28,12 @@ #include "XAO_Step.hxx" #include "XAO_XaoUtils.hxx" +#ifdef WIN32 +# define _separator_ '\\' +#else +# define _separator_ '/' +#endif + namespace XAO { const xmlChar* C_TAG_XAO = (xmlChar*)"XAO"; @@ -39,6 +45,7 @@ namespace XAO const xmlChar* C_TAG_SHAPE = (xmlChar*)"shape"; const xmlChar* C_ATTR_SHAPE_FORMAT = (xmlChar*)"format"; + const xmlChar* C_ATTR_SHAPE_FILE = (xmlChar*)"file"; const xmlChar* C_TAG_TOPOLOGY = (xmlChar*)"topology"; const xmlChar* C_TAG_VERTICES = (xmlChar*)"vertices"; @@ -83,8 +90,8 @@ namespace XAO using namespace XAO; namespace { - xmlDocPtr exportXMLDoc(Xao* xaoObject); - void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao); + xmlDocPtr exportXMLDoc(Xao* xaoObject, const std::string& shapeFileName); + void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao, const std::string& shapeFileName); void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag); void exportGroups(Xao* xaoObject, xmlNodePtr xao); @@ -109,13 +116,15 @@ namespace { void parseStepElementNode(xmlNodePtr eltNode, Step* step); std::string readStringProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const std::string& defaultValue, const std::string& exception = std::string("")); + const bool& required, const std::string& defaultValue, + const std::string& exception = std::string("")); int readIntegerProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const int& defaultValue, const std::string& exception = std::string("")); + const bool& required, const int& defaultValue, + const std::string& exception = std::string("")); - std::string readStringProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const std::string& defaultValue, - const std::string& exception /*= std::string() */) + std::string readStringProp(xmlNodePtr node, const xmlChar* attribute, + const bool& required, const std::string& defaultValue, + const std::string& exception /*= std::string() */) { xmlChar* strAttr = xmlGetProp(node, attribute); if (strAttr == NULL) @@ -161,7 +170,7 @@ namespace { return res; } - xmlDocPtr exportXMLDoc(Xao* xaoObject) + xmlDocPtr exportXMLDoc(Xao* xaoObject, const std::string& shapeFileName) { // Creating the Xml document xmlDocPtr masterDocument = xmlNewDoc(BAD_CAST "1.0"); @@ -173,7 +182,7 @@ namespace { if (xaoObject->getGeometry() != NULL) { - exportGeometry(xaoObject->getGeometry(), masterDocument, xao); + exportGeometry(xaoObject->getGeometry(), masterDocument, xao, shapeFileName); } exportGroups(xaoObject, xao); @@ -199,7 +208,8 @@ namespace { } } - void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao) + void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao, + const std::string& shapeFileName) { // Geometric part xmlNodePtr geometry = xmlNewChild(xao, 0, C_TAG_GEOMETRY, 0); @@ -207,9 +217,20 @@ namespace { xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0); xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str()); - std::string txtShape = xaoGeometry->getShapeString(); - xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size()); - xmlAddChild(shape, cdata); + + if (shapeFileName == "") + { + // export the shape in the XAO file + std::string txtShape = xaoGeometry->getShapeString(); + xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size()); + xmlAddChild(shape, cdata); + } + else + { + // export the shape in an external file + xmlNewProp(shape, C_ATTR_SHAPE_FILE, BAD_CAST shapeFileName.c_str()); + xaoGeometry->writeShapeFile(shapeFileName); + } xmlNodePtr topology = xmlNewChild(geometry, 0, C_TAG_TOPOLOGY, 0); @@ -361,11 +382,20 @@ namespace { { if (geometry->getFormat() == XAO::BREP) { - xmlChar* data = xmlNodeGetContent(shapeNode->children); - if (data == NULL) - throw XAO_Exception("Missing BREP"); - geometry->setShapeString((char*)data); - xmlFree(data); + std::string strFile = readStringProp(shapeNode, C_ATTR_SHAPE_FILE, false, ""); + if (strFile != "") + { + geometry->readShapeFile(strFile); + } + else + { + // read brep from node content + xmlChar* data = xmlNodeGetContent(shapeNode->children); + if (data == NULL) + throw XAO_Exception("Missing BREP"); + geometry->setShapeString((char*)data); + xmlFree(data); + } } else { @@ -608,10 +638,10 @@ namespace { } } -const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName) +const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName) throw (XAO_Exception) { - xmlDocPtr doc = exportXMLDoc(xaoObject); + xmlDocPtr doc = exportXMLDoc(xaoObject, shapeFileName); xmlSaveFormatFileEnc(fileName.c_str(), doc, "UTF-8", 1); // format = 1 for node indentation xmlFreeDoc(doc); @@ -621,7 +651,7 @@ throw (XAO_Exception) const std::string XaoExporter::saveToXml(Xao* xaoObject) throw (XAO_Exception) { - xmlDocPtr doc = exportXMLDoc(xaoObject); + xmlDocPtr doc = exportXMLDoc(xaoObject, ""); xmlChar *xmlbuff; int buffersize; diff --git a/src/XAO/XAO_XaoExporter.hxx b/src/XAO/XAO_XaoExporter.hxx index 966e76386..d633ecb08 100644 --- a/src/XAO/XAO_XaoExporter.hxx +++ b/src/XAO/XAO_XaoExporter.hxx @@ -44,9 +44,10 @@ namespace XAO * Saves the XAO object to a file. * @param xaoObject the object to export. * @param fileName the path of the file to create. + * @param shapeFileName if not empty save the shape in an this external file. * @return true if the export was successful, false otherwise. */ - static const bool saveToFile(Xao* xaoObject, const std::string& fileName) + static const bool saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName) throw (XAO_Exception); /** diff --git a/src/XAO/tests/ImportExportTest.cxx b/src/XAO/tests/ImportExportTest.cxx index 2c060200e..51ef590a2 100644 --- a/src/XAO/tests/ImportExportTest.cxx +++ b/src/XAO/tests/ImportExportTest.cxx @@ -46,7 +46,7 @@ void ImportExportTest::testExportNoGeometry() { Xao xao("me", "1.0"); - bool res = xao.exportXAO("empty.xao"); + bool res = xao.exportXAO("empty.xao", ""); CPPUNIT_ASSERT(res); } @@ -103,7 +103,7 @@ void ImportExportTest::testExportGeometry() } } - bool res = xao.exportXAO("mygeom.xao"); + bool res = xao.exportXAO("mygeom.xao", ""); CPPUNIT_ASSERT(res); std::string xml = xao.getXML(); diff --git a/src/XAOPlugin/XAOPlugin_ExportDlg.cxx b/src/XAOPlugin/XAOPlugin_ExportDlg.cxx index d3b32ee68..c1a5e91da 100644 --- a/src/XAOPlugin/XAOPlugin_ExportDlg.cxx +++ b/src/XAOPlugin/XAOPlugin_ExportDlg.cxx @@ -54,6 +54,7 @@ #include #include #include +#include #include //================================================================================= @@ -101,6 +102,7 @@ XAOPlugin_ExportDlg::XAOPlugin_ExportDlg(GeometryGUI* geometryGUI, QWidget* pare ledShape->setMinimumSize(QSize(100, 0)); int line = 0, col = 0; + // adWidget(widget, fromRow, fromColumn, rowSpan, columnSpan) gridLayoutExport->addWidget(lblShape, line, col++, 1, 1); gridLayoutExport->addWidget(btnShapeSelect, line, col++, 1, 1); gridLayoutExport->addWidget(ledShape, line, col++, 1, 1); @@ -121,10 +123,17 @@ XAOPlugin_ExportDlg::XAOPlugin_ExportDlg(GeometryGUI* geometryGUI, QWidget* pare ledAuthor = new QLineEdit(gbxExport); line++; col = 0; - gridLayoutExport->addWidget(lblAuthor, line, col++, 2, 1); + gridLayoutExport->addWidget(lblAuthor, line, col++, 1, 1); col++; // span gridLayoutExport->addWidget(ledAuthor, line, col++, 1, 1); + // Line 3 + ckxUseSeparateFile = new QCheckBox(tr("XAOPLUGIN_EXPORT_SHAPEFILE"), gbxExport); + + line++; col = 0; + gridLayoutExport->addWidget(ckxUseSeparateFile, line, col++, 1, 2); + + //**************************** // Filter Group box QGroupBox* gbxFilter = new QGroupBox(parent); @@ -410,6 +419,12 @@ bool XAOPlugin_ExportDlg::execute() QString author = ledAuthor->text(); QString fileName = ledFileName->text(); + QString shapeFileName = QString("");//ledShapeFile->text(); + if (ckxUseSeparateFile->isChecked()) + { + shapeFileName = fileName; + shapeFileName.append(".brep"); + } // get selected groups QList selGroups; @@ -451,6 +466,7 @@ bool XAOPlugin_ExportDlg::execute() GEOM::IXAOOperations_var aXAOOp = GEOM::IXAOOperations::_narrow( getOperation() ); res = aXAOOp->ExportXAO(m_mainObj, groups, fields, author.toUtf8().constData(), - fileName.toUtf8().constData()); + fileName.toUtf8().constData(), + shapeFileName.toStdString().c_str()); return res; } diff --git a/src/XAOPlugin/XAOPlugin_ExportDlg.h b/src/XAOPlugin/XAOPlugin_ExportDlg.h index daf27e7fa..bade0ff0a 100644 --- a/src/XAOPlugin/XAOPlugin_ExportDlg.h +++ b/src/XAOPlugin/XAOPlugin_ExportDlg.h @@ -27,6 +27,7 @@ class QLineEdit; class QButtonGroup; class QListWidget; class QPushButton; +class QCheckBox; //================================================================================= // class : XAOPlugin_ExportDlg @@ -58,6 +59,7 @@ private: QLineEdit* ledShape; QLineEdit* ledFileName; QLineEdit* ledAuthor; + QCheckBox* ckxUseSeparateFile; QListWidget* lstGroups; QListWidget* lstFields; QPushButton* btnShapeSelect; diff --git a/src/XAOPlugin/XAOPlugin_IECallBack.cxx b/src/XAOPlugin/XAOPlugin_IECallBack.cxx index 7992926b7..4e4e6ed11 100644 --- a/src/XAOPlugin/XAOPlugin_IECallBack.cxx +++ b/src/XAOPlugin/XAOPlugin_IECallBack.cxx @@ -48,9 +48,10 @@ XAOPlugin_IECallBack::~XAOPlugin_IECallBack() //============================================================================= bool XAOPlugin_IECallBack::Export( int theDocId, - const Handle(GEOM_Object) theOriginal, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName ) + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theShapeFileName ) { XAOPlugin_IOperations* aPluginOperations = XAOPlugin_OperationsCreator::get( GetEngine(), theDocId ); GEOMImpl_IShapesOperations* aShapesOperations = GetEngine()->GetIShapesOperations( theDocId ); @@ -63,7 +64,7 @@ XAOPlugin_IECallBack::Export( int theDocId, lgroups.push_back( Handle(GEOM_Object)::DownCast( groups->Value(i) ) ); for (int i = 1; i <= fields->Length(); i++) lfields.push_back( Handle(GEOM_Field)::DownCast( fields->Value(i) ) ); - aPluginOperations->ExportXAO( theOriginal, lgroups, lfields, "SIMAN Author", theFileName.ToCString() ); + aPluginOperations->ExportXAO( theOriginal, lgroups, lfields, "SIMAN Author", theFileName.ToCString(), theShapeFileName.ToCString() ); return true; } diff --git a/src/XAOPlugin/XAOPlugin_IECallBack.hxx b/src/XAOPlugin/XAOPlugin_IECallBack.hxx index d1f04cec5..8bd1b688b 100644 --- a/src/XAOPlugin/XAOPlugin_IECallBack.hxx +++ b/src/XAOPlugin/XAOPlugin_IECallBack.hxx @@ -37,9 +37,10 @@ public: ~XAOPlugin_IECallBack(); virtual bool Export( int theDocId, - const Handle(GEOM_Object) theOriginal, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName ); + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theshapeFileName ); virtual Handle(TColStd_HSequenceOfTransient) Import( int theDocId, diff --git a/src/XAOPlugin/XAOPlugin_IOperations.cxx b/src/XAOPlugin/XAOPlugin_IOperations.cxx index d33a5deaf..33e74ae6d 100644 --- a/src/XAOPlugin/XAOPlugin_IOperations.cxx +++ b/src/XAOPlugin/XAOPlugin_IOperations.cxx @@ -311,7 +311,8 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape, std::list groupList, std::list fieldList, const char* author, - const char* fileName ) + const char* fileName, + const char* shapeFileName ) { SetErrorCode(KO); @@ -348,7 +349,7 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape, exportFields(fieldList, xaoObject, geometry); // export the XAO to the file - xaoObject->exportXAO(fileName); + xaoObject->exportXAO(fileName, shapeFileName); // make a Python command GEOM::TPythonDump pd(exportFunction); @@ -378,7 +379,7 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape, } } pd << "], "; - pd << "\"" << author << "\", \"" << fileName << "\")"; + pd << "\"" << author << "\", \"" << fileName << "\", \"" << shapeFileName << "\")"; SetErrorCode(OK); delete xaoObject; diff --git a/src/XAOPlugin/XAOPlugin_IOperations.hxx b/src/XAOPlugin/XAOPlugin_IOperations.hxx index 65e42d42c..7bf885f7c 100644 --- a/src/XAOPlugin/XAOPlugin_IOperations.hxx +++ b/src/XAOPlugin/XAOPlugin_IOperations.hxx @@ -47,7 +47,8 @@ public: std::list groupList, std::list fieldList, const char* author, - const char* fileName ); + const char* fileName, + const char* shapeFileName ); bool ImportXAO( const char* fileName, Handle(GEOM_Object)& shape, diff --git a/src/XAOPlugin/XAOPlugin_IOperations_i.cc b/src/XAOPlugin/XAOPlugin_IOperations_i.cc index fa26fe5f0..20581c9b9 100644 --- a/src/XAOPlugin/XAOPlugin_IOperations_i.cc +++ b/src/XAOPlugin/XAOPlugin_IOperations_i.cc @@ -55,14 +55,16 @@ XAOPlugin_IOperations_i::~XAOPlugin_IOperations_i() * \param fields The list of fields to export * \param author The author of the export * \param fileName The name of the exported file + * \param shapeFileName If not empty, save to shape to this external file * \return boolean indicating if export was succeful. */ //============================================================================= CORBA::Boolean XAOPlugin_IOperations_i::ExportXAO( GEOM::GEOM_Object_ptr shape, - const GEOM::ListOfGO& groups, - const GEOM::ListOfFields& fields, - const char* author, - const char* fileName) + const GEOM::ListOfGO& groups, + const GEOM::ListOfFields& fields, + const char* author, + const char* fileName, + const char* shapeFileName) { bool isGood = false; // Set a not done flag @@ -94,7 +96,7 @@ CORBA::Boolean XAOPlugin_IOperations_i::ExportXAO( GEOM::GEOM_Object_ptr shape, if( !reference.IsNull() ) { // Export XAO - isGood = GetOperations()->ExportXAO( reference, groupsObj, fieldsObj, author, fileName ); + isGood = GetOperations()->ExportXAO( reference, groupsObj, fieldsObj, author, fileName, shapeFileName ); } return isGood; diff --git a/src/XAOPlugin/XAOPlugin_IOperations_i.hh b/src/XAOPlugin/XAOPlugin_IOperations_i.hh index 3b849c79e..c3dbe4917 100644 --- a/src/XAOPlugin/XAOPlugin_IOperations_i.hh +++ b/src/XAOPlugin/XAOPlugin_IOperations_i.hh @@ -47,7 +47,8 @@ public: const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields, const char* author, - const char* fileName ); + const char* fileName, + const char* shapeFileName ); CORBA::Boolean ImportXAO( const char* fileName, GEOM::GEOM_Object_out shape, diff --git a/src/XAOPlugin/XAOPlugin_msg_en.ts b/src/XAOPlugin/XAOPlugin_msg_en.ts index c37ffd620..740b0232c 100644 --- a/src/XAOPlugin/XAOPlugin_msg_en.ts +++ b/src/XAOPlugin/XAOPlugin_msg_en.ts @@ -62,6 +62,10 @@ XAOPLUGIN_EXPORT_AUTHOR Author + + XAOPLUGIN_EXPORT_SHAPEFILE + Export shape in a separate file + XAOPLUGIN_EXPORT_LGROUPS Groups diff --git a/src/XAOPlugin/XAOPlugin_msg_fr.ts b/src/XAOPlugin/XAOPlugin_msg_fr.ts index 7d3a6deec..a28228679 100644 --- a/src/XAOPlugin/XAOPlugin_msg_fr.ts +++ b/src/XAOPlugin/XAOPlugin_msg_fr.ts @@ -62,6 +62,10 @@ XAOPLUGIN_EXPORT_AUTHOR Auteur + + XAOPLUGIN_EXPORT_SHAPEFILE + Exporter la forme dans un fichier séparé + XAOPLUGIN_EXPORT_LGROUPS Groupes -- 2.39.2