+ << meshPart << ", r'"
+ << file << "', "
+ << auto_groups << ", "
+ << version << ", "
+ << overwrite << ", "
+ << autoDimension << ", "
+ << goList << ", '"
+ << ( geomAssocFields ? geomAssocFields : "" ) << "',"
+ << TVar( ZTolerance ) << ", "
+ << saveNumbers
+ << " )";
+ 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
+{
+public:
+ std::string prepareMeshNameAndGroups(SMESH_Mesh_i& self) { return self.generateMeshName(); }
+
+ void exportTo(SMESH_Mesh *mesh, const std::string& aMeshName, CORBA::Boolean auto_groups,
+ SMESH_MeshPartDS* partDS, CORBA::Boolean autoDimension, bool have0dField,
+ CORBA::Double ZTolerance, CORBA::Boolean saveNumbers )
+ {
+ _res = mesh->ExportMEDCoupling(aMeshName.c_str(), auto_groups, partDS,
+ autoDimension, have0dField, ZTolerance, saveNumbers );
+ }
+ void prepareForWriting(SMESH_Mesh_i& /*self*/) { /* nothing here */ }
+
+ void exportField(SMESH_Mesh_i& self, const std::string& aMeshName, bool have0dField,
+ SMESHDS_Mesh *meshDS, const GEOM::ListOfFields& fields,
+ const char*geomAssocFields)
+ {
+ DriverMED_W_Field_Mem fieldWriter(_res);
+ fieldWriter.SetMeshName( aMeshName );
+ fieldWriter.AddODOnVertices( have0dField );
+ self.exportMEDFields( fieldWriter, meshDS, fields, geomAssocFields );
+ _res = fieldWriter.getData();
+ }
+public:
+ MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> getData() { return _res; }
+
+private:
+ MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> _res;
+};
+
+//================================================================================
+/*!
+ * \brief Export a part of mesh to a MEDCoupling DS
+ */
+//================================================================================
+
+CORBA::LongLong SMESH_Mesh_i::ExportPartToMEDCoupling(SMESH::SMESH_IDSource_ptr meshPart,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean autoDimension,
+ const GEOM::ListOfFields& fields,
+ const char* geomAssocFields,
+ CORBA::Double ZTolerance,
+ CORBA::Boolean saveNumbers)
+{
+ MEDCoupling::MCAuto<MEDCoupling::DataArrayByte> data;
+
+ SMESH_TRY;
+ if( !this->_gen_i->isSSLMode() )
+ SMESH::throwCorbaException("SMESH_Mesh_i::ExportPartToMEDCoupling : only for embedded mode !");
+
+ MEDFileMemSpeCls spe;
+ this->ExportPartToMEDCommon( spe, meshPart, auto_groups, autoDimension, fields, geomAssocFields,
+ ZTolerance, saveNumbers );
+ data = spe.getData();