00001 #include <iostream>
00002 #include <fstream>
00003 #include <unistd.h>
00004 #include <errno.h>
00005 #include <stdlib.h>
00006 #include "vuFileHelper.h"
00007 #include "Volume/Regular/Unimodal/3d/1B/1B.h"
00008 #include "vuHistogram.h"
00009
00010 using namespace std;
00011
00012 void usage(const char* exe);
00013 bool readnumber(const char* str, int& number);
00014
00015 int main(int argc, char ** argv)
00016 {
00017 if(argc != 6) {
00018 usage(argv[0]);
00019 return -1;
00020 }
00021
00022 vuString fileName = argv[1];
00023 vuString fileType = vuFileHelper::getFileType(fileName);
00024 if (fileType.isEmpty()) {
00025 cout << "Error: Wrong filetype." << endl;
00026 return -1;
00027 }
00028
00029 vuString outfileName = argv[2];
00030
00031 int scale[3];
00032 int i;
00033 for(i=0; i<3; i++)
00034 {
00035 if(!readnumber(argv[i+3], scale[i])) {
00036 usage(argv[0]);
00037 return false;
00038 }
00039 }
00040 cout << "loading" << endl;
00041 vu11121 volume;
00042 volume.setFileName(fileName);
00043 if(!volume.read()) {
00044 cout << "Error: Could not load file " << fileName << "." << endl;
00045 return -1;
00046 }
00047 vu11121 scalevol;
00048 scalevol.scaleFrom(volume, scale[0], scale[1], scale[2]);
00049 scalevol.setFileName(outfileName);
00050 scalevol.write();
00051
00052 cout << "done." << endl;
00053 return 0;
00054 }
00055
00056 void usage(const char* exe)
00057 {
00058 const char *file = strrchr(exe,'/');
00059 if(!file)
00060 {
00061 file = strrchr(exe,'\\');
00062 if(file) file++;
00063 else file = exe;
00064 } else file++;
00065
00066 cout << "usage: " << file << " inputfile outputfile Xscale Yscale Zscale"
00067 << endl << endl;
00068 cout << "inputfile name of vud file including extension"<<endl;
00069 cout << "outputfile name of histogram file to ouput"<<endl;
00070 cout << "Xscale new x dimension" << endl;
00071 cout << "Yscale new y dimension" << endl;
00072 cout << "Zscale new z dimension" << endl;
00073 }
00074
00075 bool readnumber(const char* str, int& number)
00076 {
00077 char *endp;
00078 errno = 0;
00079 number = strtol(str,&endp,10);
00080 if(errno ||
00081 endp != str+strlen(str)) return false;
00082 return true;
00083 }
00084