MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NurbsSurface.cc File Reference
#include <array>
#include "NurbsSurface.h"
#include "NurbsUtils.h"
#include "Logger.h"
#include "Math/ExtendedMath.h"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const NurbsSurface &a)
 
std::istream & operator>> (std::istream &is, NurbsSurface &a)
 

Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const NurbsSurface a 
)

Adds all elements of the vector to an output stream. NB: this is a global function and a friend of the Vec3D class!

Parameters
[in]osthe output stream,
[in]aThe vector of interest
Returns
the output stream with vector elements added

Definition at line 333 of file NurbsSurface.cc.

References NurbsSurface::controlPoints_, NurbsSurface::knotsU_, NurbsSurface::knotsV_, and NurbsSurface::weights_.

334 {
335  os << "mu " << a.knotsU_.size() << ' ';
336  os << "mv " << a.knotsV_.size() << ' ';
337  os << "nu " << a.controlPoints_.size() << ' ';
338  os << "nv " << a.controlPoints_[0].size() << ' ';
339  os << "knotsU ";
340  for (const auto k : a.knotsU_) os << k << ' ';
341  os << "knotsV ";
342  for (const auto k : a.knotsV_) os << k << ' ';
343  os << "controlPoints ";
344  for (const auto cp0 : a.controlPoints_) for (const auto cp : cp0) os << cp << ' ';
345  os << "weights ";
346  for (const auto w0 : a.weights_) for (const auto w : w0) os << w << ' ';
347  return os;
348 }
std::vector< std::vector< Vec3D > > controlPoints_
nu x nv control points
Definition: NurbsSurface.h:113
std::vector< std::vector< double > > weights_
nu x nv weights
Definition: NurbsSurface.h:115
std::vector< double > knotsU_
mu knots
Definition: NurbsSurface.h:109
std::vector< double > knotsV_
mv knots
Definition: NurbsSurface.h:111
std::istream& operator>> ( std::istream &  is,
NurbsSurface a 
)

Reads all elements of a given vector from an input stream. NB: this is a global function and a friend of the Vec3D class!

Parameters
[in,out]isthe input stream
[in,out]athe vector to be read in
Returns
the input stream from which the vector elements were read

Definition at line 357 of file NurbsSurface.cc.

References NurbsSurface::set().

358 {
359  std::string dummy;
360  unsigned mu, mv, nu, nv;
361  is >> dummy >> mu;
362  is >> dummy >> mv;
363  is >> dummy >> nu;
364  is >> dummy >> nv;
365 
366  is >> dummy;
367  std::vector<double> knotsU;
368  knotsU.resize(mu);
369  for (auto& k : knotsU) is >> k;
370 
371  is >> dummy;
372  std::vector<double> knotsV;
373  knotsV.resize(mv);
374  for (auto& k : knotsV) is >> k;
375 
376  is >> dummy;
377  std::vector<std::vector<Vec3D>> controlPoints;
378  controlPoints.resize(nu);
379  for (auto& cp0 : controlPoints) {
380  cp0.resize(nv);
381  for (auto& cp : cp0) is >> cp;
382  }
383 
384  is >> dummy;
385  std::vector<std::vector<double>> weights;
386  weights.resize(nu);
387  for (auto& w0 : weights) {
388  w0.resize(nv);
389  for (auto& w : w0) is >> w;
390  }
391 
392  a.set(knotsU,knotsV,controlPoints,weights);
393  return is;
394 }
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