bos #24357 [CEA] Export mesh with field on vertices

+ fix warnings
This commit is contained in:
eap 2021-07-08 12:02:05 +03:00
parent 882ff39283
commit ad1d7c52f7
2 changed files with 16 additions and 4 deletions

View File

@ -26,16 +26,17 @@
#include "DriverMED_W_Field.h" #include "DriverMED_W_Field.h"
#include "MED_TFile.hxx"
#include "DriverMED.hxx" #include "DriverMED.hxx"
#include "DriverMED_W_SMESHDS_Mesh.h" #include "DriverMED_W_SMESHDS_Mesh.h"
#include "MED_Factory.hxx" #include "MED_Factory.hxx"
#include "MED_TFile.hxx"
#include "MED_Utilities.hxx" #include "MED_Utilities.hxx"
#include "MED_Wrapper.hxx" #include "MED_Wrapper.hxx"
#include "SMDS_IteratorOnIterators.hxx" #include "SMDS_IteratorOnIterators.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_SetIterator.hxx" #include "SMDS_SetIterator.hxx"
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "SMESH_TypeDefs.hxx"
//================================================================================ //================================================================================
/*! /*!
@ -98,10 +99,10 @@ bool DriverMED_W_Field::Set(SMESHDS_Mesh * mesh,
_nbElemsByGeom.resize( 1, std::make_pair( SMDSEntity_Last, 0 )); _nbElemsByGeom.resize( 1, std::make_pair( SMDSEntity_Last, 0 ));
// count nb of elems of each geometry // count nb of elems of each geometry
for ( int iG = 0; iG < SMDSEntity_Last; ++iG ) SMDSAbs_EntityType geom = SMDSEntity_0D;
for ( ; geom < SMDSEntity_Last; SMESHUtils::Increment( geom ))
{ {
SMDSAbs_EntityType geom = (SMDSAbs_EntityType) iG; SMDSAbs_ElementType t = SMDS_MeshCell::ElemType( geom );
SMDSAbs_ElementType t = SMDS_MeshCell::ElemType( geom );
if ( t != _elemType ) continue; if ( t != _elemType ) continue;
nbElems = mesh->GetMeshInfo().NbElements( geom ); nbElems = mesh->GetMeshInfo().NbElements( geom );

View File

@ -1000,9 +1000,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformInternal(LowLevelWriter myM
theIsElemNames); theIsElemNames);
TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType); TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType);
elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType ); elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType );
if ( aElemTypeData->_smdsType == SMDSAbs_0DElement && ! nodesOf0D.empty() ) if ( aElemTypeData->_smdsType == SMDSAbs_0DElement && ! nodesOf0D.empty() )
elemIterator = iterVecIter; elemIterator = iterVecIter;
while ( elemIterator->more() ) while ( elemIterator->more() )
{ {
const SMDS_MeshElement* anElem = elemIterator->next(); const SMDS_MeshElement* anElem = elemIterator->next();
@ -1029,6 +1031,15 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::PerformInternal(LowLevelWriter myM
if ( ++iElem == aCellInfo->GetNbElem() ) if ( ++iElem == aCellInfo->GetNbElem() )
break; break;
} }
// fix numbers of added SMDSAbs_0DElement
if ( aElemTypeData->_smdsType == SMDSAbs_0DElement && ! nodesOf0D.empty() )
{
iElem = myMesh->Nb0DElements();
TInt elem0DNum = FromSmIdType<TInt>( myMesh->MaxElementID() + 1 );
for ( size_t i = 0; i < nodesOf0D.size(); ++i )
aCellInfo->SetElemNum( iElem++, elem0DNum++);
}
// store data in a file // store data in a file
myMed->SetCellInfo(aCellInfo); myMed->SetCellInfo(aCellInfo);
} }