From ad175dc04e03416a27d11b597f0e9a9eaa1282af Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Tue, 30 Aug 2022 23:23:35 +0500 Subject: [PATCH] 1) call cut_segment from curve_segment; 2) fix u_bounds for FreeCAD curves. refs #4469. --- utils/curve/algorithms.py | 4 +++- utils/curve/freecad.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/curve/algorithms.py b/utils/curve/algorithms.py index ba9fc3f6a2..d245136333 100644 --- a/utils/curve/algorithms.py +++ b/utils/curve/algorithms.py @@ -988,7 +988,9 @@ def split_curve(curve, splits, rescale=False): def curve_segment(curve, new_t_min, new_t_max, rescale=False): t_min, t_max = curve.get_u_bounds() - if hasattr(curve, 'split_at') and (new_t_min > t_min or new_t_max < t_max): + if hasattr(curve, 'cut_segment'): + return curve.cut_segment(new_t_min, new_t_max, rescale=rescale) + elif hasattr(curve, 'split_at') and (new_t_min > t_min or new_t_max < t_max): if new_t_min > t_min: start, curve = curve.split_at(new_t_min) if new_t_max < t_max: diff --git a/utils/curve/freecad.py b/utils/curve/freecad.py index 02a699db96..17f0d4dfbb 100644 --- a/utils/curve/freecad.py +++ b/utils/curve/freecad.py @@ -338,7 +338,7 @@ def derivatives_array(self, n, ts, tangent_delta=None): def get_u_bounds(self): if self.u_bounds is None: - return (self.curve.FirstParameter, self.curve.LastParameter) + return (self.curve.KnotSequence[0], self.curve.KnotSequence[-1]) else: return self.u_bounds