NIVissimNodeDef_Poly.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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/Position2DVector.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
00048
00049
00050 using namespace std;
00051
00052 NIVissimNodeDef_Poly::NIVissimNodeDef_Poly(int id, const std::string &name,
00053 const Position2DVector &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 Position2DVector &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
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
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