X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSauvWriter.cxx;h=55ed3c39328d89bef07de1a6c445a96ed545d777;hb=02a3cbbd9da2e5de320574b7ed541ff75baafca1;hp=c6c05c629464f92be2495fe2739d60d5d8cf09da;hpb=9f966e0ed55cc976b59a17318a7be82445529eda;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/SauvWriter.cxx b/src/MEDLoader/SauvWriter.cxx index c6c05c629..55ed3c393 100644 --- a/src/MEDLoader/SauvWriter.cxx +++ b/src/MEDLoader/SauvWriter.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -34,7 +34,7 @@ #include #include -using namespace ParaMEDMEM; +using namespace MEDCoupling; using namespace SauvUtilities; using namespace std; @@ -106,7 +106,7 @@ namespace //================================================================================ /*! - * \brief Converts MED long names into SAUVE short ones, returnes a healed long name + * \brief Converts MED long names into SAUVE short ones, returns a healed long name */ //================================================================================ @@ -374,7 +374,7 @@ void SauvWriter::fillFamilySubMeshes() for ( size_t iDim = 0; iDim < dims.size(); ++iDim ) { int dimRelExt = dims[ iDim ]; - MEDCouplingAutoRefCountObjectPtr< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(dimRelExt); + MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(dimRelExt); const DataArrayInt * famIds = _fileMesh->getFamilyFieldAtLevel(dimRelExt); if ( !famIds ) continue; @@ -450,17 +450,21 @@ void SauvWriter::fillGroupSubMeshes() ++k; } } + if ( k == 0 ) + continue; // if a family exists but has no element, no submesh has been found for this family // => we have to resize famSubMeshes with the number of submeshes stored if (k != famNames.size()) - famSubMeshes.resize(k); + famSubMeshes.resize(k); SubMesh* grpSubMesh = addSubMesh( groupName, famSubMeshes[0]->_dimRelExt ); - if(!_cpy_grp_if_on_single_family) - grpSubMesh->_subs.swap( famSubMeshes ); + if( ! _cpy_grp_if_on_single_family ) + { + grpSubMesh->_subs.swap( famSubMeshes ); + } else { - /* If a group sub mesh consists of only one family, the group is written as - * a copy of this family. + /* If a group sub mesh consists of only one family, the group is written as + * a copy of this family. * A mesh composed of only one submesh may cause an issue with some Gibi operators.*/ if (famSubMeshes.size() == 1) { @@ -488,7 +492,7 @@ void SauvWriter::fillProfileSubMeshes() SubMesh* nilSm = (SubMesh*) 0; for ( int isOnNodes = 0; isOnNodes < 2; ++isOnNodes ) { - vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTS > > + vector< MCAuto< MEDFileFieldMultiTS > > fields = isOnNodes ? _nodeFields : _cellFields; for ( size_t i = 0; i < fields.size(); ++i ) { @@ -555,7 +559,7 @@ int SauvWriter::evaluateNbProfileSubMeshes() const //================================================================================ /*! - * \brief Transorm a profile into ids of mesh elements + * \brief Transform a profile into ids of mesh elements */ //================================================================================ @@ -563,7 +567,7 @@ void SauvWriter::makeProfileIDs( SubMesh* sm, INTERP_KERNEL::NormalizedCellType type, const DataArrayInt* profile ) { - MEDCouplingAutoRefCountObjectPtr< MEDCouplingMesh > + MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(sm->_dimRelExt); const MEDCouplingUMesh* uMesh = dynamic_cast< const MEDCouplingUMesh* > ((const MEDCouplingMesh*) mesh ); @@ -600,7 +604,7 @@ void SauvWriter::makeProfileIDs( SubMesh* sm, code[2] = -1; } vector idsPerType( 1, profile ); - MEDCouplingAutoRefCountObjectPtr + MCAuto resIDs = uMesh->checkTypeConsistencyAndContig( code, idsPerType ); if (( const DataArrayInt *) resIDs ) { @@ -661,7 +665,7 @@ void SauvWriter::write(const std::string& fileName) void SauvWriter::writeFileHead() { - MEDCouplingAutoRefCountObjectPtr< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(0); + MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(0); *_sauvFile << " ENREGISTREMENT DE TYPE 4" << endl @@ -721,7 +725,7 @@ void SauvWriter::writeSubMeshes() writeNames( nameNbMap ); - TFieldCounter fcount( *_sauvFile, 10 ); // 10 intergers per line + TFieldCounter fcount( *_sauvFile, 10 ); // 10 integers per line for ( size_t iSub = 0; iSub < _subs.size(); ++iSub ) { @@ -742,9 +746,9 @@ void SauvWriter::writeSubMeshes() else { // write each sub-type as a SAUV sub-mesh - MEDCouplingAutoRefCountObjectPtr< MEDCouplingMesh > + MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel( sm._dimRelExt ); - MEDCouplingAutoRefCountObjectPtr< MEDCouplingUMesh> + MCAuto< MEDCouplingUMesh> umesh = mesh->buildUnstructured(); for ( int iType=0; iType < sm.cellIDsByTypeSize(); ++iType ) @@ -828,7 +832,7 @@ void SauvWriter::writeCompoundSubMesh(int iSub) << zeroI8 << zeroI8 << endl; - TFieldCounter fcount( *_sauvFile, 10 ); // 10 intergers per line + TFieldCounter fcount( *_sauvFile, 10 ); // 10 integers per line for ( size_t i = 0; i < subIDs.size(); ++i, fcount++ ) *_sauvFile << setw(8) << subIDs[i]; } @@ -841,10 +845,10 @@ void SauvWriter::writeCompoundSubMesh(int iSub) void SauvWriter::writeNodes() { - MEDCouplingAutoRefCountObjectPtr< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel( 1 ); - MEDCouplingAutoRefCountObjectPtr< MEDCouplingUMesh > umesh = mesh->buildUnstructured(); + MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel( 1 ); + MCAuto< MEDCouplingUMesh > umesh = mesh->buildUnstructured(); - // write the index connecting nodes with their coodrinates + // write the index connecting nodes with their coordinates const int nbNodes = umesh->getNumberOfNodes(); *_sauvFile << " ENREGISTREMENT DE TYPE 2" << endl @@ -871,7 +875,7 @@ void SauvWriter::writeNodes() _sauvFile->precision(14); _sauvFile->setf( ios_base::scientific, ios_base::floatfield ); _sauvFile->setf( ios_base::uppercase ); - MEDCouplingAutoRefCountObjectPtr< DataArrayDouble> coordArray = umesh->getCoordinatesAndOwner(); + MCAuto< DataArrayDouble> coordArray = umesh->getCoordinatesAndOwner(); const double precision = 1.e-99; // PAL12077 for ( int i = 0; i < nbNodes; ++i) { @@ -996,7 +1000,7 @@ void SauvWriter::writeLongNames() void SauvWriter::writeFieldNames( const bool isNodal, std::map& fldNamePrefixMap) { - vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTS > >& + vector< MCAuto< MEDFileFieldMultiTS > >& flds = isNodal ? _nodeFields : _cellFields; map nameNbMap; @@ -1166,7 +1170,7 @@ void SauvWriter::writeNodalFields(map& fldNamePrefixMap) fcount.stop(); } } - } // loop on fiels + } // loop on files } //================================================================================