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"
24 //--------------------------------------------------------------------
25 int main(int argc, char * argv[]) {
28 GGO(clitkDicomRTStruct2Image, args_info);
30 // Read and display information
31 clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
32 s->Read(args_info.input_arg);
33 if (args_info.verboseFile_flag) {
37 // New filter to convert to binary image
38 clitk::DicomRTStruct2ImageFilter filter;
39 filter.SetCropMaskEnabled(args_info.crop_flag);
40 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
41 if (args_info.roiName_given) {
42 filter.SetROI(s->GetROIFromROIName(args_info.roiName_arg));
43 filter.SetOutputImageFilename(args_info.output_arg);
46 else if (args_info.roi_given && args_info.roi_arg != -1) {
47 filter.SetROI(s->GetROIFromROINumber(args_info.roi_arg));
48 filter.SetOutputImageFilename(args_info.output_arg);
52 clitk::DicomRT_StructureSet::ROIMapContainer* rois;
53 if (args_info.roiNameSubstr_given)
54 rois = s->GetROIsFromROINameSubstr(args_info.roiNameSubstr_arg);
58 clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
60 for(iter = rois->begin(); iter != rois->end(); iter++) {
61 clitk::DicomRT_ROI::Pointer roi = iter->second;
62 clitk::DicomRTStruct2ImageFilter filter;
63 std::string name = roi->GetName();
64 int num = roi->GetROINumber();
66 filter.SetCropMaskEnabled(args_info.crop_flag);
67 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
68 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
69 std::string n = std::string(args_info.output_arg).append
70 (clitk::toString(num)).append
74 if (args_info.verbose_flag) {
75 std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
77 filter.SetOutputImageFilename(n);
83 // clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
84 // for(iter = s->GetROIs().begin(); iter != s->GetROIs().end(); iter++) {
85 // clitk::DicomRT_ROI::Pointer roi = iter->second;
86 // // Create the filter
87 // clitk::DicomRTStruct2ImageFilter filter;
88 // filter.SetCropMaskEnabled(args_info.crop_flag);
89 // filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
90 // std::string name = roi->GetName();
91 // int num = roi->GetROINumber();
92 // filter.SetROI(roi);
93 // name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
94 // std::string n = std::string(args_info.output_arg).append
95 // (clitk::toString(num)).append
99 // if (args_info.verbose_flag) {
100 // std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
102 // filter.SetOutputImageFilename(n);
107 for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
108 clitk::DicomRTStruct2ImageFilter filter;
109 filter.SetCropMaskEnabled(args_info.crop_flag);
110 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
111 std::string name = s->GetListOfROI()[i]->GetName();
112 int num = s->GetListOfROI()[i]->GetROINumber();
113 filter.SetROI(s->GetListOfROI()[i]);
114 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
115 std::string n = std::string(args_info.output_arg).append
116 (clitk::toString(num)).append
120 if (args_info.verbose_flag) {
121 std::cout << i << " " << s->GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
123 filter.SetOutputImageFilename(n);
128 // This is the end my friend