// Module : VISU
#include "VISU_MeshValue.hxx"
+#include "VISU_ElnoMeshValue.hxx"
#include "VISU_Structures_impl.hxx"
#include "VISU_ConvertorUtils.hxx"
};
- //----------------------------------------------------------------------------
- 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
aFullDataArray->Delete();
// Process the case for ELNO data
+ //-------------------------------
if ( theField->myIsELNO ) {
+ // To calculate effective number of components for the VTK compatibel ELNO data representation
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;
+
+ vtkIdType anEffectNbComp = ( 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 );
+ // To create corresponding VTK representation for the ELNO data
+ TSetElnoNodeData< EDataType > aSetElnoNodeData( anEffectNbComp,
+ aNbComp,
+ aNbTuples,
+ "ELNO_FIELD",
+ "ELNO_COMPONENT_MAPPER" );
+
+ std::vector< TVTKBasicType > aDataValues( aNbComp ); // To reserve a temproary value holder
+
+ // To initilize these VTK representation for the ELNO data from the MED
+ 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);
+
+ 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[ iComp ] = aValueSlice[ iComp ];
+ }
+
+ aSetElnoNodeData.AddNextPointData( &aDataValues[ 0 ] );
+ }
+
+ aSetElnoNodeData.InsertNextCellData();
+ }
+ }
- 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();
+ // Assign the ELNO data on the corresponding VTK data set attribute
+ aSetElnoNodeData.AddData( aDataSetAttributes );
}
+ //-------------------------------
}