// Follow connected junctions and connectors from the given junction to // determine the hyperedge topology, saving objects to the deleted-objects // vectors as we go. bool HyperedgeRerouter::findAttachedObjects(size_t index, JunctionRef *junction, ConnRef *ignore, ConnRefSet& hyperedgeConns) { bool validHyperedge = false; m_deleted_junctions_vector[index].push_back(junction); ConnRefList connectors = junction->attachedConnectors(); if (connectors.size() > 2) { // A valid hyperedge must have at least one junction with three // connectors attached, i.e., more than two endpoints. validHyperedge |= true; } for (ConnRefList::iterator curr = connectors.begin(); curr != connectors.end(); ++curr) { if (*curr == ignore) { continue; } COLA_ASSERT(*curr != NULL); validHyperedge |= findAttachedObjects(index, (*curr), junction, hyperedgeConns); } return validHyperedge; }
// Follow connected junctions and connectors from the given connector to // determine the hyperedge topology, saving objects to the deleted-objects // vectors as we go. bool HyperedgeRerouter::findAttachedObjects(size_t index, ConnRef *connector, JunctionRef *ignore, ConnRefSet& hyperedgeConns) { bool validHyperedge = false; connector->assignConnectionPinVisibility(true); m_deleted_connectors_vector[index].push_back(connector); hyperedgeConns.insert(connector); std::pair<Obstacle *, Obstacle *> anchors = connector->endpointAnchors(); JunctionRef *jFirst = dynamic_cast<JunctionRef *> (anchors.first); JunctionRef *jSecond = dynamic_cast<JunctionRef *> (anchors.second); if (jFirst) { // If attached to a junction and not one we've explored, then continue. if (jFirst != ignore) { validHyperedge |= findAttachedObjects(index, jFirst, connector, hyperedgeConns); } } else { // If its an endpoint, then record the vertex for this endpoint. COLA_ASSERT(connector->m_src_vert); m_terminal_vertices_vector[index].insert(connector->m_src_vert); } if (jSecond) { // If attached to a junction and not one we've explored, then continue. if (jSecond != ignore) { validHyperedge |= findAttachedObjects(index, jSecond, connector, hyperedgeConns); } } else { // If its an endpoint, then record the vertex for this endpoint. COLA_ASSERT(connector->m_dst_vert); m_terminal_vertices_vector[index].insert(connector->m_dst_vert); } return validHyperedge; }
// Populate the deleted-object vectors with all the connectors and junctions // that form the registered hyperedges. Then return the set of all these // connectors so they can be ignored for individual rerouting. ConnRefSet HyperedgeRerouter::calcHyperedgeConnectors(void) { COLA_ASSERT(m_router != NULL); ConnRefSet allRegisteredHyperedgeConns; // Clear the deleted-object vectors. We populate them here if necessary. m_deleted_junctions_vector.clear(); m_deleted_junctions_vector.resize(count()); m_deleted_connectors_vector.clear(); m_deleted_connectors_vector.resize(count()); m_terminal_vertices_vector.clear(); m_terminal_vertices_vector.resize(count()); m_added_vertices.clear(); // Populate the deleted-object vectors. const size_t num_hyperedges = count(); for (size_t i = 0; i < num_hyperedges; ++i) { if (m_root_junction_vector[i]) { // Follow objects attached to junction to find the hyperedge. findAttachedObjects(i, m_root_junction_vector[i], NULL, allRegisteredHyperedgeConns); continue; } // Alternatively, we have a set of ConnEnds, so store the // corresponding terminals std::pair<bool, VertInf *> maybeNewVertex; for (ConnEndList::const_iterator it = m_terminals_vector[i].begin(); it != m_terminals_vector[i].end(); ++it) { maybeNewVertex = it->getHyperedgeVertex(m_router); COLA_ASSERT(maybeNewVertex.second != NULL); m_terminal_vertices_vector[i].insert(maybeNewVertex.second); if (maybeNewVertex.first) { // This is a newly created vertex. Remember it so we can // free it and it's visibility edges later. m_added_vertices.push_back(maybeNewVertex.second); } } } // Return these connectors that don't require rerouting. return allRegisteredHyperedgeConns; }
// Follow connected junctions and connectors from the given junction to // determine the hyperedge topology, saving objects to the deleted-objects // vectors as we go. void HyperedgeRerouter::findAttachedObjects(size_t index, JunctionRef *junction, ConnRef *ignore, ConnRefSet& hyperedgeConns) { m_deleted_junctions_vector[index].push_back(junction); ConnRefList connectors = junction->attachedConnectors(); for (ConnRefList::iterator curr = connectors.begin(); curr != connectors.end(); ++curr) { if (*curr == ignore) { continue; } COLA_ASSERT(*curr != NULL); findAttachedObjects(index, (*curr), junction, hyperedgeConns); } }