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;
115 printf("EED BrushFilter::Run() %d %d\n", _RangeMin, _RangeMax);
117 for (i = minX; i <= maxX; i++) {
120 for (j = minY; j <= maxY; j++) {
123 for (k = minZ; k <= maxZ; k++) {
124 // if ((i>=_minX) && (i<=_maxX) && (j>=_minY) && (j<=_maxY) && (k>=_minZ) && (k<=_maxZ))
127 float scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0);
128 if ((_RangeMin <= scalarComponent)
129 && (scalarComponent <= _RangeMax )) {
132 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
133 _image->SetScalarComponentFromFloat(i, j, k, 0,value);
139 if ((xx + yy + zz) <= rr) {
140 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
141 _image->SetScalarComponentFromFloat(i, j, k, 0,value);
144 } // GetRangeMin && GetRangeMax
146 // } //if _minX _maxX _minY _maxY _minZ _maxZ
154 "ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
158 //---------------------------------------------------------------------------
159 void BrushFilter::SetBrushSize(int brushsize) {
160 _brushsize = brushsize;
163 //---------------------------------------------------------------------------
164 void BrushFilter::SetBrushForm(int brushform) {
165 _brushform = brushform;
168 //---------------------------------------------------------------------------
169 void BrushFilter::SetBrushTool(int brushtool) {
170 _brushtool = brushtool;
173 //---------------------------------------------------------------------------
174 void BrushFilter::SetRangeMin(int min) {
178 //---------------------------------------------------------------------------
179 void BrushFilter::SetRangeMax(int max) {
183 //---------------------------------------------------------------------------
184 int BrushFilter::GetRangeMin() {
188 //---------------------------------------------------------------------------
189 int BrushFilter::GetRangeMax() {