src/tools/FreehandRoiSculptorTool.js
/**
   * Finds pairs of close handles with seperations < config.minSpacing. No handle
   * is included in more than one pair, to avoid spurious deletion of densely
   * populated regions of the contour (see mergeCloseHandles).
   *
   * @private
   * @returns {Array} An array of close pairs in points.
   */
Finds pairs of close handles with seperations < config.minSpacing. No handle
is included in more than one pair, to avoid spurious deletion of densely
populated regions of the contour .

@private
@returns {Array} An array of close pairs in points.
Finds pairs of close handles with seperations < config . minSpacing . No handle is included in more than one pair to avoid spurious deletion of densely populated regions of the contour . @private @returns { Array } An array of close pairs in points .
_findCloseHandlePairs() {
    const { points, minSpacing } = this._sculptData;
    const closePairs = [];
    let length = points.length;
    for (let i = 0; i < length; i++) {
      const nextHandleIndex = this.constructor._getNextHandleIndex(
        i,
        points.length
      );
      const distanceToNextHandle = external.cornerstoneMath.point.distance(
        points[i],
        points[nextHandleIndex]
      );
      if (distanceToNextHandle < minSpacing) {
        const pair = [i, nextHandleIndex];
        closePairs.push(pair);
        if (i === 0) {
          length -= 1;
        }
        i++;
      }
    }
    return closePairs;
  }
_findCloseHandlePairs ( ) { const { points , minSpacing } = this . _sculptData ; const closePairs = [ ] ; let length = points . length ; for ( let i = 0 ; i < length ; i ++ ) { const nextHandleIndex = this . constructor . _getNextHandleIndex ( i , points . length ) ; const distanceToNextHandle = external . cornerstoneMath . point . distance ( points [ i ] , points [ nextHandleIndex ] ) ; if ( distanceToNextHandle < minSpacing ) { const pair = [ i , nextHandleIndex ] ; closePairs . push ( pair ) ; if ( i === 0 ) { length -= 1 ; } i ++ ; } } return closePairs ; }
Finds pairs of close handles with seperations < config.minSpacing.
Finds pairs of close handles with seperations < config . minSpacing .
// Don't check last node if first in pair to avoid double counting. // Don't double count pairs in order to prevent your polygon collapsing to a singularity.