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 px, int py, int pz,int &minX, int &maxX, int &minY, int &maxY,
42 int &minZ, int &maxZ, int &size)
44 size = _brushsize - 1;
45 //EED 2020-04-28 BORRAME Change to local variables to use with openmp
55 if (_direction == 0) // YZ
60 if (_direction == 1) // XZ
65 if (_direction == 2) // XY
80 if (_direction == 0) // YZ
85 if (_direction == 1) // XZ
90 if (_direction == 2) // XY
97 if (_2D3D == 1) { } // 3D
99 if (minX < _minX) { minX = _minX; }
100 if (minY < _minY) { minY = _minY; }
101 if (minZ < _minZ) { minZ = _minZ; }
103 if (maxX >= _dimX) { maxX = _dimX-1; }
104 if (maxY >= _dimY) { maxY = _dimY-1; }
105 if (maxZ >= _dimZ) { maxZ = _dimZ-1; }
107 //EED 2020-04-28 BORRAME Change to local variables to use with openmp
108 // SetGeneralMinMax(minX, maxX, minY, maxY, minZ, maxZ);
111 //---------------------------------------------------------------------------
112 void BrushFilter::Run(int px, int py, int pz) // virtual
116 //EED 2020-04-28 BORRAME Change to local variables to use with openmp
117 // this->_IMManager->BaseInitialPoint(_px, _py ,_pz);
118 this->_IMManager->BaseInitialPoint(px, py ,pz);
120 float value = (float) _graylevel;
124 int minX, maxX, minY, maxY, minZ, maxZ;
125 FindMinMaxBrush(px,py,pz,minX, maxX, minY, maxY, minZ, maxZ, size);
127 double xx, yy, zz, rr = size * size;
128 float scalarComponent;
131 for (i = minX; i <= maxX; i++)
133 //EED 2020-04-28 BORRAME Change to local variables to use with openmp
137 for (j = minY; j <= maxY; j++)
139 //EED 2020-04-28 BORRAME Change to local variables to use with openmp
143 for (k = minZ; k <= maxZ; k++)
146 scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0);
147 if ((_RangeMin <= scalarComponent) && (scalarComponent <= _RangeMax ))
152 // this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
153 // _image->SetScalarComponentFromFloat(i, j, k, 0,value);
157 //EED 2020-04-28 BORRAME Change to local variables to use with openmp
161 if ((xx + yy + zz) <= rr) {
163 // this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
164 // _image->SetScalarComponentFromFloat(i, j, k, 0,value);
167 if (pixelModify==true)
169 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
172 _image2->SetScalarComponentFromFloat(i, j, k, 0,value);
174 _image->SetScalarComponentFromFloat(i, j, k, 0,value);
177 } // GetRangeMin && GetRangeMax
185 "ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
189 //---------------------------------------------------------------------------
190 void BrushFilter::SetBrushSize(int brushsize)
192 _brushsize = brushsize;
195 //---------------------------------------------------------------------------
196 void BrushFilter::SetBrushForm(int brushform)
198 _brushform = brushform;
201 //---------------------------------------------------------------------------
202 void BrushFilter::SetBrushTool(int brushtool)
204 _brushtool = brushtool;