From 19293142fbe7d12bfbaec385e9384a14655c41b8 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Thu, 10 Mar 2011 15:56:02 +0000 Subject: [PATCH] Add smartpointer for vtk objects --- vv/vvBinaryImageOverlayActor.cxx | 10 +++++----- vv/vvBinaryImageOverlayActor.h | 10 +++++----- vv/vvImageContour.cxx | 25 ++++++++++++++----------- vv/vvImageContour.h | 13 +++++++------ 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index 907bcb6..128b19b 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -38,7 +38,7 @@ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor() mAlpha = 0.6; mImage = 0; mSlicer = 0; - mColorLUT = vtkLookupTable::New(); + mColorLUT = vtkSmartPointer::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 mOverlayMapper = vtkSmartPointer::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 mOverlayActor = vtkSmartPointer::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) { diff --git a/vv/vvBinaryImageOverlayActor.h b/vv/vvBinaryImageOverlayActor.h index eb8a3ad..5893158 100644 --- a/vv/vvBinaryImageOverlayActor.h +++ b/vv/vvBinaryImageOverlayActor.h @@ -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 mColor; double mAlpha; double mBackgroundValue; double mForegroundValue; bool m_modeBG; - vtkLookupTable * mColorLUT; + vtkSmartPointer mColorLUT; - std::vector mMapperList; - std::vector mImageActorList; + std::vector > mMapperList; + std::vector > mImageActorList; void ComputeExtent(int orientation, int slice, diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 56a9120..5e50b06 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -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 mSquaresActor = (*actor = vtkSmartPointer::New()); + vtkSmartPointer mClipper = (*clipper = vtkSmartPointer::New()); + vtkSmartPointer mSquares = (*squares = vtkSmartPointer::New()); + vtkSmartPointer mSquaresMapper = vtkSmartPointer::New(); if (mHiddenImageIsUsed) mClipper->SetInput(mHiddenImage->GetVTKImages()[0]); diff --git a/vv/vvImageContour.h b/vv/vvImageContour.h index d93a3f3..66473d3 100644 --- a/vv/vvImageContour.h +++ b/vv/vvImageContour.h @@ -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 mClipperList; - std::vector mSquaresList; - std::vector mSquaresActorList; + std::vector > mClipperList; + std::vector > mSquaresList; + std::vector > 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, -- 2.47.1