Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

samplestofigs.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <fstream>
00003 #include <cstdlib>
00004 #include "parsecl.hpp"
00005 #include "coloring.hpp"
00006 
00007 int main(int argc, char** argv) {
00008   using namespace Arak::Util;
00009   // Parse the command line.
00010   CommandLine cl;
00011   CommandLine::Parameter<std::string> 
00012     prefix("-p", "--prefix", "the prefix for the fig file names",
00013      std::string("sample"));
00014   cl.add(prefix);
00015   CommandLine::Parameter<int> 
00016     stride("-s", "--stride", 
00017      "the number of samples skipped between samples that are rendered", 
00018      0);
00019   cl.add(stride);
00020 
00021   if (!cl.parse(argc, argv, std::cerr)) {
00022     cl.printUsage(std::cerr);
00023     exit(1);
00024   }
00025 
00026   Arak::Coloring c;
00027   int i = 0;
00028   char *buf = new char[prefix.value().length() + 32];
00029   while (std::cin.good() && !std::cin.eof()) {
00030     if (!c.readBinary(std::cin)) {
00031       std::cerr << "Error reading binary coloring from standard input." 
00032     << std::endl;
00033       return 1;
00034     }
00035     std::sprintf(buf, "%s%d.fig", prefix.value().data(), ++i);
00036     std::ofstream out(buf);
00037     c.writeXfig(out);
00038     out.close();
00039   }
00040   std::cerr << "Rendered " << i << " colorings." << std::endl;
00041   delete [] buf;
00042   return 0;
00043 }

Generated on Wed May 25 14:39:18 2005 for Arak by doxygen 1.3.6