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.vtk_flag) {
44 filter.SetWriteMesh(true);
46 if (args_info.roiName_given) {
47 filter.SetROI(s->GetROIFromROIName(args_info.roiName_arg));
48 filter.SetOutputImageFilename(args_info.output_arg);
51 else if (args_info.roi_given && args_info.roi_arg != -1) {
52 filter.SetROI(s->GetROIFromROINumber(args_info.roi_arg));
53 filter.SetOutputImageFilename(args_info.output_arg);
57 clitk::DicomRT_StructureSet::ROIMapContainer* rois;
58 if (args_info.roiNameSubstr_given)
59 rois = s->GetROIsFromROINameSubstr(args_info.roiNameSubstr_arg);
63 clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
65 for(iter = rois->begin(); iter != rois->end(); iter++) {
66 clitk::DicomRT_ROI::Pointer roi = iter->second;
67 clitk::DicomRTStruct2ImageFilter filter;
68 std::string name = roi->GetName();
69 int num = roi->GetROINumber();
71 filter.SetCropMaskEnabled(args_info.crop_flag);
72 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
73 if (args_info.vtk_flag) {
74 filter.SetWriteMesh(true);
76 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
78 if (args_info.mha_flag) {
79 n = std::string(args_info.output_arg).append
80 (clitk::toString(num)).append
86 n = std::string(args_info.output_arg).append
87 (clitk::toString(num)).append
92 if (args_info.verbose_flag) {
93 std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
95 filter.SetOutputImageFilename(n);
101 // clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
102 // for(iter = s->GetROIs().begin(); iter != s->GetROIs().end(); iter++) {
103 // clitk::DicomRT_ROI::Pointer roi = iter->second;
104 // // Create the filter
105 // clitk::DicomRTStruct2ImageFilter filter;
106 // filter.SetCropMaskEnabled(args_info.crop_flag);
107 // filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
108 // std::string name = roi->GetName();
109 // int num = roi->GetROINumber();
110 // filter.SetROI(roi);
111 // name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
112 // std::string n = std::string(args_info.output_arg).append
113 // (clitk::toString(num)).append
117 // if (args_info.verbose_flag) {
118 // std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
120 // filter.SetOutputImageFilename(n);
125 for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
126 clitk::DicomRTStruct2ImageFilter filter;
127 filter.SetCropMaskEnabled(args_info.crop_flag);
128 filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
129 std::string name = s->GetListOfROI()[i]->GetName();
130 int num = s->GetListOfROI()[i]->GetROINumber();
131 filter.SetROI(s->GetListOfROI()[i]);
132 name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
133 std::string n = std::string(args_info.output_arg).append
134 (clitk::toString(num)).append
138 if (args_info.verbose_flag) {
139 std::cout << i << " " << s->GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
141 filter.SetOutputImageFilename(n);
146 // This is the end my friend