NIVissimConnectionCluster Class Reference

#include <NIVissimConnectionCluster.h>


Detailed Description

This class holds a list of connections either all outgoing or all incoming within an edge, which do lies close together. This shall be the connections which belong to a single node. It still are not all of the node's connections, as other edges may participate to this node, too.

Definition at line 59 of file NIVissimConnectionCluster.h.


Public Member Functions

bool around (const Position2D &p, SUMOReal offset=0) const
const IntVectorgetConnections () const
NIVissimConnectiongetIncomingContinuation (NIVissimEdge *e) const
Position2DVector getIncomingContinuationGeometry (NIVissimEdge *e) const
NBNodegetNBNode () const
NIVissimConnectiongetOutgoingContinuation (NIVissimEdge *e) const
Position2DVector getOutgoingContinuationGeometry (NIVissimEdge *e) const
SUMOReal getPositionForEdge (int edgeid) const
bool hasNodeCluster () const
 NIVissimConnectionCluster (const IntVector &connections, const Boundary &boundary, int nodeCluster, const IntVector &edges)
 NIVissimConnectionCluster (const IntVector &connections, int nodeCluster, int edgeid)
 Constructor Build the boundary; The boundary includes both incoming and outgoing nodes.
bool overlapsWith (NIVissimConnectionCluster *c, SUMOReal offset=0) const
 Returns the information whether the given cluster overlaps the current.
 ~NIVissimConnectionCluster ()
 Destructor.

Static Public Member Functions

static void _debugOut (std::ostream &into)
static void buildNodeClusters ()
static void clearDict ()
static size_t dictSize ()
static int getNextFreeNodeID ()
static void joinByDisturbances (SUMOReal offset)
static void joinBySameEdges (SUMOReal offset)
 Tries to joind clusters participating within a node This is done by joining clusters which overlap.
static void searchForConnection (int id)

Private Types

typedef std::vector
< NIVissimConnectionCluster * > 
ContType

Private Member Functions

void add (NIVissimConnectionCluster *c)
 Adds the second cluster.
IntVector extendByToTreatAsSame (const IntVector &iv1, const IntVector &iv2) const
IntVector getDisturbanceParticipators ()
bool isWeakDistrictConnRealisation (NIVissimConnectionCluster *c2)
bool joinable (NIVissimConnectionCluster *c2, SUMOReal offset)
bool liesOnSameEdgesEnd (NIVissimConnectionCluster *cc2)
void recheckEdges ()
void recomputeBoundary ()
void removeConnections (const NodeSubCluster &c)

Private Attributes

int myBlaID
Boundary myBoundary
 The boundary of the cluster.
IntVector myConnections
 List of connection-ids which participate within this cluster.
IntVector myEdges
IntVector myIncomingEdges
int myNodeCluster
 The node the cluster is assigned to.
IntVector myNodes
IntVector myOutgoingEdges
IntVector myTLs

Static Private Attributes

static ContType myClusters
static int myFirstFreeID = 100000
static int myStaticBlaID = 0

Friends

class NIVissimEdge

Data Structures

class  NodeSubCluster
class  same_direction_sorter

Member Typedef Documentation

Definition at line 197 of file NIVissimConnectionCluster.h.


Constructor & Destructor Documentation

NIVissimConnectionCluster::NIVissimConnectionCluster ( const IntVector connections,
int  nodeCluster,
int  edgeid 
)

Constructor Build the boundary; The boundary includes both incoming and outgoing nodes.

Definition at line 121 of file NIVissimConnectionCluster.cpp.

References NIVissimConnection::dictionary(), NIVissimConnection::getFromEdgeID(), NIVissimConnection::getToEdgeID(), myClusters, myEdges, myIncomingEdges, myOutgoingEdges, recomputeBoundary(), and VectorHelper< T >::removeDouble().

00123         : myConnections(connections), myNodeCluster(nodeCluster),
00124         myBlaID(myStaticBlaID++) {
00125     recomputeBoundary();
00126     myClusters.push_back(this);
00127     assert(edgeid>0);
00128     if (edgeid>=0) {
00129         myEdges.push_back(edgeid);
00130     }
00131     // add information about incoming and outgoing edges
00132     for (IntVector::const_iterator i=connections.begin(); i!=connections.end(); i++) {
00133         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00134         assert(c!=0);
00135         myOutgoingEdges.push_back(c->getToEdgeID());
00136         myIncomingEdges.push_back(c->getFromEdgeID());
00137         assert(c->getFromEdgeID()==edgeid||c->getToEdgeID()==edgeid);
00138     }
00139     VectorHelper<int>::removeDouble(myIncomingEdges);
00140     VectorHelper<int>::removeDouble(myOutgoingEdges);
00141 }

NIVissimConnectionCluster::NIVissimConnectionCluster ( const IntVector connections,
const Boundary boundary,
int  nodeCluster,
const IntVector edges 
)

Definition at line 144 of file NIVissimConnectionCluster.cpp.

References NIVissimConnection::dictionary(), NIVissimConnection::getFromEdgeID(), NIVissimConnection::getToEdgeID(), myBoundary, myClusters, myIncomingEdges, myOutgoingEdges, recomputeBoundary(), VectorHelper< T >::removeDouble(), Boundary::xmax(), and Boundary::xmin().

00147         : myConnections(connections), myBoundary(boundary),
00148         myNodeCluster(nodeCluster), myEdges(edges) {
00149     myClusters.push_back(this);
00150     recomputeBoundary();
00151     assert(myBoundary.xmax()>=myBoundary.xmin());
00152     // add information about incoming and outgoing edges
00153     for (IntVector::const_iterator i=connections.begin(); i!=connections.end(); i++) {
00154         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00155         assert(c!=0);
00156         myOutgoingEdges.push_back(c->getToEdgeID());
00157         myIncomingEdges.push_back(c->getFromEdgeID());
00158         assert(find(edges.begin(), edges.end(), c->getFromEdgeID())!=edges.end()
00159                ||
00160                find(edges.begin(), edges.end(), c->getToEdgeID())!=edges.end());
00161     }
00162     VectorHelper<int>::removeDouble(myIncomingEdges);
00163     VectorHelper<int>::removeDouble(myOutgoingEdges);
00164 }

NIVissimConnectionCluster::~NIVissimConnectionCluster (  ) 

Destructor.

Definition at line 167 of file NIVissimConnectionCluster.cpp.

00167 {}


Member Function Documentation

void NIVissimConnectionCluster::_debugOut ( std::ostream &  into  )  [static]

Definition at line 546 of file NIVissimConnectionCluster.cpp.

References myClusters.

00546                                                      {
00547     for (ContType::iterator i=myClusters.begin(); i!=myClusters.end(); i++) {
00548         IntVector connections = (*i)->myConnections;
00549         for (IntVector::iterator j=connections.begin(); j!=connections.end(); j++) {
00550             if (j!=connections.begin()) {
00551                 into << ", ";
00552             }
00553             into << *j;
00554         }
00555         into << "(" << (*i)->myBoundary << ")" << std::endl;
00556     }
00557     into << "---------------------------" << std::endl;
00558 }

void NIVissimConnectionCluster::add ( NIVissimConnectionCluster c  )  [private]

Adds the second cluster.

Definition at line 187 of file NIVissimConnectionCluster.cpp.

References Boundary::add(), NIVissimEdge::dictionary(), myBoundary, myConnections, myEdges, myIncomingEdges, myNodeCluster, myOutgoingEdges, VectorHelper< T >::removeDouble(), Boundary::xmax(), and Boundary::xmin().

00187                                                            {
00188     assert(myBoundary.xmax()>=myBoundary.xmin());
00189     assert(c->myBoundary.xmax()>=c->myBoundary.xmin());
00190     myBoundary.add(c->myBoundary);
00191     for (IntVector::iterator i=c->myConnections.begin(); i!=c->myConnections.end(); i++) {
00192         myConnections.push_back(*i);
00193     }
00194     VectorHelper<int>::removeDouble(myConnections);
00195     assert(myNodeCluster==-1||c->myNodeCluster==-1);
00196     if (myNodeCluster==-1) {
00197         myNodeCluster = c->myNodeCluster;
00198     }
00199     // inform edges about merging
00200     //  !!! merge should be done within one method
00201     for (IntVector::iterator j=c->myEdges.begin(); j!=c->myEdges.end(); j++) {
00202         NIVissimEdge::dictionary(*j)->mergedInto(c, this);
00203     }
00204     copy(c->myEdges.begin(), c->myEdges.end(), back_inserter(myEdges));
00205     copy(c->myIncomingEdges.begin(), c->myIncomingEdges.end(),
00206          back_inserter(myIncomingEdges));
00207     copy(c->myOutgoingEdges.begin(), c->myOutgoingEdges.end(),
00208          back_inserter(myOutgoingEdges));
00209     VectorHelper<int>::removeDouble(myEdges);
00210     VectorHelper<int>::removeDouble(myIncomingEdges);
00211     VectorHelper<int>::removeDouble(myOutgoingEdges);
00212 }

bool NIVissimConnectionCluster::around ( const Position2D p,
SUMOReal  offset = 0 
) const

Definition at line 612 of file NIVissimConnectionCluster.cpp.

References Boundary::around(), myBoundary, Boundary::xmax(), and Boundary::xmin().

Referenced by NIVissimEdge::getFromNode(), and NIVissimEdge::resolveSameNode().

00612                                                                             {
00613     assert(myBoundary.xmax()>=myBoundary.xmin());
00614     return myBoundary.around(p, offset);
00615 }

void NIVissimConnectionCluster::buildNodeClusters (  )  [static]

Definition at line 500 of file NIVissimConnectionCluster.cpp.

References NIVissimNodeCluster::dictionary(), NIVissimDisturbance::getWithin(), myClusters, and WRITE_WARNING.

Referenced by NIImporter_Vissim::postLoadBuild().

00500                                              {
00501     for (ContType::iterator i=myClusters.begin(); i!=myClusters.end(); i++) {
00502         IntVector disturbances;
00503         IntVector tls;
00504         IntVector nodes;
00505         int tlsid = -1;
00506         int nodeid = -1;
00507         if ((*i)->myConnections.size()>0) {
00508             (*i)->recomputeBoundary();
00509             disturbances = NIVissimDisturbance::getWithin((*i)->myBoundary);
00510         }
00511         nodes = (*i)->myNodes;//NIVissimTL::getWithin((*i)->myBoundary, 5.0);
00512         if (nodes.size()>1) {
00513             WRITE_WARNING("NIVissimConnectionCluster:More than a single node");
00514             //          throw 1; // !!! eigentlich sollte hier nur eine Ampelanlage sein
00515         }
00516         if (nodes.size()>0) {
00517             nodeid = nodes[0];
00518         }
00519         //
00520         //
00521         int id = NIVissimNodeCluster::dictionary(
00522                      nodeid, tlsid, (*i)->myConnections,
00523                      disturbances, (*i)->myIncomingEdges.size()<2);
00524         assert((*i)->myNodeCluster==id||(*i)->myNodeCluster<0);
00525         (*i)->myNodeCluster = id;
00526     }
00527 }

void NIVissimConnectionCluster::clearDict (  )  [static]

Definition at line 718 of file NIVissimConnectionCluster.cpp.

References myClusters, and myFirstFreeID.

Referenced by NIImporter_Vissim::~NIImporter_Vissim().

00718                                      {
00719     for (ContType::iterator i=myClusters.begin(); i!=myClusters.end(); i++) {
00720         delete(*i);
00721     }
00722     myClusters.clear();
00723     myFirstFreeID = 100000;
00724 }

size_t NIVissimConnectionCluster::dictSize (  )  [static]

Definition at line 569 of file NIVissimConnectionCluster.cpp.

References myClusters.

00569                                     {
00570     return myClusters.size();
00571 }

IntVector NIVissimConnectionCluster::extendByToTreatAsSame ( const IntVector iv1,
const IntVector iv2 
) const [private]

Definition at line 468 of file NIVissimConnectionCluster.cpp.

References NIVissimEdge::dictionary(), and NIVissimEdge::getToTreatAsSame().

Referenced by joinable().

00469                                     {
00470     IntVector ret(iv1);
00471     for (IntVector::const_iterator i=iv1.begin(); i!=iv1.end(); i++) {
00472         NIVissimEdge *e = NIVissimEdge::dictionary(*i);
00473         const std::vector<NIVissimEdge*> treatAsSame = e->getToTreatAsSame();
00474         for (std::vector<NIVissimEdge*>::const_iterator j=treatAsSame.begin(); j!=treatAsSame.end(); j++) {
00475             if (find(iv2.begin(), iv2.end(), (*j)->getID())==iv2.end()) {
00476                 ret.push_back((*j)->getID());
00477             }
00478         }
00479     }
00480     return ret;
00481 }

const IntVector& NIVissimConnectionCluster::getConnections (  )  const [inline]

Definition at line 85 of file NIVissimConnectionCluster.h.

References myConnections.

00085                                             {
00086         return myConnections;
00087     }

IntVector NIVissimConnectionCluster::getDisturbanceParticipators (  )  [private]

Definition at line 484 of file NIVissimConnectionCluster.cpp.

References NIVissimDisturbance::dictionary(), NIVissimConnection::dictionary(), NIVissimDisturbance::getDisturbanceID(), NIVissimAbstractEdge::getDisturbances(), NIVissimDisturbance::getEdgeID(), and myConnections.

Referenced by joinable().

00484                                                        {
00485     IntVector ret;
00486     for (IntVector::iterator i=myConnections.begin(); i!=myConnections.end(); i++) {
00487         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00488         const IntVector &disturbances = c->getDisturbances();
00489         for (IntVector::const_iterator j=disturbances.begin(); j!=disturbances.end(); j++) {
00490             NIVissimDisturbance *d = NIVissimDisturbance::dictionary(*j);
00491             ret.push_back(d->getEdgeID());
00492             ret.push_back(d->getDisturbanceID());
00493         }
00494     }
00495     return ret;
00496 }

NIVissimConnection * NIVissimConnectionCluster::getIncomingContinuation ( NIVissimEdge e  )  const

Definition at line 751 of file NIVissimConnectionCluster.cpp.

References Position2DVector::beginEndAngle(), NIVissimConnection::dictionary(), NIVissimConnection::getFromEdgeID(), NIVissimAbstractEdge::getGeometry(), NIVissimAbstractEdge::getID(), and myConnections.

00751                                                                         {
00752     // collect connection where this edge is the incoming one
00753     std::vector<NIVissimConnection*> edgeIsIncoming;
00754     for (IntVector::const_iterator i=myConnections.begin(); i!=myConnections.end(); i++) {
00755         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00756         if (c->getFromEdgeID()==e->getID()) {
00757             edgeIsIncoming.push_back(c);
00758         }
00759     }
00760     //
00761     if (edgeIsIncoming.size()==0) {
00762         return 0;
00763     }
00764     // sort connected edges in same direction
00765     sort(edgeIsIncoming.begin(), edgeIsIncoming.end(),
00766          same_direction_sorter(e->getGeometry().beginEndAngle()));
00767     return *(edgeIsIncoming.begin());
00768 }

Position2DVector NIVissimConnectionCluster::getIncomingContinuationGeometry ( NIVissimEdge e  )  const

Definition at line 728 of file NIVissimConnectionCluster.cpp.

References Position2DVector::beginEndAngle(), NIVissimConnection::dictionary(), NIVissimConnection::getFromEdgeID(), NIVissimAbstractEdge::getGeometry(), NIVissimAbstractEdge::getID(), and myConnections.

00728                                                                                 {
00729     // collect connection where this edge is the incoming one
00730     std::vector<NIVissimConnection*> edgeIsIncoming;
00731     for (IntVector::const_iterator i=myConnections.begin(); i!=myConnections.end(); i++) {
00732         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00733         if (c->getFromEdgeID()==e->getID()) {
00734             edgeIsIncoming.push_back(c);
00735         }
00736     }
00737     //
00738     if (edgeIsIncoming.size()==0) {
00739         return Position2DVector();
00740     }
00741     // sort connected edges in same direction
00742     sort(edgeIsIncoming.begin(), edgeIsIncoming.end(),
00743          same_direction_sorter(e->getGeometry().beginEndAngle()));
00744     NIVissimConnection *c = *(edgeIsIncoming.begin());
00745     return c->getGeometry();
00746 }

NBNode * NIVissimConnectionCluster::getNBNode (  )  const

Definition at line 606 of file NIVissimConnectionCluster.cpp.

References NIVissimNodeCluster::dictionary(), and myNodeCluster.

Referenced by NIVissimEdge::getFromNode().

00606                                            {
00607     return NIVissimNodeCluster::dictionary(myNodeCluster)->getNBNode();
00608 }

int NIVissimConnectionCluster::getNextFreeNodeID (  )  [static]

Definition at line 172 of file NIVissimConnectionCluster.cpp.

References myFirstFreeID.

Referenced by NIVissimConnectionCluster::NodeSubCluster::getConnectionIDs().

00172                                              {
00173     return myFirstFreeID++;
00174 }

NIVissimConnection * NIVissimConnectionCluster::getOutgoingContinuation ( NIVissimEdge e  )  const

Definition at line 795 of file NIVissimConnectionCluster.cpp.

References Position2DVector::beginEndAngle(), NIVissimConnection::dictionary(), NIVissimAbstractEdge::getGeometry(), NIVissimAbstractEdge::getID(), NIVissimConnection::getToEdgeID(), and myConnections.

00795                                                                         {
00796     // collect connection where this edge is the outgoing one
00797     std::vector<NIVissimConnection*> edgeIsOutgoing;
00798     for (IntVector::const_iterator i=myConnections.begin(); i!=myConnections.end(); i++) {
00799         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00800         if (c->getToEdgeID()==e->getID()) {
00801             edgeIsOutgoing.push_back(c);
00802         }
00803     }
00804     //
00805     if (edgeIsOutgoing.size()==0) {
00806         return 0;
00807     }
00808     // sort connected edges in same direction
00809     sort(edgeIsOutgoing.begin(), edgeIsOutgoing.end(),
00810          same_direction_sorter(e->getGeometry().beginEndAngle()));
00811     return *(edgeIsOutgoing.begin());
00812 }

Position2DVector NIVissimConnectionCluster::getOutgoingContinuationGeometry ( NIVissimEdge e  )  const

Definition at line 773 of file NIVissimConnectionCluster.cpp.

References Position2DVector::beginEndAngle(), NIVissimConnection::dictionary(), NIVissimAbstractEdge::getGeometry(), NIVissimAbstractEdge::getID(), NIVissimConnection::getToEdgeID(), and myConnections.

00773                                                                                 {
00774     // collect connection where this edge is the outgoing one
00775     std::vector<NIVissimConnection*> edgeIsOutgoing;
00776     for (IntVector::const_iterator i=myConnections.begin(); i!=myConnections.end(); i++) {
00777         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00778         if (c->getToEdgeID()==e->getID()) {
00779             edgeIsOutgoing.push_back(c);
00780         }
00781     }
00782     //
00783     if (edgeIsOutgoing.size()==0) {
00784         return Position2DVector();
00785     }
00786     // sort connected edges in same direction
00787     sort(edgeIsOutgoing.begin(), edgeIsOutgoing.end(),
00788          same_direction_sorter(e->getGeometry().beginEndAngle()));
00789     NIVissimConnection *c = *(edgeIsOutgoing.begin());
00790     return c->getGeometry();
00791 }

SUMOReal NIVissimConnectionCluster::getPositionForEdge ( int  edgeid  )  const

Definition at line 651 of file NIVissimConnectionCluster.cpp.

References GeomHelper::crossPoint(), NIVissimEdge::dictionary(), NIVissimNodeDef::dictionary(), NIVissimConnection::dictionary(), Position2DVector::getBegin(), NIVissimNodeDef::getEdgePosition(), Position2DVector::getEnd(), NIVissimConnection::getFromEdgeID(), NIVissimConnection::getFromPosition(), NIVissimConnection::getToEdgeID(), NIVissimConnection::getToPosition(), myBoundary, myConnections, myEdges, myNodeCluster, GeomHelper::nearest_position_on_line_to_point(), SUMOReal, WRITE_WARNING, Boundary::xmax(), and Boundary::xmin().

Referenced by NIVissimEdge::connection_cluster_position_sorter::operator()().

00651                                                               {
00652     // return the middle of the connections when there are any
00653     if (myConnections.size()!=0) {
00654         SUMOReal sum = 0;
00655         size_t part = 0;
00656         IntVector::const_iterator i;
00657         for (i=myConnections.begin(); i!=myConnections.end(); i++) {
00658             NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00659             if (c->getFromEdgeID()==edgeid) {
00660                 part++;
00661                 sum += c->getFromPosition();
00662             }
00663             if (c->getToEdgeID()==edgeid) {
00664                 part++;
00665                 sum += c->getToPosition();
00666             }
00667         }
00668         if (part>0) {
00669             return sum / (SUMOReal) part;
00670         }
00671     }
00672     // use the position of the node if possible
00673     if (myNodeCluster>=0) {
00674         // try to find the nearest point on the edge
00675         //  !!! only the main geometry is regarded
00676         NIVissimNodeDef *node =
00677             NIVissimNodeDef::dictionary(myNodeCluster);
00678         if (node!=0) {
00679             SUMOReal pos = node->getEdgePosition(edgeid);
00680             if (pos>=0) {
00681                 return pos;
00682             }
00683         }
00684         /*
00685                 SUMOReal try1 = GeomHelper::nearest_position_on_line_to_point(
00686                     edge->getBegin2D(), edge->getEnd2D(), node->getPos());
00687                 if(try1>=0) {
00688                     return try1;
00689                 }
00690                 // try to use simple distance
00691                 SUMOReal dist1 =
00692                     GeomHelper::distance(node->getPos(), edge->getBegin2D());
00693                 SUMOReal dist2 =
00694                     GeomHelper::distance(node->getPos(), edge->getEnd2D());
00695                 return dist1<dist2
00696                     ? 0 : edge->getLength();
00697                     */
00698     }
00699     // what else?
00700     WRITE_WARNING("NIVissimConnectionCluster: how to get an edge's position?");
00701     // !!!
00702     assert(myBoundary.xmin()<=myBoundary.xmax());
00703     NIVissimEdge *edge = NIVissimEdge::dictionary(edgeid);
00704     IntVector::const_iterator i = find(myEdges.begin(), myEdges.end(), edgeid);
00705     if (i==myEdges.end()) {
00706         // edge does not exist!?
00707         throw 1;
00708     }
00709     const Position2DVector &edgeGeom = edge->getGeometry();
00710     Position2D p = GeomHelper::crossPoint(myBoundary, edgeGeom);
00711     return GeomHelper::nearest_position_on_line_to_point(
00712                edgeGeom.getBegin(), edgeGeom.getEnd(), p);
00713 }

bool NIVissimConnectionCluster::hasNodeCluster (  )  const

Definition at line 563 of file NIVissimConnectionCluster.cpp.

References myNodeCluster.

Referenced by joinable().

00563                                                 {
00564     return myNodeCluster != -1;
00565 }

bool NIVissimConnectionCluster::isWeakDistrictConnRealisation ( NIVissimConnectionCluster c2  )  [private]

Definition at line 386 of file NIVissimConnectionCluster.cpp.

References NIVissimEdge::dictionary(), NIVissimConnection::dictionary(), Position2DVector::getBegin(), Position2DVector::getEnd(), NIVissimAbstractEdge::getGeometry(), Position2DVector::intersects(), isWeakDistrictConnRealisation(), myConnections, myIncomingEdges, myOutgoingEdges, and SUMOReal.

Referenced by isWeakDistrictConnRealisation().

00386                                                                                       {
00387     if ((myIncomingEdges.size()==1&&myOutgoingEdges.size()==1)) {
00388         return false;
00389     }
00390     if ((c2->myIncomingEdges.size()==1&&c2->myOutgoingEdges.size()==1)) {
00391         return false;
00392     }
00393 
00394     // ok, may be the other way round
00395     if (myIncomingEdges.size()==1&&c2->myOutgoingEdges.size()==1) {
00396         return c2->isWeakDistrictConnRealisation(this);
00397     }
00398     // connections must cross
00399     bool crosses = false;
00400     for (IntVector::const_iterator j1=myConnections.begin(); j1!=myConnections.end()&&!crosses; j1++) {
00401         NIVissimConnection *c1 = NIVissimConnection::dictionary(*j1);
00402         const Position2DVector &g1 = c1->getGeometry();
00403         for (IntVector::const_iterator j2=c2->myConnections.begin(); j2!=c2->myConnections.end()&&!crosses; j2++) {
00404             NIVissimConnection *c2 = NIVissimConnection::dictionary(*j2);
00405             const Position2DVector &g2 = c2->getGeometry();
00406             if (g1.intersects(g2)) {
00407                 crosses = true;
00408             }
00409         }
00410     }
00411     if (!crosses) {
00412         return false;
00413     }
00414     // ok, check for connection
00415     if (myOutgoingEdges.size()!=1||c2->myIncomingEdges.size()!=1) {
00416         return false;
00417     }
00418     // check whether the connection is bidirectional
00419     NIVissimEdge *oe = NIVissimEdge::dictionary(myOutgoingEdges[0]);
00420     NIVissimEdge *ie = NIVissimEdge::dictionary(c2->myIncomingEdges[0]);
00421     if (oe==0||ie==0) {
00422         return false;
00423     }
00424     Line2D l1(oe->getGeometry().getBegin(), oe->getGeometry().getEnd());
00425     Line2D l2(ie->getGeometry().getEnd(), ie->getGeometry().getBegin());
00426     SUMOReal a1 = l1.atan2DegreeAngle();
00427     SUMOReal a2 = l2.atan2DegreeAngle();
00428     return fabs(a1-a2)<5;
00429 }

bool NIVissimConnectionCluster::joinable ( NIVissimConnectionCluster c2,
SUMOReal  offset 
) [private]

Definition at line 329 of file NIVissimConnectionCluster.cpp.

References extendByToTreatAsSame(), getDisturbanceParticipators(), hasNodeCluster(), myConnections, myIncomingEdges, myOutgoingEdges, and overlapsWith().

00329                                                                                   {
00330     // join clusters which have at least one connection in common
00331     if (VectorHelper<int>::subSetExists(myConnections, c2->myConnections)) {
00332         return true;
00333     }
00334 
00335     // connections shall overlap otherwise
00336     if (!overlapsWith(c2, offset)) {
00337         return false;
00338     }
00339 
00340     // at least one of the clusters shall not be assigned to a node in previous (!!!??)
00341     if (hasNodeCluster() && c2->hasNodeCluster()) {
00342         return false;
00343     }
00344 
00345     // join clusters which where connections do disturb each other
00346     if (VectorHelper<int>::subSetExists(c2->getDisturbanceParticipators(), myConnections)
00347             ||
00348             VectorHelper<int>::subSetExists(getDisturbanceParticipators(), c2->myConnections)) {
00349 
00350         return true;
00351     }
00352 
00353 
00354     // join clusters which do share the same incoming or outgoing edges (not mutually)
00355     IntVector extendedOutgoing1;
00356     IntVector extendedIncoming1;
00357     IntVector extendedOutgoing2;
00358     IntVector extendedIncoming2;
00359     if (myIncomingEdges.size()>1||c2->myIncomingEdges.size()>1) {
00360         extendedOutgoing1 =
00361             extendByToTreatAsSame(myOutgoingEdges, myIncomingEdges);
00362         extendedIncoming1 =
00363             extendByToTreatAsSame(myIncomingEdges, myOutgoingEdges);
00364         extendedOutgoing2 =
00365             extendByToTreatAsSame(c2->myOutgoingEdges, c2->myIncomingEdges);
00366         extendedIncoming2 =
00367             extendByToTreatAsSame(c2->myIncomingEdges, c2->myOutgoingEdges);
00368     } else {
00369         extendedOutgoing1 = myIncomingEdges;
00370         extendedIncoming1 = myOutgoingEdges;
00371         extendedOutgoing2 = c2->myIncomingEdges;
00372         extendedIncoming2 = c2->myOutgoingEdges;
00373     }
00374 
00375     if (VectorHelper<int>::subSetExists(extendedOutgoing1, extendedOutgoing2)
00376             ||
00377             VectorHelper<int>::subSetExists(extendedIncoming1, extendedIncoming2)
00378        ) {
00379         return true;
00380     }
00381     return false;
00382 }

static void NIVissimConnectionCluster::joinByDisturbances ( SUMOReal  offset  )  [static]

void NIVissimConnectionCluster::joinBySameEdges ( SUMOReal  offset  )  [static]

Tries to joind clusters participating within a node This is done by joining clusters which overlap.

Definition at line 217 of file NIVissimConnectionCluster.cpp.

References MsgHandler::getMessageInstance(), myClusters, MsgHandler::progressMsg(), and toString().

Referenced by NIImporter_Vissim::postLoadBuild().

00217                                                           {
00218     // !!! ...
00219     // Further, we try to omit joining of overlaping nodes. This is done by holding
00220     //  the lists of incoming and outgoing edges and incrementally building the nodes
00221     //  regarding this information
00222     std::vector<NIVissimConnectionCluster*> joinAble;
00223     size_t pos = 0;
00224     ContType::iterator i = myClusters.begin();
00225     // step1 - faster but no complete
00226     while (i!=myClusters.end()) {
00227         joinAble.clear();
00228         ContType::iterator j = i + 1;
00229 
00230         // check whether every combination has been processed
00231         while (j!=myClusters.end()) {
00232             // check whether the current clusters overlap
00233             if ((*i)->joinable(*j, offset)) {
00234                 joinAble.push_back(*j);
00235             }
00236             j++;
00237         }
00238         for (std::vector<NIVissimConnectionCluster*>::iterator k=joinAble.begin();
00239                 k!=joinAble.end(); k++) {
00240             // add the overlaping cluster
00241             (*i)->add(*k);
00242             // erase the overlaping cluster
00243             delete *k;
00244             myClusters.erase(find(myClusters.begin(), myClusters.end(), *k));
00245         }
00246         //
00247         if (joinAble.size()>0) {
00248             i = myClusters.begin() + pos;
00249             // clear temporary storages
00250             joinAble.clear();
00251         } else {
00252             i++;
00253             MsgHandler::getMessageInstance()->progressMsg("Checked(1): " + toString(pos) + "/" + toString(myClusters.size()) + "         ");
00254             pos++;
00255         }
00256     }
00257     //
00258     pos = 0;
00259     i = myClusters.begin();
00260     while (i!=myClusters.end()) {
00261         ContType::iterator j = i + 1;
00262         // check whether every combination has been processed
00263         while (j!=myClusters.end()) {
00264             // check whether the current clusters overlap
00265             if ((*i)->joinable(*j, offset)) {
00266                 joinAble.push_back(*j);
00267             }
00268             j++;
00269         }
00270         for (std::vector<NIVissimConnectionCluster*>::iterator k=joinAble.begin();
00271                 k!=joinAble.end(); k++) {
00272             // add the overlaping cluster
00273             (*i)->add(*k);
00274             // erase the overlaping cluster
00275             delete *k;
00276             myClusters.erase(find(myClusters.begin(), myClusters.end(), *k));
00277         }
00278         //
00279         if (joinAble.size()>0) {
00280             i = myClusters.begin();
00281             // clear temporary storages
00282             joinAble.clear();
00283             pos = 0;
00284         } else {
00285             i++;
00286             pos++;
00287             MsgHandler::getMessageInstance()->progressMsg("Checked(2): " + toString(pos) + "/" + toString(myClusters.size()) + "         ");
00288         }
00289     }
00290     // check for weak district connections
00291     //  (junctions made up by district connections, where prohibitions are not
00292     //   modelled properly)
00293     pos = 0;
00294     i = myClusters.begin();
00295     while (i!=myClusters.end()) {
00296         ContType::iterator j = i + 1;
00297         // check whether every combination has been processed
00298         while (j!=myClusters.end()) {
00299             // check whether the current clusters overlap
00300             if ((*i)->isWeakDistrictConnRealisation(*j)) {
00301                 joinAble.push_back(*j);
00302             }
00303             j++;
00304         }
00305         for (std::vector<NIVissimConnectionCluster*>::iterator k=joinAble.begin();
00306                 k!=joinAble.end(); k++) {
00307             // add the overlaping cluster
00308             (*i)->add(*k);
00309             // erase the overlaping cluster
00310             delete *k;
00311             myClusters.erase(find(myClusters.begin(), myClusters.end(), *k));
00312         }
00313         //
00314         if (joinAble.size()>0) {
00315             i = myClusters.begin();
00316             // clear temporary storages
00317             joinAble.clear();
00318             pos = 0;
00319         } else {
00320             i++;
00321             pos++;
00322             MsgHandler::getMessageInstance()->progressMsg("Checked(3): " + toString(pos) + "/" + toString(myClusters.size()) + "         ");
00323         }
00324     }
00325 }

bool NIVissimConnectionCluster::liesOnSameEdgesEnd ( NIVissimConnectionCluster cc2  )  [private]

Definition at line 433 of file NIVissimConnectionCluster.cpp.

References NIVissimEdge::dictionary(), NIVissimConnection::dictionary(), NIVissimBoundedClusterObject::getBoundary(), Boundary::getCenter(), NIVissimConnection::getFromEdgeID(), NIVissimAbstractEdge::getGeometry(), NIVissimConnection::getToEdgeID(), myConnections, GeomHelper::nearest_position_on_line_to_point(), and SUMOReal.

00433                                                                             {
00434     //
00435     for (IntVector::iterator i=myConnections.begin(); i!=myConnections.end(); i++) {
00436         NIVissimConnection *c1 = NIVissimConnection::dictionary(*i);
00437         for (IntVector::iterator j=cc2->myConnections.begin(); j!=cc2->myConnections.end(); j++) {
00438             NIVissimConnection *c2 = NIVissimConnection::dictionary(*j);
00439             if (c1->getFromEdgeID()==c2->getFromEdgeID()) {
00440                 NIVissimEdge *e = NIVissimEdge::dictionary(c1->getFromEdgeID());
00441                 const Position2DVector &g = e->getGeometry();
00442                 SUMOReal pos1 = GeomHelper::nearest_position_on_line_to_point(
00443                                     g.getBegin(), g.getEnd(), c1->getBoundary().getCenter());
00444                 SUMOReal pos2 = GeomHelper::nearest_position_on_line_to_point(
00445                                     g.getBegin(), g.getEnd(), c2->getBoundary().getCenter());
00446                 if (pos1<=5.0&&pos2<=5.0) {
00447                     return true;
00448                 }
00449             }
00450             if (c1->getToEdgeID()==c2->getToEdgeID()) {
00451                 NIVissimEdge *e = NIVissimEdge::dictionary(c1->getFromEdgeID());
00452                 const Position2DVector &g = e->getGeometry();
00453                 SUMOReal pos1 = GeomHelper::nearest_position_on_line_to_point(
00454                                     g.getBegin(), g.getEnd(), c1->getBoundary().getCenter());
00455                 SUMOReal pos2 = GeomHelper::nearest_position_on_line_to_point(
00456                                     g.getBegin(), g.getEnd(), c2->getBoundary().getCenter());
00457                 if (pos1>=g.length()-5.0&&pos2>=g.length()-5.0) {
00458                     return true;
00459                 }
00460             }
00461         }
00462     }
00463     return false;
00464 }

bool NIVissimConnectionCluster::overlapsWith ( NIVissimConnectionCluster c,
SUMOReal  offset = 0 
) const

Returns the information whether the given cluster overlaps the current.

Definition at line 178 of file NIVissimConnectionCluster.cpp.

References myBoundary, Boundary::overlapsWith(), Boundary::xmax(), and Boundary::xmin().

Referenced by joinable().

00179                                                                {
00180     assert(myBoundary.xmax()>=myBoundary.xmin());
00181     assert(c->myBoundary.xmax()>=c->myBoundary.xmin());
00182     return c->myBoundary.overlapsWith(myBoundary, offset);
00183 }

void NIVissimConnectionCluster::recheckEdges (  )  [private]

Definition at line 620 of file NIVissimConnectionCluster.cpp.

References NIVissimEdge::addToConnectionCluster(), Boundary::around(), NIVissimConnection::dictionary(), NIVissimEdge::dictionary(), NIVissimConnection::getFromEdgeID(), NIVissimConnection::getFromGeomPosition(), NIVissimConnection::getToEdgeID(), NIVissimConnection::getToGeomPosition(), myBoundary, myConnections, myEdges, NIVissimEdge::removeFromConnectionCluster(), Boundary::xmax(), and Boundary::xmin().

00620                                         {
00621     assert(myConnections.size()!=0);
00622     // remove the cluster from all edges at first
00623     IntVector::iterator i;
00624     for (i=myEdges.begin(); i!=myEdges.end(); i++) {
00625         NIVissimEdge *edge = NIVissimEdge::dictionary(*i);
00626         edge->removeFromConnectionCluster(this);
00627     }
00628     // clear edge information
00629     myEdges.clear();
00630     // recheck which edges do still participate and add edges
00631     for (i=myConnections.begin(); i!=myConnections.end(); i++) {
00632         NIVissimConnection *c = NIVissimConnection::dictionary(*i);
00633         assert(myBoundary.xmax()>=myBoundary.xmin());
00634         if (myBoundary.around(c->getFromGeomPosition(), 5)) {
00635             myEdges.push_back(c->getFromEdgeID());
00636         }
00637         assert(myBoundary.xmax()>=myBoundary.xmin());
00638         if (myBoundary.around(c->getToGeomPosition(), 5)) {
00639             myEdges.push_back(c->getToEdgeID());
00640         }
00641     }
00642     // connect edges
00643     for (i=myEdges.begin(); i!=myEdges.end(); i++) {
00644         NIVissimEdge *edge = NIVissimEdge::dictionary(*i);
00645         edge->addToConnectionCluster(this);
00646     }
00647 }

void NIVissimConnectionCluster::recomputeBoundary (  )  [private]

void NIVissimConnectionCluster::removeConnections ( const NodeSubCluster c  )  [private]

Definition at line 575 of file NIVissimConnectionCluster.cpp.

References NIVissimAbstractEdge::getID(), myConnections, NIVissimConnectionCluster::NodeSubCluster::myConnections, and recomputeBoundary().

00575                                                                     {
00576     for (NodeSubCluster::ConnectionCont::const_iterator i=c.myConnections.begin(); i!=c.myConnections.end(); i++) {
00577         NIVissimConnection *conn = *i;
00578         int connid = conn->getID();
00579         IntVector::iterator j = find(myConnections.begin(), myConnections.end(), connid);
00580         if (j!=myConnections.end()) {
00581             myConnections.erase(j);
00582         }
00583     }
00584     recomputeBoundary();
00585 }

void NIVissimConnectionCluster::searchForConnection ( int  id  )  [static]

Definition at line 531 of file NIVissimConnectionCluster.cpp.

References myClusters.

00531                                                      {
00532     int pos = 0;
00533     for (ContType::iterator i=myClusters.begin(); i!=myClusters.end(); i++) {
00534         IntVector connections = (*i)->myConnections;
00535         if (find(connections.begin(), connections.end(), id)!=connections.end()) {
00536             for (IntVector::iterator j=connections.begin(); j!=connections.end(); j++) {
00537                 int checkdummy = *j;
00538             }
00539         }
00540         pos++;
00541     }
00542 }


Friends And Related Function Documentation

friend class NIVissimEdge [friend]

Definition at line 83 of file NIVissimConnectionCluster.h.


Field Documentation

Definition at line 201 of file NIVissimConnectionCluster.h.

The boundary of the cluster.

Definition at line 182 of file NIVissimConnectionCluster.h.

Referenced by add(), around(), getPositionForEdge(), NIVissimConnectionCluster(), overlapsWith(), recheckEdges(), and recomputeBoundary().

int NIVissimConnectionCluster::myFirstFreeID = 100000 [static, private]

Definition at line 199 of file NIVissimConnectionCluster.h.

Referenced by clearDict(), and getNextFreeNodeID().

The node the cluster is assigned to.

Definition at line 185 of file NIVissimConnectionCluster.h.

Referenced by add(), getNBNode(), getPositionForEdge(), and hasNodeCluster().

Definition at line 190 of file NIVissimConnectionCluster.h.

int NIVissimConnectionCluster::myStaticBlaID = 0 [static, private]

Definition at line 200 of file NIVissimConnectionCluster.h.

Definition at line 192 of file NIVissimConnectionCluster.h.


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:53 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6