15 #include "nurbsCurveInterface.h"
16 #include "parametricCurve.h"
17 #include "config_parametrics.h"
27 ~NurbsCurveInterface() {
38 nassertr(n >= 0 && n < get_num_cvs(),
false);
41 cv.set(0.0f, 0.0f, 0.0f, w);
53 void NurbsCurveInterface::
54 write_cv(ostream &out,
int n)
const {
55 nassertv(n >= 0 && n < get_num_cvs());
57 out <<
"CV " << n <<
": " <<
get_cv_point(n) <<
", weight "
66 void NurbsCurveInterface::
67 write(ostream &out,
int indent_level)
const {
68 indent(out, indent_level);
70 PN_stdfloat min_t = 0.0f;
71 PN_stdfloat max_t = 0.0f;
73 if (get_num_knots() > 0) {
75 max_t = get_knot(get_num_knots() - 1);
78 out <<
"NurbsCurve, order " << get_order() <<
", " << get_num_cvs()
79 <<
" CV's. t ranges from " << min_t <<
" to " << max_t <<
".\n";
81 indent(out, indent_level)
84 int num_cvs = get_num_cvs();
85 for (i = 0; i < num_cvs; i++) {
86 indent(out, indent_level)
91 indent(out, indent_level)
93 int num_knots = get_num_knots();
94 for (i = 0; i < num_knots; i++) {
95 out <<
" " << get_knot(i);
106 bool NurbsCurveInterface::
107 format_egg(ostream &out,
const string &name,
const string &curve_type,
108 int indent_level)
const {
109 indent(out, indent_level)
110 <<
"<VertexPool> " << name <<
".pool {\n";
112 int num_cvs = get_num_cvs();
114 for (cv = 0; cv < get_num_cvs(); cv++) {
115 indent(out, indent_level+2)
116 <<
"<Vertex> " << cv <<
" { " << get_cv(cv) <<
" }\n";
118 indent(out, indent_level)
121 indent(out, indent_level)
122 <<
"<NurbsCurve> " << name <<
" {\n";
124 if (!curve_type.empty()) {
125 indent(out, indent_level+2)
126 <<
"<Scalar> type { " << curve_type <<
" }\n";
129 indent(out, indent_level+2) <<
"<Order> { " << get_order() <<
" }\n";
131 indent(out, indent_level+2) <<
"<Knots> {";
133 int num_knots = get_num_knots();
135 for (k = 0; k < num_knots; k++) {
138 indent(out, indent_level+4);
140 out << get_knot(k) <<
" ";
143 indent(out, indent_level+2) <<
"}\n";
145 indent(out, indent_level+2) <<
"<VertexRef> {";
146 for (cv = 0; cv < num_cvs; cv++) {
149 indent(out, indent_level+3);
154 indent(out, indent_level+4)
155 <<
"<Ref> { " << name <<
".pool }\n";
156 indent(out, indent_level+2) <<
"}\n";
158 indent(out, indent_level) <<
"}\n";
170 bool NurbsCurveInterface::
175 nurbs->remove_all_cvs();
176 nurbs->set_order(get_order());
178 int num_cvs = get_num_cvs();
180 for (i = 0; i < num_cvs; i++) {
181 nurbs->append_cv(get_cv(i));
184 int num_knots = get_num_knots();
185 for (i = 0; i < num_knots; i++) {
186 nurbs->set_knot(i, get_knot(i));
A virtual base class for parametric curves.
virtual bool recompute()
Recalculates the curve, if necessary.
PN_stdfloat get_cv_weight(int n) const
Returns the weight of the indicated CV.
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...
bool set_cv_weight(int n, PN_stdfloat w)
Sets the weight of the indicated CV without affecting its position in 3-d space.
This is the base class for all three-component vectors and points.
LVecBase3 get_cv_point(int n) const
Returns the position of the indicated CV.
TypeHandle is the identifier used to differentiate C++ class types.