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


Java Line类代码示例

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


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

示例1: reposition_lines

import geometry.planar.Line; //导入依赖的package包/类
/**
 * tries to shorten p_polyline by relocating its lines
 */
Polyline reposition_lines(Polyline p_polyline)
{
    if (p_polyline.arr.length < 5)
    {
        return p_polyline;
    }
    for (int i = 2; i < p_polyline.arr.length - 2; ++i)
    {
        Line new_line = reposition_line(p_polyline.arr, i);
        if (new_line != null)
        {
            Line[] line_arr = new Line[p_polyline.arr.length];
            System.arraycopy(p_polyline.arr, 0, line_arr, 0, line_arr.length);
            line_arr[i] = new_line;
            Polyline result = new Polyline(line_arr);
            return skip_segments_of_length_0(result);
        }
    }
    return p_polyline;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:24,代码来源:PullTightAlgo.java

示例2: calc_cutline_at_end

import geometry.planar.Line; //导入依赖的package包/类
private static Line calc_cutline_at_end(int p_index, PolylineTrace p_trace)
{
    Polyline trace_lines = p_trace.polyline();
    ShapeSearchTree search_tree = p_trace.board.search_tree_manager.get_default_tree();
    if (p_index == trace_lines.arr.length - 3 ||
            trace_lines.corner_approx(trace_lines.arr.length - 2).distance(trace_lines.corner_approx(p_index + 1))
            < p_trace.get_compensated_half_width(search_tree))
    {
        
        Line curr_line = trace_lines.arr[trace_lines.arr.length - 1];
        FloatPoint is = trace_lines.corner_approx(trace_lines.arr.length - 3);
        Line cut_line;
        if (curr_line.side_of(is) == Side.ON_THE_LEFT)
        {
            cut_line = curr_line.opposite();
        }
        else
        {
            cut_line = curr_line;
        }
        return cut_line;
    }
    return null;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:25,代码来源:CalcShapeAndFromSide.java

示例3: calc_cutline_at_start

import geometry.planar.Line; //导入依赖的package包/类
private static Line calc_cutline_at_start(int p_index, PolylineTrace p_trace)
{
    Polyline trace_lines = p_trace.polyline();
    ShapeSearchTree search_tree = p_trace.board.search_tree_manager.get_default_tree();
    if (p_index == 0 ||
            trace_lines.corner_approx(0).distance(trace_lines.corner_approx(p_index))
            < p_trace.get_compensated_half_width(search_tree))
    {
        Line curr_line = trace_lines.arr[0];
        FloatPoint is = trace_lines.corner_approx(1);
        Line cut_line;
        if (curr_line.side_of(is) == Side.ON_THE_LEFT)
        {
            cut_line = curr_line.opposite();
        }
        else
        {
            cut_line = curr_line;
        }
        return cut_line;
    }
    return null;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:24,代码来源:CalcShapeAndFromSide.java

示例4: split

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Splits this trace into two at p_point.
 * Returns the 2 pieces of the splitted trace, or null if nothing was splitted because for example 
 * p_point is not located on a line segment of the p_polyline of this trace.
 */
public Trace[] split(Point p_point)
{
    for (int i = 0; i < this.lines.arr.length - 2; ++i)
    {
        LineSegment curr_line_segment = new LineSegment(this.lines, i + 1);
        if (curr_line_segment.contains(p_point))
        {
            Direction split_line_direction = curr_line_segment.get_line().direction().turn_45_degree(2);
            Line split_line = new Line(p_point, split_line_direction);
            Trace[] result = split(i + 1, split_line);
            if (result != null)
            {
                return result;
            }
        }
    }
    return null;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:24,代码来源:PolylineTrace.java

示例5: calculate_incomplete_rooms_with_empty_neighbours

import geometry.planar.Line; //导入依赖的package包/类
private static void calculate_incomplete_rooms_with_empty_neighbours(ObstacleExpansionRoom p_room, AutorouteEngine p_autoroute_engine)
{
    TileShape room_shape = p_room.get_shape();
    for (int i = 0; i < room_shape.border_line_count(); ++i)
    {
        Line curr_line = room_shape.border_line(i);
        if (SortedRoomNeighbours.insert_door_ok(p_room, curr_line))
        {
            Line[] shape_line = new Line[1];
            shape_line[0] = curr_line.opposite();
            TileShape new_room_shape = new Simplex(shape_line);
            TileShape new_contained_shape = room_shape.intersection(new_room_shape);
            FreeSpaceExpansionRoom new_room = p_autoroute_engine.add_incomplete_expansion_room(new_room_shape, p_room.get_layer(), new_contained_shape);
            ExpansionDoor new_door = new ExpansionDoor(p_room, new_room, 1);
            p_room.add_door(new_door);
            new_room.add_door(new_door);
        }
    }
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:20,代码来源:SortedRoomNeighbours.java

示例6: insert_door_ok

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Insert 1 dimensional doors for the first and the last room of a  trace rooms only,
 * if they are parallel to the trace line.
 * Otherwise there may be check ripup problems with entering at the wrong side at a fork.
 */
private static boolean insert_door_ok(ObstacleExpansionRoom p_room, Line p_door_line)
{
    if (p_door_line == null)
    {
        System.out.println("SortedRoomNeighbours.insert_door_ok: p_door_line is null");
        return false;
    }
    Item curr_item = p_room.get_item();
    if (curr_item instanceof PolylineTrace)
    {
        int room_index = p_room.get_index_in_item();
        PolylineTrace curr_trace = (PolylineTrace) curr_item;
        if (room_index == 0 || room_index == curr_trace.tile_shape_count() - 1)
        {
            Line curr_trace_line = curr_trace.polyline().arr[room_index + 1];
            if (!curr_trace_line.is_parallel(p_door_line))
            {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:29,代码来源:SortedRoomNeighbours.java

示例7: smoothen_corners

import geometry.planar.Line; //导入依赖的package包/类
/**
 * tries to smoothen p_polyline by cutting of corners, if possible
 */
private Polyline smoothen_corners(Polyline p_polyline)
{
    if (p_polyline.arr.length < 4)
    {
        return p_polyline;
    }
    boolean polyline_changed = false;
    Line[] line_arr = new Line[p_polyline.arr.length];
    System.arraycopy(p_polyline.arr, 0, line_arr, 0, line_arr.length);
    
    for (int i = 0; i < line_arr.length - 3; ++i)
    {
        Line new_line = smoothen_corner(line_arr, i);
        if (new_line != null)
        {
            polyline_changed = true;
            // add the new line into the line array
            Line[] tmp_lines = new Line[line_arr.length + 1];
            System.arraycopy(line_arr, 0, tmp_lines, 0, i + 2);
            tmp_lines [i + 2] = new_line;
            System.arraycopy(line_arr, i + 2, tmp_lines, i + 3,
                    tmp_lines.length - (i + 3));
            line_arr = tmp_lines;
            ++i;
        }
    }
    if (!polyline_changed)
    {
        return p_polyline;
    }
    return new Polyline(line_arr);
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:36,代码来源:PullTightAlgoAnyAngle.java

示例8: reposition_lines

import geometry.planar.Line; //导入依赖的package包/类
/**
 * tries to shorten p_polyline by relocating its lines
 */
Polyline reposition_lines(Polyline p_polyline)
{
    if (p_polyline.arr.length < 5)
    {
        return p_polyline;
    }
    boolean polyline_changed = false;
    Line[] line_arr = new Line[p_polyline.arr.length];
    System.arraycopy(p_polyline.arr, 0, line_arr, 0, line_arr.length);
    for (int i = 0; i < line_arr.length - 4; ++i)
    {
        Line new_line = reposition_line(line_arr, i);
        if (new_line != null)
        {
            polyline_changed = true;
            line_arr [i + 2] = new_line;
            if (line_arr[i + 2].is_parallel(line_arr[i + 1]) ||
                    line_arr[i + 2].is_parallel(line_arr[i + 3]))
            {
                // calculation of corners not possible before skipping
                // parallel lines
                break;
            }
        }
    }
    if (!polyline_changed)
    {
        return p_polyline;
    }
    return new Polyline(line_arr);
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:35,代码来源:PullTightAlgoAnyAngle.java

示例9: nearest_trace_exit_corner

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Calculates the nearest trace exit point of the pin on p_layer.
 * Returns null, if the pin has no trace exit restrictions.
 */
public FloatPoint nearest_trace_exit_corner(FloatPoint p_from_point, int  p_trace_half_width, int p_layer)
{
     java.util.Collection<Pin.TraceExitRestriction> trace_exit_restrictions = this.get_trace_exit_restrictions(p_layer);
     if (trace_exit_restrictions.isEmpty())
     {
         return null;
     }
     Shape pin_shape = this.get_shape(p_layer - this.first_layer());
     Point pin_center = this.get_center();
     if (!(pin_shape instanceof TileShape))
     {
         return null;
     }
     final double edge_to_turn_dist = this.board.rules.get_pin_edge_to_turn_dist();
     if (edge_to_turn_dist < 0)
     {
         return null;
     }
     TileShape offset_pin_shape = (TileShape)((TileShape)pin_shape).offset(edge_to_turn_dist + p_trace_half_width);

     // calculate the nearest legal pin exit point to trace_entry_location_approx
     double min_exit_corner_distance = Double.MAX_VALUE;
     FloatPoint nearest_exit_corner = null;
     for (Pin.TraceExitRestriction curr_exit_restriction : trace_exit_restrictions)
     {
         int curr_intersecting_border_line_no = offset_pin_shape.intersecting_border_line_no(pin_center, curr_exit_restriction.direction);
         Line curr_pin_exit_ray = new Line(pin_center, curr_exit_restriction.direction);
         FloatPoint curr_exit_corner = curr_pin_exit_ray.intersection_approx(offset_pin_shape.border_line(curr_intersecting_border_line_no));
         double curr_exit_corner_distance = curr_exit_corner.distance_square(p_from_point);
         if (curr_exit_corner_distance  < min_exit_corner_distance)
         {
             min_exit_corner_distance = curr_exit_corner_distance;
             nearest_exit_corner = curr_exit_corner;
         }
     }
     return nearest_exit_corner;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:42,代码来源:Pin.java

示例10: calc_check_chape_for_from_side

import geometry.planar.Line; //导入依赖的package包/类
private static  TileShape calc_check_chape_for_from_side(TileShape p_shape,
        Point p_shape_center, Line p_border_line)
{
    FloatPoint shape_center = p_shape_center.to_float();
    FloatPoint offset_projection = shape_center.projection_approx(p_border_line);
    // Make shure, that direction restrictions are retained.
    Line [] line_arr = new Line[3];
    Direction curr_dir = p_border_line.direction();
    line_arr[0] = new Line(p_shape_center, curr_dir);
    line_arr[1] = new Line(p_shape_center, curr_dir.turn_45_degree(2));
    line_arr[2] = new Line(offset_projection.round(), curr_dir);
    Polyline check_line = new Polyline(line_arr);
    return check_line.offset_shape(1, 0);
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:15,代码来源:ForcedPadAlgo.java

示例11: try_skip_second_corner

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Tries to skip the second corner of p_polyline.
 * Return p_polyline, if nothing was changed.
 */
private Polyline try_skip_second_corner(Polyline p_polyline)
{
    if (p_polyline.arr.length < 5)
    {
        return p_polyline;
    }
    Line[] check_lines = new Line[4];
    check_lines[0] = p_polyline.arr[1];
    check_lines[1] = p_polyline.arr[0];
    check_lines[2] = p_polyline.arr[3];
    check_lines[3] = p_polyline.arr[4];
    Polyline check_polyline = new Polyline(check_lines);
    if (check_polyline.arr.length != 4 ||
            curr_clip_shape != null &&
            !curr_clip_shape.contains(check_polyline.corner_approx(1)))
    {
        return p_polyline;
    }
    for (int i = 0; i < 2; ++i)
    {
        TileShape shape_to_check = check_polyline.offset_shape(curr_half_width, i);
        if (!board.check_trace_shape(shape_to_check, curr_layer, curr_net_no_arr,
                curr_cl_type, this.contact_pins))
        {
            return p_polyline;
        }
    }
    // now the second corner can be skipped.
    Line []  new_lines = new Line [p_polyline.arr.length - 1];
    new_lines[0] = p_polyline.arr[1];
    new_lines[1] = p_polyline.arr[0];
    for (int i = 2; i < new_lines.length; ++i)
    {
        new_lines[i] = p_polyline.arr[i + 1];
    }
     return new Polyline(new_lines);
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:42,代码来源:PullTightAlgo90.java

示例12: split_inside_drill_pad_prohibited

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Checks, if the intersection of the p_line_no-th line of this trace with p_line is inside
 * the pad of a pin. In this case the trace will be split only, if the intersection
 * is at the center of the pin.
 * Extending the function to vias leaded to broken connection problems wenn the autorouter connected to a trace.
 */
private boolean split_inside_drill_pad_prohibited(int p_line_no, Line p_line)
{
    if (this.board == null)
    {
        return false;
    }
    Point intersection = this.lines.arr[p_line_no].intersection(p_line);
    java.util.Collection<Item> overlap_items = this.board.pick_items(intersection, this.get_layer(), null);
    boolean pad_found = false;
    for (Item curr_item : overlap_items)
    {
        if (!curr_item.shares_net(this))
        {
            continue;
        }
        if (curr_item instanceof Pin)
        {
            DrillItem curr_drill_item = (DrillItem) curr_item;
            if (curr_drill_item.get_center().equals(intersection))
            {
                return false; // split always at the center of a drill item.
            }
            pad_found = true;
        }
        else if (curr_item instanceof Trace)
        {
            Trace curr_trace = (Trace) curr_item;
            if (curr_trace != this && curr_trace.first_corner().equals(intersection) || curr_trace.last_corner().equals(intersection))
            {
                return false;
            }
        }
    }
    return pad_found;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:42,代码来源:PolylineTrace.java

示例13: board_to_dsn

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Transforms an array of n geometry.planar.Lines to
 * an array of 4*n  doubles in the dsn coordinate system.
 */
public double [] board_to_dsn(Line [] p_lines)
{
    double [] result = new double[4 * p_lines.length];
    for (int i = 0; i < p_lines.length; ++ i)
    {
        FloatPoint a = p_lines[i].a.to_float();
        FloatPoint b = p_lines[i].b.to_float();
        result[4 * i] = board_to_dsn(a.x) + base_x;
        result[4 * i + 1] = board_to_dsn(a.y) + base_y;
        result[4 * i + 2] = board_to_dsn(b.x) + base_x;
        result[4 * i + 3] = board_to_dsn(b.y) + base_y;
    }
    return result;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:19,代码来源:CoordinateTransform.java

示例14: first_corner

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Returns the first corner of the intersection shape with the neighbour.
 */
public Point first_corner()
{
    if (precalculated_first_corner == null)
    {
        if (room_touch_is_corner)
        {
            precalculated_first_corner = room_shape.corner(touching_side_no_of_room);
        }
        else if (neighbour_room_touch_is_corner)
        {
            precalculated_first_corner = neighbour_shape.corner(touching_side_no_of_neighbour_room);
        }
        else
        {
            Point curr_first_corner = neighbour_shape.corner(neighbour_shape.next_no(touching_side_no_of_neighbour_room));
            Line prev_line = room_shape.border_line(room_shape.prev_no(touching_side_no_of_room));
            if (prev_line.side_of(curr_first_corner) == Side.ON_THE_RIGHT)
            {
                precalculated_first_corner = curr_first_corner;
            }
            else // curr_first_corner is outside the door shape
            {
                precalculated_first_corner = room_shape.corner(touching_side_no_of_room);
            }
        }
    }
    return precalculated_first_corner;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:32,代码来源:SortedRoomNeighbours.java

示例15: last_corner

import geometry.planar.Line; //导入依赖的package包/类
/**
 * Returns the last corner of the intersection shape with the neighbour.
 */
public Point last_corner()
{
    if (precalculated_last_corner == null)
    {
        if (room_touch_is_corner)
        {
            precalculated_last_corner = room_shape.corner(touching_side_no_of_room);
        }
        else if (neighbour_room_touch_is_corner)
        {
            precalculated_last_corner = neighbour_shape.corner(touching_side_no_of_neighbour_room);
        }
        else
        {
            Point curr_last_corner = neighbour_shape.corner(touching_side_no_of_neighbour_room);
            Line next_line = room_shape.border_line(room_shape.next_no(touching_side_no_of_room));
            if (next_line.side_of(curr_last_corner) == Side.ON_THE_RIGHT)
            {
                precalculated_last_corner = curr_last_corner;
            }
            else // curr_last_corner is outside the door shape
            {
                precalculated_last_corner = room_shape.corner(room_shape.next_no(touching_side_no_of_room));
            }
        }
    }
    return precalculated_last_corner;
}
 
开发者ID:andrasfuchs,项目名称:BioBalanceDetector,代码行数:32,代码来源:SortedRoomNeighbours.java


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