Panda3D
|
A parametric NURBS curve. More...
#include "eggNurbsCurve.h"
Public Member Functions | |
EggNurbsCurve (const string &name="") | |
EggNurbsCurve (const EggNurbsCurve ©) | |
virtual TypeHandle | force_init_type () |
int | get_degree () const |
Returns the degree of the curve. | |
double | get_knot (int k) const |
Returns the nth knot value defined. | |
int | get_num_cvs () const |
Returns the total number of control vertices that should* be defined for the curve. | |
int | get_num_knots () const |
Returns the number of knots. | |
int | get_order () const |
Returns the order of the curve. | |
virtual TypeHandle | get_type () const |
bool | is_closed () const |
Returns true if the curve appears to be closed. | |
bool | is_valid () const |
Returns true if the NURBS parameters are all internally consistent (e.g. | |
MAKE_SEQ (get_knots, get_num_knots, get_knot) | |
EggNurbsCurve & | operator= (const EggNurbsCurve ©) |
void | set_knot (int k, double value) |
Resets the value of the indicated knot as indicated. | |
void | set_num_knots (int num) |
Directly changes the number of knots. | |
void | set_order (int order) |
Directly changes the order to the indicated value (which must be an integer in the range 1 <= order <= 4). | |
void | setup (int order, int num_knots) |
Prepares a new curve definition with the indicated order and number of knots. | |
virtual void | write (ostream &out, int indent_level) const |
Writes the nurbsCurve to the indicated output stream in Egg format. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
A parametric NURBS curve.
Definition at line 28 of file eggNurbsCurve.h.
int EggNurbsCurve::get_degree | ( | ) | const [inline] |
Returns the degree of the curve.
For a typical NURBS, the degree is 3.
Definition at line 100 of file eggNurbsCurve.I.
double EggNurbsCurve::get_knot | ( | int | k | ) | const [inline] |
Returns the nth knot value defined.
Definition at line 136 of file eggNurbsCurve.I.
Referenced by is_closed(), and is_valid().
int EggNurbsCurve::get_num_cvs | ( | ) | const [inline] |
Returns the total number of control vertices that should* be defined for the curve.
This is determined by the number of knots and the order, in each direction; it does not necessarily reflect the number of vertices that have actually been added to the curve. (However, if the number of vertices in the curve are wrong, the curve is invalid.)
Definition at line 126 of file eggNurbsCurve.I.
References get_num_knots(), and get_order().
Referenced by is_valid().
int EggNurbsCurve::get_num_knots | ( | ) | const [inline] |
Returns the number of knots.
Definition at line 110 of file eggNurbsCurve.I.
Referenced by get_num_cvs(), and is_valid().
int EggNurbsCurve::get_order | ( | ) | const [inline] |
Returns the order of the curve.
The order is the degree of the NURBS equation plus 1; for a typical NURBS, the order is 4. With this implementation of NURBS, the order must be in the range [1, 4].
Definition at line 89 of file eggNurbsCurve.I.
Referenced by get_num_cvs(), is_closed(), and write().
bool EggNurbsCurve::is_closed | ( | ) | const |
Returns true if the curve appears to be closed.
Since the Egg syntax does not provide a means for explicit indication of closure, this has to be guessed at by examining the curve itself.
Definition at line 109 of file eggNurbsCurve.cxx.
References get_knot(), and get_order().
bool EggNurbsCurve::is_valid | ( | ) | const |
Returns true if the NURBS parameters are all internally consistent (e.g.
it has the right number of vertices to match its number of knots and order in each dimension), or false otherwise.
Definition at line 77 of file eggNurbsCurve.cxx.
References get_knot(), get_num_cvs(), and get_num_knots().
void EggNurbsCurve::set_knot | ( | int | k, |
double | value | ||
) | [inline] |
Resets the value of the indicated knot as indicated.
k must be in the range 0 <= k < get_num_knots(), and the value must be in the range get_knot(k - 1) <= value <= get_knot(k + 1).
Definition at line 75 of file eggNurbsCurve.I.
void EggNurbsCurve::set_num_knots | ( | int | num | ) |
Directly changes the number of knots.
This will either add zero-valued knots onto the end, or truncate knot values from the end, depending on whether the list is being increased or decreased. If possible, it is preferable to use the setup() method instead of directly setting the number of knots, as this may result in an invalid curve.
Definition at line 55 of file eggNurbsCurve.cxx.
void EggNurbsCurve::set_order | ( | int | order | ) | [inline] |
Directly changes the order to the indicated value (which must be an integer in the range 1 <= order <= 4).
If possible, it is preferable to use the setup() method instead of this method, since changing the order directly may result in an invalid curve.
Definition at line 61 of file eggNurbsCurve.I.
void EggNurbsCurve::setup | ( | int | order, |
int | num_knots | ||
) |
Prepares a new curve definition with the indicated order and number of knots.
This also implies a particular number of vertices as well (the number of knots minus the order), but it is up to the user to add the correct number of vertices to the curve by repeatedly calling push_back().
Definition at line 32 of file eggNurbsCurve.cxx.
void EggNurbsCurve::write | ( | ostream & | out, |
int | indent_level | ||
) | const [virtual] |
Writes the nurbsCurve to the indicated output stream in Egg format.
Implements EggPrimitive.
Definition at line 132 of file eggNurbsCurve.cxx.
References EggCurve::get_curve_type(), get_order(), EggCurve::get_subdiv(), EggPrimitive::write_body(), and EggNamedObject::write_header().