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