From 627e436b16745df6982dec3954f2b385f180bad8 Mon Sep 17 00:00:00 2001 From: eleanor-park Date: Wed, 20 Mar 2024 23:27:21 -0400 Subject: tried to start closed curve management --- .../collectionFreeForm/CollectionFreeFormView.tsx | 53 +++++++++++++++------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 76e1646e2..b8d74dff2 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -838,8 +838,9 @@ export class CollectionFreeFormView extends CollectionSubView tVal + Math.floor(i/4)); if (currIntersects.length) { - intersections = [...intersections, ...currIntersects]; - // segmentIndexes is to keep track of the segment index that corresponds to an intersection + intersections = [...intersections, ...currIntersects] for (var j = 0; j < currIntersects.length; j++) { segmentIndexes.push(Math.floor(i / 4)); } } } + // for closed curve bookkeeping + var isClosedCurve = false; + if (intersections[0] === 0) { + isClosedCurve = true; + intersections = intersections.slice(1, intersections.length ); // take the 0 intersection out + segmentIndexes = segmentIndexes.slice(1, segmentIndexes.length); // same for indexes + } + if (intersections.length) { - // this is the indexes of the closest Ts - const closestTs = this.getClosestTs(intersections, excludeT, 0, intersections.length - 1); + // this is the indexes of the closest intersection(s) + var closestTs = this.getClosestTs(intersections, excludeT, 0, intersections.length - 1); // find the segments that need to be split var splitSegment1 = -1; // stays -1 if left end is deleted @@ -882,9 +888,9 @@ export class CollectionFreeFormView extends CollectionSubView { if (tVals[startIndex] >= excludeT) { return [-1, startIndex]; -- cgit v1.2.3-70-g09d2