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-2013 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 // used namespaces
50 // ===========================================================================
51 
52 using namespace std;
53 
54 NIVissimNodeDef_Poly::NIVissimNodeDef_Poly(int id, const std::string& name,
55  const PositionVector& poly)
57  myPoly(poly) {}
58 
59 
61 
62 
63 bool
64 NIVissimNodeDef_Poly::dictionary(int id, const std::string& name,
65  const PositionVector& poly) {
66  NIVissimNodeDef_Poly* o = new NIVissimNodeDef_Poly(id, name, poly);
67  if (!NIVissimNodeDef::dictionary(id, o)) {
68  delete o;
69  assert(false);
70  return false;
71  }
72  return true;
73 }
74 
75 
76 /*
77 void
78 NIVissimNodeDef_Poly::computeBounding()
79 {
80  // !!! compute participating edges
81  // !!! call this method after loading!
82  myBoundary = new Boundary(myPoly.getBoxBoundary());
83  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
84 }
85 
86 SUMOReal
87 NIVissimNodeDef_Poly::getEdgePosition(int edgeid) const
88 {
89  NIVissimEdge *edge = NIVissimEdge::dictionary(edgeid);
90  return edge->crossesAtPoint(
91  Position(myBoundary->xmin(), myBoundary->ymin()),
92  Position(myBoundary->xmax(), myBoundary->ymax()));
93 }
94 */
95 
96 
97 void
99  std::vector<int> within = NIVissimAbstractEdge::getWithin(myPoly, offset);
100  std::vector<int> connections;
101  std::vector<int> edges;
102  Boundary boundary(myPoly.getBoxBoundary());
103  for (std::vector<int>::const_iterator i = within.begin(); i != within.end(); i++) {
104  NIVissimConnection* c =
106  NIVissimEdge* e =
108  if (c != 0) {
109  connections.push_back(*i);
110  c->setNodeCluster(myID);
111  }
112  if (e != 0) {
113  edges.push_back(*i);
114  }
115  }
117  new NIVissimConnectionCluster(connections, boundary, myID, edges);
118  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
120  edge->myConnectionClusters.push_back(c);
121  }
122 }
123 
124 
125 
126 /****************************************************************************/
127