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