//! Get mesh with attached values for corresponding MED TIMESTAMP
virtual
VISU::PUnstructuredGridIDMapper
- GetTimeStampOnMesh(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theTimeStampNumber) = 0;
+ GetTimeStampOnMesh( const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber ) = 0;
//! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP
virtual
//---------------------------------------------------------------
vtkUnstructuredGrid*
VISU_Convertor_impl
-::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PMeshOnEntityImpl& theMeshOnEntity,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
- const VISU::PProfileImpl& theProfile,
- const VISU::TEntity& theEntity)
+::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PFieldImpl& theField,
+ const VISU::PValForTimeImpl& theValForTime,
+ const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::TEntity& theEntity )
{
- vtkUnstructuredGrid* anOutput = NULL;
-
- LoadMeshOnEntity(theMesh, theMeshOnEntity);
- GetMeshOnEntity(theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity);
- GetMeshOnProfile(theMesh, theMeshOnEntity, theProfile);
-
- bool isNeedInCells = false;
+ LoadMeshOnEntity( theMesh, theMeshOnEntity );
+ GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
+ GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
theUnstructuredGridIDMapper->myIDMapper = theProfile;
- if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){
+
+ if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
// add geometry elements to output,
// if timestamp on NODE_ENTITY and
// on profiles with status eAddPart
- VISU::TGeom2SubProfile::const_iterator anIter = theProfile->myGeom2SubProfile.begin();
- for(; anIter != (theProfile->myGeom2SubProfile).end(); anIter++){
- const VISU::EGeometry aGeom = anIter->first;
- const VISU::PSubProfileImpl aSubProfile = anIter->second;
- if(aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1){
- isNeedInCells = true;
- break;
+ const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
+ VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
+ for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
+ const VISU::EGeometry& aGeom = aSubProfileIter->first;
+ const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
+ if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
+ const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
+ for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
+ VISU::TEntity anEntity = aMeshOnEntityIter->first;
+ if ( anEntity == VISU::NODE_ENTITY )
+ continue;
+ VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
+ if( aNamedIDMapper ) {
+ theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
+ VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
+ VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
+
+ return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
+ }
+ }
}
}
- if(isNeedInCells){
- theUnstructuredGridIDMapper->myIsSpecialKey = true;
- GetTimeStampOnNodalProfile(theMesh,theUnstructuredGridIDMapper,theField,theValForTime,theEntity);
- anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
- }
- }
- if(!isNeedInCells){
- vtkUnstructuredGrid* anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
- const VISU::PUnstructuredGrid& aSource = theUnstructuredGridIDMapper->mySource.GetSource();
- //VISU::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity);
- VISU::GetElnoTimeStamp(aSource, theField, theValForTime, theEntity);
}
- return anOutput;
-}
-void
-VISU_Convertor_impl
-::GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity)
-{
- const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
- VISU::TMeshOnEntityMap::const_iterator aIter = aMeshOnEntityMap.begin();
- for(;aIter!=aMeshOnEntityMap.end();aIter++){
- VISU::TEntity aEntity = aIter->first;
- if(aEntity != VISU::NODE_ENTITY){
- VISU::PNamedIDMapper aMapper = GetMeshOnEntity(theMesh->myName,aEntity);
- if(aMapper)
- theIDMapperFilter->myMappers[aEntity] = aMapper;
- }
- }
+ VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
+ VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
- theIDMapperFilter->GetUnstructuredGridOutput();
- const VISU::PUnstructuredGrid& aSource = theIDMapperFilter->mySource.GetSource();
- VISU::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
+ return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
}
+
//---------------------------------------------------------------
VISU::PUnstructuredGridIDMapper
VISU_Convertor_impl
-::GetTimeStampOnMesh(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
+::GetTimeStampOnMesh( const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum )
{
INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
"; theMeshName = '"<<theMeshName<<"'"<<
aGaussPtsIDFilter->myIDMapper = aGaussMesh;
aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
- vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
- const VISU::PPolyData& aSource = aGaussPtsIDFilter->mySource.GetSource();
+ VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
+ vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
aGaussPtsIDFilter->myIsVTKDone = true;
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
- if(theEntity == VISU::NODE_ENTITY){
- if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
- aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
- else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end())
- aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
- else if(aMeshOnEntityMap.find(VISU::EDGE_ENTITY) != aMeshOnEntityMap.end())
- aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
- else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
- aVTKMeshOnEntity = aMeshOnEntityMap[VISU::NODE_ENTITY];
+ if ( theEntity == VISU::NODE_ENTITY ) {
+ if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
+ aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
+ else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
+ aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
+ else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
+ aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
+ else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
+ aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
}else
aVTKMeshOnEntity = aMeshOnEntity;
VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
+ VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
if(aFieldIter == aFieldMap.end())
EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
VISU::PFieldImpl aField = aFieldIter->second;
- return TFindField(aMesh,
- aMeshOnEntity,
- aVTKMeshOnEntity,
- aField);
+ return TFindField( aMesh,
+ aMeshOnEntity,
+ aVTKMeshOnEntity,
+ aField );
}
//! Implemention of the VISU_Convertor::GetTimeStampOnMesh
virtual
VISU::PUnstructuredGridIDMapper
- GetTimeStampOnMesh(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theTimeStampNumber);
+ GetTimeStampOnMesh( const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber );
//! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
virtual
VISU::PMeshOnEntityImpl,
VISU::PFieldImpl> TFindField;
TFindField
- FindField(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName);
+ FindField( const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName );
//! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
typedef boost::tuple<VISU::PMeshImpl,
int theStampsNum);
vtkUnstructuredGrid*
- GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PMeshOnEntityImpl& theMeshOnEntity,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
- const VISU::PProfileImpl& theProfile,
- const VISU::TEntity& theEntity);
-
- void
- GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity);
-
+ GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PFieldImpl& theField,
+ const VISU::PValForTimeImpl& theValForTime,
+ const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::TEntity& theEntity );
+
protected:
//! Implemention of the VISU_Convertor::GetTimeStampSize
virtual
//---------------------------------------------------------------
VISU::TEntity
- MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
+ MEDEntityToVTK( MED::EEntiteMaillage theMEDEntity )
{
+ VISU::TEntity anEntity = VISU::TEntity( -1 );
+
switch(theMEDEntity){
- case MED::eNOEUD: return VISU::NODE_ENTITY;
- case MED::eARETE: return VISU::EDGE_ENTITY;
- case MED::eFACE: return VISU::FACE_ENTITY;
- case MED::eNOEUD_ELEMENT:
- case MED::eMAILLE: return VISU::CELL_ENTITY;
+ case MED::eNOEUD :
+ anEntity = VISU::NODE_ENTITY;
+ break;
+ case MED::eARETE :
+ anEntity = VISU::EDGE_ENTITY;
+ break;
+ case MED::eFACE :
+ anEntity = VISU::FACE_ENTITY;
+ break;
+ case MED::eMAILLE :
+ anEntity = VISU::CELL_ENTITY;
+ break;
+ case MED::eNOEUD_ELEMENT :
+ anEntity = VISU::CELL_ENTITY;
+ break;
}
- return VISU::TEntity(-1);
+
+ return anEntity;
}
if(aNbTimeStamps < 1)
continue;
- VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::TEntity aVEntity = MEDEntityToVTK( aMEntity );
vtkIdType aDataType = VTK_DOUBLE;
- if(aFieldInfo->GetType() != MED::eFLOAT64){
+ if ( aFieldInfo->GetType() != MED::eFLOAT64 ) {
#if defined(HAVE_F77INT64)
aDataType = VTK_LONG;
#else
aField->myName = aFieldName;
aField->myMeshName = aMeshName;
aField->myDataSize = aMeshOnEntity->myNbCells * aNbComp;
+ aField->myIsELNO = true; // To set it true by default
INITMSG(MYDEBUG,"myName = '"<<aField->myName<<"'"<<
"; myId = "<<aField->myId<<
MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
for(; anIter != aMGeom2NbGauss.end(); anIter++){
const MED::EGeometrieElement& aMGeom = anIter->first;
- VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ VISU::EGeometry aEGeom = MEDGeom2VISU( aMGeom );
TInt aNbGauss = anIter->second;
- aVGeom2NbGauss[aEGeom] = aNbGauss;
+ aVGeom2NbGauss[ aEGeom ] = aNbGauss;
+
+ // ELNO data should satisfy the following condition ( implcitly )
+ vtkIdType aNbNodes = MEDGeom2NbNodes( aMGeom );
+ aField->myIsELNO &= ( aNbGauss == aNbNodes );
}
}
+
+ // ELNO data should satisfy the following condition ( explicitly )
+ aField->myIsELNO |= ( aMEntity == MED::eNOEUD_ELEMENT );
}
}
};
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TTimeStampOnElnoInitArray
+ {
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+ PDataArrayHolder myDataArrayHolder;
+ vtkIntArray *myComponentMapper;
+ vtkIdType myComponentStep;
+
+ TTimeStampOnElnoInitArray( const PDataArrayHolder& theDataArrayHolder,
+ vtkIntArray* theComponentMapper,
+ vtkIdType theComponentStep )
+ : myDataArrayHolder(theDataArrayHolder)
+ , myComponentMapper( theComponentMapper )
+ , myComponentStep( theComponentStep )
+ {}
+
+ void
+ Execute( const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime )
+ {
+ TVector<TVTKBasicType> aDataValues( myComponentStep );
+
+ vtkIdType aNextStartId = 0;
+ vtkIdType aNbComp = theField->myNbComp;
+ int aTuples[3] = { aNextStartId, aNbComp, -1 };
+
+ vtkIdType aComponentCount = 0, aTupleId = 0, aComponentTupleId = 0;
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
+ for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) {
+ EGeometry aEGeom = anIter->first;
+ const TMeshValuePtr aMeshValue = anIter->second;
+
+ vtkIdType aNbElem = aMeshValue->GetNbElem();
+ vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+ aTuples[ 2 ] = aNbGauss;
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ std::endl);
+
+ for ( vtkIdType iElem = 0; iElem < aNbElem; iElem++ ) {
+ const typename TMeshValue::TValueSliceArr& aValueSliceArr = aMeshValue->GetGaussValueSliceArr( iElem );
+
+ for( vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++ ) {
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[ iGauss ];
+
+ for( vtkIdType iComp = 0; iComp < aNbComp; iComp++ ) {
+ aDataValues[ aComponentCount ] = aValueSlice[ iComp ];
+ aComponentCount++;
+
+ if ( aComponentCount == myComponentStep ) {
+ this->myDataArrayHolder->SetTuple( aTupleId, &aDataValues[0] );
+ aComponentCount = 0;
+ aTupleId++;
+ }
+ }
+ }
+
+ aTuples[ 0 ] = aNextStartId;
+ aNextStartId = aTuples[ 0 ] + aNbGauss * aNbComp;
+
+ this->myComponentMapper->InsertTupleValue( aComponentTupleId, aTuples );
+ aComponentTupleId++;
+ }
+
+ if ( aComponentCount > 0 )
+ this->myDataArrayHolder->SetTuple( aTupleId, &aDataValues[0] );
+ }
+ }
+ };
+
+
//----------------------------------------------------------------------------
template<int EDataType>
void
aSelectedDataArray->SetName(aFieldName.c_str());
TVTKDataArray *aFullDataArray = TVTKDataArray::New();
- aFullDataArray->SetNumberOfComponents(aNbComp);
- aFullDataArray->SetNumberOfTuples(aNbTuples);
- aFullDataArray->SetName("VISU_FIELD");
- aDataSetAttributes->AddArray(aFullDataArray);
+ aFullDataArray->SetNumberOfComponents( aNbComp );
+ aFullDataArray->SetNumberOfTuples( aNbTuples );
+ aFullDataArray->SetName( "VISU_FIELD" );
+ aDataSetAttributes->AddArray( aFullDataArray );
INITMSG(MYDEBUG,"InitTimeStampOnProfile "<<
"- theEntity = "<<theEntity<<
"; aNbTuples = "<<aNbTuples<<
"; aNbComp = "<<aNbComp<<
std::endl);
+
TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnProfile");
const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
- typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
- typedef TTMeshValue<TVTKBasicType> TMeshValue;
- typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+ typedef typename TL::TEnum2VTKBasicType< EDataType >::TResult TVTKBasicType;
+ typedef TTMeshValue< TVTKBasicType > TMeshValue;
+ typedef MED::SharedPtr< TMeshValue > TMeshValuePtr;
- typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
- typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+ typedef TDataArrayHolder< EDataType > TTDataArrayHolder;
+ typedef MED::SharedPtr< TTDataArrayHolder > PDataArrayHolder;
TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
- if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){
+ if ( aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1 ) {
aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
aMeshValue->size(),
true);
INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<<std::endl);
- if(aNbComp == 1){
+ if ( aNbComp == 1 ) {
aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
aMeshValue->size(),
true);
aSelectedDataArray->Delete();
aFullDataArray->Delete();
+
+ // Process the case for ELNO data
+ if ( theField->myIsELNO ) {
+ vtkIdType aEffectNbTuples = 0;
+ TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
+ for ( ; anIter != aGeom2MeshValue.end(); anIter++ ) {
+ const PMeshValue& aMeshValue = anIter->second;
+ aEffectNbTuples += aMeshValue->GetNbElem() * aMeshValue->GetNbGauss();
+ }
+ vtkIdType aEffectNbComp = ( aEffectNbTuples * aNbComp ) / aNbTuples + 1;
+
+ vtkIntArray *aComponentMapper = vtkIntArray::New();
+ aComponentMapper->SetNumberOfComponents( 3 );
+ aComponentMapper->SetNumberOfTuples( aNbTuples );
+ //{ [ aStartId , aNbComp, aNbRefPoints ], ..., ... , [ ... ] }
+ aComponentMapper->SetName( "ELNO_COMPONENT_MAPPER" );
+ aDataSetAttributes->AddArray( aComponentMapper );
+
+ TVTKDataArray *aFullDataArray = TVTKDataArray::New();
+ aFullDataArray->SetNumberOfComponents( aEffectNbComp );
+ aFullDataArray->SetNumberOfTuples( aNbTuples );
+ aFullDataArray->SetName( "ELNO_FIELD" );
+ aDataSetAttributes->AddArray( aFullDataArray );
+
+ typedef TDataArrayHolder< EDataType > TTDataArrayHolder;
+ PDataArrayHolder aDataArrayHolder( new TTDataArrayHolder( aFullDataArray ) );
+ TTimeStampOnElnoInitArray< EDataType >( aDataArrayHolder, aComponentMapper, aEffectNbComp ).Execute(theField, theValForTime);
+
+ aComponentMapper->Delete();
+ aFullDataArray->Delete();
+ }
}
}
- //---------------------------------------------------------------
- template<int EDataType>
- void
- InitElnoTimeStamp(const PUnstructuredGrid& theSource,
- const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity);
-
-
//----------------------------------------------------------------------------
- void
- GetElnoTimeStamp(const PUnstructuredGrid& theSource,
- const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity)
- {
- vtkIdType aDataType = theField->GetDataType();
- switch(aDataType){
- case VTK_DOUBLE:
- InitElnoTimeStamp<VTK_DOUBLE>(theSource, theField, theValForTime, theEntity);
- break;
- case VTK_FLOAT:
- InitElnoTimeStamp<VTK_FLOAT>(theSource, theField, theValForTime, theEntity);
- break;
- case VTK_INT:
- InitElnoTimeStamp<VTK_INT>(theSource, theField, theValForTime, theEntity);
- break;
- case VTK_LONG:
- InitElnoTimeStamp<VTK_LONG>(theSource, theField, theValForTime, theEntity);
- break;
- default:
- EXCEPTION(std::runtime_error,
- "GetElnoTimeStamp - handling unsupported data type - "<<aDataType);
- }
- }
-
- //----------------------------------------------------------------------------
- template<int EDataType>
- struct TTimeStampOnElnoInitArray
- {
- typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
- typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
- typedef TTMeshValue<TVTKBasicType> TMeshValue;
- typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
-
- typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
- typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
- PDataArrayHolder myDataArrayHolder;
- vtkIntArray *myComponentMapper;
- vtkIdType myComponentStep;
-
- TTimeStampOnElnoInitArray(const PDataArrayHolder& theDataArrayHolder, vtkIntArray * aComponentMapper=0):
- myDataArrayHolder(theDataArrayHolder),
- myComponentStep(0),
- myComponentMapper(aComponentMapper)
- {}
-
- void SetComponentStep(vtkIdType& theStep){
- myComponentStep = theStep;
- }
-
- void
- Execute(const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime)
- {
- vtkIdType aNbComp = theField->myNbComp;
- TVector<TVTKBasicType> aDataValues(myComponentStep+1);
-
- vtkIdType componentCount=0,aTupleId=0,aNextStartId=0,aComponentTupleId=0;
- int theTuple[3] = {aNextStartId,
- theField->myNbComp,
- 0};
-
- const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
- TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
- for(; anIter != aGeom2MeshValue.end(); anIter++){
- EGeometry aEGeom = anIter->first;
- const TMeshValuePtr aMeshValue = anIter->second;
-
- vtkIdType aNbElem = aMeshValue->GetNbElem();
- vtkIdType aNbGauss = aMeshValue->GetNbGauss();
-
- INITMSG(MYDEBUG,
- "- aEGeom = "<<aEGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- std::endl);
- theTuple[2] = aNbGauss;
- for(vtkIdType iElem = 0; iElem < aNbElem; iElem++) {
- const typename TMeshValue::TValueSliceArr& aValueSliceArr = aMeshValue->GetGaussValueSliceArr(iElem);
-
- for( vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++ ) {
- const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
-
- for( vtkIdType iComp = 0; iComp < aNbComp; iComp++ ) {
- aDataValues[componentCount] = aValueSlice[iComp];
- componentCount++;
-
- if(componentCount == myComponentStep ) {
- this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
- componentCount=0;
- aTupleId++;
- }
- }
- }
- theTuple[0]=aNextStartId;
- if(this->myComponentMapper) {
- this->myComponentMapper->InsertTupleValue(aComponentTupleId,theTuple);
- aComponentTupleId++;
- }
- aNextStartId=theTuple[1]*theTuple[2]+theTuple[0];
- }
- if(componentCount > 0)
- this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
- }
- }
- };
-
- //----------------------------------------------------------------------------
- template<int EDataType>
- void
- InitElnoTimeStamp(const PUnstructuredGrid& theSource,
- const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity)
- {
- vtkIdType aNbTuples = theField->myDataSize / theField->myNbComp;
- std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime);
-
- vtkDataSetAttributes* aDataSetAttributes = theSource->GetCellData();
-
-
- typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
- TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
- vtkIdType aNbComp = theField->myNbComp;
-
- //Calculate Effective Nb of Tuples
- const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
- TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
- vtkIdType aEffectNbTuples = 0;
- for(;anIter != aGeom2MeshValue.end(); anIter++){
- aEffectNbTuples += anIter->second->GetNbElem()*anIter->second->GetNbGauss();
- }
-
- //Calculate Effective Nb of Components
- vtkIdType aEffectNbComp = (aEffectNbTuples*aNbComp)/aNbTuples+1;
-
- aSelectedDataArray->SetNumberOfComponents(aEffectNbComp);
- aDataSetAttributes->SetVectors(aSelectedDataArray);
-
- aSelectedDataArray->SetNumberOfTuples(aNbTuples);
- aSelectedDataArray->SetName(aFieldName.c_str());
-
- //Add in the data set attributes array to restore
- //real Nb of Components
- vtkIntArray *aComponentMapper = vtkIntArray::New();
- aComponentMapper->SetNumberOfTuples(aNbTuples);
- //Set 3 components:
- //{[startId , realNbComponents, nbData], ..., ... ,[...]}
- aComponentMapper->SetNumberOfComponents(3);
- aComponentMapper->SetName("ELNO_COMPONENT_MAPPER");
- aDataSetAttributes->AddArray(aComponentMapper);
-
- TVTKDataArray *aFullDataArray = TVTKDataArray::New();
- aFullDataArray->SetNumberOfComponents(aEffectNbComp);
- aFullDataArray->SetNumberOfTuples(aNbTuples);
- aFullDataArray->SetName("ELNO_FIELD");
-
- aDataSetAttributes->AddArray(aFullDataArray);
-
- INITMSG(MYDEBUG,"InitElnoTimeStamp "<<
- "- theEntity = "<<theEntity<<
- "; aNbTuples = "<<aNbTuples<<
- "; aNbComp = "<<aNbComp<<
- std::endl);
- TTimerLog aTimerLog(MYDEBUG,"InitElnoTimeStamp");
-
- typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
- typedef TTMeshValue<TVTKBasicType> TMeshValue;
- typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
-
- typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
- typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
-
- TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
-
- typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
- PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
- TTimeStampOnElnoInitArray<EDataType> aArrayInitializer(aDataArrayHolder,aComponentMapper);
- aArrayInitializer.SetComponentStep(aEffectNbComp);
- aArrayInitializer.Execute(theField, theValForTime);
-
-
- aSelectedDataArray->Delete();
- aFullDataArray->Delete();
- }
-
}
//---------------------------------------------------------------
- // Initilize corresponding vtkDataSetAttributes for TValForTime
- void
- GetElnoTimeStamp(const PUnstructuredGrid& theSource,
- const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity);
-
}
#endif
std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
-
- // MULTIPR
std::string myPartsEntry; //!< To simplify publication of the parts in a data tree
TMesh();
typedef std::map<std::string, PMesh> TMeshMap;
- typedef std::map<VISU::TEntity,VISU::PNamedIDMapper> PNamedIDMapperMap;
-
//---------------------------------------------------------------
//! Define a basic class which corresponds to MED PROFILE entity
struct VISU_CONVERTOR_EXPORT TSubProfile: virtual TBaseStructure
//---------------------------------------------------------------
TUnstructuredGridIDMapperImpl
- ::TUnstructuredGridIDMapperImpl():
- myIsSpecialKey(false)
+ ::TUnstructuredGridIDMapperImpl()
{
- if(!myCommonCellsFilter.GetPointer()){
+ if ( !myCommonCellsFilter.GetPointer() ) {
myCommonCellsFilter = VISU_CommonCellsFilter::New();
myCommonCellsFilter->Delete();
}
return myIDMapper->GetElemCell(theObjID);
}
- vtkUnstructuredGrid*
+ void
TUnstructuredGridIDMapperImpl
- ::GetUnstructuredGridOutput()
+ ::SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper )
{
- if(!myFilter.GetPointer()){
-
+ myCommonCellsFilter->SetCellsUG( theNamedIDMapper->GetUnstructuredGridOutput() );
+ }
+
+ void
+ TUnstructuredGridIDMapperImpl
+ ::Build()
+ {
+ if ( !myFilter.GetPointer() ) {
const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
- vtkUnstructuredGrid* aGeometry;
+ vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
const PUnstructuredGrid& aSource = mySource.GetSource();
- vtkUnstructuredGrid* aDataSet;
-
- if(myIsSpecialKey){
- PNamedIDMapperMap::iterator aIter;
- aIter = myMappers.find(VISU::CELL_ENTITY);
- if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
- else {
- aIter = myMappers.find(VISU::FACE_ENTITY);
- if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
- else {
- aIter = myMappers.find(VISU::EDGE_ENTITY);
- if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
- }
- }
- }
-
- aGeometry = anAppendFilter->GetOutput();
- aDataSet = aSource.GetPointer();
- aDataSet->ShallowCopy(aGeometry);
+ vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
+ aDataSet->ShallowCopy( aGeometry );
const PMergeFilter& aFilter = GetFilter();
- aFilter->SetGeometry(aGeometry);
- aFilter->SetScalars(aDataSet);
- aFilter->SetVectors(aDataSet);
- aFilter->AddField("VISU_FIELD",aDataSet);
- aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
- aFilter->AddField("ELNO_FIELD",aDataSet);
- aFilter->AddField("ELNO_COMPONENT_MAPPER",aDataSet);
- aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
+ aFilter->SetGeometry( aGeometry );
+ aFilter->SetScalars( aDataSet );
+ aFilter->SetVectors( aDataSet );
+ aFilter->AddField( "VISU_FIELD", aDataSet );
+ aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
+ aFilter->AddField( "ELNO_FIELD", aDataSet );
+ aFilter->AddField( "ELNO_COMPONENT_MAPPER", aDataSet );
+ aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
- myCommonCellsFilter->SetProfileUG(aFilter->GetUnstructuredGridOutput());
+ myCommonCellsFilter->SetProfileUG( aFilter->GetUnstructuredGridOutput() );
}
+ }
+
+ vtkUnstructuredGrid*
+ TUnstructuredGridIDMapperImpl
+ ::GetUnstructuredGridOutput()
+ {
+ Build();
return myCommonCellsFilter->GetOutput();
}
return GetUnstructuredGridOutput();
}
+ PUnstructuredGrid
+ TUnstructuredGridIDMapperImpl
+ ::GetSource()
+ {
+ Build();
+ return mySource.GetSource();
+ }
+
unsigned long int
TUnstructuredGridIDMapperImpl
::GetMemorySize()
{
size_t aSize = myIDMapper->GetMemorySize();
+
aSize += mySource.GetMemorySize();
- if(vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput())
+
+ if ( vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput() )
aSize += anOutput->GetActualMemorySize() * 1024;
- PNamedIDMapperMap::const_iterator aIter = myMappers.begin();
- for(;aIter!=myMappers.end();aIter++)
- aSize += (aIter->second)->GetMemorySize();
+
return aSize;
}
return myIDMapper->GetElemCell(theObjID);
}
- vtkPolyData*
+ void
TPolyDataIDMapperImpl
- ::GetPolyDataOutput()
+ ::Build()
{
- if(!myFilter.GetPointer()){
+ if ( !myFilter.GetPointer() ) {
const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter();
vtkPolyData* aGeometry = anAppendFilter->GetOutput();
const PPolyData& aSource = mySource.GetSource();
vtkPolyData* aDataSet = aSource.GetPointer();
- aDataSet->ShallowCopy(aGeometry);
+ aDataSet->ShallowCopy( aGeometry );
const PMergeFilter& aFilter = GetFilter();
- aFilter->SetGeometry(aGeometry);
- aFilter->SetScalars(aDataSet);
- aFilter->SetVectors(aDataSet);
- aFilter->AddField("VISU_FIELD",aDataSet);
- aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
- aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
+ aFilter->SetGeometry( aGeometry );
+ aFilter->SetScalars( aDataSet );
+ aFilter->SetVectors( aDataSet );
+ aFilter->AddField( "VISU_FIELD", aDataSet );
+ aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
+ aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
}
+ }
+
+ vtkPolyData*
+ TPolyDataIDMapperImpl
+ ::GetPolyDataOutput()
+ {
+ Build();
return myFilter->GetPolyDataOutput();
}
return GetPolyDataOutput();
}
+ PPolyData
+ TPolyDataIDMapperImpl
+ ::GetSource()
+ {
+ Build();
+ return mySource.GetSource();
+ }
+
unsigned long int
TPolyDataIDMapperImpl
::GetMemorySize()
return aResult;
size_t aSubMeshEnd = myGaussSubMeshArr.size();
- const PAppendFilter& anAppendFilter = GetFilter();
const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) {
const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId];
//---------------------------------------------------------------
TFieldImpl
- ::TFieldImpl():
- myDataSize(0),
- myDataType(0)
+ ::TFieldImpl()
+ : myDataSize( 0 )
+ , myDataType( 0 )
+ , myIsELNO( false )
{}
void
virtual
unsigned long int
GetMemorySize();
-
- //! if false, TIDCommonCellsFilter - same as TIDMapperFilter
- //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter
- bool myIsSpecialKey;
-
- //! Vector of id mappers, which consist of meshonentity in next sequence:
- //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
- PNamedIDMapperMap myMappers;
};
//---------------------------------------------------------------
struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
virtual TUnstructuredGridIDMapper
{
- PAppendFilterHolder myIDMapper; //!< Responsible for numbering
- PCommonCellsFilter myCommonCellsFilter;
- TUnstructuredGridHolder mySource; //!< Keeps assigned data
+ PAppendFilterHolder myIDMapper; //!< Responsible for numbering
+ PCommonCellsFilter myCommonCellsFilter;
TUnstructuredGridIDMapperImpl();
unsigned long int
GetMemorySize();
- //! if false, Not using CommonCellsFilter
- //! if true, Using CommonCellsFilter
- bool myIsSpecialKey;
+ void
+ SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper );
+
+ PUnstructuredGrid
+ GetSource();
+
+ protected:
+ void Build();
- //! Vector of id mappers, which consist of meshonentity in next sequence:
- //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
- PNamedIDMapperMap myMappers;
+ TUnstructuredGridHolder mySource; //!< Keeps assigned data
};
//---------------------------------------------------------------
virtual TPolyDataIDMapper
{
PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
- TPolyDataHolder mySource; //!< Keeps assigned data
//! Reimplement the TIDMapper::GetNodeObjID
virtual
virtual
unsigned long int
GetMemorySize();
+
+ PPolyData
+ GetSource();
+
+ protected:
+ void Build();
+
+ TPolyDataHolder mySource; //!< Keeps assigned data
};
vtkIdType myDataSize; //!< Keeps size of the assigned data
vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
+ bool myIsELNO; //!< Defines whether this field contains specific "ELNO" data or not
};