]> Creatis software - clitk.git/blobdiff - common/clitkDicomRT_StructureSet.cxx
Attempt to remove some leaks. DicomRT_Contour, DicomRT_ROI and DicomRT_StructureSet...
[clitk.git] / common / clitkDicomRT_StructureSet.cxx
index fb23570f78156124d5cb5a0f33aa7786ab9d0736..9d128b80075bf9ded4d9f3f750bf0f464dfd7916 100644 (file)
@@ -37,7 +37,6 @@ clitk::DicomRT_StructureSet::DicomRT_StructureSet()
 //--------------------------------------------------------------------
 clitk::DicomRT_StructureSet::~DicomRT_StructureSet()
 {
-
 }
 //--------------------------------------------------------------------
 
@@ -99,7 +98,7 @@ const std::string & clitk::DicomRT_StructureSet::GetTime() const
 
 
 //--------------------------------------------------------------------
-const std::vector<clitk::DicomRT_ROI*> & clitk::DicomRT_StructureSet::GetListOfROI() const
+const std::vector<clitk::DicomRT_ROI::Pointer> & clitk::DicomRT_StructureSet::GetListOfROI() const
 {
   return mListOfROI;
 }
@@ -113,8 +112,8 @@ clitk::DicomRT_ROI* clitk::DicomRT_StructureSet::GetROI(int n)
     std::cerr << "No ROI number " << n << std::endl;
     return NULL;
   }
-  DD(mListOfROI[mMapOfROIIndex[n]]->GetName());
-  DD(mListOfROI[mMapOfROIIndex[n]]->GetROINumber());
+  //  DD(mListOfROI[mMapOfROIIndex[n]]->GetName());
+  //DD(mListOfROI[mMapOfROIIndex[n]]->GetROINumber());
   return mListOfROI[mMapOfROIIndex[n]];
 }
 //--------------------------------------------------------------------
@@ -199,7 +198,7 @@ void clitk::DicomRT_StructureSet::Read(const std::string & filename)
   assert(roi_contour_seq); // TODO error message
   int n=0;
   for (gdcm::SQItem* r=roi_contour_seq->GetFirstSQItem(); r!=0; r=roi_contour_seq->GetNextSQItem()) {
-    DicomRT_ROI * roi = new DicomRT_ROI;
+    DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
     roi->Read(mMapOfROIName, r);
     mListOfROI.push_back(roi);
     mMapOfROIIndex[roi->GetROINumber()] = n;
@@ -211,24 +210,24 @@ void clitk::DicomRT_StructureSet::Read(const std::string & filename)
 
 
 //--------------------------------------------------------------------
-int clitk::DicomRT_StructureSet::AddBinaryImageAsNewROI(vvImage::Pointer im, std::string n)
+int clitk::DicomRT_StructureSet::AddBinaryImageAsNewROI(vvImage * im, std::string n)
 {
-  DD("AddBinaryImageAsNewROI");
+  //DD("AddBinaryImageAsNewROI");
   // Search max ROI number
   int max = -1;
   for(unsigned int i=0; i<mListOfROI.size(); i++) {
     if (mListOfROI[i]->GetROINumber() > max)
       max = mListOfROI[i]->GetROINumber();
   }
-  DD(max);
+  //  DD(max);
   ++max;
-  DD(max);
+  //DD(max);
 
   // Compute name
   std::ostringstream oss;
-  oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(n))
-      << "_roi_" << max << vtksys::SystemTools::GetFilenameLastExtension(n);
-  DD(oss.str());
+  oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(n));
+  //      << "_roi_" << max << vtksys::SystemTools::GetFilenameLastExtension(n);
+  //DD(oss.str());
   mMapOfROIName[max] = oss.str();
 
   // Set color
@@ -238,14 +237,11 @@ int clitk::DicomRT_StructureSet::AddBinaryImageAsNewROI(vvImage::Pointer im, std
   color.push_back(0);
 
   // Create ROI
-  DicomRT_ROI * roi = new DicomRT_ROI;
-  roi->SetFromBinaryImage(im,
-                          max,
-                          oss.str(),
-                          color);
+  DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
+  roi->SetFromBinaryImage(im, max, oss.str(), color, n);
   mListOfROI.push_back(roi);
   mMapOfROIIndex[mListOfROI.size()-1] = max;
-  DD(mMapOfROIIndex[mListOfROI.size()-1]);
+  //DD(mMapOfROIIndex[mListOfROI.size()-1]);
   return max;
 }
 //--------------------------------------------------------------------