]> Creatis software - clitk.git/blob - vv/vvImageContour.h
- correct crop 2D bug
[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 setPreserveModeEnabled(bool b);
44
45  protected:
46   vvSlicer * mSlicer;
47   int mSlice;
48   int mTSlice;
49   double mValue;
50   bool mHiddenImageIsUsed;
51   vvImage::Pointer mHiddenImage;
52   bool mDisplayModeIsPreserveMemory;
53
54   // For preserveMemory mode
55   std::vector<vtkImageClip*> mClipperList;
56   std::vector<vtkMarchingSquares*> mSquaresList;
57   std::vector<vtkActor*> mSquaresActorList;
58
59   // For fast cache mode
60   int mPreviousSlice;
61   int mPreviousOrientation;
62   std::vector<std::vector<vtkActor*> > mListOfCachedContourActors;
63
64   // Functions
65   void initializeCacheMode();
66   void updateWithPreserveMemoryMode();
67   void updateWithFastCacheMode();
68   void createNewActor(vtkActor ** actor, 
69                       vtkMarchingSquares ** squares, 
70                       vtkImageClip ** clipper);
71   void updateActor(vtkActor * actor, 
72                    vtkMarchingSquares * squares,
73                    vtkImageClip * clipper, 
74                    int threshold, int orientation, int slice);
75   void createActor(int orientation, int slice);
76   int computeCurrentOrientation();
77   
78 }; // end class vvImageContour
79 //------------------------------------------------------------------------------
80
81 #endif
82