Skip to content

Commit 371c708

Browse files
fix(tools): prevent duplicate annotation from re-converting a removed spline (#2824)
applyContourStroke already removes the source spline and rebuilds it as freehand. Skip convertContourSegmentationAnnotation when that source is gone so EvenOdd does not cancel the contour on the next stroke.
1 parent 97a426d commit 371c708

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎packages/tools/src/tools/annotation/SplineContourSegmentationTool.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { PublicToolProps } from '../../types';
33
import SplineROITool from './SplineROITool';
44
import { Events } from '../../enums';
55
import { convertContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
6+
import { getAnnotation } from '../../stateManagement/annotation/annotationState';
67

78
class SplineContourSegmentationTool extends SplineROITool {
89
static toolName = 'SplineContourSegmentationTool';
@@ -51,6 +52,20 @@ class SplineContourSegmentationTool extends SplineROITool {
5152
) {
5253
return;
5354
}
55+
56+
// applyContourStroke already removes the source stroke and rebuilds the
57+
// segment as PlanarFreehandContourSegmentationTool annotations. Converting
58+
// the removed source again would add a second, same-geometry freehand
59+
// contour. Under Clipper's EvenOdd fill rule those duplicates cancel out
60+
// when the next stroke is applied, which makes the original spline vanish.
61+
// Skip if the source annotation is no longer in the annotation state.
62+
if (
63+
!annotation?.annotationUID ||
64+
!getAnnotation(annotation.annotationUID)
65+
) {
66+
return;
67+
}
68+
5469
convertContourSegmentationAnnotation(annotation);
5570
}
5671
}

0 commit comments

Comments
 (0)