- return( this->Superclass::FillInputPortInformation( i, info ) );
-}
-
-
-// -------------------------------------------------------------------------
-#define cpExtensions_ImageBlender_Type( O, V, T, B ) \
- O V = O( 0 ); \
- switch( T ) \
- { \
- case VTK_CHAR: \
- V = O( *( reinterpret_cast< char* >( B ) ) ); \
- break; \
- case VTK_SHORT: \
- V = O( *( reinterpret_cast< short* >( B ) ) ); \
- break; \
- case VTK_INT: \
- V = O( *( reinterpret_cast< int* >( B ) ) ); \
- break; \
- case VTK_LONG: \
- V = O( *( reinterpret_cast< long* >( B ) ) ); \
- break; \
- case VTK_UNSIGNED_CHAR: \
- V = O( *( reinterpret_cast< unsigned char* >( B ) ) ); \
- break; \
- case VTK_UNSIGNED_SHORT: \
- V = O( *( reinterpret_cast< unsigned short* >( B ) ) ); \
- break; \
- case VTK_UNSIGNED_INT: \
- V = O( *( reinterpret_cast< unsigned int* >( B ) ) ); \
- break; \
- case VTK_UNSIGNED_LONG: \
- V = O( *( reinterpret_cast< unsigned long* >( B ) ) ); \
- break; \
- case VTK_FLOAT: \
- V = O( *( reinterpret_cast< float* >( B ) ) ); \
- break; \
- case VTK_DOUBLE: \
- V = O( *( reinterpret_cast< double* >( B ) ) ); \
- break; \
- }
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageBlender::
-_GenerateData(
- vtkImageData** inDatas,
- int numInputs,
- vtkImageData* outData,
- int outExt[ 6 ],
- int id
- )
-{
- static const double _0 = double( 0 );
- static const double _1 = double( 1 );
- static const double _255 = double( 255 );
-
- unsigned char* mBuffer =
- reinterpret_cast< unsigned char* >( inDatas[ 0 ]->GetScalarPointer( ) );
- unsigned char* oBuffer =
- reinterpret_cast< unsigned char* >( outData->GetScalarPointer( ) );
- int mType = inDatas[ 0 ]->GetScalarType( );
- int mSize = inDatas[ 0 ]->GetScalarSize( );
-
- double r, g, b;
- int e13 = this->m_Extent[ 1 ] * this->m_Extent[ 3 ];
- for( int k = outExt[ 4 ]; k <= outExt[ 5 ]; ++k )
- {
- int dk = ( k - this->m_Extent[ 4 ] ) * e13;
- for( int j = outExt[ 2 ]; j <= outExt[ 3 ]; ++j )
- {
- int dj = ( ( j - this->m_Extent[ 2 ] ) * this->m_Extent[ 3 ] ) + dk;
- for( int i = outExt[ 0 ]; i <= outExt[ 1 ]; ++i )
- {
- int di = ( i - this->m_Extent[ 0 ] ) + dj;
-
- // Get main value
- cpExtensions_ImageBlender_Type(
- double, v, mType, mBuffer + ( di * mSize )
- );
- v *= this->m_WLSlope;
- v += this->m_WLOffset;
- if( v < _0 ) v = _0;
- if( v > _1 ) v = _1;
-
- // Prepare color
- r = g = b = v;
-
- // Blend colors
- for( int i = 1; i < numInputs; ++i )
- {
- unsigned char* cBuffer =
- reinterpret_cast< unsigned char* >(
- inDatas[ i ]->GetScalarPointer( )
- );
- int cType = inDatas[ i ]->GetScalarType( );
- int cSize = inDatas[ i ]->GetScalarSize( );
- cpExtensions_ImageBlender_Type(
- double, c, cType, cBuffer + ( di * cSize )
- );
- if( c > double( 0 ) )
- {
- TColor rgb = this->Colors[ i ];
- r *= rgb.R * rgb.N;
- g *= rgb.G * rgb.N;
- b *= rgb.B * rgb.N;
-
- } // fi
-
- } // rof
-
- // Update color
- int di3 = di * 3;
- oBuffer[ di3 + 0 ] = static_cast< unsigned char >( r * _255 );
- oBuffer[ di3 + 1 ] = static_cast< unsigned char >( g * _255 );
- oBuffer[ di3 + 2 ] = static_cast< unsigned char >( b * _255 );
-
- } // rof
-
- } // rof
-
- } // rof