LCOV - code coverage report
Current view: top level - src/netbuild - NBNodeShapeComputer.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 1 1
Test Date: 2024-12-21 15:45:41 Functions: - 0 0

            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    NBNodeShapeComputer.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    2004-01-12
      19              : ///
      20              : // This class computes shapes of junctions
      21              : /****************************************************************************/
      22              : #pragma once
      23              : #include <config.h>
      24              : 
      25              : #include <utils/geom/PositionVector.h>
      26              : 
      27              : 
      28              : // ===========================================================================
      29              : // class definitions
      30              : // ===========================================================================
      31              : class NBNode;
      32              : class NBEdge;
      33              : 
      34              : 
      35              : // ===========================================================================
      36              : // class declarations
      37              : // ===========================================================================
      38              : /**
      39              :  * @class NBNodeShapeComputer
      40              :  * @brief This class computes shapes of junctions
      41              :  */
      42              : class NBNodeShapeComputer {
      43              : public:
      44              :     /// Constructor
      45              :     NBNodeShapeComputer(const NBNode& node);
      46              : 
      47              :     /// Destructor
      48              :     ~NBNodeShapeComputer();
      49              : 
      50              :     /// Computes the shape of the assigned junction
      51              :     const PositionVector compute(bool forceSmall);
      52              : 
      53              :     /// @brief get computed radius for node
      54              :     double getRadius() const {
      55           51 :         return myRadius;
      56              :     }
      57              : 
      58              : private:
      59              :     typedef std::map<NBEdge*, PositionVector> GeomsMap;
      60              : 
      61              :     /** @brief Computes the node geometry
      62              :      * Edges with the same direction are grouped.
      63              :      * Then the node geometry is built from intersection between the borders
      64              :      * of adjacent edge groups
      65              :      */
      66              :     const PositionVector computeNodeShapeDefault(bool simpleContinuation);
      67              : 
      68              :     /** @brief Computes the node geometry using normals
      69              :      *
      70              :      * In the case the other method does not work, this method computes the geometry
      71              :      *  of a node by adding points to the polygon which are computed by building
      72              :      *  the normals of participating edges' geometry boundaries (cw/ccw)
      73              :      *  at the node's height (the length of the edge the edge would cross the node
      74              :      *  point).
      75              :      *
      76              :      *  @note This usually gives a very small node shape, appropriate for
      77              :      *  dead-ends or turn-around-only situations
      78              :      */
      79              :     const PositionVector computeNodeShapeSmall();
      80              : 
      81              :     /// @brief compute clockwise/counter-clockwise edge boundaries
      82              :     void computeEdgeBoundaries(const EdgeVector& edges,
      83              :                                GeomsMap& geomsCCW,
      84              :                                GeomsMap& geomsCW);
      85              : 
      86              :     /** @brief Joins edges and computes ccw/cw boundaries
      87              :      *
      88              :      * This method goes through all edges and stores each edge's ccw and cw
      89              :      *  boundary in geomsCCW/geomsCW. This boundary is extrapolated by 100m
      90              :      *  at the node's position.
      91              :      * In addition, "same" is filled so that this map contains a list of
      92              :      *  all edges within the value-vector which direction at the node differs
      93              :      *  less than 1 from the key-edge's direction.
      94              :      */
      95              :     void joinSameDirectionEdges(const EdgeVector& edges, std::map<NBEdge*, std::set<NBEdge*> >& same, bool useEndpoints);
      96              : 
      97              :     /** @brief Joins edges
      98              :      *
      99              :      * This methods joins edges which are in marked as being "same" in the means
     100              :      *  as given by joinSameDirectionEdges. The result (list of so-to-say "directions"
     101              :      *  is returned;
     102              :      */
     103              :     EdgeVector computeUniqueDirectionList(
     104              :         const EdgeVector& all,
     105              :         std::map<NBEdge*, std::set<NBEdge*> >& same,
     106              :         GeomsMap& geomsCCW,
     107              :         GeomsMap& geomsCW);
     108              : 
     109              :     /** @brief Compute smoothed corner shape
     110              :      * @param[in] begShape
     111              :      * @param[in] endShape
     112              :      * @param[in] begPoint
     113              :      * @param[in] endPoint
     114              :      * @param[in] cornerDetail
     115              :      * @return shape to be appended between begPoint and endPoint
     116              :      */
     117              :     PositionVector getSmoothCorner(PositionVector begShape, PositionVector endShape,
     118              :                                    const Position& begPoint, const Position& endPoint, int cornerDetail);
     119              : 
     120              :     /** @brief Initialize neighbors and angles
     121              :      * @param[in] edges The list of edges sorted in clockwise direction
     122              :      * @param[in] current An iterator to the current edge
     123              :      * @param[in] geomsCW geometry map
     124              :      * @param[in] geomsCCW geometry map
     125              :      * @param[out] cwi An iterator to the clockwise neighbor
     126              :      * @param[out] ccwi An iterator to the counter-clockwise neighbor
     127              :      * @param[out] cad The angle difference to the clockwise neighbor
     128              :      * @param[out] ccad The angle difference to the counter-clockwise neighbor
     129              :      */
     130              :     static void initNeighbors(const EdgeVector& edges, const EdgeVector::const_iterator& current,
     131              :                               GeomsMap& geomsCW,
     132              :                               GeomsMap& geomsCCW,
     133              :                               EdgeVector::const_iterator& cwi,
     134              :                               EdgeVector::const_iterator& ccwi,
     135              :                               double& cad,
     136              :                               double& ccad);
     137              : 
     138              :     /// @return whether trying to intersect these edges would probably fail
     139              :     bool badIntersection(const NBEdge* e1, const NBEdge* e2, double distance);
     140              : 
     141              :     /// @brief return the intersection point closest to the given offset
     142              :     double closestIntersection(const PositionVector& geom1, const PositionVector& geom2, double offset);
     143              : 
     144              :     /// @brief whether the given edges (along with those in the same direction) requires a large turning radius
     145              :     bool needsLargeTurn(NBEdge* e1, NBEdge* e2,
     146              :                         std::map<NBEdge*, std::set<NBEdge*> >& same) const;
     147              : 
     148              :     /// @brief determine the default radius appropriate for the current junction
     149              :     double getDefaultRadius(const OptionsCont& oc);
     150              : 
     151              :     void computeSameEnd(PositionVector& l1, PositionVector& l2);
     152              : 
     153              :     bool isDivided(const NBEdge* e, std::set<NBEdge*> same, const PositionVector& ccw, const PositionVector& cw) const;
     154              : 
     155              :     /// @brief compute with of rightmost lanes that exlude the given permissions
     156              :     static double getExtraWidth(const NBEdge* e, SVCPermissions exclude);
     157              : 
     158              :     /// @brief compute the width of the divider space for divided roads
     159              :     static double divisionWidth(const NBEdge* e, std::set<NBEdge*> same, const Position& p, const Position& p2);
     160              : 
     161              : private:
     162              :     /// The node to compute the geometry for
     163              :     const NBNode& myNode;
     164              : 
     165              :     /// @brief the computed node radius
     166              :     double myRadius;
     167              : 
     168              :     /// @brief the maximum distance to search for a place where neighboring edges intersect and do not overlap
     169              :     double EXT;
     170              : 
     171              :     static const SVCPermissions SVC_LARGE_TURN;
     172              : 
     173              : private:
     174              :     /// @brief Invalidated assignment operator
     175              :     NBNodeShapeComputer& operator=(const NBNodeShapeComputer& s);
     176              : 
     177              : };
        

Generated by: LCOV version 2.0-1