1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
3 Main authors : XX XX XX
6 - University of LYON http://www.universite-lyon.fr/
7 - Léon Bérard cancer center http://www.centreleonberard.fr
8 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the copyright notices for more information.
14 It is distributed under dual licence
15 - BSD http://www.opensource.org/licenses/bsd-license.php
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
18 =========================================================================*/
20 #include "clitkDicomRTStruct2ImageFilter.h"
21 #include "clitkDicomRT_StructureSet.h"
22 #include "clitkDicomRTStruct2Image_ggo.h"
25 //--------------------------------------------------------------------
26 int main(int argc, char * argv[]) {
29 GGO(clitkDicomRTStruct2Image, args_info);
32 // Read and display information
33 clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
34 s->Read(args_info.input_arg);
35 if (args_info.verboseFile_flag) {
39 // New filter to convert to binary image
40 clitk::DicomRTStruct2ImageFilter filter;
41 filter.SetCropMaskEnabled(args_info.crop_flag);
42 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
43 if (args_info.roiName_given) {
44 filter.SetROI(s->GetROIFromROIName(args_info.roiName_arg));
45 filter.SetOutputImageFilename(args_info.output_arg);
48 else if (args_info.roi_given && args_info.roi_arg != -1) {
49 filter.SetROI(s->GetROIFromROINumber(args_info.roi_arg));
50 filter.SetOutputImageFilename(args_info.output_arg);
54 clitk::DicomRT_StructureSet::ROIMapContainer* rois;
55 if (args_info.roiNameSubstr_given)
56 rois = s->GetROIsFromROINameSubstr(args_info.roiNameSubstr_arg);
60 clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
62 for(iter = rois->begin(); iter != rois->end(); iter++) {
63 clitk::DicomRT_ROI::Pointer roi = iter->second;
64 clitk::DicomRTStruct2ImageFilter filter;
65 std::string name = roi->GetName();
66 int num = roi->GetROINumber();
68 filter.SetCropMaskEnabled(args_info.crop_flag);
69 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
70 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
71 std::string n = std::string(args_info.output_arg).append
72 (clitk::toString(num)).append
76 if (args_info.verbose_flag) {
77 std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
79 filter.SetOutputImageFilename(n);
85 // clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
86 // for(iter = s->GetROIs().begin(); iter != s->GetROIs().end(); iter++) {
87 // clitk::DicomRT_ROI::Pointer roi = iter->second;
88 // // Create the filter
89 // clitk::DicomRTStruct2ImageFilter filter;
90 // filter.SetCropMaskEnabled(args_info.crop_flag);
91 // filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
92 // std::string name = roi->GetName();
93 // int num = roi->GetROINumber();
94 // filter.SetROI(roi);
95 // name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
96 // std::string n = std::string(args_info.output_arg).append
97 // (clitk::toString(num)).append
101 // if (args_info.verbose_flag) {
102 // std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
104 // filter.SetOutputImageFilename(n);
109 for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
110 clitk::DicomRTStruct2ImageFilter filter;
111 filter.SetCropMaskEnabled(args_info.crop_flag);
112 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
113 std::string name = s->GetListOfROI()[i]->GetName();
114 int num = s->GetListOfROI()[i]->GetROINumber();
115 filter.SetROI(s->GetListOfROI()[i]);
116 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
117 std::string n = std::string(args_info.output_arg).append
118 (clitk::toString(num)).append
122 if (args_info.verbose_flag) {
123 std::cout << i << " " << s->GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
125 filter.SetOutputImageFilename(n);
130 // This is the end my friend