Skip to content

Commit

Permalink
Fix in refine_curve
Browse files Browse the repository at this point in the history
  • Loading branch information
portnov committed Aug 16, 2021
1 parent d38acae commit 2be8ed9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions utils/curve/nurbs_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit 2be8ed9

Please sign in to comment.