Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

windowvud.cpp

Go to the documentation of this file.
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 "Volume/Regular/Unimodal/3d/2B/2B.h"
00009 #include "vuHistogram.h"
00010 #include "vuConvert.h"
00011 
00012 using namespace std;
00013 
00014 void usage(const char* exe);
00015 bool readnumber(const char* str, int& number);
00016 
00017 int main(int argc, char ** argv)
00018 {
00019     if(argc != 7) {
00020         usage(argv[0]);
00021         return -1;
00022     }
00023 
00024     vuString fileName = argv[1];
00025     vuString fileType = vuFileHelper::getFileType(fileName);
00026     if (fileType.isEmpty()) {
00027         cout << "Error: Wrong filetype." << endl;
00028         return -1;
00029     }
00030 
00031     vuString outfileName = argv[2];
00032 
00033     int inter[4];
00034     int i;
00035     for(i=0; i<4; i++)
00036     {
00037         if(!readnumber(argv[i+3], inter[i])) {
00038             usage(argv[0]);
00039             return false;
00040         }
00041     }
00042     cout << "loading" << endl;
00043     vu11122 volume;
00044     volume.setFileName(fileName);
00045     if(!volume.read()) {
00046         cout << "Error: Could not load file " << fileName << "." << endl;
00047         return -1;
00048     }
00049 
00050     vuMap map;
00051     map.createRamp(inter[0], inter[1], inter[2], inter[3]);
00052     volume.remap(map);
00053 
00054     vu11121 bvol;
00055     vuConvert::convert(bvol, volume);
00056     bvol.setFileName(outfileName);
00057     cout << "writing file " << bvol.getFileName() << endl;
00058     bvol.write();
00059 
00060     cout << "done." << endl;
00061     return 0;
00062 }
00063 
00064 void usage(const char* exe)
00065 {
00066     const char *file = strrchr(exe,'/');
00067     if(!file) 
00068     {
00069         file = strrchr(exe,'\\');
00070         if(file) file++;
00071         else file = exe;
00072     } else file++;
00073 
00074     cout << "usage:  " << file << " inputfile outputfile "
00075          << "start startval end endval" << endl << endl;
00076     cout << "inputfile      name of vud file (data type word) including extension"<<endl;
00077     cout << "outputfile     name of output vud file (data type byte)"<<endl;
00078     cout << "start          start of intensity range to map" << endl;
00079     cout << "startval       start value of range to map to" << endl;
00080     cout << "end            end of intensity range to map" << endl;
00081     cout << "endval         end value of range to map to" << endl;
00082 }
00083 
00084 bool readnumber(const char* str, int& number)
00085 {
00086     char *endp;
00087     errno = 0;
00088     number = strtol(str,&endp,10);
00089     if(errno || 
00090        endp != str+strlen(str)) return false;
00091     return true;
00092 }
00093 

Generated on Wed Dec 15 21:20:38 2004 for vuVolume by  doxygen 1.3.9.1