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

vuf2vud.cpp

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "Volume/Regular/Unimodal/3d/1B/Intensity/SimpleFVR/vuSimpleFVR.h"
00003 #include "vuMisc/vuCommandLineTool.h"
00004 
00005 /* 
00006    Usage: vuf2vud OPTIONS input.vuf output.vud
00007 
00008    OPTIONS:
00009 */
00010 
00011 
00012 vuString g_ErrorMsg;
00013 vuString g_OutputFile;
00014 vuString g_InputFile;
00015 float    g_Scale     = 1.0f;
00016 
00017 void doIt(void) {
00018   cout << "scale   = " << g_Scale   << endl;
00019   vu1112119::convertVUF2VUD(g_InputFile, g_OutputFile, g_Scale);
00020 }
00021 
00022 vuString _helpString(vuCommandLineTool &tool)
00023 {
00024   vuString str;
00025 
00026 
00027   str += "Creates a spatial volume from a fourier volume of type '*.vuf'.\n\n";
00028   str += "Usage: ";
00029   str += tool.toolName();
00030   str += " [additional_options] inputFile outputFile\n";
00031   str += "\nadditional_options:\n";
00032   str += "  --scale=fff    image scaling  (1.0),         e.g. --scale=25.5\n";
00033   str += "  --help         prints this help text\n";
00034   str += "\ninputFile:\n";
00035   str += "  a frequency volume file,                     e.g. engine.vuf\n";
00036   str += "\noutputFile:\n";
00037   str += "  a regular 3D vuVolume data file,             e.g. engine.vud\n";
00038 
00039   return str;
00040 }
00041 
00042 bool _parseParameters(int argc, const char **argv)
00043 {
00044   bool isOk = true;
00045   vuCommandLineTool tool(argc, argv);
00046 
00047   if (tool.hasParameter("--help")) {
00048     g_ErrorMsg += _helpString(tool);
00049     return false;
00050   }
00051 
00052   if (tool.hasParameter("--scale"))
00053       g_Scale = tool.floatForParameter  ("--scale");
00054 
00055   g_ErrorMsg += "Following error(s) occured:\n";
00056 
00057   bool isValid;
00058   word fileCount = tool.numberOfNonParameters(isValid);
00059 
00060   if (fileCount == 0) {
00061     g_ErrorMsg += "  - Neither an input nor an output file is specified.\n";
00062     isOk = false;
00063   }
00064   else if (fileCount == 1)  {
00065     g_ErrorMsg += "  - No output file specified.\n";
00066     isOk = false;
00067   }
00068   else if (fileCount == 2 && isValid)  {
00069     g_InputFile  = tool.getArgument(argc-2);
00070     g_OutputFile = tool.getArgument(argc-1);
00071     if (!tool.fileExists(g_InputFile)) {
00072       g_ErrorMsg += "  - InputFile does not exist ('";
00073       g_ErrorMsg += g_InputFile + "').\n";
00074       isOk = false;
00075     }
00076     if (g_OutputFile.isEmpty()) {
00077       g_ErrorMsg += "  - No output file specified.\n";
00078       isOk = false;
00079     }
00080   }
00081   else if (fileCount > 2)  {
00082     g_ErrorMsg += "  - More than one input and one output file specified.\n";
00083     isOk = false;
00084   }
00085   else {
00086     g_ErrorMsg += "  - The input and output file are expected to be at the ";
00087     g_ErrorMsg += " end of the line.\n";
00088     isOk = false;
00089   }
00090 
00091   g_ErrorMsg += "\nType '" + tool.toolName() + " --help' for more information!\n";
00092 
00093   if (isOk) g_ErrorMsg = "";
00094 
00095   return isOk;
00096 }
00097 
00098 int main(int argc, const char **argv)
00099 {
00100   if (!_parseParameters(argc, argv)) {
00101     cerr << g_ErrorMsg << endl;
00102     exit(0);
00103   }
00104 
00105   doIt();
00106 
00107   return 0;
00108 }

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