pcb 4.1.1
An interactive printed circuit board layout editor.

box.h File Reference

Random box-related utilities. More...

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

Go to the source code of this file.

Data Structures

struct  cheap_point

Defines

#define ROTATEBOX_CW(box)
 Rotates box 90-degrees cw.
#define ROTATEBOX_TO_NORTH(box, dir)
#define ROTATEBOX_FROM_NORTH(box, dir)
#define CENTER_X(b)   ((b).X1 + ((b).X2 - (b).X1)/2)
#define CENTER_Y(b)   ((b).Y1 + ((b).Y2 - (b).Y1)/2)

Typedefs

typedef struct cheap_point CheapPointType

Enumerations

enum  direction_t {
  NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3,
  NE = 4, SE = 5, SW = 6, NW,
  ALL = 8
}

Functions

static bool point_in_box (const BoxType *box, Coord X, Coord Y)
static bool point_in_closed_box (const BoxType *box, Coord X, Coord Y)
static bool box_is_good (const BoxType *b)
static bool box_intersect (const BoxType *a, const BoxType *b)
static CheapPointType closest_point_in_box (const CheapPointType *from, const BoxType *box)
static bool box_in_box (const BoxType *outer, const BoxType *inner)
static BoxType clip_box (const BoxType *box, const BoxType *clipbox)
static BoxType shrink_box (const BoxType *box, Coord amount)
static BoxType bloat_box (const BoxType *box, Coord amount)
static BoxType box_center (const BoxType *box)
 Construct a minimum box that touches the input box at the center.
static BoxType box_corner (const BoxType *box)
 Construct a minimum box that touches the input box at the corner.
static BoxType point_box (Coord X, Coord Y)
 Construct a box that holds a single point.
static void close_box (BoxType *r)
 Close a bounding box by pushing its upper right corner.
static double dist2_to_box (const CheapPointType *p, const BoxType *b)
 Return the square of the minimum distance from a point to some point inside a box.

Detailed Description

Random box-related utilities.

Author:
This file, box.h, was written and is Copyright (c) 2001 C. Scott Ananian.

Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

Copyright (C) 1998,1999,2000,2001 harry eaton

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: harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA haceaton@aplcomm.jhuapl.edu

Definition in file box.h.


Define Documentation

#define CENTER_X (   b)    ((b).X1 + ((b).X2 - (b).X1)/2)

Definition at line 92 of file box.h.

Referenced by CreateViaEdge(), ftherm_rect_in_reg(), RouteOne(), TargetPoint(), and TracePath().

#define CENTER_Y (   b)    ((b).Y1 + ((b).Y2 - (b).Y1)/2)

Definition at line 93 of file box.h.

Referenced by CreateViaEdge(), ftherm_rect_in_reg(), RouteOne(), TargetPoint(), and TracePath().

#define ROTATEBOX_CW (   box)
Value:
{ Coord t;\
    t = (box).X1; (box).X1 = -(box).Y2; (box).Y2 = (box).X2;\
    (box).X2 = -(box).Y1; (box).Y1 = t;\
}

Rotates box 90-degrees cw.

That's a strange rotation!

Definition at line 56 of file box.h.

#define ROTATEBOX_FROM_NORTH (   box,
  dir 
)
Value:
do { Coord t;\
  switch(dir) {\
  case WEST: \
   t = (box).X1; (box).X1 = (box).Y1; (box).Y1 = -(box).X2;\
   (box).X2 = (box).Y2; (box).Y2 = -t; break;\
  case SOUTH: \
   t = (box).X1; (box).X1 = -(box).X2; (box).X2 = -t;\
   t = (box).Y1; (box).Y1 = -(box).Y2; (box).Y2 = -t; break;\
  case EAST: \
   t = (box).X1; (box).X1 = -(box).Y2; (box).Y2 = (box).X2;\
   (box).X2 = -(box).Y1; (box).Y1 = t; break;\
  case NORTH: break;\
  default: assert(0);\
  }\
  } while (0)

Definition at line 75 of file box.h.

Referenced by break_box_edge().

#define ROTATEBOX_TO_NORTH (   box,
  dir 
)
Value:
do { Coord t;\
  switch(dir) {\
  case EAST: \
   t = (box).X1; (box).X1 = (box).Y1; (box).Y1 = -(box).X2;\
   (box).X2 = (box).Y2; (box).Y2 = -t; break;\
  case SOUTH: \
   t = (box).X1; (box).X1 = -(box).X2; (box).X2 = -t;\
   t = (box).Y1; (box).Y1 = -(box).Y2; (box).Y2 = -t; break;\
  case WEST: \
   t = (box).X1; (box).X1 = -(box).Y2; (box).Y2 = (box).X2;\
   (box).X2 = -(box).Y1; (box).Y1 = t; break;\
  case NORTH: break;\
  default: assert(0);\
  }\
  } while (0)

Definition at line 60 of file box.h.

Referenced by __r_find_neighbor_rect_in_reg(), __r_find_neighbor_reg_in_sea(), break_box_edge(), and r_find_neighbor().


Typedef Documentation

typedef struct cheap_point CheapPointType

Enumeration Type Documentation

Enumerator:
NORTH 
EAST 
SOUTH 
WEST 
NE 
SE 
SW 
NW 
ALL 

Definition at line 47 of file box.h.


Function Documentation

static BoxType bloat_box ( const BoxType box,
Coord  amount 
) [inline, static]

Definition at line 178 of file box.h.

References shrink_box().

Referenced by __Expand_this_rect(), __GatherBlockers(), bloat_routebox(), blocker_to_heap(), BreakManyEdges(), clearPoly(), moveable_edge(), and mtspace_query_rect().

Here is the call graph for this function:

static BoxType box_center ( const BoxType box) [inline, static]

Construct a minimum box that touches the input box at the center.

Definition at line 188 of file box.h.

References BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by mtspace_remove(), and RouteOne().

static BoxType box_corner ( const BoxType box) [inline, static]

Construct a minimum box that touches the input box at the corner.

Definition at line 203 of file box.h.

References BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

static bool box_in_box ( const BoxType outer,
const BoxType inner 
) [inline, static]

Definition at line 146 of file box.h.

References BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by clip_box(), and TracePath().

static bool box_intersect ( const BoxType a,
const BoxType b 
) [inline, static]
static bool box_is_good ( const BoxType b) [inline, static]
static BoxType clip_box ( const BoxType box,
const BoxType clipbox 
) [inline, static]

Definition at line 154 of file box.h.

References box_in_box(), box_intersect(), MAX, MIN, BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by blocker_to_heap(), clearPoly(), RouteOne(), and TracePath().

Here is the call graph for this function:

static void close_box ( BoxType r) [inline, static]

Close a bounding box by pushing its upper right corner.

Definition at line 231 of file box.h.

References BoxType::X2, and BoxType::Y2.

Referenced by do_via_search(), SetArcBoundingBox(), SetElementBoundingBox(), SetLineBoundingBox(), SetPadBoundingBox(), SetPinBoundingBox(), SetPolygonBoundingBox(), and SetTextBoundingBox().

static CheapPointType closest_point_in_box ( const CheapPointType from,
const BoxType box 
) [inline, static]
static double dist2_to_box ( const CheapPointType p,
const BoxType b 
) [inline, static]

Return the square of the minimum distance from a point to some point inside a box.

The box is half-closed!
That is, the top-left corner is considered in the box, but the bottom-right corner is not.

Definition at line 246 of file box.h.

References closest_point_in_box(), Distance(), cheap_point::X, and cheap_point::Y.

Here is the call graph for this function:

static BoxType point_box ( Coord  X,
Coord  Y 
) [inline, static]

Construct a box that holds a single point.

Definition at line 217 of file box.h.

References X, BoxType::X1, BoxType::X2, Y, BoxType::Y1, and BoxType::Y2.

Referenced by FindRouteBoxOnLayerGroup(), and SearchObjectByLocation().

static bool point_in_box ( const BoxType box,
Coord  X,
Coord  Y 
) [inline, static]

Definition at line 106 of file box.h.

References BoxType::X1, BoxType::Y1, and BoxType::Y2.

Referenced by closest_point_in_box(), point_in_shrunk_box(), RD_DrawManhattanLine(), and TracePath().

static bool point_in_closed_box ( const BoxType box,
Coord  X,
Coord  Y 
) [inline, static]

Definition at line 112 of file box.h.

References BoxType::X1, BoxType::Y1, and BoxType::Y2.

Referenced by RD_DrawManhattanLine().

static BoxType shrink_box ( const BoxType box,
Coord  amount 
) [inline, static]