/** * The Curve class represents a non-uniform polynomial B-spline curve, while the * RationalCurve class represents a non-uniform rational B-spline (NURBS) curve. * * Use of this source code is governed by a BSD-style license that can be found in * the LICENSE file. */ #ifndef TINYNURBS_CURVE_H #define TINYNURBS_CURVE_H #include "glm/glm.hpp" #include #include #include namespace tinynurbs { // Forward declaration template struct RationalCurve; /** Struct for holding a polynomial B-spline curve @tparam T Data type of control points and knots (float or double) */ template struct Curve { unsigned int degree; std::vector knots; std::vector> control_points; Curve() = default; Curve(const RationalCurve &crv) : Curve(crv.degree, crv.knots, crv.control_points) {} Curve(unsigned int degree, const std::vector &knots, const std::vector> &control_points) : degree(degree), knots(knots), control_points(control_points) { } }; /** Struct for holding a rational B-spline curve @tparam T Data type of control points and knots (float or double) */ template struct RationalCurve { unsigned int degree; std::vector knots; std::vector> control_points; std::vector weights; RationalCurve() = default; RationalCurve(const Curve &crv) : RationalCurve(crv, std::vector(crv.control_points.size(), 1.0)) { } RationalCurve(const Curve &crv, const std::vector &weights) : RationalCurve(crv.degree, crv.knots, crv.control_points, weights) { } RationalCurve(unsigned int degree, const std::vector &knots, const std::vector> &control_points, const std::vector weights) : degree(degree), knots(knots), control_points(control_points), weights(weights) { } }; // Typedefs for ease of use typedef Curve Curve3f; typedef Curve Curve3d; typedef RationalCurve RationalCurve3f; typedef RationalCurve RationalCurve3d; } // namespace tinynurbs #endif // TINYNURBS_CURVE_H