50 #ifdef CHECK_MEMORY_LEAKS
52 #endif // CHECK_MEMORY_LEAKS
101 std::vector<int> ret;
104 ret.push_back((*i)->getID());
105 (*i)->setNodeCluster(
id);
126 const std::vector<int>& connections,
int nodeCluster,
int edgeid)
136 for (std::vector<int>::const_iterator i = connections.begin(); i != connections.end(); i++) {
149 const std::vector<int>& connections,
const Boundary& boundary,
150 int nodeCluster,
const std::vector<int>& edges)
151 : myConnections(connections), myBoundary(boundary),
152 myNodeCluster(nodeCluster), myEdges(edges) {
157 for (std::vector<int>::const_iterator i = connections.begin(); i != connections.end(); i++) {
162 assert(find(edges.begin(), edges.end(), c->
getFromEdgeID()) != edges.end()
164 find(edges.begin(), edges.end(), c->
getToEdgeID()) != edges.end());
205 for (std::vector<int>::iterator j = c->
myEdges.begin(); j != c->
myEdges.end(); j++) {
226 std::vector<NIVissimConnectionCluster*> joinAble;
232 ContType::iterator j = i + 1;
237 if ((*i)->joinable(*j, offset)) {
238 joinAble.push_back(*j);
242 for (std::vector<NIVissimConnectionCluster*>::iterator k = joinAble.begin();
243 k != joinAble.end(); k++) {
251 if (joinAble.size() > 0) {
264 ContType::iterator j = i + 1;
268 if ((*i)->joinable(*j, offset)) {
269 joinAble.push_back(*j);
273 for (std::vector<NIVissimConnectionCluster*>::iterator k = joinAble.begin();
274 k != joinAble.end(); k++) {
282 if (joinAble.size() > 0) {
298 ContType::iterator j = i + 1;
302 if ((*i)->isWeakDistrictConnRealisation(*j)) {
303 joinAble.push_back(*j);
307 for (std::vector<NIVissimConnectionCluster*>::iterator k = joinAble.begin();
308 k != joinAble.end(); k++) {
316 if (joinAble.size() > 0) {
356 std::vector<int> extendedOutgoing1;
357 std::vector<int> extendedIncoming1;
358 std::vector<int> extendedOutgoing2;
359 std::vector<int> extendedIncoming2;
400 bool crosses =
false;
422 if (oe == 0 || ie == 0) {
427 SUMOReal a1 = l1.atan2DegreeAngle();
428 SUMOReal a2 = l2.atan2DegreeAngle();
429 return fabs(a1 - a2) < 5;
447 if (pos1 <= 5.0 && pos2 <= 5.0) {
458 if (pos1 >= g.length() - 5.0 && pos2 >= g.length() - 5.0) {
470 const std::vector<int>& iv2)
const {
471 std::vector<int> ret(iv1);
472 for (std::vector<int>::const_iterator i = iv1.begin(); i != iv1.end(); i++) {
475 for (std::vector<NIVissimEdge*>::const_iterator j = treatAsSame.begin(); j != treatAsSame.end(); j++) {
476 if (find(iv2.begin(), iv2.end(), (*j)->getID()) == iv2.end()) {
477 ret.push_back((*j)->getID());
486 std::vector<int> ret;
490 for (std::vector<int>::const_iterator j = disturbances.begin(); j != disturbances.end(); j++) {
503 std::vector<int> disturbances;
504 std::vector<int> tls;
505 std::vector<int> nodes;
508 if ((*i)->myConnections.size() > 0) {
509 (*i)->recomputeBoundary();
512 nodes = (*i)->myNodes;
513 if (nodes.size() > 1) {
514 WRITE_WARNING(
"NIVissimConnectionCluster:More than a single node");
517 if (nodes.size() > 0) {
523 nodeid, tlsid, (*i)->myConnections,
524 disturbances, (*i)->myIncomingEdges.size() < 2);
525 assert((*i)->myNodeCluster ==
id || (*i)->myNodeCluster < 0);
526 (*i)->myNodeCluster = id;
534 std::vector<int> connections = (*i)->myConnections;
535 for (std::vector<int>::iterator j = connections.begin(); j != connections.end(); j++) {
536 if (j != connections.begin()) {
541 into <<
"(" << (*i)->myBoundary <<
")" << std::endl;
543 into <<
"---------------------------" << std::endl;
564 int connid = conn->
getID();
609 std::vector<int>::iterator i;
642 std::vector<int>::const_iterator i;
686 WRITE_WARNING(
"NIVissimConnectionCluster: how to get an edge's position?");
690 std::vector<int>::const_iterator i = find(
myEdges.begin(),
myEdges.end(), edgeid);
698 edgeGeom.front(), edgeGeom.back(), p);
716 std::vector<NIVissimConnection*> edgeIsIncoming;
720 edgeIsIncoming.push_back(c);
724 if (edgeIsIncoming.size() == 0) {
728 sort(edgeIsIncoming.begin(), edgeIsIncoming.end(),
739 std::vector<NIVissimConnection*> edgeIsIncoming;
743 edgeIsIncoming.push_back(c);
747 if (edgeIsIncoming.size() == 0) {
751 sort(edgeIsIncoming.begin(), edgeIsIncoming.end(),
753 return *(edgeIsIncoming.begin());
761 std::vector<NIVissimConnection*> edgeIsOutgoing;
765 edgeIsOutgoing.push_back(c);
769 if (edgeIsOutgoing.size() == 0) {
773 sort(edgeIsOutgoing.begin(), edgeIsOutgoing.end(),
783 std::vector<NIVissimConnection*> edgeIsOutgoing;
787 edgeIsOutgoing.push_back(c);
791 if (edgeIsOutgoing.size() == 0) {
795 sort(edgeIsOutgoing.begin(), edgeIsOutgoing.end(),
797 return *(edgeIsOutgoing.begin());
SUMOReal getFromPosition() const
bool joinable(NIVissimConnectionCluster *c2, SUMOReal offset)
std::vector< NIVissimConnectionCluster * > ContType
NodeSubCluster(NIVissimConnection *c)
int myNodeCluster
The node the cluster is assigned to.
NBNode * getNBNode() const
int getDisturbanceID() const
Position getCenter() const
Returns the center of the boundary.
std::vector< int > myConnections
List of connection-ids which participate within this cluster.
bool around(const Position &p, SUMOReal offset=0) const
Returns whether the boundary contains the given coordinate.
static void joinBySameEdges(SUMOReal offset)
Tries to joind clusters participating within a node This is done by joining clusters which overlap...
static std::vector< int > getWithin(const AbstractPoly &poly)
const std::vector< NIVissimEdge * > & getToTreatAsSame() const
SUMOReal xmin() const
Returns minimum x-coordinate.
NIVissimConnection * getOutgoingContinuation(NIVissimEdge *e) const
bool intersects(const Position &p1, const Position &p2) const
bool overlapsWith(NIVissimConnectionCluster *c, SUMOReal offset=0) const
Returns the information whether the given cluster overlaps the current.
void addToConnectionCluster(NIVissimConnectionCluster *c)
static bool dictionary(int id, NIVissimNodeCluster *o)
std::vector< int > myOutgoingEdges
SUMOReal beginEndAngle() const
static Position crossPoint(const Boundary &b, const PositionVector &v)
SUMOReal xmax() const
Returns maximum x-coordinate.
const PositionVector & getGeometry() const
A class that stores a 2D geometrical boundary.
bool overlapsWith(const NodeSubCluster &c, SUMOReal offset=0)
Position getToGeomPosition() const
std::vector< int > getDisturbanceParticipators()
#define WRITE_WARNING(msg)
A temporary storage for edges imported from Vissim.
static ContType myClusters
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns whether the boundary overlaps with the given polygon.
void add(NIVissimConnectionCluster *c)
Adds the second cluster.
static SUMOReal nearest_offset_on_line_to_point2D(const Position &l1, const Position &l2, const Position &p, bool perpendicular=true)
~NIVissimConnectionCluster()
Destructor.
SUMOReal getToPosition() const
A point in 2D or 3D with translation and scaling methods.
static void _debugOut(std::ostream &into)
NIVissimConnection * getIncomingContinuation(NIVissimEdge *e) const
static void buildNodeClusters()
std::vector< int > myEdges
std::vector< int > extendByToTreatAsSame(const std::vector< int > &iv1, const std::vector< int > &iv2) const
static void removeDouble(std::vector< T > &v)
static bool dictionary(int id, const std::string &name, const NIVissimExtendedEdgePoint &edge, const NIVissimExtendedEdgePoint &by, SUMOReal timegap, SUMOReal waygap, SUMOReal vmax)
virtual SUMOReal getEdgePosition(int edgeid) const =0
static bool dictionary(int id, NIVissimNodeDef *o)
const Boundary & getBoundingBox() const
std::vector< int > getConnectionIDs() const
bool around(const Position &p, SUMOReal offset=0) const
void add(NIVissimConnection *c)
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
void removeConnections(const NodeSubCluster &c)
static int getNextFreeNodeID()
ConnectionCont myConnections
bool hasNodeCluster() const
PositionVector getIncomingContinuationGeometry(NIVissimEdge *e) const
const Boundary & getBoundary() const
static bool dictionary(int id, const std::string &name, const NIVissimExtendedEdgePoint &from_def, const NIVissimExtendedEdgePoint &to_def, const PositionVector &geom, Direction direction, SUMOReal dxnothalt, SUMOReal dxeinordnen, SUMOReal zuschlag1, SUMOReal zuschlag2, SUMOReal seglength, const std::vector< int > &assignedVehicles, const NIVissimClosedLanesVector &clv)
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, SUMOReal zuschlag1, SUMOReal zuschlag2, SUMOReal length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
Boundary myBoundary
The boundary of the cluster.
Represents a single node (junction) during network building.
SUMOReal getPositionForEdge(int edgeid) const
const std::vector< int > & getDisturbances() const
bool liesOnSameEdgesEnd(NIVissimConnectionCluster *cc2)
bool isWeakDistrictConnRealisation(NIVissimConnectionCluster *c2)
NIVissimConnectionCluster(const std::vector< int > &connections, int nodeCluster, int edgeid)
Constructor Build the boundary; The boundary includes both incoming and outgoing nodes.
std::vector< int > myIncomingEdges
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Position getFromGeomPosition() const
PositionVector getOutgoingContinuationGeometry(NIVissimEdge *e) const
void removeFromConnectionCluster(NIVissimConnectionCluster *c)
int getFromEdgeID() const