11#ifndef BEMBEL_SRC_GEOMETRY_PATCH_HPP_
12#define BEMBEL_SRC_GEOMETRY_PATCH_HPP_
43 const std::vector<double> &
knots_x,
44 const std::vector<double> &
knots_y) {
63 inline void init_Patch(
const std::vector<Eigen::Matrix<double, -1, -1>> &
xyzw,
64 const std::vector<double> &
x_knots,
65 const std::vector<double> &
y_knots) {
69 unique_knots_x_ = Spl::ExtractUniqueKnotVector(
x_knots);
70 unique_knots_y_ = Spl::ExtractUniqueKnotVector(
y_knots);
71 const int xnumpatch = unique_knots_x_.size() - 1;
72 const int ynumpatch = unique_knots_y_.size() - 1;
75 data_.resize(4 * (polynomial_degree_x_ *
xnumpatch * polynomial_degree_y_ *
80 if (unique_knots_x_.size() == 2 && unique_knots_y_.size() == 2) {
81 for (
int i = 0;
i < 4;
i++) {
92 polynomial_degree_x_, polynomial_degree_y_);
94 for (
int i = 0;
i < 4;
i++) {
120 const int numy = (unique_knots_y_.size() - 1) * polynomial_degree_y_;
128 double *
xbasis =
new double[polynomial_degree_x_];
129 double *
ybasis =
new double[polynomial_degree_y_];
131 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree_x_ - 1,
133 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree_y_ - 1,
136 double tmp[4] = {0., 0., 0., 0.};
138 for (
int i = 0;
i < polynomial_degree_x_;
i++) {
139 for (
int j = 0;
j < polynomial_degree_y_;
j++) {
169 const int numy = (unique_knots_y_.size() - 1) * polynomial_degree_y_;
177 double *
xbasis =
new double[polynomial_degree_x_];
178 double *
ybasis =
new double[polynomial_degree_y_];
179 double *
xbasisD =
new double[polynomial_degree_x_];
180 double *
ybasisD =
new double[polynomial_degree_y_];
182 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree_x_ - 1,
184 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree_y_ - 1,
186 Bembel::Basis::ShapeFunctionHandler::evalDerBasis(polynomial_degree_x_ - 1,
188 Bembel::Basis::ShapeFunctionHandler::evalDerBasis(polynomial_degree_y_ - 1,
191 double tmp[4] = {0., 0., 0., 0.};
192 double tmpDx[4] = {0., 0., 0., 0.};
193 double tmpDy[4] = {0., 0., 0., 0.};
195 for (
int i = 0;
i < polynomial_degree_x_;
i++) {
196 for (
int j = 0;
j < polynomial_degree_y_;
j++) {
206 for (
int k = 0;
k < 4;
k++) {
219 Eigen::Matrix<double, 3, 2>
out;
226 for (
int k = 0;
k < 3;
k++) {
243 return jac.col(0).cross(
jac.col(1));
257 inline Eigen::Vector3d
eval(
double x,
double y)
const {
258 return eval(Eigen::Vector2d(
x,
y));
277 inline Eigen::Matrix<double, 3, 1>
evalNormal(
double x,
double y)
const {
295 const Eigen::Vector2d &
ref_pt,
double w,
296 const Eigen::Vector2d &
xi)
const {
298 Spl::FindLocationInKnotVector(
ref_pt(0), unique_knots_x_);
300 Spl::FindLocationInKnotVector(
ref_pt(1), unique_knots_y_);
301 const int numy = (unique_knots_y_.size() - 1) * polynomial_degree_y_;
310 new double[2 * (polynomial_degree_x_ + polynomial_degree_y_) + 12];
321 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree_x_ - 1,
323 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree_y_ - 1,
325 Bembel::Basis::ShapeFunctionHandler::evalDerBasis(polynomial_degree_x_ - 1,
327 Bembel::Basis::ShapeFunctionHandler::evalDerBasis(polynomial_degree_y_ - 1,
330 for (
int i = 0;
i < polynomial_degree_x_; ++
i) {
331 for (
int j = 0;
j < polynomial_degree_y_; ++
j) {
340 for (
int k = 0;
k < 4; ++
k) {
348 const double bot = 1. /
tmp[3];
351 (*srf_pt)(0) =
xi(0);
352 (*srf_pt)(1) =
xi(1);
354 (*srf_pt)(3) =
tmp[0] *
bot;
355 (*srf_pt)(4) =
tmp[1] *
bot;
356 (*srf_pt)(5) =
tmp[2] *
bot;
372 int polynomial_degree_x_;
373 int polynomial_degree_y_;
388 if (
patch.unique_knots_y_.size() == 2 &&
patch.unique_knots_x_.size() == 2) {
393 const int xchips =
patch.unique_knots_x_.size() - 1;
394 const int ychips =
patch.unique_knots_y_.size() - 1;
396 const int xp =
patch.polynomial_degree_x_;
397 const int yp =
patch.polynomial_degree_y_;
406 out[index].unique_knots_x_ = {0, 1};
407 out[index].unique_knots_y_ = {0, 1};
408 out[index].polynomial_degree_x_ =
xp;
409 out[index].polynomial_degree_y_ =
yp;
410 out[index].data_.reserve(
xp *
yp * 4);
420 for (
int k = 0;
k < 4;
k++) {
438 const std::vector<Patch> &
patches)
noexcept {
439 std::vector<Patch>
out;
Eigen::Matrix< double, 3, 1 > evalNormal(double x, double y) const
Evaluate normal vector at given point.
Eigen::Matrix< double, 3, 2 > evalJacobian(const Eigen::Vector2d &reference_point) const
Evaluate Jacobian of the parametrization at given point.
Patch(const std::vector< Eigen::Matrix< double, -1, -1 > > &control_points, const std::vector< double > &knots_x, const std::vector< double > &knots_y)
Constructor of a Patch.
Eigen::Matrix< double, 3, 2 > evalJacobian(double x, double y) const
Evaluate Jacobian of the parametrization at given point.
void init_Patch(const std::vector< Eigen::Matrix< double, -1, -1 > > &xyzw, const std::vector< double > &x_knots, const std::vector< double > &y_knots)
init
Eigen::Matrix< double, 3, 1 > evalNormal(const Eigen::Vector2d &reference_point) const
Evaluate normal vector at given point.
Eigen::Vector3d eval(double x, double y) const
Evaluate patch at given point.
Eigen::Vector3d eval(const Eigen::Vector2d &reference_point) const
Evaluate patch at given point.
std::vector< double > data_
getter
void updateSurfacePoint(SurfacePoint *srf_pt, const Eigen::Vector2d &ref_pt, double w, const Eigen::Vector2d &xi) const
Updates the surface point and returns the physical point and the derivatives there.
Eigen::Matrix< double, 12, 1 > SurfacePoint
typedef of SurfacePoint
Eigen::SparseMatrix< T > MakeProjection(const std::vector< T > &x_knots, const std::vector< T > &y_knots, const std::vector< T > &x_unique_knots, const std::vector< T > &y_unique_knots, const int polynomial_degree_x, const int polynomial_degree_y) noexcept
implements Bezier extraction via the solution of an interpolation problem.
Eigen::Matrix< T, -1, 1 > Unroll(const Eigen::Matrix< T, -1, -1 > &input_matrix) noexcept
Tiny helper functions.
Routines for the evalutation of pointwise errors.
constexpr int getFunctionSpaceOutputDimension()
std::vector< Patch > PatchShredder(const Patch &patch) noexcept
This function cuts a patch along internal knots, if any.