-#include "bbPackRecalageTransparency.h"
-#include "bbPackRecalagePackage.h"
-
-#include "vtkCamera.h"
-#include "vtkImageActor.h"
-
-#include <vtkImageMapToColors.h>
-#include <vtkLookupTable.h>
-#include <vtkCommand.h>
-
-namespace bbPackRecalage
-{
-
- class MyTransparencyImage
- {
- public:
- MyTransparencyImage(Transparency* box);
- ~MyTransparencyImage();
-
- void UpdateView();
-
- private:
-
- //The box to use
- Transparency *mBox;
-
- //Upper image (we apply the lookup table with transparency to this actor)
- vtkImageActor *upperImageActor;
-
- //Base image (not to be modifyed)
- vtkImageActor *baseImageActor;
-
- bool mUpdateCamera;
-
- };
-
- /*
- * Constructor
- */
- MyTransparencyImage::MyTransparencyImage(Transparency* box)
- :
- mBox(box)
- {
- UpdateView();
- }
-
- /*
- * Destructor
- */
- MyTransparencyImage::~MyTransparencyImage()
- {
- //if(newImage != NULL)
- {
- //newImage->Delete();
- }
- }
-
- /*
- * Set image actors and apply lookup table
- */
- void MyTransparencyImage::UpdateView()
- {
- if( ( mBox->bbGetInputImage1() == NULL ) )
- {
- mUpdateCamera = true;
- }
- else if( (mBox->bbGetInputImage1() != NULL) && ( (mBox->bbGetInputStatus("Image1") != bbtk::UPTODATE) ) )
- {
- mUpdateCamera = true;
- }
- if(mUpdateCamera)
- {
- //Lookup Table
- vtkLookupTable *lookup = vtkLookupTable::New();
- lookup->SetAlphaRange(0, 1);
- lookup->SetRange(0, 255);
- lookup->SetValueRange(0.0, 255);
-
- //We assign a table of colors for the upper image, and set the white as transparent
- for(int i = 0; i < 256; i++)
- {
- if( i >= 0 && i <= 50 )
- {
- lookup->SetTableValue(i, 1.0, 0.0, 1.0, 1);
- }
- else if( i > 50 && i <= 100 )
- {
- lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
- }
- else if( i > 100 && i <= 150 )
- {
- lookup->SetTableValue(i, 0.0, 1.0, 0.0, 1);
- }
- else if( i > 150 && i <= 200 )
- {
- lookup->SetTableValue(i, 0.0, 0.0, 1.0, 1);
- }
- else if( i > 200 && i <= 250 )
- {
- lookup->SetTableValue(i, 0.0, 1.0, 1.0, 1);
- }
- else if( i > 250 && i <= 254)
- {
- lookup->SetTableValue(i, 1.0, 1.0, 0.0, 1);
- }
- }
- lookup->SetTableValue(255, 1.0, 1.0, 1.0, 0);
-
- lookup->SetSaturationRange(0.0, 0.0);
- lookup->SetRampToLinear( );
- lookup->Build( );
-
- vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
- mapperImage->SetLookupTable( lookup );
- mapperImage->SetInput( mBox->bbGetInputImage2() );
- mapperImage->SetOutputFormatToRGBA( );
-
- upperImageActor = vtkImageActor::New( );
- upperImageActor->SetInput( mapperImage->GetOutput() );
- upperImageActor->SetOpacity( 1 );
-
- baseImageActor = vtkImageActor::New( );
- baseImageActor->SetInput( mBox->bbGetInputImage1() );
-
- mBox->bbSetOutputActor1( (vtkProp3D*) baseImageActor );
- mBox->bbSetOutputActor2( (vtkProp3D*) upperImageActor );
-
- }
- }
-
-BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,Transparency)
-BBTK_BLACK_BOX_IMPLEMENTATION(Transparency,bbtk::AtomicBlackBox);
-void Transparency::Process()
-{
- MyTransparencyImage* trs = new MyTransparencyImage( this );
-}
-void Transparency::bbUserSetDefaultValues()
-{
- bbSetInputImage1(NULL);
- bbSetInputImage2(NULL);
- bbSetOutputActor1(NULL);
- bbSetOutputActor2(NULL);
-
-}
-void Transparency::bbUserInitializeProcessing()
-{
-
-// THE INITIALIZATION METHOD BODY :
-// Here does nothing
-// but this is where you should allocate the internal/output pointers
-// if any
-
-
-}
-void Transparency::bbUserFinalizeProcessing()
-{
-
-// THE FINALIZATION METHOD BODY :
-// Here does nothing
-// but this is where you should desallocate the internal/output pointers
-// if any
-
-}
-}
-// EO namespace bbPackRecalage
-
-