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 #include "BrushFilter.h"
28 BrushFilter::BrushFilter()
31 _brushform = 0; // 0 rectangle-cube , 1 circle-sphere
32 _brushtool = 0; // 0 pencil , 1 fill
35 //---------------------------------------------------------------------------
36 BrushFilter::~BrushFilter() // virtual
40 //---------------------------------------------------------------------------
41 void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY,
42 int &minZ, int &maxZ, int &size)
44 size = _brushsize - 1;
54 if (_direction == 0) // YZ
59 if (_direction == 1) // XZ
64 if (_direction == 2) // XY
100 SetGeneralMinMax(minX, maxX, minY, maxY, minZ, maxZ);
103 //---------------------------------------------------------------------------
104 void BrushFilter::Run() // virtual
108 float value = (float) _graylevel;
112 int minX, maxX, minY, maxY, minZ, maxZ;
113 FindMinMaxBrush(minX, maxX, minY, maxY, minZ, maxZ, size);
115 double xx, yy, zz, rr = size * size;
116 float scalarComponent;
119 for (i = minX; i <= maxX; i++)
123 for (j = minY; j <= maxY; j++)
127 for (k = minZ; k <= maxZ; k++)
130 scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0);
131 if ((_RangeMin <= scalarComponent) && (scalarComponent <= _RangeMax ))
136 // this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
137 // _image->SetScalarComponentFromFloat(i, j, k, 0,value);
143 if ((xx + yy + zz) <= rr) {
145 // this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
146 // _image->SetScalarComponentFromFloat(i, j, k, 0,value);
149 if (pixelModify==true)
151 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
154 _image2->SetScalarComponentFromFloat(i, j, k, 0,value);
156 _image->SetScalarComponentFromFloat(i, j, k, 0,value);
159 } // GetRangeMin && GetRangeMax
167 "ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
171 //---------------------------------------------------------------------------
172 void BrushFilter::SetBrushSize(int brushsize)
174 _brushsize = brushsize;
177 //---------------------------------------------------------------------------
178 void BrushFilter::SetBrushForm(int brushform)
180 _brushform = brushform;
183 //---------------------------------------------------------------------------
184 void BrushFilter::SetBrushTool(int brushtool)
186 _brushtool = brushtool;