NIVissimSingleTypeParser_Knotendefinition.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/geom/Position2D.h>
00033 #include <utils/geom/Position2DVector.h>
00034 #include "../NIImporter_Vissim.h"
00035 #include "../tempstructs/NIVissimNodeParticipatingEdge.h"
00036 #include "../tempstructs/NIVissimNodeParticipatingEdgeVector.h"
00037 #include "../tempstructs/NIVissimNodeDef_Edges.h"
00038 #include "../tempstructs/NIVissimNodeDef_Poly.h"
00039 #include "../tempstructs/NIVissimNodeDef.h"
00040 #include "NIVissimSingleTypeParser_Knotendefinition.h"
00041 
00042 #ifdef CHECK_MEMORY_LEAKS
00043 #include <foreign/nvwa/debug_new.h>
00044 #endif // CHECK_MEMORY_LEAKS
00045 
00046 
00047 // ===========================================================================
00048 // method definitions
00049 // ===========================================================================
00050 NIVissimSingleTypeParser_Knotendefinition::NIVissimSingleTypeParser_Knotendefinition(NIImporter_Vissim &parent)
00051         : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00052 
00053 
00054 NIVissimSingleTypeParser_Knotendefinition::~NIVissimSingleTypeParser_Knotendefinition() {}
00055 
00056 
00057 bool
00058 NIVissimSingleTypeParser_Knotendefinition::parse(std::istream &from) {
00059     //
00060     int id;
00061     from >> id;
00062     //
00063     std::string tag;
00064     from >> tag;
00065     std::string name = readName(from);
00066     //
00067     tag = overrideOptionalLabel(from);
00068     //
00069     while (tag!="netzausschnitt") {
00070         tag = myRead(from);
00071     }
00072     //
00073     tag = myRead(from);
00074     if (tag=="strecke") {
00075         NIVissimNodeParticipatingEdgeVector edges;
00076         while (tag=="strecke") {
00077             int edgeid;
00078             SUMOReal from_pos, to_pos;
00079             from_pos = to_pos = -1.0;
00080             from >> edgeid;
00081             tag = readEndSecure(from, "strecke");
00082             if (tag=="von") {
00083                 from >> from_pos; // type-checking is missing!
00084                 from >> tag;
00085                 from >> to_pos; // type-checking is missing!
00086                 tag = readEndSecure(from, "strecke");
00087             }
00088             edges.push_back(new NIVissimNodeParticipatingEdge(edgeid, from_pos, to_pos));
00089         }
00090         NIVissimNodeDef_Edges::dictionary(id, name, edges);
00091     } else {
00092         int no = TplConvert<char>::_2int(tag.c_str());
00093         Position2DVector poly;
00094         for (int i=0; i<no; i++) {
00095             poly.push_back(getPosition2D(from));
00096         }
00097         poly.closePolygon();
00098         NIVissimNodeDef_Poly::dictionary(id, name, poly);
00099     }
00100     return true;
00101 }
00102 
00103 
00104 
00105 /****************************************************************************/
00106 

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