Improve according to review remarks

This commit is contained in:
jfa 2023-07-10 20:47:30 +01:00
parent 8e94d832a4
commit 9ef2fb1e1b
4 changed files with 30 additions and 11 deletions

View File

@ -68,7 +68,7 @@ sphere_stl2 = geompy.ImportSTL(f_stl2)
ok, sphere_xao, sub_shapes, groups, fields = geompy.ImportXAO(f_xao) ok, sphere_xao, sub_shapes, groups, fields = geompy.ImportXAO(f_xao)
# import XAO data from memory buffer (bytes array) # 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 # clean up
for f in f_brep, f_iges, f_step, f_stl1, f_stl2, f_vtk1, f_vtk2, f_xao: for f in f_brep, f_iges, f_step, f_stl1, f_stl2, f_vtk1, f_vtk2, f_xao:

View File

@ -47,7 +47,7 @@ module GEOM
in string shapeFileName ); 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 shape The shape to export
* \param groups The list of groups to export * \param groups The list of groups to export
* \param fields The list of fields to export * \param fields The list of fields to export

View File

@ -58,7 +58,7 @@ def ExportXAO(self, shape, groups, fields, author, fileName, shapeFileName = "")
RaiseIfFailed("ExportXAO", anOp) RaiseIfFailed("ExportXAO", anOp)
return res return res
## Export a shape to XAO format ## Export a shape to XAO format in byte array
# @param shape The shape to export # @param shape The shape to export
# @param groups The list of groups to export # @param groups The list of groups to export
# @param fields The list of fields 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 # @ingroup l2_import_export
def ExportXAOMem(self, shape, groups, fields, author): def ExportXAOMem(self, shape, groups, fields, author):
""" """
Export a shape to XAO format Export a shape to XAO format in byte array
Parameters: Parameters:
shape The shape to export shape The shape to export
@ -118,10 +118,26 @@ def ImportXAO(self, fileName, theName=None):
""" """
from salome.geom.geomBuilder import RaiseIfFailed from salome.geom.geomBuilder import RaiseIfFailed
anOp = GetXAOPluginOperations(self) anOp = GetXAOPluginOperations(self)
res = anOp.ImportXAO(fileName) (res, shape, subShapes, groups, fields) = anOp.ImportXAO(fileName)
RaiseIfFailed("ImportXAO", anOp) RaiseIfFailed("ImportXAO", anOp)
self._autoPublish(res[1], theName, "imported") if res:
return 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 ## Import a shape from XAO format byte array
# @param byteArray byte array with XAO data # @param byteArray byte array with XAO data
@ -139,7 +155,7 @@ def ImportXAO(self, fileName, theName=None):
# @ingroup l2_import_export # @ingroup l2_import_export
def ImportXAOMem(self, byteArray, theName=None): def ImportXAOMem(self, byteArray, theName=None):
""" """
Import a shape from XAO format Import a shape from XAO format byte array
Parameters: Parameters:
byteArray byte array with XAO data byteArray byte array with XAO data

View File

@ -101,9 +101,10 @@ SALOMEDS::TMPFile* XAOPlugin_IOperations_i::ExportXAOMem( GEOM::GEOM_Object_ptr
* \param groups The list of groups to export * \param groups The list of groups to export
* \param fields The list of fields to export * \param fields The list of fields to export
* \param author The author of the 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 fileName The name of the exported file
* \param shapeFileName If not empty, save the BREP shape to this external 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, 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 fileName The name of the file to import
* \param shape The imported shape * \param shape The imported shape
* \param subShapes The list of imported subShapes * \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 * 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 shape The imported shape
* \param subShapes The list of imported subShapes * \param subShapes The list of imported subShapes
* \param groups The list of imported groups * \param groups The list of imported groups