1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #ifndef _BASE_FILTER_MANUAL_PAINT_H_
27 #define _BASE_FILTER_MANUAL_PAINT_H_
29 #include <vtkImageData.h>
31 //#include "regionStructUR.h"
33 #include "imageModificationManager.h"
36 #define GETVALUE_MANUALPAINT(VALUE,POINTER,SCALARTYPE) \
37 if (SCALARTYPE==VTK_DOUBLE) { VALUE=(double)*((double*)POINTER); } \
38 else if (SCALARTYPE==VTK_FLOAT) { VALUE=(double)*((float*)POINTER); } \
39 else if (SCALARTYPE==VTK_CHAR) { VALUE=(double)*((char*)POINTER); } \
40 else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { VALUE=(double)*((unsigned char*)POINTER); } \
41 else if (SCALARTYPE==VTK_INT) { VALUE=(double)*((int*)POINTER); } \
42 else if (SCALARTYPE==VTK_UNSIGNED_INT) { VALUE=(double)*((unsigned int*)POINTER); } \
43 else if (SCALARTYPE==VTK_LONG) { VALUE=(double)*((long*)POINTER); } \
44 else if (SCALARTYPE==VTK_UNSIGNED_LONG) { VALUE=(double)*((unsigned long*)POINTER); } \
45 else if (SCALARTYPE==VTK_SHORT) { VALUE=(double)*((short*)POINTER); } \
46 else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ VALUE=(double)*((unsigned short*)POINTER);} \
47 else { printf("EED GETVALUE_MANUALPAINT error\n"); }
49 #define GETVALUE2_MANUALPAINT(VALUE,POINTER,SCALARTYPE,INDEX) \
50 if (SCALARTYPE==VTK_DOUBLE) { VALUE=(double)((double*)POINTER)[INDEX]; } \
51 else if (SCALARTYPE==VTK_FLOAT) { VALUE=(double)((float*)POINTER)[INDEX]; } \
52 else if (SCALARTYPE==VTK_CHAR) { VALUE=(double)((char*)POINTER)[INDEX]; } \
53 else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { VALUE=(double)((unsigned char*)POINTER)[INDEX]; } \
54 else if (SCALARTYPE==VTK_INT) { VALUE=(double)((int*)POINTER)[INDEX]; } \
55 else if (SCALARTYPE==VTK_UNSIGNED_INT) { VALUE=(double)((unsigned int*)POINTER)[INDEX]; } \
56 else if (SCALARTYPE==VTK_LONG) { VALUE=(double)((long*)POINTER)[INDEX]; } \
57 else if (SCALARTYPE==VTK_UNSIGNED_LONG) { VALUE=(double)((unsigned long*)POINTER)[INDEX]; } \
58 else if (SCALARTYPE==VTK_SHORT) { VALUE=(double)((short*)POINTER)[INDEX]; } \
59 else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ VALUE=(double)((unsigned short*)POINTER)[INDEX]; } \
60 else { printf("EED GETVALUE2_MANUALPAINT error\n"); }
62 #define SETVALUE2_MANUALPAINT(VALUE,POINTER,SCALARTYPE,INDEX) \
63 if (SCALARTYPE==VTK_DOUBLE) { ((double*)POINTER)[INDEX] = (double)VALUE; } \
64 else if (SCALARTYPE==VTK_FLOAT) { ((float*)POINTER)[INDEX] = (float)VALUE; } \
65 else if (SCALARTYPE==VTK_CHAR) { ((char*)POINTER)[INDEX] = (char)VALUE; } \
66 else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { ((unsigned char*)POINTER)[INDEX] = (unsigned char)VALUE; } \
67 else if (SCALARTYPE==VTK_INT) { ((int*)POINTER)[INDEX] = (int)VALUE; } \
68 else if (SCALARTYPE==VTK_UNSIGNED_INT) { ((unsigned int*)POINTER)[INDEX] = (unsigned int)VALUE; } \
69 else if (SCALARTYPE==VTK_LONG) { ((long*)POINTER)[INDEX] = (long)VALUE; } \
70 else if (SCALARTYPE==VTK_UNSIGNED_LONG) { ((unsigned long*)POINTER)[INDEX] = (unsigned long)VALUE; } \
71 else if (SCALARTYPE==VTK_SHORT) { ((short*)POINTER)[INDEX] = (short)VALUE; } \
72 else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ ((unsigned short*)POINTER)[INDEX] = (unsigned short)VALUE;} \
73 else { printf("EED SETVALUE2_MANUALPAINT error\n"); }
76 #define DEFINEPOINTERIMAGE_MANUALPAINT(VALUE,SCALARSIZE,POINTERIMAGE,SCALARTYPE,IMAGE) \
78 int SCALARSIZE = IMAGE->GetScalarSize(); \
79 char *POINTERIMAGE = (char*)(IMAGE->GetScalarPointer()); \
80 int SCALARTYPE = IMAGE->GetScalarType();
85 class baseFilterManualPaint {
88 baseFilterManualPaint();
89 virtual ~baseFilterManualPaint();
91 virtual void SetImages(vtkImageData *image,vtkImageData *image2);
92 void SetPoint(int px, int py, int pz);
93 void Set2D3D(int dim2D3D);
94 void SetGrayLevel(double graylevel);
95 void SetDirection(int direction);
96 void ResetGeneralMinMax();
97 void SetGeneralMinMax(int minX, int maxX, int minY, int maxY, int minZ, int maxZ);
98 void GetScalarRange(double * range);
100 void SetRangeMin( int min );//DFCH
101 void SetRangeMax( int max );//DFCH
102 int GetRangeMin( ); //DFCH
103 int GetRangeMax( ); //DFCH
105 ImageMManager* GetImageMManager(); //DFCH
106 void CleanImageMManager(); //DFCH
112 ImageMManager *_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
113 vtkImageData *_image;
114 vtkImageData *_image2;
116 int _px; // start point of the brush
119 int _pMinX; // General min max of many brush actions
125 int _minX; // min max of the image
142 #endif // _BASE_FILTER_MANUAL_PAINT_H_