|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Importer for networks stored in Vissim format 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 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 #ifndef NIImporter_Vissim_h 00020 #define NIImporter_Vissim_h 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 <string> 00033 #include <map> 00034 #include <utils/common/VectorHelper.h> 00035 #include <utils/common/RGBColor.h> 00036 #include <utils/geom/Position.h> 00037 #include "tempstructs/NIVissimExtendedEdgePoint.h" 00038 #include "NIVissimElements.h" 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class OptionsCont; 00045 class NBNetBuilder; 00046 00047 00048 // =========================================================================== 00049 // class definitions 00050 // =========================================================================== 00055 class NIImporter_Vissim { 00056 public: 00068 static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb); 00069 00070 00071 protected: 00073 NIImporter_Vissim(NBNetBuilder& nb, const std::string& file); 00074 00076 ~NIImporter_Vissim(); 00077 00079 void load(const OptionsCont& options); 00080 00081 bool admitContinue(const std::string& tag); 00082 00083 public: 00084 class VissimSingleTypeParser { 00085 public: 00087 VissimSingleTypeParser(NIImporter_Vissim& parent); 00088 00090 virtual ~VissimSingleTypeParser(); 00091 00094 virtual bool parse(std::istream& from) = 0; 00095 00096 protected: 00098 std::string myRead(std::istream& from); 00099 00101 std::string readEndSecure(std::istream& from, 00102 const std::string& excl=""); 00103 00104 std::string readEndSecure(std::istream& from, 00105 const std::vector<std::string> &excl); 00106 00108 std::string overrideOptionalLabel(std::istream& from, 00109 const std::string& tag=""); 00110 00112 Position getPosition(std::istream& from); 00113 00116 IntVector parseAssignedVehicleTypes(std::istream& from, 00117 const std::string& next); 00118 00119 NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream& from); 00120 00124 std::string readName(std::istream& from); 00125 00128 bool skipOverreading(std::istream& from, const std::string& name=""); 00129 00131 void readUntil(std::istream& from, const std::string& name); 00132 00133 private: 00134 NIImporter_Vissim& myVissimParent; 00135 00136 }; 00137 00138 00140 typedef std::map<std::string, RGBColor> ColorMap; 00141 00142 private: 00143 bool readContents(std::istream& strm); 00144 void postLoadBuild(SUMOReal offset); 00145 00146 00148 void insertKnownElements(); 00149 00151 void buildParsers(); 00152 00153 private: 00155 typedef std::map<std::string, NIVissimElement> ToElemIDMap; 00156 00158 ToElemIDMap myKnownElements; 00159 00161 typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap; 00162 00164 ToParserMap myParsers; 00165 00167 ColorMap myColorMap; 00168 00169 std::string myLastSecure; 00170 00171 NBNetBuilder& myNetBuilder; 00172 00173 private: 00175 NIImporter_Vissim(const NIImporter_Vissim&); 00176 00178 NIImporter_Vissim& operator=(const NIImporter_Vissim&); 00179 00180 }; 00181 00182 00183 #endif 00184 00185 /****************************************************************************/ 00186