Skip to content

Commit

Permalink
use numpy in BSpline.flattening()
Browse files Browse the repository at this point in the history
  • Loading branch information
mozman committed Jan 12, 2025
1 parent fe28476 commit a8f747c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/ezdxf/math/bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,23 +1083,16 @@ def subdiv(s: Vec3, e: Vec3, start_t: float, end_t: float):
yield from subdiv(m, e, mid_t, end_t)

evaluator = self.evaluator
knots: list[float] = self.knots() # type: ignore
if self.is_clamped:
lower_bound = 0.0
else:
lower_bound = knots[self.order - 1]
knots = knots[: self.count + 1]

knots = list(set(knots))
knots.sort()
t = lower_bound
knots = np.unique(np.array(self.knots()))
seg_f64 = np.float64(segments)
t = knots[0]
start_point = evaluator.point(t)
yield start_point
for t1 in knots[1:]:
delta = (t1 - t) / segments
delta = (t1 - t) / seg_f64
while t < t1:
next_t = t + delta
if math.isclose(next_t, t1):
if np.isclose(next_t, t1):
next_t = t1
end_point = evaluator.point(next_t)
yield from subdiv(start_point, end_point, t, next_t)
Expand Down

0 comments on commit a8f747c

Please sign in to comment.