gui/mapstorage.cc
changeset 1646 2dd083dded66
parent 1645 4a04bb856ac7
child 1649 95c8cd25a456
     1.1 --- a/gui/mapstorage.cc	Tue Aug 23 07:36:09 2005 +0000
     1.2 +++ b/gui/mapstorage.cc	Tue Aug 23 15:57:12 2005 +0000
     1.3 @@ -11,6 +11,9 @@
     1.4  
     1.5    nodemap_storage["id"] = new Graph::NodeMap<double>(graph);
     1.6    edgemap_storage["id"] = new Graph::EdgeMap<double>(graph);
     1.7 +
     1.8 +  nodemap_default["id"] = 1.0;
     1.9 +  edgemap_default["id"] = 1.0;
    1.10  }
    1.11  
    1.12  MapStorage::~MapStorage()
    1.13 @@ -125,6 +128,7 @@
    1.14  {
    1.15    bool read_x = false;
    1.16    bool read_y = false;
    1.17 +  bool read_edge_id = false;
    1.18  
    1.19    try {
    1.20      LemonReader lreader(filename);
    1.21 @@ -182,6 +186,16 @@
    1.22      return 1;
    1.23    }
    1.24  
    1.25 +  if (!read_edge_id)
    1.26 +  {
    1.27 +    edgemap_storage["id"] = new Graph::EdgeMap<double>(graph);
    1.28 +    int i = 1;
    1.29 +    for (EdgeIt e(graph); e != INVALID; ++e)
    1.30 +    {
    1.31 +      (*edgemap_storage["id"])[e] = i++;
    1.32 +    }
    1.33 +  }
    1.34 +
    1.35    if (!read_x || !read_y)
    1.36    {
    1.37      int node_num = 0;
    1.38 @@ -210,6 +224,17 @@
    1.39      {
    1.40        nodemap_default[it->first] = 0.0;
    1.41      }
    1.42 +    else if (it->first == "id")
    1.43 +    {
    1.44 +      NodeIt n(graph);
    1.45 +      double max = (*nodemap_storage["id"])[n];
    1.46 +      for (; n != INVALID; ++n)
    1.47 +      {
    1.48 +        if ((*nodemap_storage["id"])[n] > max)
    1.49 +          max = (*nodemap_storage["id"])[n];
    1.50 +      }
    1.51 +      nodemap_default["id"] = max + 1.0;
    1.52 +    }
    1.53    }
    1.54    for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
    1.55        edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
    1.56 @@ -218,6 +243,17 @@
    1.57      {
    1.58        edgemap_default[it->first] = 0.0;
    1.59      }
    1.60 +    else
    1.61 +    {
    1.62 +      EdgeIt e(graph);
    1.63 +      double max = (*edgemap_storage["id"])[e];
    1.64 +      for (; e != INVALID; ++e)
    1.65 +      {
    1.66 +        if ((*edgemap_storage["id"])[e] > max)
    1.67 +          max = (*edgemap_storage["id"])[e];
    1.68 +      }
    1.69 +      edgemap_default["id"] = max + 1.0;
    1.70 +    }
    1.71    }
    1.72  
    1.73    return 0;
    1.74 @@ -267,12 +303,14 @@
    1.75    for (std::map<std::string, double>::iterator it =
    1.76        nodemap_default.begin(); it != nodemap_default.end(); ++it)
    1.77    {
    1.78 -    nodemap_default.erase(it);
    1.79 +    if (it->first != "id")
    1.80 +      nodemap_default.erase(it);
    1.81    }
    1.82    for (std::map<std::string, double>::iterator it =
    1.83        edgemap_default.begin(); it != edgemap_default.end(); ++it)
    1.84    {
    1.85 -    edgemap_default.erase(it);
    1.86 +    if (it->first != "id")
    1.87 +      edgemap_default.erase(it);
    1.88    }
    1.89    graph.clear();
    1.90    file_name = "";