예제 #1
0
ConnRefList Obstacle::attachedConnectors(void) const
{
    ConnRefList attachedConns;
    for (std::set<ConnEnd *>::const_iterator curr = m_following_conns.begin();
            curr != m_following_conns.end(); ++curr)
    {
        ConnEnd *connEnd = *curr;
        COLA_ASSERT(connEnd->m_conn_ref != NULL);
        attachedConns.push_back(connEnd->m_conn_ref);
    }
    return attachedConns;
}
예제 #2
0
// This method traverses the hyperedge tree and rewrites connector ends
// that may have changed junctions due to major hyperedge improvement.
//
void HyperedgeTreeEdge::updateConnEnds(HyperedgeTreeNode *ignored, 
        bool forward, ConnRefList& changedConns)
{
    HyperedgeTreeNode *endNode = NULL;
    if (ends.first && (ends.first != ignored))
    {
        endNode = ends.first;
        ends.first->updateConnEnds(this, forward, changedConns);
    }

    if (ends.second && (ends.second != ignored))
    {
        endNode = ends.second;
        ends.second->updateConnEnds(this, forward, changedConns);
    }

    if (endNode->junction)
    {
        // We've reached a junction at the end of this connector, and it's
        // not an endpoint of the hyperedge.  So  the connector ConnEnd to 
        // connect to the junction we have reached.
        std::pair<ConnEnd, ConnEnd> existingEnds = conn->endpointConnEnds();
        ConnEnd existingEnd = (forward) ?
                existingEnds.second : existingEnds.first;
        if (existingEnd.junction() != endNode->junction)
        {
#ifdef MAJOR_HYPEREDGE_IMPROVEMENT_DEBUG
            fprintf(stderr, "HyperedgeImprover: changed %s of "
                    "connector %u (from junction %u to %u)\n", 
                    (forward) ? "tar" : "src", conn->id(),
                    existingEnd.junction()->id(), endNode->junction->id());
#endif
            ConnEnd connend(endNode->junction);
            unsigned short end = (forward) ? VertID::tar : VertID::src;
            conn->updateEndPoint(end, connend);

            // Record that this connector was changed (so long as it wasn't 
            // already recorded).
            if (changedConns.empty() || (changedConns.back() != conn))
            {
                changedConns.push_back(conn);
            }
        }
    }
}
예제 #3
0
// This method traverses the hyperedge tree and returns a list of the junctions
// and connectors that make up the hyperedge.
//
void HyperEdgeTreeEdge::listJunctionsAndConnectors(HyperEdgeTreeNode *ignored,
        JunctionRefList& junctions, ConnRefList& connectors)
{
    ConnRefList::iterator foundPosition =
            std::find(connectors.begin(), connectors.end(), conn);
    if (foundPosition == connectors.end())
    {
        // Add connector if it isn't already in the list.
        connectors.push_back(conn);
    }

    if (ends.first != ignored)
    {
        ends.first->listJunctionsAndConnectors(this, junctions, connectors);
    }
    else if (ends.second != ignored)
    {
        ends.second->listJunctionsAndConnectors(this, junctions, connectors);
    }
}
예제 #4
0
// This method traverses the hyperedge tree and rewrites connector ends
// that may have changed junctions due to major hyperedge improvement.
//
void HyperedgeTreeNode::updateConnEnds(HyperedgeTreeEdge *ignored, 
        bool forward, ConnRefList& changedConns)
{
    for (std::list<HyperedgeTreeEdge *>::iterator curr = edges.begin();
            curr != edges.end(); ++curr)
    {
        HyperedgeTreeEdge *edge = *curr;
        if (edge != ignored)
        {
            if (junction)
            {
                // If we're at a junction, then we are effectively starting
                // our traversal along a connector, so create this new connector
                // and set it's start ConnEnd to be this junction.
                forward = travellingForwardOnConnector(edge->conn, junction);

                std::pair<ConnEnd, ConnEnd> existingEnds = 
                        edge->conn->endpointConnEnds();
                ConnEnd existingEnd = (forward) ? 
                        existingEnds.first : existingEnds.second;
                if (existingEnd.junction() != junction)
                {
#ifdef MAJOR_HYPEREDGE_IMPROVEMENT_DEBUG
                    fprintf(stderr, "HyperedgeImprover: changed %s of "
                            "connector %u (from junction %u to %u)\n", 
                            (forward) ? "src" : "tar", edge->conn->id(),
                            existingEnd.junction()->id(), junction->id());
#endif
                    unsigned short end = (forward) ? VertID::src : VertID::tar;
                    ConnEnd connend(junction);
                    edge->conn->updateEndPoint(end, connend);
                    changedConns.push_back(edge->conn);
                }
            }
    
            // Continue recursive traversal.
            edge->updateConnEnds(this, forward, changedConns);
        }
    }
}