Panda3D
eggNurbsCurve.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggNurbsCurve.I
10  * @author drose
11  * @date 2000-02-15
12  */
13 
14 /**
15  *
16  */
17 INLINE EggNurbsCurve::
18 EggNurbsCurve(const std::string &name) : EggCurve(name) {
19  _order = 0;
20 }
21 
22 /**
23  *
24  */
25 INLINE EggNurbsCurve::
26 EggNurbsCurve(const EggNurbsCurve &copy) :
27  EggCurve(copy),
28  _knots(copy._knots),
29  _order(copy._order)
30 {
31 }
32 
33 /**
34  *
35  */
36 INLINE EggNurbsCurve &EggNurbsCurve::
37 operator = (const EggNurbsCurve &copy) {
38  EggCurve::operator = (copy);
39  _knots = copy._knots;
40  _order = copy._order;
41  return *this;
42 }
43 
44 /**
45  * Directly changes the order to the indicated value (which must be an integer
46  * in the range 1 <= order <= 4). If possible, it is preferable to use the
47  * setup() method instead of this method, since changing the order directly
48  * may result in an invalid curve.
49  */
50 INLINE void EggNurbsCurve::
51 set_order(int order) {
52  nassertv(order >= 1 && order <= 4);
53  _order = order;
54 }
55 
56 /**
57  * Resets the value of the indicated knot as indicated. k must be in the
58  * range 0 <= k < get_num_knots(), and the value must be in the range
59  * get_knot(k - 1) <= value <= get_knot(k + 1).
60  */
61 INLINE void EggNurbsCurve::
62 set_knot(int k, double value) {
63  nassertv(k >= 0 && k < (int)_knots.size());
64  _knots[k] = value;
65 }
66 
67 /**
68  * Returns the order of the curve. The order is the degree of the NURBS
69  * equation plus 1; for a typical NURBS, the order is 4. With this
70  * implementation of NURBS, the order must be in the range [1, 4].
71  */
72 INLINE int EggNurbsCurve::
73 get_order() const {
74  return _order;
75 }
76 
77 /**
78  * Returns the degree of the curve. For a typical NURBS, the degree is 3.
79  */
80 INLINE int EggNurbsCurve::
81 get_degree() const {
82  return _order - 1;
83 }
84 
85 /**
86  * Returns the number of knots.
87  */
88 INLINE int EggNurbsCurve::
89 get_num_knots() const {
90  return _knots.size();
91 }
92 
93 /**
94  * Returns the total number of control vertices that *should* be defined for
95  * the curve. This is determined by the number of knots and the order, in
96  * each direction; it does not necessarily reflect the number of vertices that
97  * have actually been added to the curve. (However, if the number of vertices
98  * in the curve are wrong, the curve is invalid.)
99  */
100 INLINE int EggNurbsCurve::
101 get_num_cvs() const {
102  return get_num_knots() - get_order();
103 }
104 
105 /**
106  * Returns the nth knot value defined.
107  */
108 INLINE double EggNurbsCurve::
109 get_knot(int k) const {
110  nassertr(k >= 0 && k < (int)_knots.size(), 0.0);
111  return _knots[k];
112 }
get_order
Returns the order of the curve.
Definition: eggNurbsCurve.h:55
get_num_knots
Returns the number of knots.
Definition: eggNurbsCurve.h:51
A parametric NURBS curve.
Definition: eggNurbsCurve.h:26
get_knot
Returns the nth knot value defined.
Definition: eggNurbsCurve.h:51
set_knot
Resets the value of the indicated knot as indicated.
Definition: eggNurbsCurve.h:58
A parametric curve of some kind.
Definition: eggCurve.h:24
int get_num_cvs() const
Returns the total number of control vertices that *should* be defined for the curve.
set_order
Directly changes the order to the indicated value (which must be an integer in the range 1 <= order <...
Definition: eggNurbsCurve.h:55