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() {
30 _brushform = 0; // 0 rectangle-cube , 1 circle-sphere
31 _brushtool = 0; // 0 pencil , 1 fill
34 //---------------------------------------------------------------------------
35 BrushFilter::~BrushFilter() // virtual
39 //---------------------------------------------------------------------------
40 void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY,
41 int &minZ, int &maxZ, int &size) {
42 size = _brushsize - 1;
52 if (_direction == 0) // YZ
57 if (_direction == 1) // XZ
62 if (_direction == 2) // XY
98 SetGeneralMinMax(minX, maxX, minY, maxY, minZ, maxZ);
101 //---------------------------------------------------------------------------
102 void BrushFilter::Run() // virtual
106 float value = (float) _graylevel;
110 int minX, maxX, minY, maxY, minZ, maxZ;
111 FindMinMaxBrush(minX, maxX, minY, maxY, minZ, maxZ, size);
113 double xx, yy, zz, rr = size * size;
114 float scalarComponent;
117 for (i = minX; i <= maxX; i++)
121 for (j = minY; j <= maxY; j++)
125 for (k = minZ; k <= maxZ; k++)
128 scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0);
129 if ((_RangeMin <= scalarComponent)
130 && (scalarComponent <= _RangeMax ))
135 // this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
136 // _image->SetScalarComponentFromFloat(i, j, k, 0,value);
142 if ((xx + yy + zz) <= rr) {
144 // this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
145 // _image->SetScalarComponentFromFloat(i, j, k, 0,value);
148 if (pixelModify==true)
150 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
153 _image2->SetScalarComponentFromFloat(i, j, k, 0,value);
155 _image->SetScalarComponentFromFloat(i, j, k, 0,value);
158 } // GetRangeMin && GetRangeMax
166 "ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
170 //---------------------------------------------------------------------------
171 void BrushFilter::SetBrushSize(int brushsize)
173 _brushsize = brushsize;
176 //---------------------------------------------------------------------------
177 void BrushFilter::SetBrushForm(int brushform)
179 _brushform = brushform;
182 //---------------------------------------------------------------------------
183 void BrushFilter::SetBrushTool(int brushtool)
185 _brushtool = brushtool;