]> Creatis software - creaMaracasVisu.git/commitdiff
DFCH: Manualpaint + imageUndoRedo Big changes, new class for the management of the...
authorDiego Caceres <Diego.Caceres@creatis.insa-lyon.fr>
Fri, 28 Oct 2011 17:44:05 +0000 (17:44 +0000)
committerDiego Caceres <Diego.Caceres@creatis.insa-lyon.fr>
Fri, 28 Oct 2011 17:44:05 +0000 (17:44 +0000)
19 files changed:
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/managerUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/managerUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/regionStructUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h

index 22224c51493b13d508d55d27dbe7e4e34a63d828..2b7f1401bf39bd0123633f38afb439d03ee1f8df 100755 (executable)
@@ -13,16 +13,16 @@ Image3DDequeUR::~Image3DDequeUR() {
 }
 //virtual
 void Image3DDequeUR::AddImageToUndoContainer(VTKImageDataPointerType img,
-               const RegionS& region) {
+               ImageMManagerType* imMManager) {
        //Adding image
        ImageInfoUR* imageInfo = new ImageInfoUR();
        imageInfo->SetImageName(
                        this->GetImageName(this->m_ImgUndoDeque.size(), true));
        imageInfo->SetImage(img);
-       imageInfo->SetRegion(region);
+       imageInfo->SetImageMManager(imMManager);
        ///---------------------------------------------------------------------------------------------------
        // Uncoment the following line
-       imageInfo->SaveImageAsMHD(this->m_GlobalPath);
+       //imageInfo->SaveImageAsMHD(this->m_GlobalPath);
        ///------------------------------------------------------------------------------------------------
        //Adding to deque
        this->m_ImgUndoDeque.push_back(imageInfo);
@@ -39,7 +39,7 @@ ImageInfoUR* Image3DDequeUR::Undo() {
 }
 //virtual
 void Image3DDequeUR::AddImageToRedoContainer(VTKImageDataPointerType img,
-               const RegionS& region) {
+               ImageMManagerType* imMManager) {
 }
 //virtual
 ImageInfoUR* Image3DDequeUR::Redo() {
@@ -81,11 +81,12 @@ void Image3DDequeUR::SetGlobalPath(const StringType& globalPath) {
        this->m_GlobalPath = globalPath;
 }
 
-StringType Image3DDequeUR::GetGlobalPath() {
+Image3DDequeUR::StringType Image3DDequeUR::GetGlobalPath() {
        return (this->m_GlobalPath);
 }
 
-StringType Image3DDequeUR::GetImageName(const int & pos, const bool& undo) {
+Image3DDequeUR::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;
index 63aaad24975bd6beed6f93cbc165bfc78b6f5a27..9f46cb2bbd68171847872da882ef7c3757bd2b7f 100755 (executable)
 #include <ctime>
 
 class Image3DDequeUR: public ImageDequeUR {
-private:
-       ImageInfoDeque m_ImgUndoDeque;
-       ImageInfoDeque m_ImgRedoDeque;
-       int m_CurrentUndoPos;
-       int m_CurrentRedoPos;
-       StringType m_GlobalPath;
-       StringType m_IDImages;
 public:
        Image3DDequeUR();
        virtual ~Image3DDequeUR();
@@ -26,14 +19,21 @@ public:
        StringType GetGlobalPath();
        StringType GetImageName(const int & pos, const bool& undo);
        virtual void AddImageToUndoContainer(VTKImageDataPointerType img,
-                       const RegionS& region);
+                       ImageMManagerType* imMManager);
        virtual void AddImageToRedoContainer(VTKImageDataPointerType img,
-                       const RegionS& region);
+                       ImageMManagerType* imMManager);
        virtual void CleanUndoContainerFromIndex(const int& index);
        virtual void CleanRedoContainerFromIndex(const int& index);
        virtual void CleanContainers();
        virtual ImageInfoUR* Undo();
        virtual ImageInfoUR* Redo();
+protected:
+       ImageInfoDeque m_ImgUndoDeque;
+       ImageInfoDeque m_ImgRedoDeque;
+       int m_CurrentUndoPos;
+       int m_CurrentRedoPos;
+       StringType m_GlobalPath;
+       StringType m_IDImages;
 };
 
 #endif /* IMAGE3DDEQUEUR_H_ */
index 25e95be01532547da4861d54e995f301aa830eb6..ae2b970e58ebd86b49575e73cf2d2f85f0a51341 100755 (executable)
@@ -7,10 +7,10 @@ ImageDequeUR::~ImageDequeUR() {
 
 }
 void ImageDequeUR::AddImageToUndoContainer(VTKImageDataPointerType img,
-               const RegionS& region) {
+               ImageMManager* imManager) {
 }
 void ImageDequeUR::AddImageToRedoContainer(VTKImageDataPointerType img,
-               const RegionS& region) {
+               ImageMManager* imMManager) {
 }
 void ImageDequeUR::CleanUndoContainerFromIndex(const int& index) {
 
@@ -22,10 +22,8 @@ void ImageDequeUR::CleanContainers() {
 }
 
 ImageInfoUR* ImageDequeUR::Undo() {
-       ImageInfoUR* im;
-       return im;
+       return NULL;
 }
 ImageInfoUR* ImageDequeUR::Redo() {
-       ImageInfoUR* im;
-       return im;
+       return NULL;
 }
index 761f56a0a5c9a7382be08f1634856a6edcf35820..c66c75ba43fe9899143364a00a53a72fe61d6441 100755 (executable)
 #include <vtkImageData.h>
 #include <vtkSmartPointer.h>
 #include "imageInfoUR.h"
-#include "regionStructUR.h"
-
-typedef std::deque<ImageInfoUR*> ImageInfoDeque;
-typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
-typedef RegionStructUR RegionS;
-typedef std::string StringType;
+#include "imageModificationManager.h"
 
 class ImageDequeUR {
+public:
+       typedef std::deque<ImageInfoUR*> ImageInfoDeque;
+       typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
+       typedef std::string StringType;
+       typedef ImageMManager ImageMManagerType;
 public:
        ImageDequeUR();
        virtual ~ImageDequeUR();
        virtual void AddImageToUndoContainer(VTKImageDataPointerType img,
-                       const RegionS& region);
+                       ImageMManager* imMManager);
        virtual void AddImageToRedoContainer(VTKImageDataPointerType img,
-                       const RegionS& region);
+                       ImageMManager* imMManager);
        virtual void CleanUndoContainerFromIndex(const int& index);
        virtual void CleanRedoContainerFromIndex(const int& index);
        virtual void CleanContainers();
index 3d1093752f0a67b7085eefb0e35d7e74bcd06568..d788dbc06ebc9d5aea9963ba9b8b546a9be2dea8 100755 (executable)
@@ -17,8 +17,8 @@ ImageInfoUR::~ImageInfoUR() {
 void ImageInfoUR::SetImageName(const StringType &imgName) {
        this->m_ImageName = imgName;
 }
-void ImageInfoUR::SetRegion(const RegionStructUR &region) {
-       this->m_Region = region;
+void ImageInfoUR::SetImageMManager(ImageMManagerType* imMManager) {
+       this->m_ImageMManager = imMManager;
 }
 void ImageInfoUR::SetStatus(const bool& onMemory) {
        this->m_OnMemory = onMemory;
@@ -35,8 +35,8 @@ ImageInfoUR::VTKImageDataPointerType ImageInfoUR::GetImage() {
        return (this->m_Image);
 }
 
-RegionStructUR ImageInfoUR::GetRegion() {
-       return (this->m_Region);
+ImageInfoUR::ImageMManagerType* ImageInfoUR::GetImageMManager() {
+       return (this->m_ImageMManager);
 }
 bool ImageInfoUR::GetStatus() {
        return (this->m_OnMemory);
@@ -53,6 +53,7 @@ void ImageInfoUR::LoadImageMHDToMemory(const StringType& gPath) {
        VTKMetaImageReaderPointerType reader = VTKMetaImageReaderPointerType::New();
        reader->SetFileName(filename.c_str());
        this->m_Image = reader->GetOutput();
+       this->m_Image->Update();
        this->m_OnMemory = true;
 }
 void ImageInfoUR::SaveImageAsMHD(const StringType& gPath) {
index d55baf49708e53a9af820506bc74c760d9743d81..b3d011a4cedb83a7fd3063b9a96e51b3d0436728 100755 (executable)
@@ -15,6 +15,7 @@
 #include <vtkMetaImageReader.h>
 #include <vtkSmartPointer.h>
 #include "regionStructUR.h"
+#include "imageModificationManager.h"
 
 class ImageInfoUR {
 
@@ -22,12 +23,13 @@ public:
        typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
        typedef vtkSmartPointer<vtkMetaImageReader> VTKMetaImageReaderPointerType;
        typedef vtkSmartPointer<vtkMetaImageWriter> VTKMetaImageWriterPointerType;
+       typedef ImageMManager ImageMManagerType;
        typedef std::string StringType;
 public:
        ImageInfoUR();
        virtual ~ImageInfoUR();
        void SetImageName(const StringType &imgName);
-       void SetRegion(const RegionStructUR &region);
+       void SetImageMManager(ImageMManagerType *imMManager);
        void SetStatus(const bool& onMemory);
        void SetImage(VTKImageDataPointerType img);
        void RemoveImageFromMemory(const StringType& gPath);
@@ -36,13 +38,13 @@ public:
        void RemoveImageFromDisk(const StringType& gPath);
        VTKImageDataPointerType GetImage();
        StringType GetImageName();
-       RegionStructUR GetRegion();
+       ImageMManagerType* GetImageMManager();
        bool GetStatus();
 
 private:
        VTKImageDataPointerType m_Image;
        StringType m_ImageName;
-       RegionStructUR m_Region;
+       ImageMManagerType* m_ImageMManager;
        bool m_OnMemory;
        bool m_OnDisk;
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx
new file mode 100644 (file)
index 0000000..bdbed37
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * imageManagement.cxx
+ *
+ *  Created on: Oct 28, 2011
+ *      Author: caceres
+ */
+
+#include "imageModificationManager.h"
+
+ImageMManager::ImageMManager() {
+
+}
+ImageMManager::ImageMManager(ImageMManager* manager) {
+       this->m_PixelMap = manager->GetModificationMap();
+       this->m_RegionStruct = manager->GetModifiedRegion();
+}
+ImageMManager::~ImageMManager() {
+
+}
+
+void ImageMManager::CleanModifiedRegion() {
+
+       int min = std::numeric_limits<int>::min();
+       int max = std::numeric_limits<int>::max();
+       this->m_RegionStruct.minX = max;
+       this->m_RegionStruct.maxX = min;
+       this->m_RegionStruct.minY = max;
+       this->m_RegionStruct.maxY = min;
+       this->m_RegionStruct.minZ = max;
+       this->m_RegionStruct.maxZ = min;
+       this->m_PixelMap.clear();
+
+} //DFCH
+void ImageMManager::CalculateMinMaxRegion(const int& i, const int& j,
+               const int& k) {
+       if (i <= this->m_RegionStruct.minX) {
+               this->m_RegionStruct.minX = i;
+       } //fi
+       if (i > this->m_RegionStruct.maxX) {
+               this->m_RegionStruct.maxX = i;
+       } //esle
+       if (j <= this->m_RegionStruct.minY) {
+               this->m_RegionStruct.minY = j;
+       } //fi
+       if (j > this->m_RegionStruct.maxY) {
+               this->m_RegionStruct.maxY = j;
+       } //esle
+       if (k <= this->m_RegionStruct.minZ) {
+               this->m_RegionStruct.minZ = k;
+       } //fi
+       if (k > this->m_RegionStruct.maxZ) {
+               this->m_RegionStruct.maxZ = k;
+       } //esle
+} //DFCH
+
+void ImageMManager::AddModifiedPixel(const int& i, const int& j, const int& k) {
+       this->m_PixelMap[i][j][k] = true;
+       this->CalculateMinMaxRegion(i, j, k);
+} //DFCH
+
+RegionStructUR ImageMManager::GetModifiedRegion() {
+       return (this->m_RegionStruct);
+}
+
+ImageMManager::PixelModMap ImageMManager::GetModificationMap() {
+       return (this->m_PixelMap);
+}
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h
new file mode 100644 (file)
index 0000000..3e11b7e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * imageManagement.h
+ *
+ *  Created on: Oct 28, 2011
+ *      Author: caceres
+ */
+
+#ifndef IMAGEMANAGEMENT_H_
+#define IMAGEMANAGEMENT_H_
+
+#include <iostream>
+#include <map>
+#include <limits>
+
+#include "regionStructUR.h"
+
+class ImageMManager {
+public:
+       typedef std::map<int, std::map<int, std::map<int, bool> > > PixelModMap; //x,y,z
+public:
+       ImageMManager();
+       ImageMManager(ImageMManager* manager);
+       virtual ~ImageMManager();
+       void CleanModifiedRegion(); //DFCH
+       void AddModifiedPixel(const int& i, const int& j, const int& k); //DFCH
+       //void SetRegion(const RegionStructUR& region);
+       //void SetPixelModMap(const PixelModMap& map); //DFCH
+       RegionStructUR GetModifiedRegion(); //DFCH
+       PixelModMap GetModificationMap(); //DFCH
+private:
+       void CalculateMinMaxRegion(const int& i, const int& j, const int& k); //DFCH
+private:
+       RegionStructUR m_RegionStruct;
+       PixelModMap m_PixelMap;
+};
+
+#endif /* IMAGEMANAGEMENT_H_ */
index 55a4e1f24b9fc907f100e6396a65247d05ab75f2..2f80bd6594ff3352d3a53f0e57b1eb5c917d7c88 100755 (executable)
@@ -35,27 +35,30 @@ void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
        this->m_OriginalImage->DeepCopy(m_CurrentImage);
 }
 //virtual
-void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
+void ImageUndoRedo::SetUndoImage(ImageMManagerType* imMManager) {
+       ImageMManagerType* newImageManager = new ImageMManagerType(imMManager);
+       RegionSType region = newImageManager->GetModifiedRegion();
        VTKImageDataPointerType imgResult = this->GetImageRegion(region,
                        this->m_OriginalImage);
-       this->m_ImagesDeque->AddImageToUndoContainer(imgResult, region);
+       this->m_ImagesDeque->AddImageToUndoContainer(imgResult, newImageManager);
 }
 //virtual
-void ImageUndoRedo::SetRedoImage(const RegionSType& region) {
-       VTKImageDataPointerType imgResult = this->GetImageRegion(region,
-                       this->m_CurrentImage);
-       this->m_ImagesDeque->AddImageToRedoContainer(imgResult, region);
+void ImageUndoRedo::SetRedoImage(const ImageMManagerType* imMManager) {
+       /*RegionSType region = imMManager.GetModifiedRegion();
+        VTKImageDataPointerType imgResult = this->ImageMManagerType(region,
+        this->m_CurrentImage);
+        this->m_ImagesDeque->AddImageToRedoContainer(imgResult, imMManager);*/
 }
 
 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_OriginalImage);
-       imgResult = extract->GetOutput();
+       VTKImageDataPointerType imgResult = extract->GetOutput();
+       imgResult->Update();
        return (imgResult);
 }
 
@@ -68,17 +71,21 @@ void ImageUndoRedo::SetCurrentImage(VTKImageDataPointerType img) {
 //virtual
 void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo) {
        VTKImageDataPointerType img = imageInfo->GetImage();
-       if( img != NULL )
-       {
-               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);
+       RegionSType region = imageInfo->GetImageMManager()->GetModifiedRegion();
+       ImageMManager::PixelModMap map =
+                       imageInfo->GetImageMManager()->GetModificationMap();
+       std::cout << "Region " << "(" << region.maxX << "," << region.maxY << ","
+                       << region.maxZ << ")" << std::endl;
+       if (img != NULL) {
+               for (int i = region.minX, x = 0; i <= region.maxX; i++, x++) {
+                       for (int j = region.minY, y = 0; j <= region.maxY; j++, y++) {
+                               for (int k = region.minZ, z = 0; k <= region.maxZ; k++, z++) {
+                                       if (map[i][j][k]) {
+                                               float value = img->GetScalarComponentAsFloat(i, j, k,
+                                                               0);
+                                               this->m_CurrentImage->SetScalarComponentFromFloat(i, j,
+                                                               k, 0, value);
+                                       }
                                } //rof
                        } //rof
                } //rof
index 087fbe5d81073321c23e91bb43832a539c97eb7b..78ff99b2e2497ec3f7d00d268ecaee68f10c4ff9 100755 (executable)
 #include "managerUR.h"
 
 class ImageUndoRedo: public ManagerUR {
-
 public:
        ImageUndoRedo();
        virtual ~ImageUndoRedo();
        virtual void Undo();
        virtual void Redo();
        virtual void SetImage(VTKImageDataPointerType image);
-       virtual void SetUndoImage(const RegionSType& region);
-       virtual void SetRedoImage(const RegionSType& region);
+       virtual void SetUndoImage(ImageMManagerType* imMManager);
+       virtual void SetRedoImage(const ImageMManagerType* imMManager);
        void SetOriginalImage(VTKImageDataPointerType img);
        void SetCurrentImage(VTKImageDataPointerType img);
        VTKImageDataPointerType GetImageRegion(const RegionSType& region,
index e298e7981e35311347b1ce5ee3272ff3860601df..afd33b6ee5895e53c4a0ba0a1ffe3038961d1fd5 100755 (executable)
@@ -22,10 +22,10 @@ void ManagerUR::Undo() {
 void ManagerUR::Redo() {
 
 }
-void ManagerUR::SetUndoImage(const RegionSType& region) {
+void ManagerUR::SetUndoImage(ImageMManagerType* imMManager) {
 
 }
-void ManagerUR::SetRedoImage(const RegionSType& region) {
+void ManagerUR::SetRedoImage(ImageMManagerType* imMManager) {
 
 }
 void ManagerUR::DrawUR(ImageInfoUR imageInfo) {
index af4691157ebfb00058566d25b2c0a75f0e532a53..aae2158b4769263a60f0c388084dc17ddf4938d2 100755 (executable)
 #include <vtkExtractVOI.h>
 
 #include "image3DDequeUR.h"
+#include "imageModificationManager.h"
+#include "regionStructUR.h"
 
 class ManagerUR {
 public:
        typedef Image3DDequeUR IDequeType;
        typedef RegionStructUR RegionSType;
+       typedef ImageMManager ImageMManagerType;
        typedef vtkSmartPointer<vtkImageData> VTKImageDataPointerType;
        typedef vtkSmartPointer<vtkExtractVOI> VTKExtractVOIPointerType;
        typedef std::string StringType;
@@ -29,8 +32,8 @@ public:
        virtual void SetImage(vtkImageData *image);
        virtual void Undo();
        virtual void Redo();
-       virtual void SetUndoImage(const RegionSType& region);
-       virtual void SetRedoImage(const RegionSType& region);
+       virtual void SetUndoImage(ImageMManagerType* imMManager);
+       virtual void SetRedoImage(ImageMManagerType* imMManager);
 protected:
        virtual void DrawUR(ImageInfoUR imageInfo);
 
index 76e4a11ae173f9d20bae1a775dbecc061b15c39d..a6aac622aaf5dd5be9790436136e5f184ad403aa 100755 (executable)
@@ -8,17 +8,13 @@
 #ifndef REGIONSTRUCT_H_
 #define REGIONSTRUCT_H_
 
-#include <iostream>
-
-struct RegionStructUR{
+struct RegionStructUR {
        int minX;
        int maxX;
        int minY;
        int maxY;
        int minZ;
        int maxZ;
-       float value;
 };
 
-
 #endif /* REGIONSTRUCT_H_ */
index bdbd267d4bdc75a3424c09640b00b6e91342c9b5..785cdd7171b49cfe591aeb05f5312f905c22c3dc 100644 (file)
@@ -79,7 +79,6 @@ void BrushFilter::Run() // virtual
        if (_image != NULL)
        {
                float value = (float) _graylevel;
-               this->_MRegion->value = (float) _graylevel;
                int i, j, k;
 
                int size;
@@ -105,12 +104,12 @@ void BrushFilter::Run() // virtual
                                                zz = _pz - k;
                                                zz = zz * zz;
                                                if (_brushform == 0) {
-                                                       this->CalculateMinMaxRegion(i, j, k); //DFCH
+                                                       this->_IMManager->AddModifiedPixel(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
+                                                               this->_IMManager->AddModifiedPixel(i, j, k); //DFCH
                                                                _image->SetScalarComponentFromFloat(i, j, k, 0,
                                                                                value);
                                                        }
index 9dc1cb43686f4e2334b74b99411d9c3ba2019a2a..c12e1f9c89491bb8c249af66b52b131c00627638 100644 (file)
-
 #include "FillFilter.h"
 
-
-FillFilter::FillFilter()
-{
-    _tolerancefill      =   50;
-    _distancefill       =   500;
-    _limitRecursionFill =   50000;
-    _auxImageFill       =   NULL;
+FillFilter::FillFilter() {
+       _tolerancefill = 50;
+       _distancefill = 500;
+       _limitRecursionFill = 50000;
+       _auxImageFill = NULL;
 }
 
 //---------------------------------------------------------------------------
-FillFilter::~FillFilter()
-{
-    if (_auxImageFill!=NULL)
-    {
-        _auxImageFill->Delete();
-    }
+FillFilter::~FillFilter() {
+       if (_auxImageFill != NULL)
+       {
+               _auxImageFill->Delete();
+       }
 }
 
 //---------------------------------------------------------------------------
 void FillFilter::SetImage(vtkImageData *image) // virtual
-{
-    baseFilterManualPaint::SetImage(image);
-    if (_auxImageFill!=NULL)
-    {
-        _auxImageFill->Delete();
-    }
+               {
+       baseFilterManualPaint::SetImage(image);
+       if (_auxImageFill != NULL)
+       {
+               _auxImageFill->Delete();
+       }
        _auxImageFill = vtkImageData::New();
-       _auxImageFill->SetDimensions(_maxX+1,_maxY+1,_maxZ+1);
-       _auxImageFill->SetOrigin(0,0,0);
-       _auxImageFill->SetExtent( 0 , _maxX , 0 , _maxY , 0, _maxZ );
-       _auxImageFill->SetWholeExtent( 0 , _maxX , 0 , _maxY , 0, _maxZ );
+       _auxImageFill->SetDimensions(_maxX + 1, _maxY + 1, _maxZ + 1);
+       _auxImageFill->SetOrigin(0, 0, 0);
+       _auxImageFill->SetExtent(0, _maxX, 0, _maxY, 0, _maxZ);
+       _auxImageFill->SetWholeExtent(0, _maxX, 0, _maxY, 0, _maxZ);
        _auxImageFill->SetScalarTypeToUnsignedChar();
        _auxImageFill->AllocateScalars();
 }
 
-
 //---------------------------------------------------------------------------
 void FillFilter::Run() // virtual
 {
-    if ((_px>=_minX) && (_px<=_maxX) && (_py>=_minY) && (_py<=_maxY) && (_pz>=_minZ) && (_pz<=_maxZ))
-    {
-        _graylevelbasefill          = _image->GetScalarComponentAsDouble(_px,_py,_pz, 0);
-        _pxfill                     = _px;
-        _pyfill                     = _py;
-        _pzfill                     = _pz;
-        _distbasefill               = _distancefill*_distancefill;
-        _countRecursiveFill         = 0;
-        _countRecursiveFillProblem  = 0;
-        _countProgressingFill       = 0;
-        unsigned char *pImage = (unsigned char *)_auxImageFill->GetScalarPointer();
-        _usingAuxImageFill=false;
-        memset ( pImage , 0 , _maxX*_maxY*_maxZ );
-
-        FillToolRecursive(_px,_py,_pz);
-        printf("--\n");
-
-        int ii,jj,kk;
-        while (_countRecursiveFillProblem!=0)
-        {
-            _countRecursiveFillProblem  = 0;
-            _usingAuxImageFill=true;
-            for(ii=0;ii<=_maxX;ii++)
-            {
-                for(jj=0;jj<=_maxY;jj++)
-                {
-                    for(kk=0;kk<=_maxZ;kk++)
-                    {
-                        pImage=(unsigned char *)_auxImageFill->GetScalarPointer(ii,jj,kk);
-                        if ( (*pImage)==1 )
-                        {
-                            FillToolRecursive(ii,jj,kk);
-                        }
-                    } // for kk
-                } // for jj
-            } //for ii
-            printf("-\n");
-        } // while
-
-    } //if _minX _maxX _minY _maxY _minZ _maxZ
+       if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY)
+                       && (_pz >= _minZ) && (_pz <= _maxZ)) {
+               _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz,
+                               0);
+               _pxfill = _px;
+               _pyfill = _py;
+               _pzfill = _pz;
+               _distbasefill = _distancefill * _distancefill;
+               _countRecursiveFill = 0;
+               _countRecursiveFillProblem = 0;
+               _countProgressingFill = 0;
+               unsigned char *pImage =
+                               (unsigned char *) _auxImageFill->GetScalarPointer();
+               _usingAuxImageFill = false;
+               memset(pImage, 0, _maxX * _maxY * _maxZ);
+
+               FillToolRecursive(_px, _py, _pz);
+               printf("--\n");
+
+               int ii, jj, kk;
+               while (_countRecursiveFillProblem != 0) {
+                       _countRecursiveFillProblem = 0;
+                       _usingAuxImageFill = true;
+                       for (ii = 0; ii <= _maxX; ii++) {
+                               for (jj = 0; jj <= _maxY; jj++) {
+                                       for (kk = 0; kk <= _maxZ; kk++) {
+                                               pImage =
+                                                               (unsigned char *) _auxImageFill->GetScalarPointer(
+                                                                               ii, jj, kk);
+                                               if ((*pImage) == 1) {
+                                                       FillToolRecursive(ii, jj, kk);
+                                               }
+                                       } // for kk
+                               } // for jj
+                       } //for ii
+                       printf("-\n");
+               } // while
+
+       } //if _minX _maxX _minY _maxY _minZ _maxZ
 }
 
-
 //---------------------------------------------------------------------------
-void FillFilter::FillToolRecursive(int px,int py, int pz)
-{
-       this->_MRegion->value = (float) _graylevel;
-    _countRecursiveFill++;
-
-    _countProgressingFill++;
-    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)
-        {
-               this->CalculateMinMaxRegion(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);
-
-        float grayLBFMTOL = _graylevelbasefill-_tolerancefill;
-        float grayLBFPTOL = _graylevelbasefill+_tolerancefill;
-        bool isInRange = false;
-        //DFCH
-        if( _RangeMin <= grayLBFMTOL && _RangeMax >= grayLBFPTOL )
-        {
-               isInRange = true;
-        }//fi esle
-        else if( _RangeMin > grayLBFMTOL && _RangeMax >= grayLBFPTOL )
-        {
-               grayLBFMTOL = _RangeMin;
-               isInRange = true;
-        }//fi esle
-        else if( _RangeMin <= grayLBFMTOL && _RangeMax < grayLBFPTOL )
-        {
-               grayLBFPTOL = _RangeMax;
-               isInRange = true;
-        }//fi esle
-        else if(  ( _RangeMin <= _graylevelbasefill ) && ( _graylevelbasefill <= _RangeMax ) )
-        {
-               grayLBFMTOL = _RangeMin;
-               grayLBFPTOL = _RangeMax;
-               isInRange = true;
-        }//fi esle
-
-        if( isInRange )
-        {
-               _auxGrayLevelValidationFill =  (_tmpiglfill!=_graylevel) &&
-                                           (_tmpiglfill>=grayLBFMTOL) &&
-                                           (_tmpiglfill<=grayLBFPTOL) &&
-                                           (_tmpDistfill<=_distbasefill); //DFCH
-        }//fi
-        else
-        {
-               _auxGrayLevelValidationFill = false;
-        }//esle
-        //DFCH
-        /*_auxGrayLevelValidationFill =   (_tmpiglfill!=_graylevel) &&
-                                        (_tmpiglfill>=_graylevelbasefill-_tolerancefill) &&
-                                        (_tmpiglfill<=_graylevelbasefill+_tolerancefill) &&
-                                        (_tmpDistfill<=_distbasefill);*/ //DFCH
-
-
-        if (  _auxGrayLevelValidationFill==true )
-        {
-               this->CalculateMinMaxRegion(px,py,pz); //DFCH
-            _image->SetScalarComponentFromFloat (px,py,pz, 0, (float)_graylevel );
-
-            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);
-                        FillToolRecursive(px,py-1,pz);
-                        FillToolRecursive(px,py,pz-1);
-                        FillToolRecursive(px,py,pz+1);
-                    }
-                    if (_direction==1) // XZ
-                    {
-                        FillToolRecursive(px+1,py,pz);
-                        FillToolRecursive(px-1,py,pz);
-                        //FillToolRecursive(px,py+1,pz);
-                        //FillToolRecursive(px,py-1,pz);
-                        FillToolRecursive(px,py,pz-1);
-                        FillToolRecursive(px,py,pz+1);
-                    }
-                    if (_direction==2) // XY
-                    {
-                        FillToolRecursive(px+1,py,pz);
-                        FillToolRecursive(px,py+1,pz);
-                        FillToolRecursive(px-1,py,pz);
-                        FillToolRecursive(px,py-1,pz);
-                        //FillToolRecursive(px,py,pz-1);
-                        //FillToolRecursive(px,py,pz+1);
-                    }
-                } else  {   // 3D
-
-                    FillToolRecursive(px+1,py,pz);
-                    FillToolRecursive(px-1,py,pz);
-                    FillToolRecursive(px,py+1,pz);
-                    FillToolRecursive(px,py-1,pz);
-                    FillToolRecursive(px,py,pz-1);
-                    FillToolRecursive(px,py,pz+1);
-                } // 2D 3D
-
-            } //_countRecursiveFill
-        } // _graylevel
-
-
-        if (  (_auxGrayLevelValidationFill==true ) &&
-              (_countRecursiveFill>= _limitRecursionFill)
-            )
-        {
-            _countRecursiveFillProblem++;
-
-                if (_2D3D==0) //2D
-                {
-                    if (_direction==0)  // YZ
-                    {
-                        //SetAuxImageFill(px+1,py,pz);
-                        //SetAuxImageFill(px-1,py,pz);
-                        SetAuxImageFill(px,py+1,pz);
-                        SetAuxImageFill(px,py-1,pz);
-                        SetAuxImageFill(px,py,pz-1);
-                        SetAuxImageFill(px,py,pz+1);
-                    }
-                    if (_direction==1) // XZ
-                    {
-                        SetAuxImageFill(px+1,py,pz);
-                        SetAuxImageFill(px-1,py,pz);
-                        //SetAuxImageFill(px,py+1,pz);
-                        //SetAuxImageFill(px,py-1,pz);
-                        SetAuxImageFill(px,py,pz-1);
-                        SetAuxImageFill(px,py,pz+1);
-                    }
-                    if (_direction==2) // XY
-                    {
-                        SetAuxImageFill(px+1,py,pz);
-                        SetAuxImageFill(px-1,py,pz);
-                        SetAuxImageFill(px,py+1,pz);
-                        SetAuxImageFill(px,py-1,pz);
-                        //SetAuxImageFill(px,py,pz-1);
-                        //SetAuxImageFill(px,py,pz+1);
-                    }
-                } else  {   // 3D
-
-                    SetAuxImageFill(px+1,py,pz);
-                    SetAuxImageFill(px-1,py,pz);
-                    SetAuxImageFill(px,py+1,pz);
-                    SetAuxImageFill(px,py-1,pz);
-                    SetAuxImageFill(px,py,pz-1);
-                    SetAuxImageFill(px,py,pz+1);
-                } // 2D 3D
-
-        } // _graylevel   //_limitRecursionFill
-
-
-    } //if _minX _maxX _minY _maxY _minZ _maxZ
-
-
-    _countRecursiveFill--;
+void FillFilter::FillToolRecursive(int px, int py, int pz) {
+       _countRecursiveFill++;
+
+       _countProgressingFill++;
+       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) {
+                       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);
+
+               float grayLBFMTOL = _graylevelbasefill - _tolerancefill;
+               float grayLBFPTOL = _graylevelbasefill + _tolerancefill;
+               bool isInRange = false;
+               //DFCH
+               if (_RangeMin <= grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
+                       isInRange = true;
+               } //fi esle
+               else if (_RangeMin > grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
+                       grayLBFMTOL = _RangeMin;
+                       isInRange = true;
+               } //fi esle
+               else if (_RangeMin <= grayLBFMTOL && _RangeMax < grayLBFPTOL) {
+                       grayLBFPTOL = _RangeMax;
+                       isInRange = true;
+               } //fi esle
+               else if ((_RangeMin <= _graylevelbasefill)
+                               && (_graylevelbasefill <= _RangeMax)) {
+                       grayLBFMTOL = _RangeMin;
+                       grayLBFPTOL = _RangeMax;
+                       isInRange = true;
+               } //fi esle
+
+               if (isInRange) {
+                       _auxGrayLevelValidationFill = (_tmpiglfill != _graylevel)
+                                       && (_tmpiglfill >= grayLBFMTOL)
+                                       && (_tmpiglfill <= grayLBFPTOL)
+                                       && (_tmpDistfill <= _distbasefill); //DFCH
+               } //fi
+               else {
+                       _auxGrayLevelValidationFill = false;
+               } //esle
+                 //DFCH
+               /*_auxGrayLevelValidationFill =   (_tmpiglfill!=_graylevel) &&
+                (_tmpiglfill>=_graylevelbasefill-_tolerancefill) &&
+                (_tmpiglfill<=_graylevelbasefill+_tolerancefill) &&
+                (_tmpDistfill<=_distbasefill);*/ //DFCH
+               if (_auxGrayLevelValidationFill == true) {
+                       this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
+                       _image->SetScalarComponentFromFloat(px, py, pz, 0,
+                                       (float) _graylevel);
+
+                       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);
+                                               FillToolRecursive(px, py - 1, pz);
+                                               FillToolRecursive(px, py, pz - 1);
+                                               FillToolRecursive(px, py, pz + 1);
+                                       }
+                                       if (_direction == 1) // XZ
+                                                       {
+                                               FillToolRecursive(px + 1, py, pz);
+                                               FillToolRecursive(px - 1, py, pz);
+                                               //FillToolRecursive(px,py+1,pz);
+                                               //FillToolRecursive(px,py-1,pz);
+                                               FillToolRecursive(px, py, pz - 1);
+                                               FillToolRecursive(px, py, pz + 1);
+                                       }
+                                       if (_direction == 2) // XY
+                                                       {
+                                               FillToolRecursive(px + 1, py, pz);
+                                               FillToolRecursive(px, py + 1, pz);
+                                               FillToolRecursive(px - 1, py, pz);
+                                               FillToolRecursive(px, py - 1, pz);
+                                               //FillToolRecursive(px,py,pz-1);
+                                               //FillToolRecursive(px,py,pz+1);
+                                       }
+                               } else { // 3D
+
+                                       FillToolRecursive(px + 1, py, pz);
+                                       FillToolRecursive(px - 1, py, pz);
+                                       FillToolRecursive(px, py + 1, pz);
+                                       FillToolRecursive(px, py - 1, pz);
+                                       FillToolRecursive(px, py, pz - 1);
+                                       FillToolRecursive(px, py, pz + 1);
+                               } // 2D 3D
+
+                       } //_countRecursiveFill
+               } // _graylevel
+
+               if ((_auxGrayLevelValidationFill == true)
+                               && (_countRecursiveFill >= _limitRecursionFill)) {
+                       _countRecursiveFillProblem++;
+
+                       if (_2D3D == 0) //2D
+                                       {
+                               if (_direction == 0) // YZ
+                                               {
+                                       //SetAuxImageFill(px+1,py,pz);
+                                       //SetAuxImageFill(px-1,py,pz);
+                                       SetAuxImageFill(px, py + 1, pz);
+                                       SetAuxImageFill(px, py - 1, pz);
+                                       SetAuxImageFill(px, py, pz - 1);
+                                       SetAuxImageFill(px, py, pz + 1);
+                               }
+                               if (_direction == 1) // XZ
+                                               {
+                                       SetAuxImageFill(px + 1, py, pz);
+                                       SetAuxImageFill(px - 1, py, pz);
+                                       //SetAuxImageFill(px,py+1,pz);
+                                       //SetAuxImageFill(px,py-1,pz);
+                                       SetAuxImageFill(px, py, pz - 1);
+                                       SetAuxImageFill(px, py, pz + 1);
+                               }
+                               if (_direction == 2) // XY
+                                               {
+                                       SetAuxImageFill(px + 1, py, pz);
+                                       SetAuxImageFill(px - 1, py, pz);
+                                       SetAuxImageFill(px, py + 1, pz);
+                                       SetAuxImageFill(px, py - 1, pz);
+                                       //SetAuxImageFill(px,py,pz-1);
+                                       //SetAuxImageFill(px,py,pz+1);
+                               }
+                       } else { // 3D
+
+                               SetAuxImageFill(px + 1, py, pz);
+                               SetAuxImageFill(px - 1, py, pz);
+                               SetAuxImageFill(px, py + 1, pz);
+                               SetAuxImageFill(px, py - 1, pz);
+                               SetAuxImageFill(px, py, pz - 1);
+                               SetAuxImageFill(px, py, pz + 1);
+                       } // 2D 3D
+
+               } // _graylevel   //_limitRecursionFill
+
+       } //if _minX _maxX _minY _maxY _minZ _maxZ
+
+       _countRecursiveFill--;
 
 }
 
 //---------------------------------------------------------------------------
-void FillFilter::SetAuxImageFill(int px,int py, int pz)
-{
-    if ((px>=_minX) && (px<=_maxX) && (py>=_minY) && (py<=_maxY) && (pz>=_minZ) && (pz<=_maxZ))
-    {
-       this->CalculateMinMaxRegion(px,py,pz); //DFCH
-        _auxImageFill->SetScalarComponentFromFloat (px, py, pz,0, 1);
-    }
+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
+               _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 1);
+       }
 }
 
-
 //---------------------------------------------------------------------------
-void FillFilter::SetToleranceFill(double tolerancefill)
-{
-    _tolerancefill = tolerancefill;
+void FillFilter::SetToleranceFill(double tolerancefill) {
+       _tolerancefill = tolerancefill;
 }
 
 //---------------------------------------------------------------------------
-void FillFilter::SetDistanceFill(int distancefill)
-{
-    _distancefill = distancefill;
+void FillFilter::SetDistanceFill(int distancefill) {
+       _distancefill = distancefill;
 }
 
 //---------------------------------------------------------------------------
-void FillFilter::SetRangeMin(  int min )
-{
-       _RangeMin  = min;
+void FillFilter::SetRangeMin(int min) {
+       _RangeMin = min;
 }
 
 //---------------------------------------------------------------------------
-void FillFilter::SetRangeMax(  int max )
-{
-       _RangeMax  = max;
+void FillFilter::SetRangeMax(int max) {
+       _RangeMax = max;
 }
 
 //---------------------------------------------------------------------------
-int FillFilter::GetRangeMin( )
-{
-       return( _RangeMin );
+int FillFilter::GetRangeMin() {
+       return (_RangeMin);
 }
 
 //---------------------------------------------------------------------------
-int FillFilter::GetRangeMax(  )
-{
-       return( _RangeMax );
+int FillFilter::GetRangeMax() {
+       return (_RangeMax);
 }
index 7e7a1fa2adcaedb0f312d10c1ffc736f80f476b2..eec9a1ba950f10f90f6d2911e20d82f130cca1a9 100644 (file)
@@ -40,7 +40,6 @@ void ManualPaintModel::Set2D3D(int dim2D3D) {
 void ManualPaintModel::SetImage(vtkImageData *image) {
        _brushfilter->SetImage(image);
        _fillfilter->SetImage(image);
-       std::cout<<"setIMAAAAAAGEEEEEE"<<std::endl;
        _imageUndoRedo->SetImage(image);
 }
 
@@ -93,16 +92,16 @@ void ManualPaintModel::GetScalarRange(double * range) {
 }
 //---------------------------------------------------------------------------
 void ManualPaintModel::SetUndoImage() {
-       RegionStructUR* region = NULL;
+       ImageMManager* imMManager = NULL;
        if (_tool == 0) {
-               region = this->_brushfilter->GetModifiedRegion();
+               imMManager = this->_brushfilter->GetImageMManager();
        }
        if (_tool == 1) {
-               region = this->_fillfilter->GetModifiedRegion();
+               imMManager = this->_fillfilter->GetImageMManager();
        }
-       this->_imageUndoRedo->SetUndoImage((*region));
-       this->_brushfilter->CleanModifiedRegion();
-       this->_fillfilter->CleanModifiedRegion();
+       this->_imageUndoRedo->SetUndoImage(imMManager);
+       this->_brushfilter->CleanImageMManager();
+       this->_fillfilter->CleanImageMManager();
 }
 //---------------------------------------------------------------------------
 
index 93adac962337fc698c78ceeaa3c62668c158f668..06d3142db77f6e26ce60888d6dd550c0beab7f52 100644 (file)
@@ -3,40 +3,38 @@
 
 #include "BrushFilter.h"
 #include "FillFilter.h"
-#include "regionStructUR.h"
+#include "imageModificationManager.h"
 #include "imageUndoRedo.h"
 
-class ManualPaintModel  {
+class ManualPaintModel {
 public:
        ManualPaintModel();
        virtual ~ManualPaintModel();
 
-    void SetTool( int tool );
-    void Set2D3D( int dim2D3D );
-    void SetImage(vtkImageData *image);
-    void SetGrayLevel( double graylevel );
-    void SetDirection(int direction);
-    void SetBrushSize( int brushsize );
-    void SetBrushForm( int brushform );
-    void SetToleranceFill(double tolerancefill);
-    void SetDistanceFill(int distancefill);
-    void PaintImage(int px,int py, int pz);
-    void SetRangeMin( int min );
-    void SetRangeMax( int max );
-    void GetScalarRange( double * range );
-    void SetUndoImage();//DFCH
-    void Undo();//DFCH
-
+       void SetTool(int tool);
+       void Set2D3D(int dim2D3D);
+       void SetImage(vtkImageData *image);
+       void SetGrayLevel(double graylevel);
+       void SetDirection(int direction);
+       void SetBrushSize(int brushsize);
+       void SetBrushForm(int brushform);
+       void SetToleranceFill(double tolerancefill);
+       void SetDistanceFill(int distancefill);
+       void PaintImage(int px, int py, int pz);
+       void SetRangeMin(int min);
+       void SetRangeMax(int max);
+       void GetScalarRange(double * range);
+       void SetUndoImage(); //DFCH
+       void Undo(); //DFCH
 
 private:
-    int             _tool;
-    BrushFilter     *_brushfilter;
-    FillFilter      *_fillfilter;
-       ImageUndoRedo   *_imageUndoRedo;
+       int _tool;
+       BrushFilter *_brushfilter;
+       FillFilter *_fillfilter;
+       ImageUndoRedo *_imageUndoRedo;
 
 protected:
 
 };
 
-
 #endif // _MANUAL_PAINT_MODEL_H_
index e6b2fd85b2302a9481ebdb15240da3f1a68b4cfa..67bda4fa6f2e7147b72799b8d66d0b9599052689 100644 (file)
@@ -1,8 +1,8 @@
 #include "baseFilterManualPaint.h"
 
 baseFilterManualPaint::baseFilterManualPaint() {
-       _MRegion = new RegionStructUR();
-       CleanModifiedRegion();
+       _IMManager = new ImageMManager();
+       _IMManager->CleanModifiedRegion();
        _graylevel = 0.0;
        _2D3D = 1; // 0 2D             ,   1 true 3D
        _direction = 0; // 1 XZ             ,   0 YZ            ,   2 XY
@@ -110,38 +110,10 @@ void baseFilterManualPaint::GetScalarRange(double * range) {
        range = this->_image->GetScalarRange();
 }
 
-RegionStructUR* baseFilterManualPaint::GetModifiedRegion() {
-       return (this->_MRegion);
+ImageMManager* baseFilterManualPaint::GetImageMManager() {
+       return (this->_IMManager);
 } //DFCH
-void baseFilterManualPaint::CleanModifiedRegion() {
-       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;
+void baseFilterManualPaint::CleanImageMManager() {
+       this->_IMManager->CleanModifiedRegion();
 } //DFCH
-void baseFilterManualPaint::CalculateMinMaxRegion(const int& i, const int& j,
-               const int& k) {
-       if (i <= this->_MRegion->minX) {
-               this->_MRegion->minX = i;
-       } //fi
-       if (i > this->_MRegion->maxX) {
-               this->_MRegion->maxX = i;
-       } //esle
-       if (j <= this->_MRegion->minY) {
-               this->_MRegion->minY = j;
-       } //fi
-       if (j > this->_MRegion->maxY) {
-               this->_MRegion->maxY = j;
-       } //esle
-       if (k <= this->_MRegion->minZ) {
-               this->_MRegion->minZ = k;
-       } //fi
-       if (k > this->_MRegion->maxZ) {
-               this->_MRegion->maxZ = k;
-       } //esle
-}
 
index 71e53988eea3a960a563f9fed2235ea85f6342a4..f2406be7de51df235d04df0325808df71c91a1bc 100644 (file)
@@ -2,51 +2,50 @@
 #define _BASE_FILTER_MANUAL_PAINT_H_
 
 #include <vtkImageData.h>
-#include <limits>
-#include "regionStructUR.h"
+#include "imageModificationManager.h"
 
-class baseFilterManualPaint  {
+class baseFilterManualPaint {
 
-    public:
-        baseFilterManualPaint();
-        virtual ~baseFilterManualPaint();
+public:
+       baseFilterManualPaint();
+       virtual ~baseFilterManualPaint();
 
-        virtual void SetImage(vtkImageData *image);
-        void SetPoint(int px,int py, int pz);
-        void Set2D3D( int dim2D3D );
-        void SetGrayLevel( double graylevel );
-        void SetDirection(int direction);
-        void ResetGeneralMinMax();
-        void SetGeneralMinMax(int minX,int maxX,int minY,int maxY,int minZ,int maxZ);
-        void GetScalarRange( double * range );
-        RegionStructUR* GetModifiedRegion();//DFCH
-        void CleanModifiedRegion();//DFCH
-        void CalculateMinMaxRegion( const int& i, const int& j, const int& k);//DFCH
-        virtual void Run();
+       virtual void SetImage(vtkImageData *image);
+       void SetPoint(int px, int py, int pz);
+       void Set2D3D(int dim2D3D);
+       void SetGrayLevel(double graylevel);
+       void SetDirection(int direction);
+       void ResetGeneralMinMax();
+       void SetGeneralMinMax(int minX, int maxX, int minY, int maxY, int minZ,
+                       int maxZ);
+       void GetScalarRange(double * range);
+       ImageMManager* GetImageMManager(); //DFCH
+       void CleanImageMManager(); //DFCH
+       virtual void Run();
 
-    private:
+private:
 
-    protected:
-        RegionStructUR *_MRegion; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
-        vtkImageData    *_image;
-        int             _direction;
-        int            _px;    // start point of the brush
-        int            _py;
-        int            _pz;
-        int            _pMinX;  // General min max of many brush actions
-        int            _pMinY;
-        int            _pMinZ;
-        int            _pMaxX;
-        int            _pMaxY;
-        int            _pMaxZ;
-        int             _minX;   // min max of the image
-        int             _maxX;
-        int             _minY;
-        int             _maxY;
-        int             _minZ;
-        int             _maxZ;
-        bool            _2D3D;
-        double          _graylevel;
+protected:
+       ImageMManager *_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
+       vtkImageData *_image;
+       int _direction;
+       int _px; // start point of the brush
+       int _py;
+       int _pz;
+       int _pMinX; // General min max of many brush actions
+       int _pMinY;
+       int _pMinZ;
+       int _pMaxX;
+       int _pMaxY;
+       int _pMaxZ;
+       int _minX; // min max of the image
+       int _maxX;
+       int _minY;
+       int _maxY;
+       int _minZ;
+       int _maxZ;
+       bool _2D3D;
+       double _graylevel;
 };
 
 #endif // _BASE_FILTER_MANUAL_PAINT_H_