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

convfrez.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 "Volume/Regular/Unimodal/3d/2B/2B.h"
00007 
00008 using namespace std;
00009 
00010 void usage(const char* exe);
00011 bool readnumber(const char* str, int& number);
00012 
00013 int main(int argc, char ** argv)
00014 {
00015     if(argc < 5) {
00016         usage(argv[0]);
00017         return -1;
00018     }
00019 
00020     vu11122 volume;
00021     int startID, endID, incID = 1;
00022     if(!readnumber(argv[3], startID)) { usage(argv[0]); return false; }
00023     if(!readnumber(argv[4], endID)) { usage(argv[0]); return false; }
00024     if (argc == 6) 
00025         if(!readnumber(argv[5], incID)) { usage(argv[0]); return false; }
00026 
00027     cout << "reading slices with mask " << argv[1] << " from " << startID 
00028          << " to " << endID << endl;
00029     if(readFreZ(volume, argv[1], startID, endID, incID))
00030     {
00031         volume.setFileName(argv[2]);
00032         volume.write();
00033     } else cout << "Error: Could not load file." << endl;
00034 
00035     cout << "done." << endl;
00036     return 0;
00037 }
00038 
00039 void usage(const char* exe)
00040 {
00041     const char *file = strrchr(exe,'/');
00042     if(!file) 
00043     {
00044         file = strrchr(exe,'\\');
00045         if(file) file++;
00046         else file = exe;
00047     } else file++;
00048 
00049     cout << "usage:  " << file << " inputmask outputfile startID " 
00050          << "endID [incrementID]" << endl << endl;
00051     cout << "inputmask    format string with ID, e.g., \"c_vm%i.fre.Z\" "<<endl;
00052     cout << "outputfile   name of vud file including extension"<<endl;
00053     cout << "startID      file ID number of first slice" << endl;
00054     cout << "endID        file ID numer of last slice, has to be greater than "
00055          << "startID" << endl;
00056     cout << "incrementID  stepping if only every nth slice should be read. "
00057          << "(default is 1)" << endl;
00058 }
00059 
00060 bool readnumber(const char* str, int& number)
00061 {
00062     char *endp;
00063     errno = 0;
00064     number = strtol(str,&endp,10);
00065     if(errno || 
00066        endp != str+strlen(str)) return false;
00067     return true;
00068 }
00069 

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