From 2be8ed9892e897f8fe0bc3cb284ac98b1be31916 Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Mon, 16 Aug 2021 21:50:20 +0500 Subject: [PATCH] Fix in refine_curve --- utils/curve/nurbs_algorithms.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/curve/nurbs_algorithms.py b/utils/curve/nurbs_algorithms.py index 8086b2c05a..c3ebbd76ed 100644 --- a/utils/curve/nurbs_algorithms.py +++ b/utils/curve/nurbs_algorithms.py @@ -414,16 +414,16 @@ def remove_excessive_knots(curve, tolerance=1e-6): def refine_curve(curve, samples, algorithm=REFINE_DISTRIBUTE, refine_max=False, solver=None): if refine_max: degree = curve.get_degree() - count = degree + inserts_count = degree else: - count = 1 + inserts_count = 1 if algorithm == REFINE_TRIVIAL: t_min, t_max = curve.get_u_bounds() ts = np.linspace(t_min, t_max, num=samples+1, endpoint=False)[1:] for t in ts: try: - curve = curve.insert_knot(t, count=count) + curve = curve.insert_knot(t, count=inserts_count) except CantInsertKnotException: break @@ -433,13 +433,14 @@ def refine_curve(curve, samples, algorithm=REFINE_DISTRIBUTE, refine_max=False, length_params = solver.calc_length_params(existing_knots) sizes = length_params[1:] - length_params[:-1] + #print(f"K: {existing_knots} => Ls {length_params} => Sz {sizes}") counts = distribute_int(samples, sizes) for l1, l2, count in zip(length_params[1:], length_params[:-1], counts): ls = np.linspace(l1, l2, num=count+2, endpoint=True)[1:-1] ts = solver.solve(ls) for t in ts: try: - curve = curve.insert_knot(t, count=count, if_possible=True) + curve = curve.insert_knot(t, count=inserts_count, if_possible=True) except CantInsertKnotException: continue else: @@ -450,7 +451,7 @@ def refine_curve(curve, samples, algorithm=REFINE_DISTRIBUTE, refine_max=False, ts = np.linspace(t1, t2, num=count+2, endpoint=True)[1:-1] for t in ts: try: - curve = curve.insert_knot(t, count=count, if_possible=True) + curve = curve.insert_knot(t, count=inserts_count, if_possible=True) except CantInsertKnotException: continue