]> Creatis software - clitk.git/blob - tools/clitkMergeAsciiDoseActor.cxx
Add scalar into clitkImageArithm operation
[clitk.git] / tools / clitkMergeAsciiDoseActor.cxx
1 /*=========================================================================
2   Program:         vv http://www.creatis.insa-lyon.fr/rio/vv
3   Main authors :   XX XX XX
4
5   Authors belongs to: 
6   - University of LYON           http://www.universite-lyon.fr/
7   - Léon Bérard cancer center    http://oncora1.lyon.fnclcc.fr
8   - CREATIS CNRS laboratory      http://www.creatis.insa-lyon.fr
9
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.
13
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
17
18   =========================================================================*/
19
20 #include <fstream>
21 #include "clitkCommon.h"
22 #include "clitkMergeAsciiDoseActor_ggo.h"
23
24 //--------------------------------------------------------------------
25 int main(int argc, char * argv[]) {
26
27   // Init command line
28   GGO(clitkMergeAsciiDoseActor, args_info);
29
30   // Read input 1
31   std::vector<double> input1;
32   clitk::readDoubleFromFile(args_info.input1_arg, input1);
33   DD(input1.size());
34
35   // Read input 2
36   std::vector<double> input2;
37   clitk::readDoubleFromFile(args_info.input2_arg, input2);
38   DD(input2.size());
39
40   // Check 
41   if (input1.size() != input2.size()) {
42       std::cerr << "Error. Please provide input file with the same number of values. Read " 
43                 << input1.size()  << " in " << args_info.input1_arg 
44                 << " and " << input2.size() << " in " << args_info.input2_arg << std::endl;
45       exit(0);
46   }
47   
48   // Add
49   for(unsigned int i=0; i<input1.size(); i++) {
50     input1[i] += input2[i];
51   }
52
53   // Write output
54   std::ofstream os;
55   clitk::openFileForWriting(os, args_info.output_arg);
56   os << "## Merge " << input1.size() << " values" << std::endl;
57   for(unsigned int i=0; i<input1.size(); i++) {
58     os << input1[i] << std::endl;
59   }  
60   os.close();
61
62   // This is the end my friend 
63   return 0;
64 }