## com.bbn.openmap.proj
Class Clip

    java.lang.Object
      com.bbn.openmap.proj.Clip

public class Clip
extends java.lang.Object

Clipping functions.

Method Summary
`static int[]` `liang_clip(int xleft, int xright, int ytop, int ybottom, int[] x, int[] y, int n, int[] ret_val)` Liang Barsy polygon clipping algorithm.
`static int` `liang_get_buflen(int nverts)` Calculate the int[] x,y buffer length for nverts.
`static int` `quickCheckLineClip(int x1, int y1, int x2, int y2, int xleft, int xright, int ytop, int ybottom)` Check if a line is completely inside or completely outside viewport.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### liang_get_buflen

    public static final int liang_get_buflen(int nverts)

  Calculate the int[] x,y buffer length for nverts.

  Parameters:
    `nverts` - number of verts
  Returns:
    int length required

### liang_clip

    public static final int[] liang_clip(int xleft,
                                         int xright,
                                         int ytop,
                                         int ybottom,
                                         int[] x,
                                         int[] y,
                                         int n,
                                         int[] ret_val)

  Liang Barsy polygon clipping algorithm.

  Viewport: xleft < xright, ybottom < ytop

  Set up with: `int[] ret_val = new int[n*2*2]; ret_val = liang_clip(,...,ret_val);`

  Points: xpoints, ypoints, npts HACK: closure on these points?

  Parameters:
    `xleft` - left side of viewport
    `xright` - right side of viewport
    `ytop` - top of viewport
    `ybottom` - bottom of viewport
    `x` - int[] x coords
    `y` - int[] y coords
    `n` - numcoords
    `ret_val` - int[] clipped polygon
  See Also:
    `liang_get_buflen(int)`

### quickCheckLineClip

    public static final int quickCheckLineClip(int x1,
                                               int y1,
                                               int x2,
                                               int y2,
                                               int xleft,
                                               int xright,
                                               int ytop,
                                               int ybottom)

  Check if a line is completely inside or completely outside viewport.

  Parameters:
    `x1` - pt1.x
    `y1` - pt1.y
    `x2` - pt2.x
    `y2` - pt2.y
    `xleft` - left
    `xright` - right
    `ytop` - ytop < ybottom
    `ybottom` - ybottom < ytop
  Returns:
    int -1=outside, 1=inside, 0=undetermined

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details