Esempio n. 1
0
 /**
  * returns the endpoint of this trace with the shortest distance to p_from_point
  *
  * @param p_from_point a {@link geometry.planar.Point} object.
  * @return a {@link geometry.planar.Point} object.
  */
 public Point nearest_end_point(Point p_from_point) {
   Point p1 = first_corner();
   Point p2 = last_corner();
   FloatPoint from_point = p_from_point.to_float();
   double d1 = from_point.distance(p1.to_float());
   double d2 = from_point.distance(p2.to_float());
   Point result;
   if (d1 < d2) {
     result = p1;
   } else {
     result = p2;
   }
   return result;
 }
Esempio n. 2
0
 /**
  * Looks up touching pins at the first corner and the last corner of the trace. Used to avoid acid
  * traps.
  */
 Set<Pin> touching_pins_at_end_corners() {
   Set<Pin> result = new TreeSet<Pin>();
   if (this.board == null) {
     return result;
   }
   Point curr_end_point = this.first_corner();
   for (int i = 0; i < 2; ++i) {
     IntOctagon curr_oct = curr_end_point.surrounding_octagon();
     curr_oct = curr_oct.enlarge(this.half_width);
     Set<Item> curr_overlaps =
         this.board.overlapping_items_with_clearance(
             curr_oct, this.layer, new int[0], this.clearance_class_no());
     for (Item curr_item : curr_overlaps) {
       if ((curr_item instanceof Pin) && curr_item.shares_net(this)) {
         result.add((Pin) curr_item);
       }
     }
     curr_end_point = this.last_corner();
   }
   return result;
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /** checks, if p_point is contained in the bounding box of this board. */
 public boolean contains(Point p_point) {
   return p_point.is_contained_in(bounding_box);
 }