SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimNodeDef_Poly.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // -------------------
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2014 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 
96 void
98  std::vector<int> within = NIVissimAbstractEdge::getWithin(myPoly, offset);
99  std::vector<int> connections;
100  std::vector<int> edges;
101  Boundary boundary(myPoly.getBoxBoundary());
102  for (std::vector<int>::const_iterator i = within.begin(); i != within.end(); i++) {
103  NIVissimConnection* c =
105  NIVissimEdge* e =
107  if (c != 0) {
108  connections.push_back(*i);
109  c->setNodeCluster(myID);
110  }
111  if (e != 0) {
112  edges.push_back(*i);
113  }
114  }
116  new NIVissimConnectionCluster(connections, boundary, myID, edges);
117  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
119  edge->myConnectionClusters.push_back(c);
120  }
121 }
122 
123 
124 
125 /****************************************************************************/
126