35 setup(
int order,
int num_knots) {
40 _knots.reserve(num_knots);
41 for (i = 0; i < num_knots; i++) {
42 _knots.push_back((
double)i);
55 if ((
int)_knots.size() >= num) {
57 _knots.erase(_knots.begin() + num, _knots.end());
61 for (
int i = _knots.size(); i < num; i++) {
62 _knots.push_back(0.0);
74 if (_order < 1 || _order > 4) {
109 for (i = 1; i < get_order(); i++) {
121 write(std::ostream &out,
int indent_level)
const {
125 indent(out, indent_level + 2)
129 indent(out, indent_level + 2)
130 <<
"<Scalar> subdiv { " <<
get_subdiv() <<
" }\n";
132 indent(out, indent_level + 2)
133 <<
"<Order> { " <<
get_order() <<
" }\n";
134 indent(out, indent_level + 2)
138 indent(out, indent_level + 2)
141 write_body(out, indent_level+2);
142 indent(out, indent_level) <<
"}\n";
void setup(int order, int num_knots)
Prepares a new curve definition with the indicated order and number of knots.
get_order
Returns the order of the curve.
void write_header(std::ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
CurveType get_curve_type() const
Returns the indicated type of the curve.
virtual EggNurbsCurve * make_copy() const override
Makes a copy of this object.
void set_num_knots(int num)
Directly changes the number of knots.
get_num_knots
Returns the number of knots.
int get_subdiv() const
Returns the requested number of subdivisions, or 0 if no particular subdivisions have been requested.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void write_long_list(std::ostream &out, int indent_level, InputIterator ifirst, InputIterator ilast, std::string first_prefix="", std::string later_prefix="", int max_col=72)
Writes a list of things to the indicated output stream, with a space separating each item.
A parametric NURBS curve.
virtual void write(std::ostream &out, int indent_level) const override
Writes the nurbsCurve to the indicated output stream in Egg format.
get_knot
Returns the nth knot value defined.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
int get_num_cvs() const
Returns the total number of control vertices that *should* be defined for the curve.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_valid() const
Returns true if the NURBS parameters are all internally consistent (e.g.