|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // ------------------- 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 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 00031 #include <string> 00032 #include <map> 00033 #include <cassert> 00034 #include <algorithm> 00035 #include <utils/geom/PositionVector.h> 00036 #include "NIVissimEdge.h" 00037 #include "NIVissimNodeDef.h" 00038 #include "NIVissimNodeDef_Poly.h" 00039 #include "NIVissimConnection.h" 00040 #include "NIVissimAbstractEdge.h" 00041 #include <utils/geom/Boundary.h> 00042 00043 #ifdef CHECK_MEMORY_LEAKS 00044 #include <foreign/nvwa/debug_new.h> 00045 #endif // CHECK_MEMORY_LEAKS 00046 // =========================================================================== 00047 // used namespaces 00048 // =========================================================================== 00049 00050 using namespace std; 00051 00052 NIVissimNodeDef_Poly::NIVissimNodeDef_Poly(int id, const std::string& name, 00053 const PositionVector& poly) 00054 : NIVissimNodeDef_Edges(id, name, NIVissimNodeParticipatingEdgeVector()), 00055 myPoly(poly) {} 00056 00057 00058 NIVissimNodeDef_Poly::~NIVissimNodeDef_Poly() {} 00059 00060 00061 bool 00062 NIVissimNodeDef_Poly::dictionary(int id, const std::string& name, 00063 const PositionVector& poly) { 00064 NIVissimNodeDef_Poly* o = new NIVissimNodeDef_Poly(id, name, poly); 00065 if (!NIVissimNodeDef::dictionary(id, o)) { 00066 delete o; 00067 assert(false); 00068 return false; 00069 } 00070 return true; 00071 } 00072 00073 00074 /* 00075 void 00076 NIVissimNodeDef_Poly::computeBounding() 00077 { 00078 // !!! compute participating edges 00079 // !!! call this method after loading! 00080 myBoundary = new Boundary(myPoly.getBoxBoundary()); 00081 assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin()); 00082 } 00083 00084 SUMOReal 00085 NIVissimNodeDef_Poly::getEdgePosition(int edgeid) const 00086 { 00087 NIVissimEdge *edge = NIVissimEdge::dictionary(edgeid); 00088 return edge->crossesAtPoint( 00089 Position(myBoundary->xmin(), myBoundary->ymin()), 00090 Position(myBoundary->xmax(), myBoundary->ymax())); 00091 } 00092 */ 00093 00094 00095 void 00096 NIVissimNodeDef_Poly::searchAndSetConnections(SUMOReal offset) { 00097 IntVector within = NIVissimAbstractEdge::getWithin(myPoly, offset); 00098 IntVector connections; 00099 IntVector edges; 00100 Boundary boundary(myPoly.getBoxBoundary()); 00101 for (IntVector::const_iterator i=within.begin(); i!=within.end(); i++) { 00102 NIVissimConnection* c = 00103 NIVissimConnection::dictionary(*i); 00104 NIVissimEdge* e = 00105 NIVissimEdge::dictionary(*i); 00106 if (c!=0) { 00107 connections.push_back(*i); 00108 c->setNodeCluster(myID); 00109 } 00110 if (e!=0) { 00111 edges.push_back(*i); 00112 } 00113 } 00114 NIVissimConnectionCluster* c = 00115 new NIVissimConnectionCluster(connections, boundary, myID, edges); 00116 for (IntVector::iterator j=edges.begin(); j!=edges.end(); j++) { 00117 NIVissimEdge* edge = NIVissimEdge::dictionary(*j); 00118 edge->myConnectionClusters.push_back(c); 00119 } 00120 } 00121 00122 00123 00124 /****************************************************************************/ 00125