]> Creatis software - clitk.git/commitdiff
Replace ListOfROI (vector) by MapOfROI to avoid ambiguity between the ROI number...
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Wed, 27 Jul 2011 09:44:13 +0000 (11:44 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Wed, 27 Jul 2011 09:44:13 +0000 (11:44 +0200)
Remplace GetROI with GetROIFromROINumber

tools/clitkDicomRTStruct2Image.cxx

index 228ca0b0cc33480946f3cd5bb33bf62cc94582c6..cc231260f29c57287738efb1b3fee641884f0afe 100644 (file)
@@ -39,11 +39,35 @@ int main(int argc, char * argv[]) {
   filter.SetCropMaskEnabled(args_info.crop_flag);
   filter.SetImageFilename(args_info.image_arg);  // Used to get spacing + origin
   if (args_info.roi_arg != -1) {
-    filter.SetROI(s->GetROI(args_info.roi_arg)); 
+    filter.SetROI(s->GetROIFromROINumber(args_info.roi_arg)); 
     filter.SetOutputImageFilename(args_info.output_arg);
   filter.Update();  
   }
   else {
+    clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
+    for(iter = s->GetROIs().begin(); iter != s->GetROIs().end(); iter++) {
+      clitk::DicomRT_ROI::Pointer roi = iter->second;
+      // Create the filter
+      clitk::DicomRTStruct2ImageFilter filter;
+      filter.SetCropMaskEnabled(args_info.crop_flag);
+      filter.SetImageFilename(args_info.image_arg);  // Used to get spacing + origin
+      std::string name = roi->GetName();
+      int num = roi->GetROINumber();
+      filter.SetROI(roi); 
+      name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
+      std::string n = std::string(args_info.output_arg).append
+        (clitk::toString(num)).append
+        ("_").append
+        (name).append
+        (".mhd");
+      if (args_info.verbose_flag) {
+        std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
+      }
+      filter.SetOutputImageFilename(n);
+      filter.Update();
+    }
+
+    /*
     for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
       clitk::DicomRTStruct2ImageFilter filter;
       filter.SetCropMaskEnabled(args_info.crop_flag);
@@ -62,7 +86,7 @@ int main(int argc, char * argv[]) {
       }
       filter.SetOutputImageFilename(n);
       filter.Update();  
-    }
+      }*/
   }
 
   // This is the end my friend