]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkImagePlanes.h
#3194 BBTK Feature New Normal - Update surfaceTexture box with new lookuptables
[bbtk.git] / packages / vtk / src / bbvtkImagePlanes.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbvtkImagePlanes.h,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:51:58 $
33   Version:   $Revision: 1.25 $
34 =========================================================================*/
35
36 /**
37  * \brief Short description in one line
38  * 
39  * Long description which 
40  * can span multiple lines
41  */
42 /**
43  * \file 
44  * \brief Pattern for the definition of a new type of Node (header)
45  */
46 /**
47  * \class bbtk::NodePatern 
48  * \brief Pattern for the definition of a new type of Node 
49  */
50 #ifdef _USE_VTK_
51
52
53 #ifndef __bbvtkImagePlanes_h_INCLUDED__
54 #define __bbvtkImagePlanes_h_INCLUDED__
55
56 #include "bbtkAtomicBlackBox.h"
57
58 class vtkImageData;
59 class vtkImagePlaneWidget;
60
61 #include "vtkPlaneWidget.h"
62 #include "vtkRenderWindowInteractor.h"
63 #include "vtkImageReslice.h"
64 #include <vtkTransform.h>
65
66 namespace bbvtk
67 {
68   typedef std::vector<double> winLevel;
69   
70   class /*BBTK_EXPORT*/ ImagePlanes : public bbtk::AtomicBlackBox
71   { 
72   public:
73     BBTK_BLACK_BOX_INTERFACE(ImagePlanes,bbtk::AtomicBlackBox);
74     //    BBTK_DECLARE_INPUT(Contour, int);
75     BBTK_DECLARE_INPUT(In,             vtkImageData*);
76     BBTK_DECLARE_INPUT(WindowLevel,    winLevel);
77     BBTK_DECLARE_INPUT(PointsX,        std::vector<int>);
78     BBTK_DECLARE_INPUT(PointsY,        std::vector<int>);
79     BBTK_DECLARE_INPUT(PointsZ,        std::vector<int>);
80     BBTK_DECLARE_INPUT(Interactor,         vtkRenderWindowInteractor*);
81         BBTK_DECLARE_INPUT(Interpolation,  int);
82
83     BBTK_DECLARE_OUTPUT(PlaneX,                 vtkImagePlaneWidget*);
84     BBTK_DECLARE_OUTPUT(PlaneY,                 vtkImagePlaneWidget*);
85     BBTK_DECLARE_OUTPUT(PlaneZ,                 vtkImagePlaneWidget*);
86     BBTK_DECLARE_OUTPUT(Plane3Pts,              vtkInteractorObserver*);
87     BBTK_DECLARE_OUTPUT(ImageX,                 vtkImageData*);
88     BBTK_DECLARE_OUTPUT(ImageY,                 vtkImageData*);        
89     BBTK_DECLARE_OUTPUT(ImageZ,                 vtkImageData*);  
90     BBTK_DECLARE_OUTPUT(Image3Pts,              vtkImageData*);         
91     BBTK_DECLARE_OUTPUT(Transform3Pts, vtkLinearTransform*);
92
93     BBTK_PROCESS(Process);
94     void Process();
95     
96           
97         vtkTransform *_imageTransform;
98
99           
100   protected:
101
102   private:
103     class VtkCallbackType;
104     VtkCallbackType     *mVtkCallback;
105     vtkImageData        *image;
106     vtkImageReslice     *_imageReslicer;
107
108     vtkTransform        *_transform;
109     vtkMatrix4x4        *_matrix;
110
111     double      *getCrossProduct(double* vect0,double* vect1);
112     double      getPodoubleProduct(double* vect0,double* vect1);
113     double      *getNormal(double* vect);
114     double      getMagnitud(double* vect);
115     double      *makeVector(double podouble0[3], double podouble1[3]);
116     void        updateInteractor();
117
118     vtkImagePlaneWidget* GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker);
119   };
120    
121   //=================================================================
122   // UserBlackBox description
123   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImagePlanes,bbtk::AtomicBlackBox);
124   BBTK_NAME("ImagePlanes");
125   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
126   BBTK_DESCRIPTION("Creates three 3D planes with the input image mapped onto which the user can interact with. The output vtkImagePlaneWidget objects are to be inserted into a 3D scene (e.g. a Viewer3D)");
127   BBTK_CATEGORY("3D object creator");
128   
129   BBTK_INPUT(ImagePlanes, In,          "Input Image",  vtkImageData *,   "");
130   BBTK_INPUT(ImagePlanes, WindowLevel, "Widdow Level", winLevel,         "");
131   BBTK_INPUT(ImagePlanes, PointsX,     "Points in X",  std::vector<int>, "");
132   BBTK_INPUT(ImagePlanes, PointsY,     "Points in Y",  std::vector<int>, "");
133   BBTK_INPUT(ImagePlanes, PointsZ,     "Points in Z",  std::vector<int>, "");
134   BBTK_INPUT(ImagePlanes, Interactor,  "Interactor for the planes",  vtkRenderWindowInteractor*, "");
135   BBTK_INPUT(ImagePlanes, Interpolation,  "Interpolation (default 1)  0=NEAREST_RESLICE  1=LINEAR_RESLICE  2=CUBIC_RESLICE",  int, "");
136
137         
138   BBTK_OUTPUT(ImagePlanes,PlaneX,    "The image plane in X direction",         vtkImagePlaneWidget*,   "");
139   BBTK_OUTPUT(ImagePlanes,PlaneY,    "The image plane in Y direction",         vtkImagePlaneWidget*,   "");
140   BBTK_OUTPUT(ImagePlanes,PlaneZ,    "The image plane in Z direction",         vtkImagePlaneWidget*,   "");
141   BBTK_OUTPUT(ImagePlanes,Plane3Pts, "The image plane (3 points definition) ", vtkInteractorObserver*, "");
142   BBTK_OUTPUT(ImagePlanes,ImageX,    "The image in X direction",               vtkImageData*,          "");
143   BBTK_OUTPUT(ImagePlanes,ImageY,    "The image in Y direction",               vtkImageData*,          "");
144   BBTK_OUTPUT(ImagePlanes,ImageZ,    "The image in Z direction",               vtkImageData*,          "");    
145   BBTK_OUTPUT(ImagePlanes,Image3Pts, "The image (3 points plane definition)",  vtkImageData*,          "");    
146   BBTK_OUTPUT(ImagePlanes,Transform3Pts, "The Tranform of the image",          vtkLinearTransform*,    "");    
147      
148  
149   BBTK_END_DESCRIBE_BLACK_BOX(ImagePlanes);
150   //=================================================================
151
152
153 }//namespace bbvtk
154
155
156 /*
157 namespace bbvtk
158 {
159   typedef vtkImageData* vtkImageDataPointer;
160 }
161 */
162 typedef vtkImageData* vtkImageDataPointer;      
163
164 namespace bbtk
165 {
166   BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(vtkImageDataPointer, "vtkImageDataPointer");
167 }
168
169
170 #endif  //__bbtvtkImagePlanes_h__
171
172 #endif //_USE_VTK_
173