ts::BSpline ts::BSpline::buckle(const ts::rational b) const { ts::BSpline bs; const tsError err = ts_bspline_buckle(&bspline, b, &bs.bspline); if (err < 0) throw std::runtime_error(ts_enum_str(err)); return bs; }
void display(void) { size_t i; tsBSpline buckled; tsReal *ctrlp, *knots; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ts_bspline_buckle(&spline, b, &buckled, NULL); /* draw buckled */ ts_bspline_control_points(&buckled, &ctrlp, NULL); ts_bspline_knots(&buckled, &knots, NULL); glColor3f(1.0, 1.0, 1.0); glLineWidth(3); gluBeginCurve(theNurb); gluNurbsCurve( theNurb, (GLint)ts_bspline_num_knots(&buckled), knots, (GLint)ts_bspline_dimension(&buckled), ctrlp, (GLint)ts_bspline_order(&buckled), GL_MAP1_VERTEX_3 ); gluEndCurve(theNurb); /* draw control points */ glColor3f(1.0, 0.0, 0.0); glPointSize(5.0); glBegin(GL_POINTS); for (i = 0; i < ts_bspline_num_control_points(&buckled); i++) glVertex3fv(&ctrlp[i * ts_bspline_dimension(&buckled)]); glEnd(); ts_bspline_free(&buckled); free(ctrlp); free(knots); b -= 0.001f; if (b < 0.f) b = 1.f; glutSwapBuffers(); glutPostRedisplay(); }