getContours function

dynamic getContours(
  1. dynamic points
)

Implementation

getContours(points) {
    var contours = [];
    var currentContour = [];
    for (var i = 0; i < points.length; i += 1) {
        var pt = points[i];
        currentContour.add(pt);
        if (pt["lastPointOfContour"]) {
            contours.add(currentContour);
            currentContour = [];
        }
    }

    argument(currentContour.length == 0, 'There are still points left in the current contour.');
    return contours;
}