SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // Importer for networks stored in Vissim format 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 #ifndef NIImporter_Vissim_h 00022 #define NIImporter_Vissim_h 00023 00024 00025 // =========================================================================== 00026 // included modules 00027 // =========================================================================== 00028 #ifdef _MSC_VER 00029 #include <windows_config.h> 00030 #else 00031 #include <config.h> 00032 #endif 00033 00034 #include <string> 00035 #include <map> 00036 #include <vector> 00037 #include <utils/common/RGBColor.h> 00038 #include <utils/geom/Position.h> 00039 #include "tempstructs/NIVissimExtendedEdgePoint.h" 00040 #include "NIVissimElements.h" 00041 00042 00043 // =========================================================================== 00044 // class declarations 00045 // =========================================================================== 00046 class OptionsCont; 00047 class NBNetBuilder; 00048 00049 00050 // =========================================================================== 00051 // class definitions 00052 // =========================================================================== 00057 class NIImporter_Vissim { 00058 public: 00070 static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb); 00071 00072 00073 protected: 00075 NIImporter_Vissim(NBNetBuilder& nb, const std::string& file); 00076 00078 ~NIImporter_Vissim(); 00079 00081 void load(const OptionsCont& options); 00082 00083 bool admitContinue(const std::string& tag); 00084 00085 public: 00086 class VissimSingleTypeParser { 00087 public: 00089 VissimSingleTypeParser(NIImporter_Vissim& parent); 00090 00092 virtual ~VissimSingleTypeParser(); 00093 00096 virtual bool parse(std::istream& from) = 0; 00097 00098 protected: 00100 std::string myRead(std::istream& from); 00101 00103 std::string readEndSecure(std::istream& from, 00104 const std::string& excl = ""); 00105 00106 std::string readEndSecure(std::istream& from, 00107 const std::vector<std::string> &excl); 00108 00110 std::string overrideOptionalLabel(std::istream& from, 00111 const std::string& tag = ""); 00112 00114 Position getPosition(std::istream& from); 00115 00118 std::vector<int> parseAssignedVehicleTypes(std::istream& from, 00119 const std::string& next); 00120 00121 NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream& from); 00122 00126 std::string readName(std::istream& from); 00127 00130 bool skipOverreading(std::istream& from, const std::string& name = ""); 00131 00133 void readUntil(std::istream& from, const std::string& name); 00134 00135 private: 00136 NIImporter_Vissim& myVissimParent; 00137 00138 private: 00140 VissimSingleTypeParser& operator=(const VissimSingleTypeParser&); 00141 00142 }; 00143 00144 00146 typedef std::map<std::string, RGBColor> ColorMap; 00147 00148 private: 00149 bool readContents(std::istream& strm); 00150 void postLoadBuild(SUMOReal offset); 00151 00152 00154 void insertKnownElements(); 00155 00157 void buildParsers(); 00158 00159 private: 00161 typedef std::map<std::string, NIVissimElement> ToElemIDMap; 00162 00164 ToElemIDMap myKnownElements; 00165 00167 typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap; 00168 00170 ToParserMap myParsers; 00171 00173 ColorMap myColorMap; 00174 00175 std::string myLastSecure; 00176 00177 NBNetBuilder& myNetBuilder; 00178 00179 private: 00181 NIImporter_Vissim(const NIImporter_Vissim&); 00182 00184 NIImporter_Vissim& operator=(const NIImporter_Vissim&); 00185 00186 }; 00187 00188 00189 #endif 00190 00191 /****************************************************************************/ 00192