All files / packages/tools/src/utilities/math/polyline containsPoints.ts

83.33% Statements 5/6
50% Branches 1/2
100% Functions 1/1
75% Lines 3/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                            1x 1x 1x            
import type { Types } from '@cornerstonejs/core';
import containsPoint from './containsPoint';
 
/**
 * Checks if a polyline contains a set of points.
 *
 * @param polyline - Polyline points (2D)
 * @param points - 2D points to verify
 * @returns True if all points are inside the polyline or false otherwise
 */
export default function containsPoints(
  polyline: Types.Point2[],
  points: Types.Point2[]
): boolean {
  for (let i = 0, numPoint = points.length; i < numPoint; i++) {
    Eif (!containsPoint(polyline, points[i])) {
      return false;
    }
  }
 
  return true;
}