Medusa  1.1
Coordinate Free Mehless Method implementation
NURBSPatch_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_DOMAINS_NURBSPATCH_FWD_HPP_
2 #define MEDUSA_BITS_DOMAINS_NURBSPATCH_FWD_HPP_
3 
11 #include <medusa/Config.hpp>
15 #include <memory>
16 
17 namespace mm {
18 
22 namespace nurbs_patch_internal {
33 template <typename vec_t, typename param_vec_t>
34 struct NURBSPatchHelper {};
35 
41 template<size_t dim, typename T>
42 struct NestedRange{
44  typedef Range<typename NestedRange<dim - 1, T>::type> type;
45 };
46 
48 template<typename T>
49 struct NestedRange<0, T>{
50  typedef T type;
51 };
53 } // namespace nurbs_patch_internal
54 
71 template <typename vec_t, typename param_vec_t>
72 class NURBSPatch {
73  friend struct nurbs_patch_internal::NURBSPatchHelper<vec_t, param_vec_t>;
74 
75  public:
76  typedef typename vec_t::scalar_t scalar_t;
82 
83  template <typename T>
86 
87  private:
88  std::array<int, param_dim> p;
90  std::array<Range<scalar_t>, param_dim> knots;
91 
93  std::unique_ptr<std::array<NURBSPatch<vec_t, param_vec_t>, param_dim>> der_structure;
94 
95  public:
103  NURBSPatch(const NdRange<proj_vec_t>& wcp,
104  const std::array<Range<scalar_t>, param_dim>& ks,
105  const std::array<int, param_dim>& in_p);
106 
114  NURBSPatch(const NdRange<vec_t>& cp, const NdRange<double>& w,
115  const std::array<Range<scalar_t>, param_dim>& ks,
116  const std::array<int, param_dim>& in_p);
117 
119  NURBSPatch(const NURBSPatch<vec_t, param_vec_t>& patch) noexcept;
120 
123 
125  NURBSPatch(NURBSPatch<vec_t, param_vec_t>&&) noexcept = default;
127  NURBSPatch<vec_t, param_vec_t>& operator=(NURBSPatch<vec_t, param_vec_t>&&) noexcept = default;
128 
131 
138  vec_t evaluate(const param_vec_t& t, scalar_t* w) const;
139 
145  vec_t evaluate(const param_vec_t& t) const;
146 
152  proj_vec_t evaluateWeighted(const param_vec_t& t) const;
153 
163  Eigen::Matrix<scalar_t, dim, param_dim> jacobian(const param_vec_t& t, const vec_t& pt,
164  const scalar_t& w) const;
165 
174  Eigen::Matrix<scalar_t, dim, param_dim> jacobian(const param_vec_t& t) const;
175 
181  std::pair<vec_t, Eigen::Matrix<scalar_t, dim, param_dim>> evaluatePointAndJacobian(
182  const param_vec_t& t) const;
183 
188  BoxShape<param_vec_t> getDomain() const;
189 
194  Range<NURBSPatch<vec_t, Vec<scalar_t, param_dim - 1>>> getBoundaries() const;
195 
207  param_vec_t getPatchParameterFromBoundaryParameter(const Vec<scalar_t, param_dim - 1>& t, int i,
208  scalar_t epsilon = 0) const;
209 
220  int i) const;
221 };
222 
223 } // namespace mm
224 
225 #endif // MEDUSA_BITS_DOMAINS_NURBSPATCH_FWD_HPP_
mm::NURBSPatch::getPatchParameterFromBoundaryParameter
param_vec_t getPatchParameterFromBoundaryParameter(const Vec< scalar_t, param_dim - 1 > &t, int i, scalar_t epsilon=0) const
Get vector from the parametric domain of the NURBS patch from the parameter of the NURBS patch repres...
Definition: NURBSPatch.hpp:140
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
scalar_t
Scalar scalar_t
Type of the elements, alias of Scalar.
Definition: MatrixBaseAddons.hpp:16
mm::Vec
Eigen::Matrix< scalar_t, dim, 1, Eigen::ColMajor|Eigen::AutoAlign, dim, 1 > Vec
Fixed size vector type, representing a mathematical 1d/2d/3d vector.
Definition: Vec_fwd.hpp:31
mm::NURBSPatch::evaluateWeighted
proj_vec_t evaluateWeighted(const param_vec_t &t) const
Evaluate NURBS patch in one point.
Definition: NURBSPatch.hpp:88
mm::NURBSPatch::NURBSPatch
NURBSPatch(const NdRange< proj_vec_t > &wcp, const std::array< Range< scalar_t >, param_dim > &ks, const std::array< int, param_dim > &in_p)
Construct NURBS patch with weighted control points.
Definition: NURBSPatch.hpp:17
mm::NURBSPatch::evaluate
vec_t evaluate(const param_vec_t &t, scalar_t *w) const
Evaluate NURBS patch in one point along the second dimension.
Definition: NURBSPatch.hpp:69
mm::NURBSPatch::jacobian
Eigen::Matrix< scalar_t, dim, param_dim > jacobian(const param_vec_t &t, const vec_t &pt, const scalar_t &w) const
Evaluate NURBS jacobian matrix in one point.
Definition: NURBSPatch.hpp:95
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
mm::nurbs_patch_internal::NURBSPatchHelper
Internal structure of NURBSPatch that helps with partial class specialization.
Definition: NURBSPatch_fwd.hpp:34
mm::nurbs_patch_internal::NestedRange::type
Range< typename NestedRange< dim - 1, T >::type > type
Type of the multidimensional Range.
Definition: NURBSPatch_fwd.hpp:44
mm::NURBSPatch::param_dim
@ param_dim
Dimensionality of parametric space.
Definition: NURBSPatch_fwd.hpp:80
mm::NURBSPatch::getBoundaryParameterFromPatchParameter
Vec< scalar_t, param_dim - 1 > getBoundaryParameterFromPatchParameter(const param_vec_t &t, int i) const
Get parameter from the parametric domain of the NURBS patch representing the boundary of the NURBS pa...
Definition: NURBSPatch.hpp:149
mm::NURBSPatch::p
std::array< int, param_dim > p
Underlying B-spline orders.
Definition: NURBSPatch_fwd.hpp:88
mm::NURBSPatch
Class representing a single NURBS patch in an arbitrary dimensional space, defined on an arbitrary di...
Definition: NURBSPatch_fwd.hpp:72
mm::NURBSPatch::scalar_t
vec_t::scalar_t scalar_t
Scalar type.
Definition: NURBSPatch_fwd.hpp:76
Config.hpp
mm::NURBSPatch::computeDerivativeStructure
void computeDerivativeStructure()
Calculate data needed for derivative evaluation.
Definition: NURBSPatch.hpp:64
mm::NURBSPatch::proj_dim
@ proj_dim
Dimensionality of space before projection.
Definition: NURBSPatch_fwd.hpp:79
mm::NURBSPatch::getBoundaries
Range< NURBSPatch< vec_t, Vec< scalar_t, param_dim - 1 > > > getBoundaries() const
Get all boundaries of the NURBS patch as a Range of NURBS patches.
Definition: NURBSPatch.hpp:135
mm::NURBSPatch::getDomain
BoxShape< param_vec_t > getDomain() const
Get domain of the NURBS patch.
Definition: NURBSPatch.hpp:122
mm::NURBSPatch::knots
std::array< Range< scalar_t >, param_dim > knots
Array of Ranges of knots (knot vector).
Definition: NURBSPatch_fwd.hpp:90
mm::NURBSPatch::der_structure
std::unique_ptr< std::array< NURBSPatch< vec_t, param_vec_t >, param_dim > > der_structure
NURBS surfaces needed for derivative calculation.
Definition: NURBSPatch_fwd.hpp:93
mm::BoxShape
Class for working with box shaped domains.
Definition: BoxShape_fwd.hpp:28
mm::NURBSPatch::evaluatePointAndJacobian
std::pair< vec_t, Eigen::Matrix< scalar_t, dim, param_dim > > evaluatePointAndJacobian(const param_vec_t &t) const
Evaluate NURBS and its jacobian matrix in one parameter.
Definition: NURBSPatch.hpp:114
mm::NURBSPatch::operator=
NURBSPatch< vec_t, param_vec_t > & operator=(const NURBSPatch< vec_t, param_vec_t > &) noexcept
Copy assignment.
Definition: NURBSPatch.hpp:47
mm::nurbs_patch_internal::NestedRange
Struct for declaring a nested Range.
Definition: NURBSPatch_fwd.hpp:42
mm::NURBSPatch::weighted_control_points
NdRange< proj_vec_t > weighted_control_points
Multidimensional Range of control points.
Definition: NURBSPatch_fwd.hpp:89
Vec.hpp
mm::NURBSPatch::dim
@ dim
Dimensionality of space after projection.
Definition: NURBSPatch_fwd.hpp:78
mm::NURBSPatch::proj_vec_t
Vec< scalar_t, proj_dim > proj_vec_t
Vector type before projection.
Definition: NURBSPatch_fwd.hpp:81
mm::NURBSPatch::NdRange
typename nurbs_patch_internal::NestedRange< param_dim, T >::type NdRange
Range of param_dim dimensions.
Definition: NURBSPatch_fwd.hpp:85
Matrix
Matrix(const Scalar &s)
Construct matrix from scalar. Enabled only for fixed size matrices.
Definition: MatrixAddons.hpp:21
mm::Range
An extension of std::vector<T> to support additional useful operations.
Definition: Range_fwd.hpp:30
BoxShape.hpp
Range.hpp