Example #1
0
void buildConnectorRouteCheckpointCache(Router *router)
{
    for (ConnRefList::const_iterator curr = router->connRefs.begin(); 
            curr != router->connRefs.end(); ++curr) 
    {
        ConnRef *conn = *curr;
        if (conn->routingType() != ConnType_Orthogonal)
        {
            continue;
        }

        PolyLine& displayRoute = conn->displayRoute();
        std::vector<Point> checkpoints = conn->routingCheckpoints();
       
        // Initialise checkpoint vector and set to false.  There will be
        // one entry for each *segment* in the path, and the value indicates
        // whether the segment is affected by a checkpoint.
        displayRoute.segmentHasCheckpoint = 
                std::vector<bool>(displayRoute.size() - 1, false);
        size_t nCheckpoints = displayRoute.segmentHasCheckpoint.size();

        for (size_t cpi = 0; cpi < checkpoints.size(); ++cpi)
        {
            for (size_t ind = 0; ind < displayRoute.size(); ++ind)
            {
                if (displayRoute.ps[ind].equals(checkpoints[cpi]))
                {
                    // The checkpoint is at a bendpoint, so mark the edge
                    // before and after and being affected by checkpoints.
                    if (ind > 0)
                    {
                        displayRoute.segmentHasCheckpoint[ind - 1] = true;
                    }

                    if (ind < nCheckpoints)
                    {
                        displayRoute.segmentHasCheckpoint[ind] = true;
                    }
                }
                else if ((ind > 0) && pointOnLine(displayRoute.ps[ind - 1], 
                         displayRoute.ps[ind], checkpoints[cpi]) )
                {
                    // If the checkpoint is on a segment, only that segment is
                    // affected.
                    displayRoute.segmentHasCheckpoint[ind - 1] = true;
                }
            }
        }
    }
}
Example #2
0
void buildConnectorRouteCheckpointCache(Router *router)
{
    for (ConnRefList::const_iterator curr = router->connRefs.begin();
            curr != router->connRefs.end(); ++curr)
    {
        ConnRef *conn = *curr;
        if (conn->routingType() != ConnType_Orthogonal)
        {
            continue;
        }

        PolyLine& displayRoute = conn->displayRoute();
        std::vector<Checkpoint> checkpoints = conn->routingCheckpoints();

        // Initialise checkpoint vector and set to false.  There will be
        // one entry for each *segment* in the path, and the value indicates
        // whether the segment is affected by a checkpoint.
        displayRoute.checkpointsOnRoute =
            std::vector<std::pair<size_t, Point> >();

        for (size_t ind = 0; ind < displayRoute.size(); ++ind)
        {
            if (ind > 0)
            {
                for (size_t cpi = 0; cpi < checkpoints.size(); ++cpi)
                {
                    if (pointOnLine(displayRoute.ps[ind - 1],
                                    displayRoute.ps[ind], checkpoints[cpi].point) )
                    {
                        // The checkpoint is on a segment.
                        displayRoute.checkpointsOnRoute.push_back(
                            std::make_pair((ind * 2) - 1,
                                           checkpoints[cpi].point));
                    }
                }
            }

            for (size_t cpi = 0; cpi < checkpoints.size(); ++cpi)
            {
                if (displayRoute.ps[ind].equals(checkpoints[cpi].point))
                {
                    // The checkpoint is at a bendpoint.
                    displayRoute.checkpointsOnRoute.push_back(
                        std::make_pair(ind * 2, checkpoints[cpi].point));
                }
            }
        }
    }
}
Example #3
0
void clearConnectorRouteCheckpointCache(Router *router)
{
    for (ConnRefList::const_iterator curr = router->connRefs.begin();
            curr != router->connRefs.end(); ++curr)
    {
        ConnRef *conn = *curr;
        if (conn->routingType() != ConnType_Orthogonal)
        {
            continue;
        }

        // Clear the cache.
        PolyLine& displayRoute = conn->displayRoute();
        displayRoute.checkpointsOnRoute.clear();
    }
}
Example #4
0
CardinalDir LeaflessOrthoRouter::departureDir(const Edge_SP &e, const Node_SP &u) const {
    ConnRef *cr = m_ra.edgeIdToConnRef.at(e->id());
    PolyLine poly = cr->displayRoute();
    vector<Point> pts = poly.ps;
    Point p0, p1;
    if (u->id() == e->getSourceEnd()->id()) {
        // Node u is the source end of Edge e.
        // So we want the first two points in the route, in order.
        p0 = pts[0];
        p1 = pts[1];
    } else {
        // Node u is the target end of Edge e.
        // So we want the last two points in the route, in reverse order.
        size_t L = pts.size();
        p0 = pts[L-1];
        p1 = pts[L-2];
    }
    return Compass::cardinalDirection(p0, p1);
}