#include "FillFilter.h"
-FillFilter::FillFilter() {
- _tolerancefill = 50;
- _distancefill = 500;
+FillFilter::FillFilter()
+{
+ _tolerancefill = 50;
+ _distancefill = 500;
_limitRecursionFill = 50000;
- _auxImageFill = NULL;
+ _auxImageFill = NULL;
}
//---------------------------------------------------------------------------
-FillFilter::~FillFilter() {
+FillFilter::~FillFilter()
+{
if (_auxImageFill != NULL)
{
_auxImageFill->Delete();
}
//---------------------------------------------------------------------------
-void FillFilter::SetImage(vtkImageData *image) // virtual
- {
- baseFilterManualPaint::SetImage(image);
+void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual
+{
+ baseFilterManualPaint::SetImages(image,image2);
if (_auxImageFill != NULL)
{
_auxImageFill->Delete();
}
//---------------------------------------------------------------------------
-void FillFilter::FillToolRecursive(int px, int py, int pz) {
+void FillFilter::FillToolRecursive(int px, int py, int pz)
+{
_countRecursiveFill++;
_countProgressingFill++;
- if (_countProgressingFill > 200000) {
+ if (_countProgressingFill > 200000)
+ {
printf("R %ld \n", _countRecursiveFill);
_countProgressingFill = 0;
}
if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY)
- && (pz >= _minZ) && (pz <= _maxZ)) {
- if (_usingAuxImageFill == true) {
+ && (pz >= _minZ) && (pz <= _maxZ))
+ {
+ if (_usingAuxImageFill == true)
+ {
this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
_auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0);
}
_tmpDistfill = (px - _pxfill) * (px - _pxfill)
+ (py - _pyfill) * (py - _pyfill)
+ (pz - _pzfill) * (pz - _pzfill);
- _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0);
+ _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0);
+
+ if (_image2!=NULL)
+ {
+ _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0);
+ } else {
+ _tmpiglfill2 = _tmpiglfill;
+ }
float grayLBFMTOL = _graylevelbasefill - _tolerancefill;
float grayLBFPTOL = _graylevelbasefill + _tolerancefill;
isInRange = true;
} //fi esle
- if (isInRange) {
+ if (isInRange)
+ {
_auxGrayLevelValidationFill = (_tmpiglfill != _graylevel)
+ && (_tmpiglfill2 != _graylevel)
&& (_tmpiglfill >= grayLBFMTOL)
&& (_tmpiglfill <= grayLBFPTOL)
&& (_tmpDistfill <= _distbasefill); //DFCH
- } //fi
- else {
+ } else {
_auxGrayLevelValidationFill = false;
- } //esle
+ } // if isInRange
+
//DFCH
/*_auxGrayLevelValidationFill = (_tmpiglfill!=_graylevel) &&
(_tmpiglfill>=_graylevelbasefill-_tolerancefill) &&
(_tmpiglfill<=_graylevelbasefill+_tolerancefill) &&
(_tmpDistfill<=_distbasefill);*/ //DFCH
- if (_auxGrayLevelValidationFill == true) {
+
+ if (_auxGrayLevelValidationFill == true)
+ {
this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
- _image->SetScalarComponentFromFloat(px, py, pz, 0,
- (float) _graylevel);
+ if (_image2!=NULL)
+ {
+ _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
+ } else {
+ _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
+ }
- if (_countRecursiveFill < _limitRecursionFill) {
+ if (_countRecursiveFill < _limitRecursionFill)
+ {
if (_2D3D == 0) //2D
- {
+ {
if (_direction == 0) // YZ
- {
+ {
//FillToolRecursive(px+1,py,pz);
//FillToolRecursive(px-1,py,pz);
FillToolRecursive(px, py + 1, pz);
} // _graylevel
if ((_auxGrayLevelValidationFill == true)
- && (_countRecursiveFill >= _limitRecursionFill)) {
+ && (_countRecursiveFill >= _limitRecursionFill))
+ {
_countRecursiveFillProblem++;
if (_2D3D == 0) //2D
}
//---------------------------------------------------------------------------
-void FillFilter::SetAuxImageFill(int px, int py, int pz) {
+void FillFilter::SetAuxImageFill(int px, int py, int pz)
+{
if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY)
&& (pz >= _minZ) && (pz <= _maxZ)) {
this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
}
//---------------------------------------------------------------------------
-void FillFilter::SetToleranceFill(double tolerancefill) {
+void FillFilter::SetToleranceFill(double tolerancefill)
+{
_tolerancefill = tolerancefill;
}
//---------------------------------------------------------------------------
-void FillFilter::SetDistanceFill(int distancefill) {
+void FillFilter::SetDistanceFill(int distancefill)
+{
_distancefill = distancefill;
}
-//---------------------------------------------------------------------------
-void FillFilter::SetRangeMin(int min) {
- _RangeMin = min;
-}
-
-//---------------------------------------------------------------------------
-void FillFilter::SetRangeMax(int max) {
- _RangeMax = max;
-}
-
-//---------------------------------------------------------------------------
-int FillFilter::GetRangeMin() {
- return (_RangeMin);
-}
-//---------------------------------------------------------------------------
-int FillFilter::GetRangeMax() {
- return (_RangeMax);
-}