src/gui/mapstorage.cc
author deba
Wed, 11 May 2005 17:36:25 +0000
changeset 1413 3f45d58969d4
permissions -rw-r--r--
Fixing invertable maps:
InvertableMap
DescriptorMap
IdMap
     1 #include <mapstorage.h>
     2 
     3 MapStorage::MapStorage(Graph & graph):g(graph)
     4 {
     5   for(int i=0;i<PROPERTY_NUM;i++)
     6   {
     7     Graph::EdgeMap<double> emd(g);
     8     default_edgemaps.push_back(emd);
     9     Graph::NodeMap<double> nmd(g);
    10     default_nodemaps.push_back(nmd);
    11   }
    12 
    13   //std::string defaultstr="Default ";
    14   for(int i=0;i<PROPERTY_NUM;i++)
    15   {
    16       for (EdgeIt j(g); j!=INVALID; ++j)
    17       {
    18 	(default_edgemaps[i])[j]=property_defaults[i];
    19       }
    20       addEdgeMap(property_strings[i],&(default_edgemaps[i]));
    21   }
    22 
    23 };
    24 
    25 int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
    26 {
    27   nodemap_storage[name]=nodemap;
    28   return 0;
    29 }
    30 int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
    31 {
    32   edgemap_storage[name]=edgemap;
    33   return 0;
    34 }
    35 
    36 double MapStorage::maxOfNodeMap(const std::string & name)
    37 {
    38   double max=0;
    39   for (NodeIt j(g); j!=INVALID; ++j)
    40   {
    41     if( (*nodemap_storage[name])[j]>max )
    42     {
    43       max=(*nodemap_storage[name])[j];
    44     }
    45   }
    46   return max;
    47 }
    48 
    49 double MapStorage::maxOfEdgeMap(const std::string & name)
    50 {
    51   double max=0;
    52   for (EdgeIt j(g); j!=INVALID; ++j)
    53   {
    54     if( (*edgemap_storage[name])[j]>max )
    55     {
    56       max=(*edgemap_storage[name])[j];
    57     }
    58   }
    59   return max;
    60 }
    61 
    62 double MapStorage::minOfNodeMap(const std::string & name)
    63 {
    64   NodeIt j(g);
    65   double min=(*nodemap_storage[name])[j];
    66   for (; j!=INVALID; ++j)
    67   {
    68     if( (*nodemap_storage[name])[j]<min )
    69     {
    70       min=(*nodemap_storage[name])[j];
    71     }
    72   }
    73   return min;
    74 }
    75 
    76 double MapStorage::minOfEdgeMap(const std::string & name)
    77 {
    78   EdgeIt j(g);
    79   double min=(*edgemap_storage[name])[j];
    80   for (EdgeIt j(g); j!=INVALID; ++j)
    81   {
    82     if( (*edgemap_storage[name])[j]<min )
    83     {
    84       min=(*edgemap_storage[name])[j];
    85     }
    86   }
    87   return min;
    88 }
    89