NurbsSurface.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef MERCURYDPM_NURBSSURFACE_H
6 #define MERCURYDPM_NURBSSURFACE_H
7 
8 #include <vector>
9 #include <array>
10 #include "Math/Vector.h"
11 
13 {
14 public:
18  NurbsSurface();
19 
27  NurbsSurface(const std::vector<double>& knotsU, const std::vector<double>& knotsV,
28  const std::vector<std::vector<Vec3D>>& controlPoints,
29  const std::vector<std::vector<double>>& weights);
30 
42  NurbsSurface(const std::vector<std::vector<Vec3D>>& controlPoints,
43  const std::vector<std::vector<Mdouble>>& weights,
44  unsigned int degreeU, unsigned int degreeV,
45  bool clampedAtStartU = true, bool clampedAtEndU = true,
46  bool clampedAtStartV = true, bool clampedAtEndV = true);
47 
54  Vec3D evaluate(double u, double v) const;
55 
56  void evaluateDerivatives(double u, double v, std::array<std::array<Vec3D,3>,3>& S) const;
57 
61  bool getDistance(Vec3D P, double radius, double& distance, Vec3D& normal) const;
62 
70  void set(const std::vector<double>& knotsU, const std::vector<double>& knotsV,
71  const std::vector<std::vector<Vec3D>>& controlPoints, const std::vector<std::vector<double>>& weights);
72 
73  void setClosedInU(bool closedInU);
74 
75  void setClosedInV(bool closedInV);
76 
77  void flipOrientation();
78 
79  void closestPoint(Vec3D position, double& u, double& v) const;
80 
81  void splitSurface (int spanU, int spanV) {
82 
83  }
84 
88  friend std::ostream& operator<<(std::ostream& os, const NurbsSurface& a);
89 
93  friend std::istream& operator>>(std::istream& is, NurbsSurface& a);
94 
98  double getLowerBoundU() const{
99  return knotsU_[degreeU_];
100  }
104  double getUpperBoundU() const{
105  return knotsU_[knotsU_.size() - degreeU_ - 1]; // same as knotsU_[controlPoints.size()];
106  }
110  double getLowerBoundV() const{
111  return knotsV_[degreeV_];
112  }
116  double getUpperBoundV() const{
117  return knotsV_[knotsV_.size() - degreeV_ - 1]; // same as knotsV_[controlPoints[0].size()];
118  }
119 
120  const std::vector<std::vector<Vec3D>>& getControlPoints() const
121  { return controlPoints_; }
122 
123  const std::vector<std::vector<Mdouble>>& getWeights() const
124  { return weights_; }
125 
126  const std::vector<Mdouble>& getKnotsU() const
127  { return knotsU_; }
128 
129  const std::vector<Mdouble>& getKnotsV() const
130  { return knotsV_; }
131 
140 
149 
156  void makeClosedInU();
157 
164  void makeClosedInV();
165 
171  void unclampKnots(bool inU, bool atStart);
172 
173  void moveControlPoint(unsigned int indexU, unsigned int indexV, Vec3D dP, bool includingClosedOrPeriodic);
174 
175 private:
177  std::vector<Mdouble> knotsU_;
179  std::vector<Mdouble> knotsV_;
181  std::vector<std::vector<Vec3D>> controlPoints_;
183  std::vector<std::vector<Mdouble>> weights_;
185  unsigned int degreeU_, degreeV_;
188  // For when using periodic boundaries and the surface is extended to make it continuous
190 
191  // Storing starting points for a quick start of the getDistance method
192  std::vector<Vec3D> startingPoints_;
193  std::vector<Mdouble> startingKnotsU_;
194  std::vector<Mdouble> startingKnotsV_;
195 
203  void wrapAroundInU(unsigned int numStartToEnd, unsigned int numEndToStart, bool forceBothEndsUniform = false);
204 
212  void wrapAroundInV(unsigned int numStartToEnd, unsigned int numEndToStart, bool forceBothEndsUniform = false);
213 };
214 
215 #endif //MERCURYDPM_NURBSSURFACE_H
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Definition: NurbsSurface.h:13
std::vector< Mdouble > startingKnotsU_
Definition: NurbsSurface.h:193
void makeClosedInU()
This will make the surface close around on itself and ensure continuity.
Definition: NurbsSurface.cc:450
Vec3D evaluate(double u, double v) const
Definition: NurbsSurface.cc:149
void closestPoint(Vec3D position, double &u, double &v) const
bool getDistance(Vec3D P, double radius, double &distance, Vec3D &normal) const
Definition: NurbsSurface.cc:177
unsigned int degreeU_
degree pu = mu-nu-1, pv = mv-nv-1
Definition: NurbsSurface.h:185
void setClosedInU(bool closedInU)
Definition: NurbsSurface.cc:121
void makeClosedInV()
This will make the surface close around on itself and ensure continuity.
Definition: NurbsSurface.cc:457
void setClosedInV(bool closedInV)
Definition: NurbsSurface.cc:125
unsigned int degreeV_
Definition: NurbsSurface.h:185
void makePeriodicContinuousInV()
This will make the surface repeat itself and ensure continuity over periodic boundaries.
Definition: NurbsSurface.cc:443
void wrapAroundInU(unsigned int numStartToEnd, unsigned int numEndToStart, bool forceBothEndsUniform=false)
Copies control points from the start and adds to the end and vice versa. The first and last control p...
Definition: NurbsSurface.cc:464
void splitSurface(int spanU, int spanV)
Definition: NurbsSurface.h:81
void evaluateDerivatives(double u, double v, std::array< std::array< Vec3D, 3 >, 3 > &S) const
Definition: NurbsSurface.cc:308
bool periodicInV_
Definition: NurbsSurface.h:189
const std::vector< std::vector< Vec3D > > & getControlPoints() const
Definition: NurbsSurface.h:120
bool closedInU_
make it a periodic system
Definition: NurbsSurface.h:187
std::vector< std::vector< Vec3D > > controlPoints_
nu x nv control points
Definition: NurbsSurface.h:181
const std::vector< std::vector< Mdouble > > & getWeights() const
Definition: NurbsSurface.h:123
void set(const std::vector< double > &knotsU, const std::vector< double > &knotsV, const std::vector< std::vector< Vec3D >> &controlPoints, const std::vector< std::vector< double >> &weights)
Definition: NurbsSurface.cc:39
void unclampKnots(bool inU, bool atStart)
Unclamps the knot vector by changing the control points, weights and knots.
Definition: NurbsSurface.cc:557
std::vector< Vec3D > startingPoints_
Definition: NurbsSurface.h:192
double getLowerBoundV() const
Definition: NurbsSurface.h:110
void makePeriodicContinuousInU()
This will make the surface repeat itself and ensure continuity over periodic boundaries.
Definition: NurbsSurface.cc:436
NurbsSurface()
Definition: NurbsSurface.cc:13
bool periodicInU_
Definition: NurbsSurface.h:189
void flipOrientation()
Definition: NurbsSurface.cc:129
void wrapAroundInV(unsigned int numStartToEnd, unsigned int numEndToStart, bool forceBothEndsUniform=false)
Copies control points from the start and adds to the end and vice versa. The first and last control p...
Definition: NurbsSurface.cc:517
std::vector< Mdouble > knotsU_
mu knots
Definition: NurbsSurface.h:177
friend std::istream & operator>>(std::istream &is, NurbsSurface &a)
Adds elements to an input stream.
Definition: NurbsSurface.cc:381
double getUpperBoundU() const
Definition: NurbsSurface.h:104
bool closedInV_
Definition: NurbsSurface.h:187
const std::vector< Mdouble > & getKnotsU() const
Definition: NurbsSurface.h:126
std::vector< Mdouble > knotsV_
mv knots
Definition: NurbsSurface.h:179
void moveControlPoint(unsigned int indexU, unsigned int indexV, Vec3D dP, bool includingClosedOrPeriodic)
Definition: NurbsSurface.cc:637
friend std::ostream & operator<<(std::ostream &os, const NurbsSurface &a)
Adds elements to an output stream.
Definition: NurbsSurface.cc:355
const std::vector< Mdouble > & getKnotsV() const
Definition: NurbsSurface.h:129
double getLowerBoundU() const
Definition: NurbsSurface.h:98
double getUpperBoundV() const
Definition: NurbsSurface.h:116
std::vector< Mdouble > startingKnotsV_
Definition: NurbsSurface.h:194
std::vector< std::vector< Mdouble > > weights_
nu x nv weights
Definition: NurbsSurface.h:183
Definition: Kernel/Math/Vector.h:30
const Scalar * a
Definition: level2_cplx_impl.h:32
std::array< T, N > array
Definition: EmulateArray.h:231
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77
radius
Definition: UniformPSDSelfTest.py:15
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
list weights
Definition: calibrate.py:94
@ S
Definition: quadtree.h:62