Curvature comb: a seam segment whose anchors coincide uses its handle direction

comb_closes took a straight segment's chord as its direction at the seam.
When the segment's anchors sit on one point and its handle is too short to
count, that chord has no length, the reversal test compared against a zero
vector, and the comb closed across a seam where the path turns back. The
seam check now uses the chord only when it has a length, as curvature_comb
does, and falls back to the handle direction otherwise.

The View › Show Curvature Comb params help and the ROADMAP line now say
that the line through the tips starts again at a cusp, a straight segment
included; ui_catalog.rs is regenerated.
This commit is contained in:
dotCooCoo committed 2026-12-04 02:38:51 -08:00
1 parent 57efe8105e
commit d5be27f55a
4 files changed
+22 -5

No files matched your search

+1 -1
View File
@@ -124,7 +124,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
## Progress log
- 2026-12-03: View › Show Curvature Comb (`view.curvatureComb`) draws the curvature comb of the selected paths and compound paths: teeth along the normal as long as the curvature, and a line through their tips (#10659). Headline numbers unchanged.
- 2026-12-03: View › Show Curvature Comb (`view.curvatureComb`) draws the curvature comb of the selected paths and compound paths: teeth along the normal as long as the curvature, and a line through their tips that starts again where the path turns back on itself at a cusp, a straight segment included (#10659). Headline numbers unchanged.
- 2026-12-02: The desktop Print dialog looks up installed printers in the background. Named printers become selectable after the lookup returns and the dialog applies the list. PDF File is available at once. Physical printing waits for the list to be applied, and Done can save settings while the lookup runs. The dialog shows and announces discovery and disables physical Print until the list is applied.
+19 -2
View File
@@ -350,8 +350,10 @@ pub fn comb_closes(sp: &SubPath, teeth: &[CombTooth]) -> bool {
match ((0..n).rev().find(|&i| !no_length(i)), (0..n).find(|&i| !no_length(i))) {
(Some(into), Some(out)) => {
let (a, b) = (sp.segment(into), sp.segment(out));
let a = if sp.segment_is_line(into) { a.p3 - a.p0 } else { end_direction(a) };
let b = if sp.segment_is_line(out) { b.p3 - b.p0 } else { start_direction(b) };
// A straight segment's chord, as `curvature_comb` uses it, when the chord has a length.
let chord = |i: usize, c: CubicBez| Some(c.p3 - c.p0).filter(|v| sp.segment_is_line(i) && v.hypot() > 0.0);
let a = chord(into, a).unwrap_or_else(|| end_direction(a));
let b = chord(out, b).unwrap_or_else(|| start_direction(b));
!turns_back(a, b)
}
_ => false,
@@ -488,6 +490,21 @@ mod tests {
}
}
/// A segment whose anchors sit on one point and whose handle is too short to count still has
/// a direction at the seam, so a reversal there keeps the comb open.
#[test]
fn the_comb_stays_open_at_a_seam_segment_with_coincident_anchors() {
let a0 = Anchor::corner(Point::ORIGIN);
let a1 = Anchor::corner(Point::new(100.0, 0.0));
let a2 = Anchor { h_out: Point::new(1e-12, 0.0), ..Anchor::corner(Point::ORIGIN) };
let sp = SubPath::new(vec![a0, a1, a2], true);
assert!(sp.segment_is_line(2));
let teeth = curvature_comb(&sp, 3, 1000.0, MAX_COMB_TEETH);
let (first, last) = (teeth.first().map(|t| t.at), teeth.last().map(|t| t.at));
assert!(first.zip(last).is_some_and(|(f, l)| f.distance(l) < 1e-9), "the teeth meet at the seam: {teeth:?}");
assert!(!comb_closes(&sp, &teeth), "the closing segment heads back against the first one");
}
/// Large finite line directions still break the comb at a reversal inside the path and at its seam.
#[test]
fn the_comb_breaks_where_large_straight_segments_turn_back() {
+1 -1
View File
@@ -265,7 +265,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"view.curvatureComb",
"Show Curvature Comb",
"",
"{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on",
"{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color that starts again where the path turns back on itself at a cusp, a straight segment included; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on",
),
(
"type.hiddenCharacters",
+1 -1
View File
@@ -266,7 +266,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"view.curvatureComb",
"Show Curvature Comb",
"",
"{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on",
"{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color that starts again where the path turns back on itself at a cusp, a straight segment included; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on",
),
(
"type.hiddenCharacters",