]> Creatis software - clitk.git/commitdiff
Add smartpointer for vtk objects
authordsarrut <dsarrut>
Thu, 10 Mar 2011 15:56:02 +0000 (15:56 +0000)
committerdsarrut <dsarrut>
Thu, 10 Mar 2011 15:56:02 +0000 (15:56 +0000)
vv/vvBinaryImageOverlayActor.cxx
vv/vvBinaryImageOverlayActor.h
vv/vvImageContour.cxx
vv/vvImageContour.h

index 907bcb6bb18b4292e35e9c0102d3c1cc13c2e19a..128b19b6056ad0fe667394852e518c7a55ca2de4 100644 (file)
@@ -38,7 +38,7 @@ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor()
   mAlpha = 0.6;
   mImage = 0;
   mSlicer = 0;
-  mColorLUT = vtkLookupTable::New();
+  mColorLUT = vtkSmartPointer<vtkLookupTable>::New();
   mForegroundValue = 1;
   mBackgroundValue = 0;
   m_modeBG = true;
@@ -52,8 +52,8 @@ vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor()
   for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) {
     mSlicer->GetRenderer()->RemoveActor(mImageActorList[i]);
   }
-  mImageActorList.clear();
   mMapperList.clear();
+  mImageActorList.clear();
 }
 //------------------------------------------------------------------------------
 
@@ -91,7 +91,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
   // Create an actor for each time slice
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
     // how many intensity ?
-    vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New();
+    vtkSmartPointer<vtkImageMapToRGBA> mOverlayMapper = vtkSmartPointer<vtkImageMapToRGBA>::New();
     mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!!
 
     double range[2];
@@ -117,7 +117,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
 
     mOverlayMapper->SetLookupTable(mColorLUT);
 
-    vtkImageActor * mOverlayActor = vtkImageActor::New();
+    vtkSmartPointer<vtkImageActor> mOverlayActor = vtkSmartPointer<vtkImageActor>::New();
     mOverlayActor->SetInput(mOverlayMapper->GetOutput());
     mOverlayActor->SetPickable(0);
     mOverlayActor->SetVisibility(IsVisible);
@@ -174,7 +174,7 @@ void vvBinaryImageOverlayActor::SetOpacity(double d)
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG)
+void vvBinaryImageOverlayActor::SetImage(vvImage * image, double bg, bool modeBG)
 {
   mImage = image;
   if (modeBG) {
index eb8a3ad66aee787dd37f004e11d64f9fdab0ce96..5893158fa3472c670894a5a06a0600c656d12f29 100644 (file)
@@ -39,7 +39,7 @@ class vvBinaryImageOverlayActor
   void SetSlicer(vvSlicer * slicer);
   void SetColor(double r, double g, double b);
   void SetOpacity(double d);
-  void SetImage(vvImage::Pointer image, double bg, bool modeBG=true);
+  void SetImage(vvImage * image, double bg, bool modeBG=true);
   void Initialize(bool IsVisible=true);
   void UpdateColor();
   void UpdateSlice(int slicer, int slice);
@@ -52,16 +52,16 @@ class vvBinaryImageOverlayActor
   int mTSlice;
   int mPreviousTSlice;
   int mPreviousSlice;
-  vvImage::Pointer mImage;
+  vvImage * mImage;
   std::vector<double> mColor;
   double mAlpha;
   double mBackgroundValue;
   double mForegroundValue;
   bool m_modeBG;
-  vtkLookupTable * mColorLUT;
+  vtkSmartPointer<vtkLookupTable> mColorLUT;
 
-  std::vector<vtkImageMapToRGBA *> mMapperList;
-  std::vector<vtkImageActor*> mImageActorList;
+  std::vector<vtkSmartPointer<vtkImageMapToRGBA> > mMapperList;
+  std::vector<vtkSmartPointer<vtkImageActor> > mImageActorList;
 
   void ComputeExtent(int orientation, 
                     int slice, 
index 56a91203b1a8609bf4e8465d34cd01e5996bcd1b..5e50b06fd4032655e8eb2841c46e64263eea18fa 100644 (file)
@@ -45,9 +45,9 @@ vvImageContour::~vvImageContour()
   for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) {
     mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]);
   }
 mSquaresActorList.clear();
 mSquaresList.clear();
 mClipperList.clear();
+ mSquaresActorList.clear();
+ mSquaresList.clear();
+ mClipperList.clear();
 }
 //------------------------------------------------------------------------------
 
@@ -57,9 +57,9 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) {
   mSlicer = slicer;  
   // Create an actor for each time slice
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
-    vtkImageClip * mClipper = vtkImageClip::New();
-    vtkMarchingSquares * mSquares = vtkMarchingSquares::New();
-    vtkActor * mSquaresActor = vtkActor::New();
+    vtkImageClip * mClipper;// = vtkImageClip::New();
+    vtkMarchingSquares * mSquares;// = vtkMarchingSquares::New();
+    vtkActor * mSquaresActor;// = vtkActor::New();
     CreateNewActor(&mSquaresActor, &mSquares, &mClipper, numImage);
     mSquaresActorList.push_back(mSquaresActor);
     mSquaresList.push_back(mSquares);
@@ -70,7 +70,7 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::SetImage(vvImage::Pointer image) {
+void vvImageContour::SetImage(vvImage * image) {
   for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) {
     mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]);
   }
@@ -197,6 +197,7 @@ void vvImageContour::UpdateWithPreserveMemoryMode() {
 
 //------------------------------------------------------------------------------
 void vvImageContour::InitializeCacheMode() {
+clitkExceptionMacro("TODO : not implemented yet");
   mPreviousSlice = mPreviousOrientation = 0;
   int dim = mSlicer->GetImage()->GetNumberOfDimensions();
 
@@ -232,6 +233,8 @@ int vvImageContour::ComputeCurrentOrientation() {
 
 //------------------------------------------------------------------------------
 void vvImageContour::UpdateWithFastCacheMode() {
+clitkExceptionMacro("TODO : not implemented yet");
+
   // Compute orientation
   int orientation = ComputeCurrentOrientation();
 
@@ -263,10 +266,10 @@ void vvImageContour::CreateNewActor(vtkActor ** actor,
                                     vtkMarchingSquares ** squares, 
                                     vtkImageClip ** clipper, 
                                     int numImage) {
-  vtkActor * mSquaresActor = (*actor = vtkActor::New());
-  vtkImageClip * mClipper = (*clipper = vtkImageClip::New());
-  vtkMarchingSquares * mSquares = (*squares = vtkMarchingSquares::New());
-  vtkPolyDataMapper * mSquaresMapper = vtkPolyDataMapper::New();
+  vtkSmartPointer<vtkActor> mSquaresActor = (*actor = vtkSmartPointer<vtkActor>::New());
+  vtkSmartPointer<vtkImageClip> mClipper = (*clipper = vtkSmartPointer<vtkImageClip>::New());
+  vtkSmartPointer<vtkMarchingSquares> mSquares = (*squares = vtkSmartPointer<vtkMarchingSquares>::New());
+  vtkSmartPointer<vtkPolyDataMapper> mSquaresMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
 
   if (mHiddenImageIsUsed)
     mClipper->SetInput(mHiddenImage->GetVTKImages()[0]);
index d93a3f343b29ffbe1e0339903b935fc30984a1fd..66473d37320063b456d9481c379f32e9f77d0476 100644 (file)
@@ -40,7 +40,7 @@ class vvImageContour
   void ShowActors();
   void SetColor(double r, double g, double b);
   void SetLineWidth(double w);
-  void SetImage(vvImage::Pointer image);
+  void SetImage(vvImage * image);
   void SetPreserveMemoryModeEnabled(bool b);
 
  protected:
@@ -51,13 +51,13 @@ class vvImageContour
   int mPreviousTSlice;
   double mPreviousValue;
   bool mHiddenImageIsUsed;
-  vvImage::Pointer mHiddenImage;
+  vvImage * mHiddenImage;
   bool mDisplayModeIsPreserveMemory;
 
   // For preserveMemory mode
-  std::vector<vtkImageClip*> mClipperList;
-  std::vector<vtkMarchingSquares*> mSquaresList;
-  std::vector<vtkActor*> mSquaresActorList;
+  std::vector<vtkSmartPointer<vtkImageClip> > mClipperList;
+  std::vector<vtkSmartPointer<vtkMarchingSquares> > mSquaresList;
+  std::vector<vtkSmartPointer<vtkActor> > mSquaresActorList;
 
   // For fast cache mode
   int mPreviousSlice;
@@ -70,7 +70,8 @@ class vvImageContour
   void UpdateWithFastCacheMode();
   void CreateNewActor(vtkActor ** actor, 
                      vtkMarchingSquares ** squares, 
-                     vtkImageClip ** clipper, int numImage);
+                      vtkImageClip ** clipper, 
+                      int numImage);
   void UpdateActor(vtkActor * actor, 
                   vtkMarchingSquares * squares,
                   vtkImageClip * clipper,