/** * Looks if at the input position ends a trace with the input net number, which has no normal * contact at that position. Returns null, if no tail is found. */ public Trace get_trace_tail(Point p_location, int p_layer, int[] p_net_no_arr) { TileShape point_shape = TileShape.get_instance(p_location); Collection<SearchTreeObject> found_items = overlapping_objects(point_shape, p_layer); Iterator<SearchTreeObject> it = found_items.iterator(); while (it.hasNext()) { SearchTreeObject curr_ob = it.next(); if (curr_ob instanceof Trace) { Trace curr_trace = (Trace) curr_ob; if (!curr_trace.nets_equal(p_net_no_arr)) { continue; } if (curr_trace.first_corner().equals(p_location)) { Collection<Item> contacts = curr_trace.get_start_contacts(); if (contacts.size() == 0) { return curr_trace; } } if (curr_trace.last_corner().equals(p_location)) { Collection<Item> contacts = curr_trace.get_end_contacts(); if (contacts.size() == 0) { return curr_trace; } } } } return null; }
/** * Checks, if p_item item is part of a cycle and remuve it together with its connection in this * case. */ public boolean remove_if_cycle(Trace p_trace) { if (!p_trace.is_on_the_board()) { return false; } if (!p_trace.is_cycle()) { return false; } // Remove tails at the endpoints after removing the cycle, // if there was no tail before. boolean[] tail_at_endpoint_before = null; Point[] end_corners = null; int curr_layer = p_trace.get_layer(); int[] curr_net_no_arr = p_trace.net_no_arr; end_corners = new Point[2]; end_corners[0] = p_trace.first_corner(); end_corners[1] = p_trace.last_corner(); tail_at_endpoint_before = new boolean[2]; for (int i = 0; i < 2; ++i) { Trace tail = get_trace_tail(end_corners[i], curr_layer, curr_net_no_arr); tail_at_endpoint_before[i] = (tail != null); } Set<Item> connection_items = p_trace.get_connection_items(); this.remove_items(connection_items, false); for (int i = 0; i < 2; ++i) { if (!tail_at_endpoint_before[i]) { Trace tail = get_trace_tail(end_corners[i], curr_layer, curr_net_no_arr); if (tail != null) { remove_items(tail.get_connection_items(), false); } } } return true; }
Point normal_contact_point(Trace p_other) { if (this.layer != p_other.layer) { return null; } boolean contact_at_first_corner = this.first_corner().equals(p_other.first_corner()) || this.first_corner().equals(p_other.last_corner()); boolean contact_at_last_corner = this.last_corner().equals(p_other.first_corner()) || this.last_corner().equals(p_other.last_corner()); Point result; if (!(contact_at_first_corner || contact_at_last_corner) || contact_at_first_corner && contact_at_last_corner) { // no contact point or more than 1 contact point result = null; } else if (contact_at_first_corner) { result = this.first_corner(); } else // contact at last corner { result = this.last_corner(); } return result; }
/** * Maybe trace of type turret without net in Mentor design. Try to assig the net by calculating * the overlaps. */ private void try_correct_net(Item p_item) { if (!(p_item instanceof Trace)) { return; } Trace curr_trace = (Trace) p_item; java.util.Set<Item> contacts = curr_trace.get_normal_contacts(curr_trace.first_corner(), true); contacts.addAll(curr_trace.get_normal_contacts(curr_trace.last_corner(), true)); int corrected_net_no = 0; for (Item curr_contact : contacts) { if (curr_contact.net_count() == 1) { corrected_net_no = curr_contact.get_net_no(0); break; } } if (corrected_net_no != 0) { p_item.assign_net_no(corrected_net_no); } }
/** * Get a list of all items having a connection point at p_point on the layer of this trace. If * p_ignore_net is false, only contacts to items sharing a net with this trace are calculated. * This is the normal case. * * @param p_point a {@link geometry.planar.Point} object. * @param p_ignore_net a boolean. * @return a {@link java.util.Set} object. */ public Set<Item> get_normal_contacts(Point p_point, boolean p_ignore_net) { if (p_point == null || !(p_point.equals(this.first_corner()) || p_point.equals(this.last_corner()))) { return new TreeSet<Item>(); } TileShape search_shape = TileShape.get_instance(p_point); Set<SearchTreeObject> overlaps = board.overlapping_objects(search_shape, this.layer); Set<Item> result = new TreeSet<Item>(); for (SearchTreeObject curr_ob : overlaps) { if (!(curr_ob instanceof Item)) { continue; } Item curr_item = (Item) curr_ob; if (curr_item != this && curr_item.shares_layer(this) && (p_ignore_net || curr_item.shares_net(this))) { if (curr_item instanceof Trace) { Trace curr_trace = (Trace) curr_item; if (p_point.equals(curr_trace.first_corner()) || p_point.equals(curr_trace.last_corner())) { result.add(curr_item); } } else if (curr_item instanceof DrillItem) { DrillItem curr_drill_item = (DrillItem) curr_item; if (p_point.equals(curr_drill_item.get_center())) { result.add(curr_item); } } else if (curr_item instanceof ConductionArea) { ConductionArea curr_area = (ConductionArea) curr_item; if (curr_area.get_area().contains(p_point)) { result.add(curr_item); } } } } return result; }