Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

PlotFile.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_Plot_PlotFile_h
00002 #define Impala_Visualization_Plot_PlotFile_h
00003 
00004 #include "Visualization/Plot/Plot.h"
00005 #include "Visualization/Plot/HeightMap.h"
00006 #include "Basis/File.h"
00007 #include "Core/Array/ReadRaw.h"
00008 #include <string>
00009 
00010 namespace Impala
00011 {
00012 namespace Visualization
00013 {
00014 namespace Plot
00015 {
00016 
00017 
00018     void ReadPlotFile(const std::string& filename, const std::string& filedir, Plot* plot)
00019     {
00020         std::string name = filedir + filename;
00021         File info(name.c_str(), "r");
00022         if(!info.Valid())
00023         {
00024             std::cout << "[ReadPlotFile] couldn't open file " << name << std::endl;
00025             return;
00026         }
00027 
00028         Plottable* plottable = 0;
00029         while(!info.Eof())
00030         {
00031             std::string line = info.ReadLine();
00032             if(line[0] != '#')
00033             {
00034                 std::istringstream iss(line);
00035                 std::string cmd;
00036                 iss >> cmd;
00037                 if(cmd == "axis")
00038                 {
00039                     // read axis;
00040                 }
00041                 else if(cmd == "landscape")
00042                 {
00043                     plottable = new HeightMap;
00044                     plot->Add(plottable);
00045                 }
00046                 else if(cmd == "data:")
00047                 {
00048                     if(plottable)
00049                     {
00050                         std::string datafilename;
00051                         iss >> datafilename;
00052                         datafilename = filedir + datafilename;
00053                         Core::Array::Array2dScalarReal64* data=0;
00054                         std::cout << "reading data from \"" << datafilename << "\"\n";
00055                         ReadRaw(data, datafilename);
00056                         plottable->SetData(data);
00057                     }
00058                     else
00059                         std::cout << "[ReadPlotFile] syntax error, dataset before plottable is defined in \""
00060                                   << filename << "\"\n";
00061                 }
00062             }
00063         }
00064 
00065         info.Close();
00066     }
00067 
00068 }//namespace Impala
00069 }//namespace Visulization
00070 }//namespace Plot
00071 
00072 #endif

Generated on Fri Mar 19 09:31:51 2010 for ImpalaSrc by  doxygen 1.5.1