当前位置: 首页>>代码示例>>C++>>正文


C++ Router::routingPenalty方法代码示例

本文整理汇总了C++中Router::routingPenalty方法的典型用法代码示例。如果您正苦于以下问题:C++ Router::routingPenalty方法的具体用法?C++ Router::routingPenalty怎么用?C++ Router::routingPenalty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Router的用法示例。


在下文中一共展示了Router::routingPenalty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assignPinVisibilityTo

// 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->routingPenalty(portDirectionPenalty);
            }

            if (router->_orthogonalRouting)
            {
                // 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->_polyLineRouting)
            {
                // 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 connecotr 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);
    }
}
开发者ID:amolenaar,项目名称:adaptagrams,代码行数:99,代码来源:connend.cpp


注:本文中的Router::routingPenalty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。