WARPXM v1.10.0
Loading...
Searching...
No Matches
BsplineEvaluator2D.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "warpxm/warpxm_config.h"
6#include "lib/spline/spline.h"
8
16{
17private:
18 std::vector<real> _tx, _ty;
19 int _nx, _ny;
20 std::vector<real> _c;
21 int _kx, _ky;
22 std::vector<real> _lx, _ly;
23 std::vector<real> _hx, _hy;
24 std::vector<std::vector<real>> _wx, _wy;
25 int _mx, _my;
27public:
28 BsplineEvaluator2D(const std::string& filename)
29 {
30 std::string file = WmUDGFunctions::readFile(filename);
31
32 _tx = WmUDGFunctions::parseStringForVector<real>(file, "knotX");
33 _ty = WmUDGFunctions::parseStringForVector<real>(file, "knotY");
34 _c = WmUDGFunctions::parseStringForVector<real>(file, "coefs");
35 _kx = WmUDGFunctions::parseStringForValue<int>(file, "degreeX");
36 _ky = WmUDGFunctions::parseStringForValue<int>(file, "degreeY");
37 _nx = _tx.size();
38 _ny = _ty.size();
39 _hx.resize(_kx+1);
40 _hy.resize(_ky+1);
41
42 // Default is set to having only one evaluated point
43 _lx.resize(1);
44 _ly.resize(1);
45 _wx.resize(1);
46 _wx[0].resize(_kx+1);
47 _wy.resize(1);
48 _wy[0].resize(_ky+1);
49 _mx = 1;
50 _my = 1;
51 }
52
61 void eval_spline_2d(const std::vector<real>& x,
62 const std::vector<real>& y,
63 std::vector<std::vector<real>>& spline_value)
64 {
65 if (x.size() != _mx)
66 {
67 throw WxExcept("Not allowed to have more than one evaluated point.");
68 }
69 if (y.size() != _my)
70 {
71 throw WxExcept("Not allowed to have more than one evaluated point.");
72 }
73
74 wxm::spline::eval_spline2d(_tx, _ty, _nx, _ny, _c, _kx, _ky,
75 _lx, _ly, _hx, _hy, _wx, _wy,
76 _mx, _my, x, y, spline_value);
77 }
78
79}; // class SplineEvaluator
The elements needed to evaluate the 2D B-spline.
Definition: BsplineEvaluator2D.h:16
BsplineEvaluator2D(const std::string &filename)
Definition: BsplineEvaluator2D.h:28
void eval_spline_2d(const std::vector< real > &x, const std::vector< real > &y, std::vector< std::vector< real > > &spline_value)
Evaluate 2D B-spline values at (x, y), given the knot vectors and coefficients stored in the class Bs...
Definition: BsplineEvaluator2D.h:61
std::string readFile(const std::string &filename)
Definition: wmudgfunctions.h:174
void eval_spline2d(const std::vector< real > &tx, const std::vector< real > &ty, const int nx, const int ny, const std::vector< real > &c, const int kx, const int ky, std::vector< real > &lx, std::vector< real > &ly, std::vector< real > &hx, std::vector< real > &hy, std::vector< std::vector< real > > &wx, std::vector< std::vector< real > > &wy, const int mx, const int my, const std::vector< real > &x, const std::vector< real > &y, std::vector< std::vector< real > > &SplineValue2D)
Evaluate 2D B-spline values at (x, y), given the knots vector and coefficients.
wxm::lib::Except WxExcept
Definition: wxexcept.h:120