當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。