]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageBlender.h
...
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageBlender.h
1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEBLENDER__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGEBLENDER__H__
3
4 #include <cpExtensions/cpExtensions_Export.h>
5
6 #include <cmath>
7 #include <map>
8
9 #include <vtkThreadedImageAlgorithm.h>
10
11 namespace cpExtensions
12 {
13   namespace Visualization
14   {
15     /**
16      */
17     class cpExtensions_EXPORT ImageBlender
18       : public vtkThreadedImageAlgorithm
19     {
20     public:
21       typedef ImageBlender Self;
22       vtkTypeMacro( ImageBlender, vtkThreadedImageAlgorithm );
23
24       vtkGetMacro( MaxWindow, double );
25       vtkGetMacro( MaxLevel, double );
26       vtkGetMacro( MinWindow, double );
27       vtkGetMacro( MinLevel, double );
28       vtkGetMacro( Window, double );
29       vtkGetMacro( Level, double );
30
31       vtkSetMacro( MaxWindow, double );
32       vtkSetMacro( MaxLevel, double );
33       vtkSetMacro( MinWindow, double );
34       vtkSetMacro( MinLevel, double );
35       vtkSetMacro( Window, double );
36       vtkSetMacro( Level, double );
37
38     public:
39       static Self* New( );
40       void PrintSelf( std::ostream& os, vtkIndent indent );
41
42       unsigned int GetNumberOfImages( ) const;
43       void SetWindowLevel( const double& w, const double& l );
44
45       void GetColor(
46         const unsigned int& i,
47         double& r,
48         double& g,
49         double& b
50         ) const;
51       void SetColor(
52         const unsigned int& i,
53         const double& r,
54         const double& g,
55         const double& b
56         );
57
58     protected:
59       ImageBlender( );
60       virtual ~ImageBlender( );
61
62       int RequestInformation(
63         vtkInformation* request,
64         vtkInformationVector** inputVector,
65         vtkInformationVector* outputVector
66         );
67       void ThreadedRequestData(
68         vtkInformation* request,
69         vtkInformationVector** inputVector,
70         vtkInformationVector* outputVector,
71         vtkImageData*** inData,
72         vtkImageData** outData,
73         int outExt[ 6 ], int id
74         );
75       int FillInputPortInformation( int i, vtkInformation* info );
76
77       void _GenerateData(
78         vtkImageData** inDatas,
79         int numInputs,
80         vtkImageData* outData,
81         int outExt[ 6 ],
82         int id
83         );
84
85     private:
86       // Purposely not implemented.
87       ImageBlender( const Self& other );
88       void operator=( const Self& other );
89
90     protected:
91       struct TColor
92       {
93         double R, G, B, N;
94         TColor(
95           const double& r = double( 1 ),
96           const double& g = double( 0 ),
97           const double& b = double( 0 )
98           )
99           : R( r ),
100             G( g ),
101             B( b )
102           {
103             this->N = std::sqrt( ( r * r ) + ( g * g ) + ( b * b ) );
104           }
105       };
106       mutable std::map< unsigned int, TColor > Colors;
107
108       double MaxWindow;
109       double MaxLevel;
110       double MinWindow;
111       double MinLevel;
112       double Window;
113       double Level;
114
115       int    m_Extent[ 6 ];
116       double m_WLSlope;
117       double m_WLOffset;
118     };
119
120   } // ecapseman
121
122 } // ecapseman
123
124 #endif //  __CPEXTENSIONS__VISUALIZATION__IMAGEBLENDER__H__
125
126 // eof - $RCSfile$