X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Mesh_i.cxx;h=b5c003e4c3b292fc5764cd60495a741205b11ac3;hp=37394ce64468daf29a573305a8317147db4f396e;hb=HEAD;hpb=274fd4f2db8d3a7fa23701764280ea1d175b194b diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 37394ce64..e1c8ca916 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -57,6 +57,7 @@ #include "SMESH_PreMeshInfo.hxx" #include "SMESH_PythonDump.hxx" #include "SMESH_subMesh_i.hxx" +#include "SMESH_Meshio.h" #include #include @@ -4052,6 +4053,55 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, SMESH_CATCH( SMESH::throwCorbaException ); } +//================================================================================ +/*! + * \brief Export a part of mesh to a file with meshio library + */ +//================================================================================ + +void SMESH_Mesh_i::ExportPartToMESHIO(SMESH::SMESH_IDSource_ptr meshPart, + const char* file, + const char* selectedFilter) +{ + // Get default MED version + SMESH::long_array_var medVersions = GetMEDVersionsCompatibleForAppend(); + const CORBA::Long version = medVersions[0]; + MESSAGE("Export part with meshio through MED version: " << version); + + // Default values are the same as for MED export + const bool auto_groups = false; + const bool overwrite = true; + const bool autoDimension = true; + const GEOM::ListOfFields fields; + const char* geomAssocFields = ""; + const double ZTolerance = -1.0; + const bool saveNumbers = true; + + // Create an object that holds a temp file name and + // removes the file when goes out of scope. + SMESH_Meshio meshio(selectedFilter); + const QString tempFileName = meshio.CreateTempFileName(file); + + // Export a given mesh into the temp file + MEDFileSpeCls spe(tempFileName.toUtf8().data(), overwrite, version); + this->ExportPartToMEDCommon(spe, meshPart, auto_groups, autoDimension, fields, + geomAssocFields, ZTolerance, saveNumbers); + + // Convert temp file into a target one with meshio command + meshio.Convert(tempFileName, file); + + // Prepare python dump + SMESH_TRY; + + TPythonDump() << _this() << ".ExportPartToMESHIO(" + << meshPart << ", r'" + << file << "', '" + << selectedFilter << "'" + << ")"; + + SMESH_CATCH(SMESH::throwCorbaException); +} + //================================================================================ class MEDFileMemSpeCls @@ -5954,7 +6004,7 @@ void SMESH_Mesh_i::CreateGroupServants() */ //============================================================================= -bool SMESH_Mesh_i::IsComputedOK() +CORBA::Boolean SMESH_Mesh_i::IsComputedOK() { return _impl->IsComputedOK(); }