intersectsPixelClosure method

bool intersectsPixelClosure(
  1. Coordinate p0,
  2. Coordinate p1
)

Test whether the given segment intersects the closure of this hot pixel. This is NOT the test used in the standard snap-rounding algorithm, which uses the partially closed tolerance square instead. This routine is provided for testing purposes only.

@param p0 the start point of a line segment @param p1 the end point of a line segment @return true if the segment intersects the closure of the pixel's tolerance square

Implementation

bool intersectsPixelClosure(Coordinate p0, Coordinate p1) {
  li.computeIntersection(p0, p1, corner[0], corner[1]);
  if (li.hasIntersection()) return true;
  li.computeIntersection(p0, p1, corner[1], corner[2]);
  if (li.hasIntersection()) return true;
  li.computeIntersection(p0, p1, corner[2], corner[3]);
  if (li.hasIntersection()) return true;
  li.computeIntersection(p0, p1, corner[3], corner[0]);
  if (li.hasIntersection()) return true;

  return false;
}