Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
NurbsSurface.hh
1 /*
2  * NurbsSurface.hh
3  *
4  * Created on: Mar 8, 2010
5  * Author: bruenger
6  */
7 
8 #ifndef NURBSSURFACE_HH_
9 #define NURBSSURFACE_HH_
10 
11 #include <vector>
12 #include <Base/Math/Vector2.hh>
13 #include <Base/Geometry/HomgPoint3D.hh>
14 
15 namespace BIAS {
16 
17 class NurbsSurface {
18 public:
19  NurbsSurface();
20  virtual ~NurbsSurface();
21  void Init(int dimu, int dimv, int degree);
22  void SetKnotsToDefault();
24  Vector3<double> GetSurfacePoint(double u, double v);
25 #ifdef BIAS_HAVE_XML2
26  int LoadFromXML(std::string xmlfile);
27  void LoadFromXMLWeighted(std::string xmlfile,float weight);
28  void SaveToXML(std::string xmlfile);
29 #endif
30 
31  void SetCtrlPoint(int i, int j, HomgPoint3D val)
32  {
33  ctrlpoints_[i][j] = val;
34  }
35 
36  HomgPoint3D GetCtrlPoint(int i, int j)
37  {
38  return ctrlpoints_[i][j];
39  }
40 
41  void SetWeight(int i, int j, double val)
42  {
43  HomgPoint3D tmp;
44  tmp.Set(ctrlpoints_[i][j].GetX(),ctrlpoints_[i][j].GetY(),ctrlpoints_[i][j].GetZ(),val);
45  SetCtrlPoint(i,j,tmp);
46  }
47 
48  double GetWeight(int i, int j)
49  {
50  return ctrlpoints_[i][j].GetW();
51  }
52 
53  void SetKnotU(int i, double val)
54  {
55  knotsu_[i] = val;
56  }
57 
58  double GetKnotU(int i)
59  {
60  return knotsu_[i];
61  }
62 
63  void SetKnotV(int i, double val)
64  {
65  knotsv_[i] = val;
66  }
67 
68  double GetKnotV(int i)
69  {
70  return knotsv_[i];
71  }
72 
73  std::vector<double> GetKnotsU() const
74  {
75  return knotsu_;
76  }
77 
78  std::vector<double> GetKnotsV() const
79  {
80  return knotsv_;
81  }
82 
83  int GetDimU() const
84  {
85  return dimu_;
86  }
87 
88  void SetDimU(int dimu)
89  {
90  dimu_ = dimu;
91  }
92 
93  int GetDimV() const
94  {
95  return dimv_;
96  }
97 
98  void SetDimV(int dimv)
99  {
100  dimv_ = dimv;
101  }
102 
103  int GetDegree() const
104  {
105  return degree_;
106  }
107 
108  void SetDegree(int degree)
109  {
110  degree_ = degree;
111  }
112 
113  bool GetInitialized() const
114  {
115  return initialized_;
116  }
117 
118  void SetInitialized(bool initialized)
119  {
120  initialized_ = initialized;
121  }
122 
123 protected:
124  int FindSpan(int n, int p, double u, std::vector<double> U);
125  std::vector<double> BasisFuns(int i, double u, int p, std::vector<double> U);
126  std::vector<std::vector<HomgPoint3D> > ctrlpoints_;
127  std::vector<double> knotsu_;
128  std::vector<double> knotsv_;
129  int dimu_;
130  int dimv_;
131  int degree_;
133 };
134 
135 }
136 #endif /* NURBSSURFACE_HH_ */
int FindSpan(int n, int p, double u, std::vector< double > U)
void SetCtrlPoint(int i, int j, HomgPoint3D val)
Definition: NurbsSurface.hh:31
std::vector< double > knotsu_
void SetWeight(int i, int j, double val)
Definition: NurbsSurface.hh:41
void Set(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z)
set elementwise with given 3 euclidean scalar values.
Definition: HomgPoint3D.hh:321
void SetDimU(int dimu)
Definition: NurbsSurface.hh:88
std::vector< double > BasisFuns(int i, double u, int p, std::vector< double > U)
double GetWeight(int i, int j)
Definition: NurbsSurface.hh:48
double GetKnotU(int i)
Definition: NurbsSurface.hh:58
void SetDegree(int degree)
void SetKnotV(int i, double val)
Definition: NurbsSurface.hh:63
double GetKnotV(int i)
Definition: NurbsSurface.hh:68
int LoadFromXML(std::string xmlfile)
void SetInitialized(bool initialized)
Vector3< double > GetSurfacePoint(double u, double v)
std::vector< double > GetKnotsU() const
Definition: NurbsSurface.hh:73
std::vector< std::vector< HomgPoint3D > > ctrlpoints_
void SetCTRLPointsToRandom(Vector2< double > start, Vector2< double > ende)
std::vector< double > knotsv_
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
int GetDimV() const
Definition: NurbsSurface.hh:93
int GetDegree() const
void Init(int dimu, int dimv, int degree)
virtual ~NurbsSurface()
std::vector< double > GetKnotsV() const
Definition: NurbsSurface.hh:78
void SaveToXML(std::string xmlfile)
void SetDimV(int dimv)
Definition: NurbsSurface.hh:98
HomgPoint3D GetCtrlPoint(int i, int j)
Definition: NurbsSurface.hh:36
int GetDimU() const
Definition: NurbsSurface.hh:83
void LoadFromXMLWeighted(std::string xmlfile, float weight)
bool GetInitialized() const
void SetKnotU(int i, double val)
Definition: NurbsSurface.hh:53