}
//virtual
-void Image3DDequeUR::AddImageToUndoContainer(ImageType* img,
+void Image3DDequeUR::AddImageToUndoContainer(VTKImageDataPointerType img,
const RegionS& region) {
//managing memory
if (this->m_ImgUndoDeque.size() > 0) {
- this->m_ImgUndoDeque.back()->RemoveImageFromMemory(this->m_GlobalPath);
- } //fi
- //Adding image
+ this->m_ImgUndoDeque.back()->RemoveImageFromMemory(this->m_GlobalPath);
+ } //fi
+ //Adding image
ImageInfoUR* imageInfo = new ImageInfoUR();
imageInfo->SetImageName(
this->GetImageName(this->m_ImgUndoDeque.size(), true));
this->m_ImgRedoDeque.clear();
//Adding to deque
this->m_ImgUndoDeque.push_back(imageInfo);
- std::cout<<"Parceeeeeeeee: aaa " << this->m_ImgUndoDeque.size()<<std::endl;
this->m_CurrentUndoPos = this->m_ImgUndoDeque.size() - 1;
}
//virtual
-void Image3DDequeUR::AddImageToRedoContainer(ImageType* img,
+void Image3DDequeUR::AddImageToRedoContainer(VTKImageDataPointerType img,
const RegionS& region) {
//managing memory
- if (this->m_ImgRedoDeque.size() > 0) {
+ /*if (this->m_ImgRedoDeque.size() > 0) {
this->m_ImgRedoDeque.back()->RemoveImageFromMemory(this->m_GlobalPath);
} //fi
//adding image
imageInfo->SaveImageAsMHD(this->m_GlobalPath);
//Adding to deque
this->m_ImgRedoDeque.push_back(imageInfo);
- this->m_CurrentUndoPos = this->m_ImgRedoDeque.size() - 1;
+ this->m_CurrentUndoPos = this->m_ImgRedoDeque.size() - 1;*/
}
//virtual
void Image3DDequeUR::CleanUndoContainerFromIndex(const int& index) {
//virtual
ImageInfoUR* Image3DDequeUR::Undo() {
- ImageInfoUR* imgRet = new ImageInfoUR();
+ ImageInfoUR* imgRet = NULL;
if ((this->m_ImgUndoDeque.size() > 0) && (this->m_CurrentUndoPos != -1)) {
+ std::cout<<"Controooool"<<std::endl;
//removing from memory
if ((this->m_CurrentUndoPos + 1) < this->m_ImgUndoDeque.size()) {
- this->m_ImgUndoDeque[(m_CurrentUndoPos + 1)]->RemoveImageFromMemory(
- this->m_GlobalPath);
- } //fi
+ this->m_ImgUndoDeque[(m_CurrentUndoPos + 1)]->RemoveImageFromMemory(
+ this->m_GlobalPath);
+ } //fi
imgRet = this->m_ImgUndoDeque[m_CurrentUndoPos];
+ std::cout << "imageName: " << imgRet->GetImageName() << std::endl;
this->m_CurrentUndoPos--;
//adding to memory
if (this->m_CurrentUndoPos != -1) {
//Loading image
- std::string fullPath = this->m_GlobalPath
+ StringType fullPath = this->m_GlobalPath
+ this->m_ImgUndoDeque[m_CurrentUndoPos]->GetImageName();
this->m_ImgUndoDeque[m_CurrentUndoPos]->LoadImageMHDToMemory(
this->m_GlobalPath);
this->m_ImgUndoDeque.clear();
}
-void Image3DDequeUR::SetGlobalPath(const std::string& globalPath) {
+void Image3DDequeUR::SetGlobalPath(const StringType& globalPath) {
this->m_GlobalPath = globalPath;
}
-std::string Image3DDequeUR::GetGlobalPath() {
+StringType Image3DDequeUR::GetGlobalPath() {
return (this->m_GlobalPath);
}
-std::string Image3DDequeUR::GetImageName(const int & pos, const bool& undo) {
+StringType Image3DDequeUR::GetImageName(const int & pos, const bool& undo) {
//Giving a name to an image using the date and time
if (this->m_IDImages.empty()) {
time_t rawtime;
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, 80, "%H%M%S_%a_%d_%b_%y_", timeinfo);
- std::string date(buffer);
- std::string aux(buffer);
+ StringType date(buffer);
+ StringType aux(buffer);
this->m_IDImages = "img_" + aux;
}
std::stringstream ss; //create a stringstream
ss << pos; //add number to the stream
- std::string imgType;
+ StringType imgType;
if (undo) {
imgType = "undo";
- }
- else
- {
+ } else {
imgType = "redo";
}
- std::string imageName = this->m_IDImages + imgType + ss.str();
+ StringType imageName = this->m_IDImages + imgType + ss.str();
imageName.append(".mhd");
return (imageName);
}
#include "imageDequeUR.h"
#include <ctime>
-
class Image3DDequeUR: public ImageDequeUR {
private:
ImageInfoDeque m_ImgUndoDeque;
ImageInfoDeque m_ImgRedoDeque;
int m_CurrentUndoPos;
int m_CurrentRedoPos;
- std::string m_GlobalPath;
- std::string m_IDImages;
+ StringType m_GlobalPath;
+ StringType m_IDImages;
public:
Image3DDequeUR();
virtual ~Image3DDequeUR();
- void SetGlobalPath(const std::string& globalPath);
- std::string GetGlobalPath();
- std::string GetImageName(const int & pos, const bool& undo);
- virtual void AddImageToUndoContainer(ImageType* img, const RegionS& region);
- virtual void AddImageToRedoContainer(ImageType* img, const RegionS& region);
+ void SetGlobalPath(const StringType& globalPath);
+ StringType GetGlobalPath();
+ StringType GetImageName(const int & pos, const bool& undo);
+ virtual void AddImageToUndoContainer(VTKImageDataPointerType img,
+ const RegionS& region);
+ virtual void AddImageToRedoContainer(VTKImageDataPointerType img,
+ const RegionS& region);
virtual void CleanUndoContainerFromIndex(const int& index);
virtual void CleanRedoContainerFromIndex(const int& index);
virtual void CleanContainers();
ImageDequeUR::~ImageDequeUR() {
}
-void ImageDequeUR::AddImageToUndoContainer(ImageType* img,
+void ImageDequeUR::AddImageToUndoContainer(VTKImageDataPointerType img,
const RegionS& region) {
}
-void ImageDequeUR::AddImageToRedoContainer(ImageType* img,
+void ImageDequeUR::AddImageToRedoContainer(VTKImageDataPointerType img,
const RegionS& region) {
}
void ImageDequeUR::CleanUndoContainerFromIndex(const int& index) {
#include <string>
#include <deque>
#include <vtkImageData.h>
+#include <vtkSmartPointer.h>
#include "imageInfoUR.h"
#include "regionStructUR.h"
typedef std::deque<ImageInfoUR*> ImageInfoDeque;
-typedef vtkImageData ImageType;
+typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
typedef RegionStructUR RegionS;
+typedef std::string StringType;
class ImageDequeUR {
public:
ImageDequeUR();
virtual ~ImageDequeUR();
- virtual void AddImageToUndoContainer(ImageType* img, const RegionS& region);
- virtual void AddImageToRedoContainer(ImageType* img, const RegionS& region);
+ virtual void AddImageToUndoContainer(VTKImageDataPointerType img,
+ const RegionS& region);
+ virtual void AddImageToRedoContainer(VTKImageDataPointerType img,
+ const RegionS& region);
virtual void CleanUndoContainerFromIndex(const int& index);
virtual void CleanRedoContainerFromIndex(const int& index);
virtual void CleanContainers();
#include "imageInfoUR.h"
ImageInfoUR::ImageInfoUR() {
- this->m_Image = NULL;
this->m_OnMemory = false;
this->m_OnDisk = false;
}
ImageInfoUR::~ImageInfoUR() {
}
-void ImageInfoUR::SetImageName(const std::string &imgName) {
+void ImageInfoUR::SetImageName(const StringType &imgName) {
this->m_ImageName = imgName;
}
void ImageInfoUR::SetRegion(const RegionStructUR ®ion) {
void ImageInfoUR::SetStatus(const bool& onMemory) {
this->m_OnMemory = onMemory;
}
-void ImageInfoUR::SetImage(vtkImageData* img) {
+void ImageInfoUR::SetImage(VTKImageDataPointerType img) {
this->m_Image = img;
this->SetStatus(true);
}
-std::string ImageInfoUR::GetImageName() {
+ImageInfoUR::StringType ImageInfoUR::GetImageName() {
return (this->m_ImageName);
}
+
+ImageInfoUR::VTKImageDataPointerType ImageInfoUR::GetImage() {
+ return (this->m_Image);
+}
+
RegionStructUR ImageInfoUR::GetRegion() {
return (this->m_Region);
}
bool ImageInfoUR::GetStatus() {
return (this->m_OnMemory);
}
-void ImageInfoUR::RemoveImageFromMemory(const std::string& gPath) {
+void ImageInfoUR::RemoveImageFromMemory(const StringType& gPath) {
if (!this->m_OnDisk) {
this->SaveImageAsMHD(gPath);
}
this->m_Image = NULL;
this->SetStatus(false);
}
-void ImageInfoUR::LoadImageMHDToMemory(const std::string& gPath) {
- std::string filename = gPath + this->m_ImageName;
- vtkSmartPointer<vtkMetaImageReader> reader = vtkSmartPointer<
- vtkMetaImageReader>::New();
+void ImageInfoUR::LoadImageMHDToMemory(const StringType& gPath) {
+ StringType filename = gPath + this->m_ImageName;
+ VTKMetaImageReaderPointerType reader = VTKMetaImageReaderPointerType::New();
reader->SetFileName(filename.c_str());
this->m_Image = reader->GetOutput();
this->m_OnMemory = true;
}
-void ImageInfoUR::SaveImageAsMHD(const std::string& gPath) {
+void ImageInfoUR::SaveImageAsMHD(const StringType& gPath) {
this->m_OnDisk = true;
- std::string filename = gPath + this->m_ImageName;
- vtkSmartPointer<vtkMetaImageWriter> w =
- vtkSmartPointer<vtkMetaImageWriter>::New();
+ StringType filename = gPath + this->m_ImageName;
+ VTKMetaImageWriterPointerType w = VTKMetaImageWriterPointerType::New();
w->SetInput(this->m_Image);
w->SetCompression(false);
w->SetFileDimensionality(this->m_Image->GetDataDimension());
w->Write();
}
-void ImageInfoUR::RemoveImageFromDisk(const std::string& gPath)
-{
+void ImageInfoUR::RemoveImageFromDisk(const StringType& gPath) {
}
#include "regionStructUR.h"
class ImageInfoUR {
-private:
- vtkImageData* m_Image;
- std::string m_ImageName;
- RegionStructUR m_Region;
- bool m_OnMemory;
- bool m_OnDisk;
+
+public:
+ typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
+ typedef vtkSmartPointer<vtkMetaImageReader> VTKMetaImageReaderPointerType;
+ typedef vtkSmartPointer<vtkMetaImageWriter> VTKMetaImageWriterPointerType;
+ typedef std::string StringType;
public:
ImageInfoUR();
virtual ~ImageInfoUR();
- void SetImageName(const std::string &imgName);
+ void SetImageName(const StringType &imgName);
void SetRegion(const RegionStructUR ®ion);
void SetStatus(const bool& onMemory);
- void SetImage(vtkImageData* img);
- void RemoveImageFromMemory(const std::string& gPath);
- void LoadImageMHDToMemory(const std::string& gPath);
- void SaveImageAsMHD(const std::string& gPath);
- void RemoveImageFromDisk(const std::string& gPath);
- std::string GetImageName();
+ void SetImage(VTKImageDataPointerType img);
+ void RemoveImageFromMemory(const StringType& gPath);
+ void LoadImageMHDToMemory(const StringType& gPath);
+ void SaveImageAsMHD(const StringType& gPath);
+ void RemoveImageFromDisk(const StringType& gPath);
+ VTKImageDataPointerType GetImage();
+ StringType GetImageName();
RegionStructUR GetRegion();
bool GetStatus();
+
+private:
+ VTKImageDataPointerType m_Image;
+ StringType m_ImageName;
+ RegionStructUR m_Region;
+ bool m_OnMemory;
+ bool m_OnDisk;
+
};
#endif /* IMAGEINFO_H_ */
//virtual
void ImageUndoRedo::Undo() {
ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo();
- this->SetRedoImage(imageInfo->GetRegion());
- std::cout<<"undooooooooooooooooooooooooooo"<<std::endl;
- this->DrawUR(imageInfo);
+ if (imageInfo != NULL)
+ {
+ this->SetRedoImage(imageInfo->GetRegion());
+ this->DrawUR(imageInfo);
+ }
}
//virtual
void ImageUndoRedo::Redo() {
ImageInfoUR* imageInfo = this->m_ImagesDeque->Redo();
this->DrawUR(imageInfo);
}
-void ImageUndoRedo::SetImage(vtkImageData *image) {
+void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
this->m_CurrentImage = image;
this->m_CurrentImage->Update();
- this->m_OriginalImage = ImageType::New();
+ this->m_OriginalImage = VTKImageDataPointerType::New();
this->m_OriginalImage->DeepCopy(m_CurrentImage);
}
//virtual
void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
- vtkSmartPointer<vtkExtractVOI> extract =
- vtkSmartPointer<vtkExtractVOI>::New();
- extract->SetVOI(region.minX, region.maxX, region.minY, region.maxY,
- region.minZ, region.maxZ);
- extract->SetSampleRate(1, 1, 1);
- extract->SetInput(this->m_OriginalImage);
- vtkImageData* imgResult = extract->GetOutput();
+ VTKImageDataPointerType imgResult = this->GetImageRegion(region,
+ this->m_OriginalImage);
this->m_ImagesDeque->AddImageToUndoContainer(imgResult, region);
}
//virtual
void ImageUndoRedo::SetRedoImage(const RegionSType& region) {
- vtkSmartPointer<vtkExtractVOI> extract =
- vtkSmartPointer<vtkExtractVOI>::New();
+ VTKImageDataPointerType imgResult = this->GetImageRegion(region,
+ this->m_CurrentImage);
+ this->m_ImagesDeque->AddImageToRedoContainer(imgResult, region);
+}
+
+ImageUndoRedo::VTKImageDataPointerType ImageUndoRedo::GetImageRegion(
+ const RegionSType& region, VTKImageDataPointerType img) {
+ VTKExtractVOIPointerType extract = VTKExtractVOIPointerType::New();
+ VTKImageDataPointerType imgResult = VTKImageDataPointerType::New();
extract->SetVOI(region.minX, region.maxX, region.minY, region.maxY,
region.minZ, region.maxZ);
extract->SetSampleRate(1, 1, 1);
- extract->SetInput(this->m_CurrentImage);
- vtkImageData* imgResult = extract->GetOutput();
- this->m_ImagesDeque->AddImageToRedoContainer(imgResult, region);
+ extract->SetInput(this->m_OriginalImage);
+ imgResult = extract->GetOutput();
+ return (imgResult);
}
-void ImageUndoRedo::SetOriginalImage(ImageType* img) {
+
+void ImageUndoRedo::SetOriginalImage(VTKImageDataPointerType img) {
this->m_OriginalImage = img;
}
-void ImageUndoRedo::SetCurrentImage(ImageType* img) {
+void ImageUndoRedo::SetCurrentImage(VTKImageDataPointerType img) {
this->m_CurrentImage = img;
}
//virtual
void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo) {
-
+ VTKImageDataPointerType img = imageInfo->GetImage();
+ for (int i = imageInfo->GetRegion().minX, x = 0;
+ i <= imageInfo->GetRegion().maxX; i++, x++) {
+ for (int j = imageInfo->GetRegion().minY, y = 0;
+ j <= imageInfo->GetRegion().maxY; j++, y++) {
+ for (int k = imageInfo->GetRegion().minZ, z = 0;
+ k <= imageInfo->GetRegion().maxZ; k++, z++) {
+ float value = img->GetScalarComponentAsFloat(i, j, k, 0);
+ this->m_CurrentImage->SetScalarComponentFromFloat(i, j, k, 0,
+ value);
+ } //rof
+ } //rof
+ } //rof
+ this->m_CurrentImage->Modified();
}
#define IMAGEUNDOREDO_H_
#include "managerUR.h"
-#include <vtkExtractVOI.h>
-#include <vtkSmartPointer.h>
class ImageUndoRedo: public ManagerUR {
-private:
-
- IDequeType* m_ImagesDeque;
- ImageType* m_OriginalImage;
- ImageType* m_CurrentImage;
-
public:
ImageUndoRedo();
virtual ~ImageUndoRedo();
virtual void Undo();
virtual void Redo();
- virtual void SetImage(vtkImageData *image);
+ virtual void SetImage(VTKImageDataPointerType image);
virtual void SetUndoImage(const RegionSType& region);
virtual void SetRedoImage(const RegionSType& region);
- void SetOriginalImage(ImageType* img);
- void SetCurrentImage(ImageType* img);
-private:
+ void SetOriginalImage(VTKImageDataPointerType img);
+ void SetCurrentImage(VTKImageDataPointerType img);
+ VTKImageDataPointerType GetImageRegion(const RegionSType& region,
+ VTKImageDataPointerType img);
+protected:
virtual void DrawUR(ImageInfoUR* imageInfo);
+protected:
+
+ IDequeType* m_ImagesDeque;
+ VTKImageDataPointerType m_OriginalImage;
+ VTKImageDataPointerType m_CurrentImage;
+
};
#endif /* IMAGEUNDOREDO_H_ */
#include <iostream>
#include <string>
#include <vtkImageData.h>
+#include <vtkSmartPointer.h>
+#include <vtkExtractVOI.h>
#include "image3DDequeUR.h"
-typedef Image3DDequeUR IDequeType;
-typedef RegionStructUR RegionSType;
-typedef vtkImageData ImageType;
-
class ManagerUR {
+public:
+ typedef Image3DDequeUR IDequeType;
+ typedef RegionStructUR RegionSType;
+ typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
+ typedef vtkSmartPointer<vtkExtractVOI> VTKExtractVOIPointerType;
+ typedef std::string StringType;
public:
ManagerUR();
virtual ~ManagerUR();
virtual void Redo();
virtual void SetUndoImage(const RegionSType& region);
virtual void SetRedoImage(const RegionSType& region);
-private:
+protected:
virtual void DrawUR(ImageInfoUR imageInfo);
};
int maxY;
int minZ;
int maxZ;
+ float value;
};
-
#include "BrushFilter.h"
-
-
-BrushFilter::BrushFilter()
-{
- _brushsize = 1;
- _brushform = 0; // 0 rectangle-box , 1 circle-sphere
- _brushtool = 0; // 0 pencil , 1 fill
+BrushFilter::BrushFilter() {
+ _brushsize = 1;
+ _brushform = 0; // 0 rectangle-box , 1 circle-sphere
+ _brushtool = 0; // 0 pencil , 1 fill
}
//---------------------------------------------------------------------------
-BrushFilter::~BrushFilter() // virtual
+BrushFilter::~BrushFilter() // virtual
{
}
//---------------------------------------------------------------------------
-void BrushFilter::FindMinMaxBrush(int &minX,int &maxX,int &minY,int &maxY,int &minZ,int &maxZ,int &size)
-{
- size = _brushsize-1;
- minX = _px-size;
- maxX = _px+size;
- minY = _py-size;
- maxY = _py+size;
- minZ = _pz-size;
- maxZ = _pz+size;
-
- if (_2D3D==0) //2D
- {
- if (_direction==0) // YZ
- {
- minX=_px;
- maxX=_px;
- }
- if (_direction==1) // XZ
- {
- minY=_py;
- maxY=_py;
- }
- if (_direction==2) // XY
- {
- minZ=_pz;
- maxZ=_pz;
- }
- }
-
- if (_2D3D==1) // 3D
- {
- }
-
- if (minX<_minX)
- {
- minX=_minX;
- }
-
- if (minY<_minY)
- {
- minY=_minY;
- }
-
- if (minZ<_minZ)
- {
- minZ=_minZ;
- }
-
- if (maxX>_maxX)
- {
- maxX=_maxX;
- }
-
- if (maxY>_maxY)
- {
- maxY=_maxY;
- }
-
- if (maxZ>_maxZ)
- {
- maxZ=_maxZ;
- }
+void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY,
+ int &minZ, int &maxZ, int &size) {
+ size = _brushsize - 1;
+ minX = _px - size;
+ maxX = _px + size;
+ minY = _py - size;
+ maxY = _py + size;
+ minZ = _pz - size;
+ maxZ = _pz + size;
+
+ if (_2D3D == 0) //2D
+ {
+ if (_direction == 0) // YZ
+ {
+ minX = _px;
+ maxX = _px;
+ }
+ if (_direction == 1) // XZ
+ {
+ minY = _py;
+ maxY = _py;
+ }
+ if (_direction == 2) // XY
+ {
+ minZ = _pz;
+ maxZ = _pz;
+ }
+ }
+
+ if (_2D3D == 1) // 3D
+ {
+ }
+
+ if (minX < _minX) {
+ minX = _minX;
+ }
+
+ if (minY < _minY) {
+ minY = _minY;
+ }
+
+ if (minZ < _minZ) {
+ minZ = _minZ;
+ }
+
+ if (maxX > _maxX) {
+ maxX = _maxX;
+ }
+
+ if (maxY > _maxY) {
+ maxY = _maxY;
+ }
+
+ if (maxZ > _maxZ) {
+ maxZ = _maxZ;
+ }
//--
- SetGeneralMinMax(minX,maxX,minY,maxY,minZ,maxZ);
+ SetGeneralMinMax(minX, maxX, minY, maxY, minZ, maxZ);
}
-
-
//---------------------------------------------------------------------------
-void BrushFilter::Run() // virtual
+void BrushFilter::Run() // virtual
{
- if (_image!=NULL)
- {
- float value=(float)_graylevel;
- int i,j,k;
-
- int size;
- int minX,maxX,minY,maxY,minZ,maxZ;
- FindMinMaxBrush(minX,maxX,minY,maxY,minZ,maxZ,size);
-
- double xx,yy,zz,rr=size*size;
-
- for (i=minX; i<=maxX; i++)
- {
- xx=_px-i;
- xx=xx*xx;
- for (j=minY; j<=maxY; j++)
- {
- yy=_py-j;
- yy=yy*yy;
- for (k=minZ; k<=maxZ; k++)
- {
+ if (_image != NULL)
+ {
+ float value = (float) _graylevel;
+ this->_MRegion->value = (float) _graylevel;
+ int i, j, k;
+
+ int size;
+ int minX, maxX, minY, maxY, minZ, maxZ;
+ FindMinMaxBrush(minX, maxX, minY, maxY, minZ, maxZ, size);
+
+ double xx, yy, zz, rr = size * size;
+
+ for (i = minX; i <= maxX; i++) {
+ xx = _px - i;
+ xx = xx * xx;
+ for (j = minY; j <= maxY; j++) {
+ yy = _py - j;
+ yy = yy * yy;
+ for (k = minZ; k <= maxZ; k++) {
// if ((i>=_minX) && (i<=_maxX) && (j>=_minY) && (j<=_maxY) && (k>=_minZ) && (k<=_maxZ))
// {
- float scalarComponent = _image->GetScalarComponentAsFloat(i,j,k, 0);
- if( ( this->GetRangeMin() <= scalarComponent ) && ( scalarComponent <= this->GetRangeMax() ) )
- {
- zz=_pz-k;
- zz=zz*zz;
- if (_brushform==0)
- {
- this->CalculateMinMaxRegion(i,j,k); //DFCH
- _image->SetScalarComponentFromFloat (i,j,k, 0, value );
- } else if (_brushform==1)
- {
- if ((xx+yy+zz)<=rr)
- {
- this->CalculateMinMaxRegion(i,j,k); //DFCH
- _image->SetScalarComponentFromFloat (i,j,k, 0, value );
- }
- } // _brushform
- } // GetRangeMin && GetRangeMax
+ float scalarComponent = _image->GetScalarComponentAsFloat(i,
+ j, k, 0);
+ if ((this->GetRangeMin() <= scalarComponent)
+ && (scalarComponent <= this->GetRangeMax())) {
+ zz = _pz - k;
+ zz = zz * zz;
+ if (_brushform == 0) {
+ this->CalculateMinMaxRegion(i, j, k); //DFCH
+ _image->SetScalarComponentFromFloat(i, j, k, 0,
+ value);
+ } else if (_brushform == 1) {
+ if ((xx + yy + zz) <= rr) {
+ this->CalculateMinMaxRegion(i, j, k); //DFCH
+ _image->SetScalarComponentFromFloat(i, j, k, 0,
+ value);
+ }
+ } // _brushform
+ } // GetRangeMin && GetRangeMax
// } //if _minX _maxX _minY _maxY _minZ _maxZ
- }//k
- }//j
- }//i
- _image->Modified();
- } else {
- printf("ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
- } // _image
+ } //k
+ } //j
+ } //i
+ _image->Modified();
+ } else {
+ printf(
+ "ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n");
+ } // _image
}
-
//---------------------------------------------------------------------------
-void BrushFilter::SetBrushSize( int brushsize )
-{
- _brushsize = brushsize;
+void BrushFilter::SetBrushSize(int brushsize) {
+ _brushsize = brushsize;
}
//---------------------------------------------------------------------------
-void BrushFilter::SetBrushForm( int brushform )
-{
- _brushform = brushform;
+void BrushFilter::SetBrushForm(int brushform) {
+ _brushform = brushform;
}
//---------------------------------------------------------------------------
-void BrushFilter::SetBrushTool( int brushtool )
-{
- _brushtool = brushtool;
+void BrushFilter::SetBrushTool(int brushtool) {
+ _brushtool = brushtool;
}
//---------------------------------------------------------------------------
-void BrushFilter::SetRangeMin( int min )
-{
- _RangeMin = min;
+void BrushFilter::SetRangeMin(int min) {
+ _RangeMin = min;
}
//---------------------------------------------------------------------------
-void BrushFilter::SetRangeMax( int max )
-{
- _RangeMax = max;
+void BrushFilter::SetRangeMax(int max) {
+ _RangeMax = max;
}
//---------------------------------------------------------------------------
-int BrushFilter::GetRangeMin( )
-{
- return( _RangeMin );
+int BrushFilter::GetRangeMin() {
+ return (_RangeMin);
}
//---------------------------------------------------------------------------
-int BrushFilter::GetRangeMax( )
-{
- return( _RangeMax );
+int BrushFilter::GetRangeMax() {
+ return (_RangeMax);
}
-
//---------------------------------------------------------------------------
void FillFilter::FillToolRecursive(int px,int py, int pz)
{
+ this->_MRegion->value = (float) _graylevel;
_countRecursiveFill++;
_countProgressingFill++;
return (this->_MRegion);
} //DFCH
void baseFilterManualPaint::CleanModifiedRegion() {
- this->_MRegion->minX = 0;
- this->_MRegion->maxX = 0;
- this->_MRegion->minY = 0;
- this->_MRegion->maxY = 0;
- this->_MRegion->minZ = 0;
- this->_MRegion->maxZ = 0;
+ int min = std::numeric_limits<int>::min();
+ int max = std::numeric_limits<int>::max();
+ this->_MRegion->minX = max;
+ this->_MRegion->maxX = min;
+ this->_MRegion->minY = max;
+ this->_MRegion->maxY = min;
+ this->_MRegion->minZ = max;
+ this->_MRegion->maxZ = min;
} //DFCH
void baseFilterManualPaint::CalculateMinMaxRegion(const int& i, const int& j,
const int& k) {
- if (i < this->_MRegion->minX) {
+ if (i <= this->_MRegion->minX) {
this->_MRegion->minX = i;
- } else {
- this->_MRegion->maxX = i;
} //fi
- if (j < this->_MRegion->minY) {
+ if (i > this->_MRegion->maxX) {
+ this->_MRegion->maxX = i;
+ } //esle
+ if (j <= this->_MRegion->minY) {
this->_MRegion->minY = j;
- } else {
- this->_MRegion->maxY = j;
} //fi
- if (k < this->_MRegion->minZ) {
+ if (j > this->_MRegion->maxY) {
+ this->_MRegion->maxY = j;
+ } //esle
+ if (k <= this->_MRegion->minZ) {
this->_MRegion->minZ = k;
- } else {
- this->_MRegion->maxZ = k;
} //fi
+ if (k > this->_MRegion->maxZ) {
+ this->_MRegion->maxZ = k;
+ } //esle
}
-
#define _BASE_FILTER_MANUAL_PAINT_H_
#include <vtkImageData.h>
+#include <limits>
#include "regionStructUR.h"
class baseFilterManualPaint {