forked from 1b-agent/opencadstudio-upstream
fix(spline): edit fit-point splines, and stop deleting the kept half
Two faults, reported together. Fit-point splines could not be edited at all. A SPLINE is stored either as a control polygon the curve approaches or as fit points it must pass through with optional end tangents, and `spline_to_nurbs` only read the first. A fit-point spline has no control points, so every command that touched one — TRIM, BREAK, LENGTHEN, OFFSET — got nothing back and did nothing. Two fit points with start and end tangents, which is what a drawing stores for the simplest curve, was the clearest case. Fit points now interpolate into an exact curve through cadkernel, so they are as editable as any other spline. Trimming deleted the whole spline when the surviving piece reached the curve's own start. `trim_spline` cut away everything before the interval and everything after it, and a cut at either end is a no-op that reports nothing to do — which the end case handled and the start case propagated as failure, dropping the piece. That is why one side of the cutting line worked and the other emptied the drawing. Elevation is read from whichever point list the spline actually has. A fit-point spline has no control points, so it was falling to z = 0 on the first edit. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
0f8f4864ba
commit
042a479244
3 files changed
+59
-17
No files matched your search
@@ -985,8 +985,13 @@ fn trim_spline(spl: &SplineEnt, ts: &[f64], t_click: f64) -> Vec<EntityType> {
|
||||
return None;
|
||||
}
|
||||
// Cut away everything before the interval, then everything after
|
||||
// it, leaving [t_lo, t_hi].
|
||||
let (_, after_low) = spline_cut(spl, t_lo)?;
|
||||
// it, leaving [t_lo, t_hi]. Either cut is a no-op when the
|
||||
// interval already reaches that end of the curve — dropping the
|
||||
// piece there would delete the half the user meant to keep.
|
||||
let after_low = match spline_cut(spl, t_lo) {
|
||||
Some((_, right)) => right,
|
||||
None => spl.clone(),
|
||||
};
|
||||
let kept = match spline_cut(&after_low, t_hi) {
|
||||
Some((middle, _)) => middle,
|
||||
// The interval reaches the far end, so nothing is left to cut.
|
||||
|
||||
Reference in new issue
Block a user