24 ~NurbsCurveInterface() {
33 nassertr(n >= 0 && n < get_num_cvs(),
false);
34 LVecBase4 cv = get_cv(n);
36 cv.set(0.0f, 0.0f, 0.0f, w);
46 void NurbsCurveInterface::
47 write_cv(std::ostream &out,
int n)
const {
48 nassertv(n >= 0 && n < get_num_cvs());
50 out <<
"CV " << n <<
": " <<
get_cv_point(n) <<
", weight " 57 void NurbsCurveInterface::
58 write(std::ostream &out,
int indent_level)
const {
61 PN_stdfloat min_t = 0.0f;
62 PN_stdfloat max_t = 0.0f;
64 if (get_num_knots() > 0) {
66 max_t = get_knot(get_num_knots() - 1);
69 out <<
"NurbsCurve, order " << get_order() <<
", " << get_num_cvs()
70 <<
" CV's. t ranges from " << min_t <<
" to " << max_t <<
".\n";
75 int num_cvs = get_num_cvs();
76 for (i = 0; i < num_cvs; i++) {
84 int num_knots = get_num_knots();
85 for (i = 0; i < num_knots; i++) {
86 out <<
" " << get_knot(i);
95 bool NurbsCurveInterface::
96 format_egg(std::ostream &out,
const std::string &name,
const std::string &curve_type,
97 int indent_level)
const {
99 <<
"<VertexPool> " << name <<
".pool {\n";
101 int num_cvs = get_num_cvs();
103 for (cv = 0; cv < get_num_cvs(); cv++) {
104 indent(out, indent_level+2)
105 <<
"<Vertex> " << cv <<
" { " << get_cv(cv) <<
" }\n";
111 <<
"<NurbsCurve> " << name <<
" {\n";
113 if (!curve_type.empty()) {
114 indent(out, indent_level+2)
115 <<
"<Scalar> type { " << curve_type <<
" }\n";
118 indent(out, indent_level+2) <<
"<Order> { " << get_order() <<
" }\n";
120 indent(out, indent_level+2) <<
"<Knots> {";
122 int num_knots = get_num_knots();
124 for (k = 0; k < num_knots; k++) {
127 indent(out, indent_level+4);
129 out << get_knot(k) <<
" ";
132 indent(out, indent_level+2) <<
"}\n";
134 indent(out, indent_level+2) <<
"<VertexRef> {";
135 for (cv = 0; cv < num_cvs; cv++) {
138 indent(out, indent_level+3);
143 indent(out, indent_level+4)
144 <<
"<Ref> { " << name <<
".pool }\n";
145 indent(out, indent_level+2) <<
"}\n";
147 indent(out, indent_level) <<
"}\n";
156 bool NurbsCurveInterface::
159 nassertr(nurbs !=
nullptr,
false);
161 nurbs->remove_all_cvs();
162 nurbs->set_order(get_order());
164 int num_cvs = get_num_cvs();
166 for (i = 0; i < num_cvs; i++) {
167 nurbs->append_cv(get_cv(i));
170 int num_knots = get_num_knots();
171 for (i = 0; i < num_knots; i++) {
172 nurbs->set_knot(i, get_knot(i));
A virtual base class for parametric curves.
virtual bool recompute()
Recalculates the curve, if necessary.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This abstract class defines the interface only for a Nurbs-style curve, with knots and coordinates in...
virtual NurbsCurveInterface * get_nurbs_interface()
Returns a pointer to the object as a NurbsCurveInterface object if it happens to be a NURBS-style cur...
PN_stdfloat get_cv_weight(int n) const
Returns the weight of the indicated CV.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
bool set_cv_weight(int n, PN_stdfloat w)
Sets the weight of the indicated CV without affecting its position in 3-d space.
LVecBase3 get_cv_point(int n) const
Returns the position of the indicated CV.
TypeHandle is the identifier used to differentiate C++ class types.