]> Creatis software - clitk.git/blob - vv/vvImageContour.h
- add mechanism to stop callback if nothing change (far from perfect)
[clitk.git] / vv / vvImageContour.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef VVIMAGECONTOUR_H
19 #define VVIMAGECONTOUR_H
20
21 #include "clitkCommon.h"
22 #include "vvSlicer.h"
23
24 class vtkImageClip;
25 class vtkMarchingSquares;
26 class vtkActor;
27 class vvImage;
28
29 //------------------------------------------------------------------------------
30 class vvImageContour
31 {
32   //  Q_OBJECT
33  public:
34   vvImageContour();
35   ~vvImageContour();
36
37   void setSlicer(vvSlicer * slicer);
38   void update(double value);
39   void hideActors();
40   void showActors();
41   void setColor(double r, double g, double b);
42   void setImage(vvImage::Pointer image);
43   void setPreserveMemoryModeEnabled(bool b);
44
45  protected:
46   vvSlicer * mSlicer;
47   int mSlice;
48   int mTSlice;
49   double mValue;
50   int mPreviousTSlice;
51   double mPreviousValue;
52   bool mHiddenImageIsUsed;
53   vvImage::Pointer mHiddenImage;
54   bool mDisplayModeIsPreserveMemory;
55
56   // For preserveMemory mode
57   std::vector<vtkImageClip*> mClipperList;
58   std::vector<vtkMarchingSquares*> mSquaresList;
59   std::vector<vtkActor*> mSquaresActorList;
60
61   // For fast cache mode
62   int mPreviousSlice;
63   int mPreviousOrientation;
64   std::vector<std::vector<vtkActor*> > mListOfCachedContourActors;
65
66   // Functions
67   void initializeCacheMode();
68   void updateWithPreserveMemoryMode();
69   void updateWithFastCacheMode();
70   void createNewActor(vtkActor ** actor, 
71                       vtkMarchingSquares ** squares, 
72                       vtkImageClip ** clipper, int numImage);
73   void updateActor(vtkActor * actor, 
74                    vtkMarchingSquares * squares,
75                    vtkImageClip * clipper, 
76                    int threshold, int orientation, int slice);
77   void createActor(int orientation, int slice);
78   int computeCurrentOrientation();
79   
80 }; // end class vvImageContour
81 //------------------------------------------------------------------------------
82
83 #endif
84