From 9ef2fb1e1bfaf2796c2db6ac04e1cb33799d3cce Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 10 Jul 2023 20:47:30 +0100 Subject: [PATCH] Improve according to review remarks --- doc/salome/examples/import_export.py | 2 +- idl/XAOPlugin.idl | 2 +- src/GEOM_SWIG/XAOPluginBuilder.py | 28 +++++++++++++++++++----- src/XAOPlugin/XAOPlugin_IOperations_i.cc | 9 +++++--- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/doc/salome/examples/import_export.py b/doc/salome/examples/import_export.py index 37c9abbb3..85e31d1db 100644 --- a/doc/salome/examples/import_export.py +++ b/doc/salome/examples/import_export.py @@ -68,7 +68,7 @@ sphere_stl2 = geompy.ImportSTL(f_stl2) ok, sphere_xao, sub_shapes, groups, fields = geompy.ImportXAO(f_xao) # import XAO data from memory buffer (bytes array) -ok, sphere_xao, sub_shapes, groups, fields = geompy.ImportXAOMem(buff_xao) +ok_mem, sphere_xao_mem, sub_shapes_mem, groups_mem, fields_mem = geompy.ImportXAOMem(buff_xao) # clean up for f in f_brep, f_iges, f_step, f_stl1, f_stl2, f_vtk1, f_vtk2, f_xao: diff --git a/idl/XAOPlugin.idl b/idl/XAOPlugin.idl index 29afdba2a..f60cbd5ed 100644 --- a/idl/XAOPlugin.idl +++ b/idl/XAOPlugin.idl @@ -47,7 +47,7 @@ module GEOM in string shapeFileName ); /*! - * Export a shape to XAO format + * Export a shape to XAO format in a byte array * \param shape The shape to export * \param groups The list of groups to export * \param fields The list of fields to export diff --git a/src/GEOM_SWIG/XAOPluginBuilder.py b/src/GEOM_SWIG/XAOPluginBuilder.py index 409b49015..cb69d400d 100644 --- a/src/GEOM_SWIG/XAOPluginBuilder.py +++ b/src/GEOM_SWIG/XAOPluginBuilder.py @@ -58,7 +58,7 @@ def ExportXAO(self, shape, groups, fields, author, fileName, shapeFileName = "") RaiseIfFailed("ExportXAO", anOp) return res -## Export a shape to XAO format +## Export a shape to XAO format in byte array # @param shape The shape to export # @param groups The list of groups to export # @param fields The list of fields to export @@ -68,7 +68,7 @@ def ExportXAO(self, shape, groups, fields, author, fileName, shapeFileName = "") # @ingroup l2_import_export def ExportXAOMem(self, shape, groups, fields, author): """ - Export a shape to XAO format + Export a shape to XAO format in byte array Parameters: shape The shape to export @@ -118,10 +118,26 @@ def ImportXAO(self, fileName, theName=None): """ from salome.geom.geomBuilder import RaiseIfFailed anOp = GetXAOPluginOperations(self) - res = anOp.ImportXAO(fileName) + (res, shape, subShapes, groups, fields) = anOp.ImportXAO(fileName) RaiseIfFailed("ImportXAO", anOp) - self._autoPublish(res[1], theName, "imported") - return res + if res: + # publish imported shape + self._autoPublish(shape, theName, "imported") + # publish imported sub shapes, groups and fields + if theName or self.myMaxNbSubShapesAllowed: + for ss in (subShapes + groups + fields): + self.addToStudyInFather(shape, ss, ss.GetName()) + if isinstance( ss, GEOM._objref_GEOM_Field ): + listStepIDs = ss.GetSteps() + for stepID in listStepIDs: + step = ss.GetStep(stepID) + self.addToStudyInFather(ss, step, step.GetName()) + pass + pass + pass + pass + pass + return (res, shape, subShapes, groups, fields) ## Import a shape from XAO format byte array # @param byteArray byte array with XAO data @@ -139,7 +155,7 @@ def ImportXAO(self, fileName, theName=None): # @ingroup l2_import_export def ImportXAOMem(self, byteArray, theName=None): """ - Import a shape from XAO format + Import a shape from XAO format byte array Parameters: byteArray byte array with XAO data diff --git a/src/XAOPlugin/XAOPlugin_IOperations_i.cc b/src/XAOPlugin/XAOPlugin_IOperations_i.cc index 899099c85..b22666653 100644 --- a/src/XAOPlugin/XAOPlugin_IOperations_i.cc +++ b/src/XAOPlugin/XAOPlugin_IOperations_i.cc @@ -101,9 +101,10 @@ SALOMEDS::TMPFile* XAOPlugin_IOperations_i::ExportXAOMem( GEOM::GEOM_Object_ptr * \param groups The list of groups to export * \param fields The list of fields to export * \param author The author of the export + * \param toFile Export to file if true, otherwise export to memory buffer (the returned string) * \param fileName The name of the exported file * \param shapeFileName If not empty, save the BREP shape to this external file - * \return boolean indicating if export was successful. + * \return string The exported buffer if toFile=false, otherwise an empty string */ //============================================================================= std::string XAOPlugin_IOperations_i::exportXAO( GEOM::GEOM_Object_ptr shape, @@ -180,7 +181,7 @@ CORBA::Boolean XAOPlugin_IOperations_i::ImportXAO( const char* fileName, //============================================================================= /*! - * Import a shape from XAO format + * Import a shape from XAO format memory buffer * \param fileName The name of the file to import * \param shape The imported shape * \param subShapes The list of imported subShapes @@ -202,7 +203,9 @@ CORBA::Boolean XAOPlugin_IOperations_i::ImportXAOMem( const SALOMEDS::TMPFile& t //============================================================================= /*! * Import a shape from XAO format - * \param fileName The name of the file to import + * \param isFile Boolean flag to switch between import from file or from buffer + * \param fileName The name of the file to import from if isFile=true + * \param theBuff The buffer to import from if isFile=false * \param shape The imported shape * \param subShapes The list of imported subShapes * \param groups The list of imported groups -- 2.39.2