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-box , 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 for (i = minX; i <= maxX; i++) {
118 for (j = minY; j <= maxY; j++) {
121 for (k = minZ; k <= maxZ; k++) {
122 // if ((i>=_minX) && (i<=_maxX) && (j>=_minY) && (j<=_maxY) && (k>=_minZ) && (k<=_maxZ))
125 float scalarComponent = _image->GetScalarComponentAsFloat(i,
127 if ((this->GetRangeMin() <= scalarComponent)
128 && (scalarComponent <= this->GetRangeMax())) {
131 if (_brushform == 0) {
132 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
133 _image->SetScalarComponentFromFloat(i, j, k, 0,
135 } else if (_brushform == 1) {
136 if ((xx + yy + zz) <= rr) {
137 this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
138 _image->SetScalarComponentFromFloat(i, j, k, 0,
142 } // GetRangeMin && GetRangeMax
144 // } //if _minX _maxX _minY _maxY _minZ _maxZ
152 "ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
156 //---------------------------------------------------------------------------
157 void BrushFilter::SetBrushSize(int brushsize) {
158 _brushsize = brushsize;
161 //---------------------------------------------------------------------------
162 void BrushFilter::SetBrushForm(int brushform) {
163 _brushform = brushform;
166 //---------------------------------------------------------------------------
167 void BrushFilter::SetBrushTool(int brushtool) {
168 _brushtool = brushtool;
171 //---------------------------------------------------------------------------
172 void BrushFilter::SetRangeMin(int min) {
176 //---------------------------------------------------------------------------
177 void BrushFilter::SetRangeMax(int max) {
181 //---------------------------------------------------------------------------
182 int BrushFilter::GetRangeMin() {
186 //---------------------------------------------------------------------------
187 int BrushFilter::GetRangeMax() {