NIVissimSingleTypeParser_Fahrzeugklassendefinition.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include <iostream>
00031 #include <utils/common/TplConvert.h>
00032 #include <utils/common/ToString.h>
00033 #include <utils/common/VectorHelper.h>
00034 #include "../NIImporter_Vissim.h"
00035 #include "../tempstructs/NIVissimVehTypeClass.h"
00036 #include "NIVissimSingleTypeParser_Fahrzeugklassendefinition.h"
00037 
00038 #ifdef CHECK_MEMORY_LEAKS
00039 #include <foreign/nvwa/debug_new.h>
00040 #endif // CHECK_MEMORY_LEAKS
00041 
00042 
00043 // ===========================================================================
00044 // method definitions
00045 // ===========================================================================
00046 NIVissimSingleTypeParser_Fahrzeugklassendefinition::NIVissimSingleTypeParser_Fahrzeugklassendefinition(
00047     NIImporter_Vissim &parent, NIImporter_Vissim::ColorMap &colorMap)
00048         : NIImporter_Vissim::VissimSingleTypeParser(parent),
00049         myColorMap(colorMap) {}
00050 
00051 
00052 NIVissimSingleTypeParser_Fahrzeugklassendefinition::~NIVissimSingleTypeParser_Fahrzeugklassendefinition() {}
00053 
00054 
00055 bool
00056 NIVissimSingleTypeParser_Fahrzeugklassendefinition::parse(std::istream &from) {
00057     // id
00058     int id;
00059     from >> id; // type-checking is missing!
00060     // name
00061     std::string tag;
00062     from >> tag;
00063     std::string name = readName(from);
00064     // color
00065     from >> tag;
00066     std::string colorName = myRead(from);
00067     RGBColor color;
00068     NIImporter_Vissim::ColorMap::iterator i=myColorMap.find(colorName);
00069     if (i!=myColorMap.end()) {
00070         color = (*i).second;
00071     } else {
00072         int r, g, b;
00073         r = TplConvert<char>::_2int(colorName.c_str());
00074         from >> g; // type-checking is missing!
00075         from >> b; // type-checking is missing!
00076         color = RGBColor(
00077                     (SUMOReal) r / (SUMOReal) 255.0,
00078                     (SUMOReal) g / (SUMOReal) 255.0,
00079                     (SUMOReal) b / (SUMOReal) 255.0);
00080     }
00081     // types
00082     from >> tag;
00083     IntVector types;
00084     from >> tag;
00085     do {
00086         types.push_back(TplConvert<char>::_2int(tag.c_str()));
00087         tag = readEndSecure(from);
00088     } while (tag!="DATAEND");
00089     return NIVissimVehTypeClass::dictionary(id, name, color, types);
00090 }
00091 
00092 
00093 
00094 /****************************************************************************/
00095 

Generated on Wed May 5 00:06:34 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6