Skip to content

Commit

Permalink
Fix #4735 by falling back to native implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
portnov committed Nov 3, 2022
1 parent 1f9f99b commit ea6582e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions utils/curve/freecad.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from sverchok.utils.nurbs_common import SvNurbsMaths
from sverchok.utils.curve.core import SvCurve, UnsupportedCurveTypeException
from sverchok.utils.curve.nurbs import SvNurbsCurve
from sverchok.utils.curve.nurbs_solver_applications import interpolate_nurbs_curve
from sverchok.utils.curve import knotvector as sv_knotvector
from sverchok.utils.curve.primitives import SvLine, SvCircle
from sverchok.utils.curve.biarc import SvBiArc
Expand Down Expand Up @@ -257,6 +258,11 @@ def build_2d(cls, degree, knotvector, control_points, weights=None):
curve.buildFromPolesMultsKnots(pts, mults, knots, False, degree, weights)
return SvFreeCadNurbsCurve(curve, ndim=2)

@classmethod
def interpolate(cls, degree, points, metric='DISTANCE', tknots=None, cyclic=False, logger=None, **kwargs):
curve = interpolate_nurbs_curve(degree, points, metric=metric, tknots=tknots, cyclic=cyclic, logger=logger)
return curve.copy(implementation = SvNurbsMaths.FREECAD)

def to_2d(self):
return SvFreeCadNurbsCurve.build_2d(self.get_degree(), self.get_knotvector(),
self.get_control_points(), self.get_weights())
Expand Down
2 changes: 2 additions & 0 deletions utils/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def create_knots(cls, pts, metric="DISTANCE"):
tknots = tknots - tknots[0]
if tknots[-1] != 0:
tknots = tknots / tknots[-1]
else:
raise Exception(f"Unsupported metric: {metric}")

return tknots

Expand Down
3 changes: 1 addition & 2 deletions utils/surface/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,6 @@ def simple_loft(curves, degree_v = None, knots_u = 'UNIFY', knotvector_accuracy=
raise Exception(f"Unsupported knots_u option: {knots_u}")
if logger is None:
logger = getLogger()
curve_class = type(curves[0])
curves = unify_curves_degree(curves)
if knots_u == 'UNIFY':
curves = unify_curves(curves, accuracy=knotvector_accuracy)
Expand Down Expand Up @@ -1198,7 +1197,7 @@ def simple_loft(curves, degree_v = None, knots_u = 'UNIFY', knotvector_accuracy=
src_points = np.array(src_points)
src_points = np.transpose(src_points, axes=(1,0,2))

v_curves = [SvNurbsMaths.interpolate_curve(curve_class, degree_v, points, metric=metric, tknots=tknots, logger=logger) for points in src_points]
v_curves = [SvNurbsMaths.interpolate_curve(implementation, degree_v, points, metric=metric, tknots=tknots, logger=logger) for points in src_points]
control_points = [curve.get_homogenous_control_points() for curve in v_curves]
control_points = np.array(control_points)
#weights = [curve.get_weights() for curve in v_curves]
Expand Down

0 comments on commit ea6582e

Please sign in to comment.