]> Creatis software - clitk.git/blobdiff - common/clitkDicomRT_Contour.cxx
Use QSharedPointers for vvROIActors
[clitk.git] / common / clitkDicomRT_Contour.cxx
index cee3b678b8891718ece52546469e5e4eef23af27..9a98045faf174182f8cd7cc0f23b1c45c4356988 100644 (file)
@@ -25,6 +25,7 @@ clitk::DicomRT_Contour::DicomRT_Contour()
 {
   mMeshIsUpToDate = false;
   mNbOfPoints = 0;
+  mZ = -1;
 }
 //--------------------------------------------------------------------
 
@@ -71,23 +72,22 @@ 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);
-  double z = -1;
   for(unsigned int i=0; i<mNbOfPoints; i++) {
     double p[3];
     p[0] = points[i*3];
     p[1] = points[i*3+1];
     p[2] = points[i*3+2];
     mData->SetPoint(i, p);
-    if (z == -1) z = p[2];
-    if (p[2] != z) {
+    if (mZ == -1) mZ = p[2];
+    if (p[2] != mZ) {
       DD(i);
       DD(p[2]);
-      DD(z);
+      DD(mZ);
       std::cout << "ERROR ! contour not in the same slice" << std::endl;
-      assert(p[2] == z);
+      assert(p[2] == mZ);
     }
   }
 
@@ -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],