LCOV - code coverage report
Current view: top level - src/netimport/vissim/tempstructs - NIVissimNodeDef_Edges.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 58.8 % 17 10
Test Date: 2024-11-22 15:46:21 Functions: 80.0 % 5 4

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    NIVissimNodeDef_Edges.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @date    Sept 2002
      18              : ///
      19              : // -------------------
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : 
      23              : 
      24              : 
      25              : #include <string>
      26              : #include <map>
      27              : #include <algorithm>
      28              : #include <cassert>
      29              : #include <utils/geom/Boundary.h>
      30              : #include "NIVissimNodeParticipatingEdgeVector.h"
      31              : #include "NIVissimNodeDef.h"
      32              : #include "NIVissimEdge.h"
      33              : #include "NIVissimNodeDef_Edges.h"
      34              : #include "NIVissimDisturbance.h"
      35              : #include "NIVissimConnection.h"
      36              : 
      37              : 
      38              : // ===========================================================================
      39              : // method definitions
      40              : // ===========================================================================
      41          105 : NIVissimNodeDef_Edges::NIVissimNodeDef_Edges(int id,
      42          105 :         const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
      43          105 :     : NIVissimNodeDef(id, name), myEdges(edges) {}
      44              : 
      45              : 
      46          210 : NIVissimNodeDef_Edges::~NIVissimNodeDef_Edges() {
      47         1065 :     for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
      48          960 :         delete (*i);
      49              :     }
      50              :     myEdges.clear();
      51          210 : }
      52              : 
      53              : 
      54              : bool
      55          105 : NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
      56              :                                   const NIVissimNodeParticipatingEdgeVector& edges) {
      57          105 :     NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
      58          105 :     if (!NIVissimNodeDef::dictionary(id, o)) {
      59            0 :         delete o;
      60            0 :         return false;
      61              :     }
      62              :     return true;
      63              : }
      64              : 
      65              : 
      66              : /*
      67              : void
      68              : NIVissimNodeDef_Edges::searchAndSetConnections() {
      69              :     std::vector<int> connections;
      70              :     std::vector<int> edges;
      71              :     Boundary boundary;
      72              :     for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
      73              :         NIVissimNodeParticipatingEdge* edge = *i;
      74              :         NIVissimConnection* c =
      75              :             NIVissimConnection::dictionary(edge->getID());
      76              :         NIVissimEdge* e =
      77              :             NIVissimEdge::dictionary(edge->getID());
      78              :         if (c != 0) {
      79              :             connections.push_back(edge->getID());
      80              :             boundary.add(c->getFromGeomPosition());
      81              :             boundary.add(c->getToGeomPosition());
      82              :             c->setNodeCluster(myID);
      83              :         }
      84              :         if (e != 0) {
      85              :             edges.push_back(edge->getID());
      86              :             boundary.add(e->getGeomPosition(edge->getFromPos()));
      87              :             boundary.add(e->getGeomPosition(edge->getToPos()));
      88              :         }
      89              :     }
      90              :     NIVissimConnectionCluster* c =
      91              :         new NIVissimConnectionCluster(connections, boundary, myID, edges);
      92              :     for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
      93              :         NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
      94              :         edge->myConnectionClusters.push_back(c);
      95              :     }
      96              : }
      97              : */
      98              : 
      99              : 
     100              : double
     101            0 : NIVissimNodeDef_Edges::getEdgePosition(int edgeid) const {
     102            0 :     for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
     103            0 :         NIVissimNodeParticipatingEdge* edge = *i;
     104            0 :         if (edge->getID() == edgeid) {
     105            0 :             return (edge->getFromPos() + edge->getToPos()) / (double) 2.0;
     106              :         }
     107              :     }
     108              :     return -1;
     109              : }
     110              : 
     111              : 
     112              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1