MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NurbsSurface.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef MERCURY_NURBSSURFACE_H
27 #define MERCURY_NURBSSURFACE_H
28 
29 #include <vector>
30 #include <array>
31 #include "Math/Vector.h"
32 
34 {
35 public:
39  NurbsSurface();
40 
49  NurbsSurface(const std::vector<double>& knotsU, const std::vector<double>& knotsV,
50  const std::vector<std::vector<Vec3D>>& controlPoints,
51  const std::vector<std::vector<double>>& weights);
52 
64  Vec3D evaluate(double u, double v) const;
65 
66  void evaluateDerivatives(double u, double v, std::array<std::array<Vec3D,3>,3>& S) const;
67 
71  bool getDistance(Vec3D P, double radius, double& distance, Vec3D& normal) const;
72 
81  void set(const std::vector<double>& knotsU, const std::vector<double>& knotsV,
82  const std::vector<std::vector<Vec3D>>& controlPoints, const std::vector<std::vector<double>>& weights);
83 
84  void setClosedInU(bool closedInU);
85 
86  void setClosedInV(bool closedInV);
87 
88  void flipOrientation();
89 
90  void closestPoint(Vec3D position, double& u, double& v) const;
91 
92  void splitSurface (int spanU, int spanV) {
93 
94  }
95 
99  friend std::ostream& operator<<(std::ostream& os, const NurbsSurface& a);
100 
104  friend std::istream& operator>>(std::istream& is, NurbsSurface& a);
105 
106 
107 private:
109  std::vector<double> knotsU_;
111  std::vector<double> knotsV_;
113  std::vector<std::vector<Vec3D>> controlPoints_;
115  std::vector<std::vector<double>> weights_;
117  unsigned int degreeU_, degreeV_;
120 };
121 
122 #endif //MERCURY_NURBSSURFACE_H
bool getDistance(Vec3D P, double radius, double &distance, Vec3D &normal) const
Find projection onto surface, return distance (and contactPoint)
void setClosedInV(bool closedInV)
std::vector< std::vector< Vec3D > > controlPoints_
nu x nv control points
Definition: NurbsSurface.h:113
void flipOrientation()
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)
Create a non-rational NurbsSurface.
Definition: NurbsSurface.cc:53
std::vector< std::vector< double > > weights_
nu x nv weights
Definition: NurbsSurface.h:115
void closestPoint(Vec3D position, double &u, double &v) const
std::vector< double > knotsU_
mu knots
Definition: NurbsSurface.h:109
void setClosedInU(bool closedInU)
friend std::ostream & operator<<(std::ostream &os, const NurbsSurface &a)
Adds elements to an output stream.
bool closedInU_
make it a periodic system
Definition: NurbsSurface.h:119
NurbsSurface()
Create a non-rational NurbsSurface.
Definition: NurbsSurface.cc:34
unsigned int degreeU_
degree pu = mu-nu-1, pv = mv-nv-1
Definition: NurbsSurface.h:117
std::vector< double > knotsV_
mv knots
Definition: NurbsSurface.h:111
Vec3D evaluate(double u, double v) const
Evaluate point on a nonrational NURBS surface.
unsigned int degreeV_
Definition: NurbsSurface.h:117
Definition: Vector.h:49
void splitSurface(int spanU, int spanV)
Definition: NurbsSurface.h:92
friend std::istream & operator>>(std::istream &is, NurbsSurface &a)
Adds elements to an input stream.
void evaluateDerivatives(double u, double v, std::array< std::array< Vec3D, 3 >, 3 > &S) const
Evaluate derivatives of a rational NURBS curve.