imaging/tools/strategies/eraseFreehand.js
/**
 * Erase all pixels labeled with the activeSegmentIndex,
 * in the region defined by evt.operationData.points.
 * @param  {} evt The Cornerstone event.
 * @param  {} operationData An object containing the `pixelData` to
 *                          modify, the `segmentIndex` and the `points` array.
 * @returns {null}
 */
Erase all pixels labeled with the activeSegmentIndex,
in the region defined by evt.operationData.points.
@param  {} evt The Cornerstone event.
Erase all pixels labeled with the activeSegmentIndex in the region defined by evt . operationData . points . @param {} evt The Cornerstone event .
function eraseFreehand(evt, operationData, inside = true) {
  const { points, segmentationMixinType } = operationData;
  if (segmentationMixinType !== `freehandSegmentationMixin`) {
    logger.error(
      `eraseInsideFreehand operation requires freehandSegmentationMixin operationData, recieved ${segmentationMixinType}`
    );
    return;
  }
  const { image } = evt.detail;
  const vertices = points.map(a => [a.x, a.y]);
  const [topLeft, bottomRight] = getBoundingBoxAroundPolygon(vertices, image);
  inside
    ? eraseInsideShape(
        evt,
        operationData,
        point => isPointInPolygon([point.x, point.y], vertices),
        topLeft,
        bottomRight
      )
    : eraseOutsideShape(
        evt,
        operationData,
        point => isPointInPolygon([point.x, point.y], vertices),
        topLeft,
        bottomRight
      );
}
function eraseFreehand ( evt , operationData , inside = true ) { const { points , segmentationMixinType } = operationData ; if ( segmentationMixinType !== ` ` ) { logger . error ( ` ${ segmentationMixinType } ` ) ; return ; } const { image } = evt . detail ; const vertices = points . map ( a => [ a . x , a . y ] ) ; const [ topLeft , bottomRight ] = getBoundingBoxAroundPolygon ( vertices , image ) ; inside ? eraseInsideShape ( evt , operationData , point => isPointInPolygon ( [ point . x , point . y ] , vertices ) , topLeft , bottomRight ) : eraseOutsideShape ( evt , operationData , point => isPointInPolygon ( [ point . x , point . y ] , vertices ) , topLeft , bottomRight ) ; }
Erase all pixels labeled with the activeSegmentIndex,
 in the region defined by evt.operationData.points.
Erase all pixels labeled with the activeSegmentIndex in the region defined by evt . operationData . points .