23 const unsigned int cps_per_half,
25 const std::string & caller_name)
27 _start_point(start_point),
28 _end_point(end_point),
29 _start_dir(start_direction),
30 _end_dir(end_direction),
31 _cps_per_half(cps_per_half),
32 _sharpness(sharpness),
33 _caller_name(caller_name),
34 _control_points(createControlPoints()),
35 _knot_vector(buildKnotVector())
42 mooseAssert((t >= 0) && (t <= 1),
"t should be in [0, 1]. t=" + std::to_string(t));
52std::vector<libMesh::Point>
55 std::vector<libMesh::Point> cps;
62std::vector<libMesh::Real>
65 std::vector<libMesh::Real> knot_vector(
_degree, 0);
70 ": Number of control points must be greater than or equal to degree + 1!");
72 for (
const auto i : make_range(num_points_left))
74 knot_vector.push_back(i);
76 "i must be less than the number of control points because of 0 indexing.");
82 for (
const auto i : make_range(
_degree))
85 knot_vector.push_back(num_points_left - 1);
91 for (
auto & value : knot_vector)
93 value /= (num_points_left - 1);
94 mooseAssert(value <= 1.0 && value >= 0.0,
95 "knot_vector must be normalized to 1 with minimum value 0.");
104 mooseAssert(i + 1 <
_knot_vector.size(),
"Out of bounds access in knot vector");
106 "Knot vector is ill-formatted. Ensure values are increasing." +
118 mooseAssert(i + j <
_knot_vector.size(),
"Out of bounds access in knot vector");
122 return (t - ti) / (tij - ti);
130 mooseAssert(i + j + 1 <
_knot_vector.size(),
"Out of bounds access in knot vector");
134 return (tij1 - t) / (tij1 - ti1);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
const unsigned int _degree
The polynomial degree of the B-Spline.
libMesh::Real CdBBasis(const libMesh::Real t, const unsigned int i, const unsigned int j) const
Evaluates the the basis function for a B-Spline according to the Cox-de-Boor recursive formula.
libMesh::Point getPoint(const libMesh::Real t) const
Evaluate the BSpline interpolation at given value of t.
const std::vector< libMesh::Real > _knot_vector
The knot vector.
const libMesh::Real _sharpness
sharpness of the curve
libMesh::Real secondCoeff(const libMesh::Real t, const unsigned int i, const unsigned int j) const
Submethod used in CdBBasis routine.
const std::vector< libMesh::Point > _control_points
The control points.
const libMesh::Point _start_point
starting point of spline
BSpline(const unsigned int degree, const libMesh::Point &start_point, const libMesh::Point &end_point, const libMesh::RealVectorValue &start_direction, const libMesh::RealVectorValue &end_direction, const unsigned int cps_per_half, const libMesh::Real sharpness, const std::string &caller_name)
const std::string _caller_name
Name of the object working with this class, used for error reporting.
const libMesh::Point _end_point
ending point of spline
libMesh::Real firstCoeff(const libMesh::Real t, const unsigned int i, const unsigned int j) const
Submethod used in CdBBasis routine.
const libMesh::RealVectorValue _end_dir
ending direction of spline
std::vector< libMesh::Real > buildKnotVector() const
Internal method for building the knot vector given the degree and control points.
const unsigned int _cps_per_half
number of control points per half of the spline (vertex is auto-included)
const libMesh::RealVectorValue _start_dir
starting direction of spline
std::vector< libMesh::Point > createControlPoints() const
Creates a vector control points from the SplineUtils set of functions.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
std::string stringify(const T &t)
conversion to string
std::vector< Point > bSplineControlPoints(const libMesh::Point &start_point, const libMesh::Point &end_point, const libMesh::RealVectorValue &start_direction, const libMesh::RealVectorValue &end_direction, const unsigned int cps_per_half, const libMesh::Real sharpness, const std::string &caller_name)
Creates control points for an open uniform BSpline.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real