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


Java TreeEntry类代码示例

本文整理汇总了Java中datastructures.ShapeTree.TreeEntry的典型用法代码示例。如果您正苦于以下问题:Java TreeEntry类的具体用法?Java TreeEntry怎么用?Java TreeEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TreeEntry类属于datastructures.ShapeTree包,在下文中一共展示了TreeEntry类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check_trace_segment

import datastructures.ShapeTree.TreeEntry; //导入依赖的package包/类
/**
 * Checks if a trace shape around the input parameters can
 * be inserted without conflict. If a conflict exists,
 * The result length is the maximal line length from p_line.a to p_line.b,
 *  which can be inserted without conflict (Integer.MAX_VALUE, if no conflict exists).
 * If p_only_not_shovable_obstacles, unfixed traces and vias are ignored.
 */
public double check_trace_segment(LineSegment p_line_segment, int p_layer, int[] p_net_no_arr,
        int p_trace_half_width, int p_cl_class_no, boolean p_only_not_shovable_obstacles)
{
    Polyline check_polyline = p_line_segment.to_polyline();
    if (check_polyline.arr.length != 3)
    {
        return 0;
    }
    TileShape shape_to_check = check_polyline.offset_shape(p_trace_half_width, 0);
    FloatPoint from_point = p_line_segment.start_point_approx();
    FloatPoint to_point = p_line_segment.end_point_approx();
    double line_length = to_point.distance(from_point);
    double ok_length = Integer.MAX_VALUE;
    ShapeSearchTree default_tree = this.search_tree_manager.get_default_tree();

    Collection<TreeEntry> obstacle_entries = default_tree.overlapping_tree_entries_with_clearance(shape_to_check, p_layer, p_net_no_arr, p_cl_class_no);

    for (TreeEntry curr_obstacle_entry : obstacle_entries)
    {

        if (!(curr_obstacle_entry.object instanceof Item))
        {
            continue;
        }
        Item curr_obstacle = (Item) curr_obstacle_entry.object;
        if (p_only_not_shovable_obstacles && curr_obstacle.is_route() && !curr_obstacle.is_shove_fixed())
        {
            continue;
        }
        TileShape curr_obstacle_shape = curr_obstacle_entry.object.get_tree_shape(default_tree, curr_obstacle_entry.shape_index_in_object);
        TileShape curr_offset_shape;
        FloatPoint nearest_obstacle_point;
        double shorten_value;
        if (default_tree.is_clearance_compensation_used())
        {
            curr_offset_shape = shape_to_check;
            shorten_value = p_trace_half_width + rules.clearance_matrix.clearance_compensation_value(curr_obstacle.clearance_class_no(), p_layer);
        }
        else
        {
            int clearance_value = this.clearance_value(curr_obstacle.clearance_class_no(), p_cl_class_no, p_layer);
            curr_offset_shape = (TileShape) shape_to_check.offset(clearance_value);
            shorten_value = p_trace_half_width + clearance_value;
        }
        TileShape intersection = curr_obstacle_shape.intersection(curr_offset_shape);
        if (intersection.is_empty())
        {
            continue;
        }
        nearest_obstacle_point = intersection.nearest_point_approx(from_point);

        double projection = from_point.scalar_product(to_point, nearest_obstacle_point) / line_length;

        projection = Math.max(0.0, projection - shorten_value - 1);

        if (projection < ok_length)
        {
            ok_length = projection;
            if (ok_length <= 0)
            {
                return 0;
            }
        }
    }

    return ok_length;
}
 
开发者ID:32bitmicro,项目名称:Freerouting,代码行数:75,代码来源:RoutingBoard.java


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