return( new Self( ) );
}
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::ImageBlender::
+GetNumberOfInputs( )
+{
+ unsigned int np = this->GetNumberOfInputPorts( );
+ unsigned int ni = 0;
+ for( unsigned int p = 0; p < np; ++p )
+ ni += this->GetNumberOfInputConnections( p );
+ return( ni );
+}
// -------------------------------------------------------------------------
cpExtensions::Visualization::ImageBlender::
return( 1 );
}
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::ImageBlender::
+RequestData(
+ vtkInformation* request,
+ vtkInformationVector** inputVector,
+ vtkInformationVector* outputVector
+ )
+{
+ this->m_Ranges.clear( );
+ for( int i = 0; i < this->GetNumberOfInputPorts( ); ++i )
+ {
+ vtkInformationVector* portInfo = inputVector[ i ];
+ for( int j = 0; j < portInfo->GetNumberOfInformationObjects( ); ++j )
+ {
+ vtkInformation* info = portInfo->GetInformationObject( j );
+ vtkImageData* image = vtkImageData::SafeDownCast(
+ info->Get( vtkDataObject::DATA_OBJECT( ) )
+ );
+ if( image != NULL )
+ {
+ double r[ 2 ];
+ image->GetScalarRange( r );
+ this->m_Ranges.push_back( r[ 0 ] );
+ this->m_Ranges.push_back( r[ 1 ] );
+ }
+ else
+ {
+ this->m_Ranges.push_back( double( 0 ) );
+ this->m_Ranges.push_back( double( 0 ) );
+
+ } // fi
+
+ } // rof
+
+ } // rof
+ return(
+ this->Superclass::RequestData( request, inputVector, outputVector )
+ );
+}
+
// -------------------------------------------------------------------------
// Description:
// This templated function executes the filter for any type of data.
template< class T >
void cpExtensions_Visualization_ImageBlender_Execute(
cpExtensions::Visualization::ImageBlender* self,
- vtkImageData** inDatas, int numInputs, vtkImageData* outData,
+ vtkImageData** inDatas, int numInputs,
+ const std::vector< double >& ranges, vtkImageData* outData,
int outExt[ 6 ], int id, T* really_not_used
)
{
// Pixel operation
while( outSI != outSIEnd )
{
-#error TENER EN CUENTA EL ORDEN DE LAS IMAGENES PARA PONER COLORES
-
- double vmax = double( *inSI[ 0 ] );
+ // Input 0 is ignored: it is just used to guarantee sizes all over
+ // the result
+ double vmax = double( 0 );
for( int k = 1; k < numInputs; ++k )
- vmax = ( vmax < double( *inSI[ k ] ) )? double( *inSI[ k ] ): vmax;
+ {
+ double v =
+ ( ( double( k ) * double( *inSI[ k ] ) ) - ranges[ k << 1 ] ) /
+ ( ranges[ ( k << 1 ) + 1 ] - ranges[ k << 1 ] );
+ vmax = ( vmax < v )? v: vmax;
+
+ } // rof
*outSI = static_cast< T >( vmax );
outSI++;
for( int l = 0; l < numInputs; ++l )
{
vtkTemplateMacro(
cpExtensions_Visualization_ImageBlender_Execute(
- this, inData[ 0 ], numInputs,
+ this, inData[ 0 ], numInputs, this->m_Ranges,
outData[ 0 ], outExt, id, static_cast< VTK_TT* >( 0 )
)
);