pcb 4.1.1
An interactive printed circuit board layout editor.

find.h File Reference

Prototypes for connection search routines. More...

#include <stdio.h>
#include "global.h"
Include dependency graph for find.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LOOKUP_FIRST   (PIN_TYPE | PAD_TYPE)
#define LOOKUP_MORE   (VIA_TYPE | LINE_TYPE | RATLINE_TYPE | POLYGON_TYPE | ARC_TYPE)
#define SILK_TYPE   (LINE_TYPE | ARC_TYPE | POLYGON_TYPE)

Functions

bool LineLineIntersect (LineType *, LineType *)
 Checks if two lines intersect.
bool LineArcIntersect (LineType *, ArcType *)
 Check for line intersection with an arc.
bool PinLineIntersect (PinType *, LineType *)
bool LinePadIntersect (LineType *, PadType *)
 
bool ArcPadIntersect (ArcType *, PadType *)
void LookupElementConnections (ElementType *, FILE *)
 Find all connections to pins within one element.
void LookupConnectionsToAllElements (FILE *)
 Find all connections to pins of all element.
void LookupConnection (Coord, Coord, bool, Coord, int, bool AndRats)
 Looks up all connections from the object at the given coordinates the TheFlag (normally 'FOUNDFLAG') is set for all objects found.
void LookupUnusedPins (FILE *)
 Find all unused pins of all elements.
bool ClearFlagOnLinesAndPolygons (bool, int flag)
 Resets all used flags of LOs.
bool ClearFlagOnPinsViasAndPads (bool, int flag)
 Resets all used flags of pins and vias.
bool ClearFlagOnAllObjects (bool, int flag)
 Resets all found connections.
void InitConnectionLookup (void)
void FreeConnectionLookupMemory (void)
void RatFindHook (int, void *, void *, void *, bool, int flag, bool)
 Find connections for rats nesting.
int DRCAll (void)
 Check for DRC violations.
void LookupConnectionByPin (int, void *)

Detailed Description

Prototypes for connection search routines.

Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact addresses for paper mail and Email: Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany Thomas.Nau@rz.uni-ulm.de

Definition in file find.h.


Define Documentation

#define LOOKUP_FIRST   (PIN_TYPE | PAD_TYPE)

Definition at line 40 of file find.h.

Referenced by LookupConnection().

#define LOOKUP_MORE   (VIA_TYPE | LINE_TYPE | RATLINE_TYPE | POLYGON_TYPE | ARC_TYPE)

Definition at line 42 of file find.h.

Referenced by LookupConnection().

#define SILK_TYPE   (LINE_TYPE | ARC_TYPE | POLYGON_TYPE)

Definition at line 44 of file find.h.

Referenced by describe_location(), and LookupConnection().


Function Documentation

bool ArcPadIntersect ( ArcType ,
PadType  
)

Definition at line 317 of file find.c.

References LineArcIntersect().

Referenced by LOCtoArcPad_callback(), and LOCtoPadArc_callback().

Here is the call graph for this function:

bool ClearFlagOnLinesAndPolygons ( bool  ,
int  flag 
)
bool ClearFlagOnPinsViasAndPads ( bool  ,
int  flag 
)

Resets all used flags of pins and vias.

Definition at line 3265 of file find.c.

References AddObjectToFlagUndoList(), CLEAR_FLAG, PCBType::Data, DrawPad(), DrawPin(), DrawVia(), ELEMENT_LOOP, END_LOOP, lo_info::pad, PAD_LOOP, PCB, pin, PIN_LOOP, SetChangedFlag(), TEST_FLAG, and VIA_LOOP.

Referenced by ActionConnection(), ClearFlagOnAllObjects(), and IPCD356_Netlist().

Here is the call graph for this function:

bool LineArcIntersect ( LineType Line,
ArcType Arc 
)

Check for line intersection with an arc.

Mostly this is like the circle/line intersection found in IsPointOnLine (search.c) see the detailed discussion for the basics there.

Since this is only an arc, not a full circle we need to find the actual points of intersection with the circle, and see if they are on the arc.

To do this, we translate along the line from the point Q plus or minus a distance delta = sqrt(Radius^2 - d^2) but it's handy to normalize with respect to l, the line length so a single projection is done (e.g. we don't first find the point Q.

 The projection is now of the form:
      Px = X1 + (r +- r2)(X2 - X1)
      Py = Y1 + (r +- r2)(Y2 - Y1)
 

Where r2 sqrt(Radius^2 l^2 - d^2)/l^2 note that this is the variable d, not the symbol d described in IsPointOnLine (variable d = symbol d * l).

The end points are hell so they are checked individually.

Definition at line 1674 of file find.c.

References Bloat, box, GetArcEnds(), IsPointInPad(), IsPointOnArc(), MAX, ArcType::Thickness, ArcType::Width, ArcType::X, BoxType::X1, BoxType::X2, ArcType::Y, BoxType::Y1, and BoxType::Y2.

Referenced by ArcPadIntersect(), drcArc_callback(), IsArcInRectangle(), LOCtoArcLine_callback(), and LOCtoLineArc_callback().

Here is the call graph for this function:

bool LineLineIntersect ( LineType Line1,
LineType Line2 
)

Checks if two lines intersect.

 From news FAQ:
 Let A,B,C,D be 2-space position vectors.
 Then the directed line segments AB & CD are given by:
      AB=A+r(B-A), r in [0,1]
      CD=C+s(D-C), s in [0,1]
 If AB & CD intersect, then
      A+r(B-A)=C+s(D-C), or
      XA+r(XB-XA)=XC+s*(XD-XC)
      YA+r(YB-YA)=YC+s(YD-YC)  for some r,s in [0,1]
 Solving the above for r and s yields
          (YA-YC)(XD-XC)-(XA-XC)(YD-YC)
      r = -----------------------------  (eqn 1)
          (XB-XA)(YD-YC)-(YB-YA)(XD-XC)
          (YA-YC)(XB-XA)-(XA-XC)(YB-YA)
      s = -----------------------------  (eqn 2)
          (XB-XA)(YD-YC)-(YB-YA)(XD-XC)
 Let I be the position vector of the intersection point, then:
      I=A+r(B-A) or
      XI=XA+r(XB-XA)
      YI=YA+r(YB-YA)
 By examining the values of r & s, you can also determine some
 other limiting conditions:
      If 0<=r<=1 & 0<=s<=1, intersection exists
          r<0 or r>1 or s<0 or s>1 line segments do not intersect
      If the denominator in eqn 1 is zero, AB & CD are parallel
      If the numerator in eqn 1 is also zero, AB & CD are coincident
 If the intersection point of the 2 lines are needed (lines in this
 context mean infinite lines) regardless whether the two line
 segments intersect, then
      If r>1, I is located on extension of AB
      If r<0, I is located on extension of BA
      If s>1, I is located on extension of CD
      If s<0, I is located on extension of DC
 Also note that the denominators of eqn 1 & 2 are identical.
 

Definition at line 1564 of file find.c.

References Bloat, form_slanted_rectangle(), IsLineInQuadrangle(), IsPointInPad(), MAX, s, and TEST_FLAG.

Referenced by drcLine_callback(), IsLineInQuadrangle(), IsLineInRectangle(), LinePadIntersect(), and LOCtoLineLine_callback().

Here is the call graph for this function:

bool LinePadIntersect ( LineType Line,
PadType Pad 
)

Some of the 'pad' routines are the same as for lines because the 'pad' struct starts with a line struct. See global.h for details.

Definition at line 311 of file find.c.

References LineLineIntersect().

Referenced by drcPad_callback(), LOCtoLinePad_callback(), LOCtoPadLine_callback(), and PadPadIntersect().

Here is the call graph for this function:

void LookupConnection ( Coord  X,
Coord  Y,
bool  AndDraw,
Coord  Range,
int  flag,
bool  AndRats 
)

Looks up all connections from the object at the given coordinates the TheFlag (normally 'FOUNDFLAG') is set for all objects found.

The objects are re-drawn if AndDraw is true, also the action is marked as undoable if AndDraw is true.

Definition at line 3148 of file find.c.

References hid_st::beep, ConnectionName(), PCBType::Data, DoIt(), Draw(), FreeConnectionLookupMemory(), GetLayerNumber(), gui, hid_actionl(), IncrementUndoSerialNumber(), InitConnectionLookup(), ListStart(), LOOKUP_FIRST, LOOKUP_MORE, max_copper_layer, PCB, ptr1, ptr2, ptr3, reassign_no_drc_flags(), SettingType::RingBellWhenFinished, SearchObjectByLocation(), Settings, SILK_TYPE, and User.

Referenced by ActionConnection(), ActionDisplay(), netlist_find(), netlist_select(), NotifyLine(), NotifyMode(), and XYtoNetLength().

Here is the call graph for this function:

void LookupConnectionByPin ( int  ,
void *   
)

Definition at line 3203 of file find.c.

References DoIt(), FreeConnectionLookupMemory(), InitConnectionLookup(), ListStart(), and User.

Referenced by IPCD356_Netlist().

Here is the call graph for this function:

void LookupConnectionsToAllElements ( FILE *  )

Find all connections to pins of all element.

Definition at line 3047 of file find.c.

References hid_st::beep, ClearFlagOnAllObjects(), PCBType::Data, ELEMENT_LOOP, END_LOOP, FreeConnectionLookupMemory(), gui, InitConnectionLookup(), n, PCB, PrintElementConnections(), Redraw(), SettingType::ResetAfterElement, SettingType::RingBellWhenFinished, SEPARATE, Settings, and User.

Referenced by ActionSaveTo().

Here is the call graph for this function:

void LookupElementConnections ( ElementType ,
FILE *   
)

Find all connections to pins within one element.

Definition at line 3027 of file find.c.

References hid_st::beep, ClearFlagOnAllObjects(), Draw(), FreeConnectionLookupMemory(), gui, IncrementUndoSerialNumber(), InitConnectionLookup(), PrintElementConnections(), SettingType::RingBellWhenFinished, SetChangedFlag(), Settings, and User.

Referenced by ActionSaveTo().

Here is the call graph for this function:

void LookupUnusedPins ( FILE *  )
bool PinLineIntersect ( PinType ,
LineType  
)

Definition at line 398 of file find.c.

References Bloat, IsLineInRectangle(), IsPointInPad(), MAX, PIN_SIZE, TEST_FLAG, pin_st::X, and pin_st::Y.

Referenced by canonicalize_line(), drcVia_callback(), LOCtoPVline_callback(), and pv_line_callback().

Here is the call graph for this function:

void RatFindHook ( int  type,
void *  ptr1,
void *  ptr2,
void *  ptr3,
bool  undo,
int  flag,
bool  AndRats 
)

Find connections for rats nesting.

Assumes InitConnectionLookup() has already been done.

Definition at line 3222 of file find.c.

References DoIt(), DumpList(), ListStart(), and User.

Referenced by GatherSubnets(), gsvit_create_netlist(), nbcb_select_common(), and netlist_select_cb().

Here is the call graph for this function: