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());
72 if (args_info.mha_flag) {
73 n = std::string(args_info.output_arg).append
74 (clitk::toString(num)).append
80 n = std::string(args_info.output_arg).append
81 (clitk::toString(num)).append
86 if (args_info.verbose_flag) {
87 std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
89 filter.SetOutputImageFilename(n);
95 // clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
96 // for(iter = s->GetROIs().begin(); iter != s->GetROIs().end(); iter++) {
97 // clitk::DicomRT_ROI::Pointer roi = iter->second;
98 // // Create the filter
99 // clitk::DicomRTStruct2ImageFilter filter;
100 // filter.SetCropMaskEnabled(args_info.crop_flag);
101 // filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
102 // std::string name = roi->GetName();
103 // int num = roi->GetROINumber();
104 // filter.SetROI(roi);
105 // name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
106 // std::string n = std::string(args_info.output_arg).append
107 // (clitk::toString(num)).append
111 // if (args_info.verbose_flag) {
112 // std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
114 // filter.SetOutputImageFilename(n);
119 for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
120 clitk::DicomRTStruct2ImageFilter filter;
121 filter.SetCropMaskEnabled(args_info.crop_flag);
122 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
123 std::string name = s->GetListOfROI()[i]->GetName();
124 int num = s->GetListOfROI()[i]->GetROINumber();
125 filter.SetROI(s->GetListOfROI()[i]);
126 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
127 std::string n = std::string(args_info.output_arg).append
128 (clitk::toString(num)).append
132 if (args_info.verbose_flag) {
133 std::cout << i << " " << s->GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
135 filter.SetOutputImageFilename(n);
140 // This is the end my friend