From c93a32f96e61514b8b945d515ffcf11c2a12ae66 Mon Sep 17 00:00:00 2001
From: srit <srit>
Date: Fri, 25 Mar 2011 14:21:11 +0000
Subject: [PATCH] More vtkSmartPointer

---
 common/clitkDicomRT_Contour.cxx                  | 7 ++++---
 common/clitkDicomRT_Contour.h                    | 7 ++++---
 common/clitkDicomRT_ROI.cxx                      | 2 +-
 common/clitkDicomRT_ROI_ConvertToImageFilter.cxx | 2 +-
 common/clitkDicomRT_ROI_ConvertToImageFilter.h   | 2 +-
 vv/vvStructureSetActor.cxx                       | 1 +
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/common/clitkDicomRT_Contour.cxx b/common/clitkDicomRT_Contour.cxx
index 6059f03..9a98045 100644
--- a/common/clitkDicomRT_Contour.cxx
+++ b/common/clitkDicomRT_Contour.cxx
@@ -72,7 +72,7 @@ bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item)
   assert(points.size() == static_cast<unsigned int>(mNbOfPoints)*3);
 
   // Organize values
-  mData = vtkPoints::New();
+  mData = vtkSmartPointer<vtkPoints>::New();
   mData->SetDataTypeToDouble();
   mData->SetNumberOfPoints(mNbOfPoints);
   for(unsigned int i=0; i<mNbOfPoints; i++) {
@@ -111,9 +111,10 @@ vtkPolyData * clitk::DicomRT_Contour::GetMesh()
 void clitk::DicomRT_Contour::ComputeMesh()
 {
 //  DD("ComputeMesh Contour");
-  mMesh = vtkPolyData::New();
+  mMesh = vtkSmartPointer<vtkPolyData>::New();
   mMesh->Allocate(); //for cell structures
-  mMesh->SetPoints(vtkPoints::New());
+  mPoints = vtkSmartPointer<vtkPoints>::New();
+  mMesh->SetPoints(mPoints);
   vtkIdType ids[2];
   for (unsigned int idx=0 ; idx<mNbOfPoints ; idx++) {
     mMesh->GetPoints()->InsertNextPoint(mData->GetPoint(idx)[0],
diff --git a/common/clitkDicomRT_Contour.h b/common/clitkDicomRT_Contour.h
index 8596702..88100f4 100644
--- a/common/clitkDicomRT_Contour.h
+++ b/common/clitkDicomRT_Contour.h
@@ -21,11 +21,11 @@
 #define CLITKDICOMRT_CONTOUR_H
 
 #include "clitkCommon.h" 
-#include "clitkDicomRT_Contour.h"
 #include <gdcm.h>
 #include <gdcmSQItem.h>
 #include <vtkPoints.h>
 #include <vtkPolyData.h>
+#include <vtkSmartPointer.h>
 
 namespace clitk {
 
@@ -47,8 +47,9 @@ protected:
   void ComputeMesh();
   unsigned int mNbOfPoints;
   std::string mType;
-  vtkPoints * mData;
-  vtkPolyData * mMesh;
+  vtkSmartPointer<vtkPoints> mData;
+  vtkSmartPointer<vtkPolyData> mMesh;
+  vtkSmartPointer<vtkPoints> mPoints;
   bool mMeshIsUpToDate;
   ///Z location of the contour
   double mZ;
diff --git a/common/clitkDicomRT_ROI.cxx b/common/clitkDicomRT_ROI.cxx
index 6096ddc..48099e0 100644
--- a/common/clitkDicomRT_ROI.cxx
+++ b/common/clitkDicomRT_ROI.cxx
@@ -195,7 +195,7 @@ clitk::DicomRT_Contour * clitk::DicomRT_ROI::GetContour(int n)
 //--------------------------------------------------------------------
 void clitk::DicomRT_ROI::ComputeMesh()
 {
-  vtkAppendPolyData * append = vtkAppendPolyData::New();
+  vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
   for(unsigned int i=0; i<mListOfContours.size(); i++) {
     append->AddInput(mListOfContours[i]->GetMesh());
   }
diff --git a/common/clitkDicomRT_ROI_ConvertToImageFilter.cxx b/common/clitkDicomRT_ROI_ConvertToImageFilter.cxx
index 6c2fd39..7b4d04e 100644
--- a/common/clitkDicomRT_ROI_ConvertToImageFilter.cxx
+++ b/common/clitkDicomRT_ROI_ConvertToImageFilter.cxx
@@ -156,7 +156,7 @@ void clitk::DicomRT_ROI_ConvertToImageFilter::Update()
   }
 
   // Create new output image
-  mBinaryImage = vtkImageData::New();
+  mBinaryImage = vtkSmartPointer<vtkImageData>::New();
   mBinaryImage->SetScalarTypeToUnsignedChar();
   mBinaryImage->SetOrigin(&origin[0]);
   mBinaryImage->SetSpacing(&mSpacing[0]);
diff --git a/common/clitkDicomRT_ROI_ConvertToImageFilter.h b/common/clitkDicomRT_ROI_ConvertToImageFilter.h
index 33d74b6..8e4e27c 100644
--- a/common/clitkDicomRT_ROI_ConvertToImageFilter.h
+++ b/common/clitkDicomRT_ROI_ConvertToImageFilter.h
@@ -56,7 +56,7 @@ namespace clitk {
     std::vector<double> mOrigin;
     std::vector<unsigned long> mSize;
     clitk::DicomRT_ROI * mROI;
-    vtkImageData * mBinaryImage;
+    vtkSmartPointer<vtkImageData> mBinaryImage;
   };
   //--------------------------------------------------------------------
 
diff --git a/vv/vvStructureSetActor.cxx b/vv/vvStructureSetActor.cxx
index b6f08f8..9a9ac8c 100644
--- a/vv/vvStructureSetActor.cxx
+++ b/vv/vvStructureSetActor.cxx
@@ -30,6 +30,7 @@ vvStructureSetActor::vvStructureSetActor()
 //------------------------------------------------------------------------------
 vvStructureSetActor::~vvStructureSetActor()
 {
+
 }
 //------------------------------------------------------------------------------
 
-- 
2.47.1