void JunctionRef::preferOrthogonalDimension(const size_t dim) { const double smallPenalty = 1.0; for (ShapeConnectionPinSet::iterator curr = m_connection_pins.begin(); curr != m_connection_pins.end(); ++curr) { ShapeConnectionPin *pin = *curr; if (dim == YDIM) { if (pin->directions() & (ConnDirLeft | ConnDirRight)) { pin->setConnectionCost(smallPenalty); } } else if (dim == XDIM) { if (pin->directions() & (ConnDirUp | ConnDirDown)) { pin->setConnectionCost(smallPenalty); } } } }
// Assign visibility to a dummy vertex representing all the possible pins // for this pinClassId. void ConnEnd::assignPinVisibilityTo(VertInf *dummyConnectionVert, VertInf *targetVert) { unsigned int validPinCount = 0; COLA_ASSERT(m_anchor_obj); COLA_ASSERT(m_connection_pin_class_id != CONNECTIONPIN_UNSET); Router *router = m_anchor_obj->router(); for (ShapeConnectionPinSet::iterator curr = m_anchor_obj->m_connection_pins.begin(); curr != m_anchor_obj->m_connection_pins.end(); ++curr) { ShapeConnectionPin *currPin = *curr; if ((currPin->m_class_id == m_connection_pin_class_id) && (!currPin->m_exclusive || currPin->m_connend_users.empty())) { double routingCost = currPin->m_connection_cost; Point adjTargetPt = targetVert->point - currPin->m_vertex->point; double angle = rotationalAngle(adjTargetPt); bool inVisibilityRange = false; if (angle <= 45 || angle >= 315) { if (currPin->directions() & ConnDirRight) { inVisibilityRange = true; } } if (angle >= 45 && angle <= 135) { if (currPin->directions() & ConnDirDown) { inVisibilityRange = true; } } if (angle >= 135 && angle <= 225) { if (currPin->directions() & ConnDirLeft) { inVisibilityRange = true; } } if (angle >= 225 && angle <= 315) { if (currPin->directions() & ConnDirUp) { inVisibilityRange = true; } } if (!inVisibilityRange) { routingCost += router->routingParameter(portDirectionPenalty); } if (router->m_allows_orthogonal_routing) { // This has same ID and is either unconnected or not // exclusive, so give it visibility. EdgeInf *edge = new EdgeInf(dummyConnectionVert, currPin->m_vertex, true); // XXX Can't use a zero cost due to assumptions // elsewhere in code. edge->setDist(manhattanDist(dummyConnectionVert->point, currPin->m_vertex->point) + std::max(0.001, routingCost)); } if (router->m_allows_orthogonal_routing) { // This has same ID and is either unconnected or not // exclusive, so give it visibility. EdgeInf *edge = new EdgeInf(dummyConnectionVert, currPin->m_vertex, false); // XXX Can't use a zero cost due to assumptions // elsewhere in code. edge->setDist(euclideanDist(dummyConnectionVert->point, currPin->m_vertex->point) + std::max(0.001, routingCost)); } // Increment the number of valid pins for this ConnEnd connection. validPinCount++; } } if (validPinCount == 0) { // There should be at least one pin, otherwise we will have // problems finding connector routes. err_printf("Warning: In ConnEnd::assignPinVisibilityTo():\n" " ConnEnd for connector %d can't connect to shape %d\n" " since it has no pins with class id of %u.\n", (int) m_conn_ref->id(), (int) m_anchor_obj->id(), m_connection_pin_class_id); } }