NurbsSurface.cc File Reference
#include <array>
#include "NurbsSurface.h"
#include "NurbsUtils.h"
#include "Logger.h"
#include "Math/ExtendedMath.h"

Functions

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

Function Documentation

◆ operator<<()

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
377 {
378  os << "mu " << a.knotsU_.size() << ' ';
379  os << "mv " << a.knotsV_.size() << ' ';
380  os << "nu " << a.controlPoints_.size() << ' ';
381  os << "nv " << a.controlPoints_[0].size() << ' ';
382  os << "knotsU ";
383  for (const auto k : a.knotsU_) os << k << ' ';
384  os << "knotsV ";
385  for (const auto k : a.knotsV_) os << k << ' ';
386  os << "controlPoints ";
387  for (const auto& cp0 : a.controlPoints_) for (const auto cp : cp0) os << cp << ' ';
388  os << "weights ";
389  for (const auto& w0 : a.weights_) for (const auto w : w0) os << w << ' ';
390  os << "closedInUV " << a.closedInU_ << ' ' << a.closedInV_;
391  os << " periodicInUV " << a.periodicInU_ << ' ' << a.periodicInV_;
392  return os;
393 }
bool periodicInV_
Definition: NurbsSurface.h:210
bool closedInU_
make it a periodic system
Definition: NurbsSurface.h:208
std::vector< std::vector< Vec3D > > controlPoints_
nu x nv control points
Definition: NurbsSurface.h:202
bool periodicInU_
Definition: NurbsSurface.h:210
std::vector< Mdouble > knotsU_
mu knots
Definition: NurbsSurface.h:198
bool closedInV_
Definition: NurbsSurface.h:208
std::vector< Mdouble > knotsV_
mv knots
Definition: NurbsSurface.h:200
std::vector< std::vector< Mdouble > > weights_
nu x nv weights
Definition: NurbsSurface.h:204

◆ operator>>()

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
403 {
404  std::string dummy;
405  unsigned mu, mv, nu, nv;
406  is >> dummy >> mu;
407  is >> dummy >> mv;
408  is >> dummy >> nu;
409  is >> dummy >> nv;
410 
411  is >> dummy;
412  std::vector<double> knotsU;
413  knotsU.resize(mu);
414  for (auto& k : knotsU) is >> k;
415 
416  is >> dummy;
417  std::vector<double> knotsV;
418  knotsV.resize(mv);
419  for (auto& k : knotsV) is >> k;
420 
421  is >> dummy;
422  std::vector<std::vector<Vec3D>> controlPoints;
423  controlPoints.resize(nu);
424  for (auto& cp0 : controlPoints) {
425  cp0.resize(nv);
426  for (auto& cp : cp0) is >> cp;
427  }
428 
429  is >> dummy;
430  std::vector<std::vector<double>> weights;
431  weights.resize(nu);
432  for (auto& w0 : weights) {
433  w0.resize(nv);
434  for (auto& w : w0) is >> w;
435  }
436 
437  a.set(knotsU,knotsV,controlPoints,weights);
438 
439  // After setting, since in that method the defaults are set to false.
440  // Also, check if dummy variable exist, for backwards compatibility.
441  is >> dummy;
442  if (dummy == "closedInUV")
443  {
444  is >> a.closedInU_;
445  is >> a.closedInV_;
446  }
447  is >> dummy;
448  if (dummy == "periodicInUV")
449  {
450  is >> a.periodicInU_;
451  is >> a.periodicInV_;
452  }
453 
454  return is;
455 }
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:60