1.1 --- a/src/work/peter/xy-reader.cc Sun Apr 17 18:57:22 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,76 +0,0 @@
1.4 -#include <fstream>
1.5 -#include <iostream>
1.6 -
1.7 -#include <lemon/xy.h>
1.8 -#include <lemon/maps.h>
1.9 -#include <lemon/error.h>
1.10 -#include <lemon/list_graph.h>
1.11 -#include <lemon/graph_reader.h>
1.12 -#include <lemon/graph_utils.h>
1.13 -
1.14 -using namespace lemon;
1.15 -
1.16 -typedef ListGraph Graph;
1.17 -typedef xy<double> Coordinates;
1.18 -typedef Graph::NodeMap<Coordinates> CoordinatesMap;
1.19 -typedef Graph::Node Node;
1.20 -typedef Graph::EdgeIt EdgeIt;
1.21 -typedef Graph::NodeIt NodeIt;
1.22 -
1.23 -class CoordReaderMap: public MapBase <Node, double>
1.24 -{
1.25 - CoordinatesMap & cm;
1.26 - char xoy;
1.27 -
1.28 -public:
1.29 - CoordReaderMap(char xory, CoordinatesMap & coordmap): cm(coordmap)
1.30 - {
1.31 - switch(xory)
1.32 - {
1.33 - case 'x':
1.34 - case 'y':
1.35 - xoy=xory;
1.36 - break;
1.37 - default:
1.38 - throw UninitializedParameter() ;
1.39 - }
1.40 - }
1.41 -
1.42 - void set(Node node, double coord)
1.43 - {
1.44 - switch(xoy)
1.45 - {
1.46 - case 'x':
1.47 - cm[node].x=coord;
1.48 - break;
1.49 - case 'y':
1.50 - cm[node].y=coord;
1.51 - break;
1.52 - default:
1.53 - throw UninitializedParameter() ;
1.54 - }
1.55 - }
1.56 -};
1.57 -
1.58 -int main(void)
1.59 -{
1.60 - Graph g;
1.61 - CoordinatesMap cm(g);
1.62 -
1.63 - CoordReaderMap xreader('x',cm);
1.64 - CoordReaderMap yreader('y',cm);
1.65 -
1.66 - std::ifstream is("graphocska.lemon");
1.67 -
1.68 - GraphReader<Graph> reader(is, g);
1.69 - reader.addNodeMap("coordinates_x", xreader);
1.70 - reader.addNodeMap("coordinates_y", yreader);
1.71 - reader.run();
1.72 - std::cout << "Megvagyok" << std::endl;
1.73 -
1.74 - for (NodeIt i(g); i!=INVALID; ++i)
1.75 - std::cout << " " << g.id(i) << " " << cm[i];
1.76 - std::cout << std::endl;
1.77 -
1.78 - return 0;
1.79 -}