Path: blob/main/src/netimport/vissim/tempstructs/NIVissimConnectionCluster.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NIVissimConnectionCluster.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Sept 200217///18// -------------------19/****************************************************************************/20#pragma once21#include <config.h>222324#include <iostream>25#include <vector>26#include <utils/geom/Boundary.h>27#include <utils/geom/GeomHelper.h>28#include "NIVissimConnection.h"293031// ===========================================================================32// class declarations33// ===========================================================================34class NBNode;35class NIVissimEdge;363738// ===========================================================================39// class definitions40// ===========================================================================41/**42* @class NIVissimConnectionCluster43* This class holds a list of connections either all outgoing or all44* incoming within an edge, which do lies close together.45* This shall be the connections which belong to a single node.46* It still are not all of the node's connections, as other edges47* may participate to this node, too.48*/49class NIVissimConnectionCluster {50public:51/** @brief Constructor52Build the boundary; The boundary includes both incoming and outgoing nodes */53NIVissimConnectionCluster(const std::vector<int>& connections, int nodeCluster,54int edgeid);5556NIVissimConnectionCluster(const std::vector<int>& connections,57const Boundary& boundary, int nodeCluster, const std::vector<int>& edges);5859/// Destructor60~NIVissimConnectionCluster();6162/// Returns the information whether the given cluster overlaps the current63bool overlapsWith(NIVissimConnectionCluster* c, double offset = 0) const;6465bool hasNodeCluster() const;6667NBNode* getNBNode() const;6869bool around(const Position& p, double offset = 0) const;7071double getPositionForEdge(int edgeid) const;7273friend class NIVissimEdge; // !!! debug7475const std::vector<int>& getConnections() const {76return myConnections;77}7879PositionVector getIncomingContinuationGeometry(NIVissimEdge* e) const;80PositionVector getOutgoingContinuationGeometry(NIVissimEdge* e) const;81NIVissimConnection* getIncomingContinuation(NIVissimEdge* e) const;82NIVissimConnection* getOutgoingContinuation(NIVissimEdge* e) const;838485public:86/** @brief Tries to joind clusters participating within a node87This is done by joining clusters which overlap */88static void joinBySameEdges(double offset);8990static void joinByDisturbances(double offset);9192static void buildNodeClusters();9394static void _debugOut(std::ostream& into);9596static int getNextFreeNodeID();9798static void clearDict();99100private:101class NodeSubCluster {102public:103NodeSubCluster(NIVissimConnection* c);104~NodeSubCluster();105void add(NIVissimConnection* c);106void add(const NodeSubCluster& c);107int size() const;108bool overlapsWith(const NodeSubCluster& c, double offset = 0);109std::vector<int> getConnectionIDs() const;110friend class NIVissimConnectionCluster;111public:112Boundary myBoundary;113typedef std::vector<NIVissimConnection*> ConnectionCont;114ConnectionCont myConnections;115};116117class same_direction_sorter {118private:119double myAngle;120121public:122/// constructor123explicit same_direction_sorter(double angle)124: myAngle(angle) { }125126public:127/// comparing operation128int operator()(NIVissimConnection* c1, NIVissimConnection* c2) const {129return fabs(GeomHelper::angleDiff(c1->getGeometry().beginEndAngle(), myAngle))130<131fabs(GeomHelper::angleDiff(c2->getGeometry().beginEndAngle(), myAngle));132}133};134135136137private:138/// Adds the second cluster139void add(NIVissimConnectionCluster* c);140141void removeConnections(const NodeSubCluster& c);142143void recomputeBoundary();144145void recheckEdges();146147bool joinable(NIVissimConnectionCluster* c2, double offset);148149150std::vector<int> getDisturbanceParticipators();151152std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,153const std::vector<int>& iv2) const;154155bool isWeakDistrictConnRealisation(NIVissimConnectionCluster* c2);156157bool liesOnSameEdgesEnd(NIVissimConnectionCluster* cc2);158159160161private:162/// List of connection-ids which participate within this cluster163std::vector<int> myConnections;164165/// The boundary of the cluster166Boundary myBoundary;167168/// The node the cluster is assigned to169int myNodeCluster;170171// The edge which holds the cluster172std::vector<int> myEdges;173174std::vector<int> myNodes;175176std::vector<int> myTLs;177178std::vector<int> myOutgoingEdges, myIncomingEdges;179180private:181typedef std::vector<NIVissimConnectionCluster*> ContType;182static ContType myClusters;183static int myFirstFreeID;184static int myStaticBlaID;185int myBlaID;186};187188189