SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NIVissimNodeDef_Poly.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // -------------------
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 
33 #include <string>
34 #include <map>
35 #include <cassert>
36 #include <algorithm>
38 #include "NIVissimEdge.h"
39 #include "NIVissimNodeDef.h"
40 #include "NIVissimNodeDef_Poly.h"
41 #include "NIVissimConnection.h"
42 #include "NIVissimAbstractEdge.h"
43 #include <utils/geom/Boundary.h>
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 NIVissimNodeDef_Poly::NIVissimNodeDef_Poly(int id, const std::string& name,
54  const PositionVector& poly)
56  myPoly(poly) {}
57 
58 
60 
61 
62 bool
63 NIVissimNodeDef_Poly::dictionary(int id, const std::string& name,
64  const PositionVector& poly) {
65  NIVissimNodeDef_Poly* o = new NIVissimNodeDef_Poly(id, name, poly);
66  if (!NIVissimNodeDef::dictionary(id, o)) {
67  delete o;
68  assert(false);
69  return false;
70  }
71  return true;
72 }
73 
74 
75 /*
76 void
77 NIVissimNodeDef_Poly::computeBounding()
78 {
79  // !!! compute participating edges
80  // !!! call this method after loading!
81  myBoundary = new Boundary(myPoly.getBoxBoundary());
82  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
83 }
84 
85 SUMOReal
86 NIVissimNodeDef_Poly::getEdgePosition(int edgeid) const
87 {
88  NIVissimEdge *edge = NIVissimEdge::dictionary(edgeid);
89  return edge->crossesAtPoint(
90  Position(myBoundary->xmin(), myBoundary->ymin()),
91  Position(myBoundary->xmax(), myBoundary->ymax()));
92 }
93 
94 
95 void
96 NIVissimNodeDef_Poly::searchAndSetConnections(SUMOReal offset) {
97  std::vector<int> within = NIVissimAbstractEdge::getWithin(myPoly, offset);
98  std::vector<int> connections;
99  std::vector<int> edges;
100  Boundary boundary(myPoly.getBoxBoundary());
101  for (std::vector<int>::const_iterator i = within.begin(); i != within.end(); i++) {
102  NIVissimConnection* c =
103  NIVissimConnection::dictionary(*i);
104  NIVissimEdge* e =
105  NIVissimEdge::dictionary(*i);
106  if (c != 0) {
107  connections.push_back(*i);
108  c->setNodeCluster(myID);
109  }
110  if (e != 0) {
111  edges.push_back(*i);
112  }
113  }
114  NIVissimConnectionCluster* c =
115  new NIVissimConnectionCluster(connections, boundary, myID, edges);
116  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
117  NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
118  edge->myConnectionClusters.push_back(c);
119  }
120 }
121 */
122 
123 
124 /****************************************************************************/
125 
NIVissimNodeDef_Poly(int id, const std::string &name, const PositionVector &poly)
A list of positions.
static bool dictionary(int id, NIVissimNodeDef *o)
std::vector< NIVissimNodeParticipatingEdge * > NIVissimNodeParticipatingEdgeVector
static bool dictionary(int id, const std::string &name, const PositionVector &poly)