本文整理汇总了C++中PointSetHandle::asBezier方法的典型用法代码示例。如果您正苦于以下问题:C++ PointSetHandle::asBezier方法的具体用法?C++ PointSetHandle::asBezier怎么用?C++ PointSetHandle::asBezier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointSetHandle
的用法示例。
在下文中一共展示了PointSetHandle::asBezier方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timer_stream) {
D2<SBasis> skeleton = skel_handles.asBezier();
D2<SBasis> pattern = pat_handles.asBezier();
cairo_set_line_width(cr,1.);
cairo_pw_d2_sb(cr, Piecewise<D2<SBasis> >(skeleton));
cairo_set_source_rgba(cr,0.0,0.0,1.0,1.0);
cairo_stroke(cr);
cairo_pw_d2_sb(cr, Piecewise<D2<SBasis> >(pattern));
cairo_set_source_rgba(cr,1.0,0.0,1.0,1.0);
cairo_stroke(cr);
origin_handle.pos[0]=150;
Geom::Point origin = origin_handle.pos;
Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(skeleton),2,.1);
uskeleton = remove_short_cuts(uskeleton,.01);
Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton));
n = force_continuity(remove_short_cuts(n,.1));
Piecewise<SBasis> x=Piecewise<SBasis>(pattern[0]-origin[0]);
Piecewise<SBasis> y=Piecewise<SBasis>(pattern[1]-origin[1]);
Interval pattBnds = *bounds_exact(x);
int nbCopies = int(uskeleton.cuts.back()/pattBnds.extent());
//double pattWidth = uskeleton.cuts.back()/nbCopies;
double pattWidth = pattBnds.extent();
double offs = 0;
x-=pattBnds.min();
//x*=pattWidth/pattBnds.extent();
Piecewise<D2<SBasis> >output;
for (int i=0; i<nbCopies; i++){
output.concat(compose(uskeleton,x+offs)+y*compose(n,x+offs));
offs+=pattWidth;
}
//Perform cut for last segment
double tt = uskeleton.cuts.back() - offs;
if(tt > 0.) {
vector<double> rs = roots(x - tt);
rs.push_back(0); rs.push_back(1); //regard endpoints
std::sort(rs.begin(), rs.end());
std::unique(rs.begin(), rs.end());
//enumerate indices of sections to the left of the line
for(unsigned i = (x[0].at0()>tt ? 1 : 0); i < rs.size()-1; i+=2) {
Piecewise<SBasis> port = portion(x+offs, rs[i], rs[i+1]);
output.concat(compose(uskeleton,port)+portion(y, rs[i], rs[i+1])*compose(n,port));
}
}
cairo_pw_d2_sb(cr, output);
cairo_set_source_rgba(cr,1.0,0.0,1.0,1.0);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save,timer_stream);
}
示例2: draw
void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timer_stream) {
D2<SBasis> B = B_handle.asBezier();
D2<SBasis> P = P_handle.asBezier();
Geom::Point O = O_handle.pos;
NormalBundle NBdle;
NBdle.setBase(B);
Geom::Point Oo(O[0]+*(NBdle.lengths.rbegin()),O[1]);
vector<D2<SBasis> > Q=compose(NBdle,P,O);
cairo_set_line_width (cr, 0.5);
//Base lines
cairo_set_source_rgba (cr, 0.9, 0., 0., 1);
cairo_d2_sb(cr, B);
draw_line_seg(cr, O, Oo);
cairo_stroke(cr);
//Sections
cairo_set_source_rgba (cr, 0, 0, 0.9, 1);
cairo_d2_sb(cr, P);
for (unsigned i=0;i<Q.size();i++){
cairo_d2_sb(cr, Q[i]);
}
cairo_stroke(cr);
//Normal bundle
cairo_set_source_rgba (cr, 0., 0., 0., 1);
NBdle.draw(cr,3,5);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save,timer_stream);
}
示例3: draw
void draw(cairo_t *cr,
std::ostringstream *notify,
int width, int height, bool save) {
D2<SBasis> B1 = b1_handle.asBezier();
D2<SBasis> B2 = b2_handle.asBezier();
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
B.concat(Piecewise<D2<SBasis> >(B2));
// testing fuse_nearby_ends
std::vector< Piecewise<D2<SBasis> > > pieces;
pieces = fuse_nearby_ends(split_at_discontinuities(B),9);
Piecewise<D2<SBasis> > C;
for (unsigned i=0; i<pieces.size(); i++){
C.concat(pieces[i]);
}
// testing fuse_nearby_ends
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
//cairo_d2_sb(cr, B1);
cairo_pw_d2_sb(cr, C);
//cairo_pw_d2_sb(cr, B);
cairo_stroke(cr);
Piecewise<D2<SBasis> > uniform_B = arc_length_parametrization(B);
cairo_set_source_rgba (cr, 0., 0., 0.9, 1);
dot_plot(cr,uniform_B);
cairo_stroke(cr);
*notify << "pieces = " << uniform_B.size() << ";\n";
Toy::draw(cr, notify, width, height, save);
}
示例4: draw
void draw( cairo_t *cr, std::ostringstream *notify,
int width, int height, bool save )
{
cairo_set_line_width (cr, 0.3);
m_selection_kind = (unsigned int) (sliders[0].value());
for (unsigned int i = 0; i < m_pathvector_coll.size(); ++i)
{
cairo_set_source_rgba(cr, 0.0, 0.4*(i+1), 0.8/(i+1), 1.0);
for (unsigned int j = 0; j < m_pathvector_coll[i].size(); ++j)
{
m_pathvector_coll[i][j].clear();
for (unsigned int k = 0; k < m_curves_per_path; ++k)
{
PointSetHandle psh;
psh.pts.resize(m_handles_per_curve);
for (unsigned int h = 0; h < m_handles_per_curve; ++h)
{
unsigned int kk = k * (m_handles_per_curve-1) + h;
psh.pts[h] = m_pathvector_coll_handles[i][j].pts[kk];
}
m_pathvector_coll[i][j].append(psh.asBezier());
}
cairo_path(cr, m_pathvector_coll[i][j]);
}
cairo_stroke(cr);
}
Rect bound;
if ( (m_selection_kind == CURVE) && (m_selected_curve != -1) )
{
const Curve & curve = m_pathvector_coll[m_selected_pathvector][m_selected_path][m_selected_curve];
bound = toggles[0].on ? *curve.boundsExact()
: *curve.boundsFast();
}
else if ( (m_selection_kind == PATH) && (m_selected_path != -1) )
{
const Path & path = m_pathvector_coll[m_selected_pathvector][m_selected_path];
bound = toggles[0].on ? *path.boundsExact()
: *path.boundsFast();
}
else if ( (m_selection_kind == PATHVECTOR) && (m_selected_pathvector != -1) )
{
const PathVector & pathvector = m_pathvector_coll[m_selected_pathvector];
bound = toggles[0].on ? *bounds_exact(pathvector)
: *bounds_fast(pathvector);
}
cairo_set_source_rgba(cr, 0.5, 0.0, 0.0, 1.0);
cairo_set_line_width (cr, 0.4);
cairo_rectangle(cr, bound.left(), bound.top(), bound.width(), bound.height());
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save);
}
示例5: draw
virtual void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save) {
D2<SBasis> B1 = pB1.asBezier();
D2<SBasis> B2 = pB2.asBezier();
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
B.concat(Piecewise<D2<SBasis> >(B2));
std::vector<Point> e;
std::vector<Piecewise<D2<SBasis> > > s;
s.push_back(derivative(B));
for(int j = 0; j < 5; j++) s.push_back(derivative(s.back()));
for(int j = 0; j <= 5; j++) {
for(unsigned d = 0; d < 2; d++) {
std::vector<double> r = roots(make_cuts_independent(s[j])[d]);
for(unsigned k = 0; k < r.size(); k++) e.push_back(B.valueAt(r[k]));
}
}
for(unsigned i = 0; i < e.size(); i++) draw_cross(cr, e[i]);
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
cairo_pw_d2_sb(cr, B);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save);
}
示例6: draw
void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timer_stream) {
draw_toggles(cr, toggles);
D2<SBasis> B = curve_handle.asBezier();
cairo_set_line_width (cr, 1);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
cairo_d2_sb(cr, B);
cairo_stroke(cr);
sample_point1.pos[1]=400;
sample_point1.pos[0]=std::max(150.,sample_point1.pos[0]);
sample_point1.pos[0]=std::min(450.,sample_point1.pos[0]);
sample_point2.pos[1]=400;
sample_point2.pos[0]=std::max(150.,sample_point2.pos[0]);
sample_point2.pos[0]=std::min(450.,sample_point2.pos[0]);
cairo_move_to(cr, Geom::Point(150,400));
cairo_line_to(cr, Geom::Point(450,400));
cairo_set_source_rgba (cr, 0., 0., 0.5, 0.8);
cairo_stroke(cr);
double t0=std::max(0.,std::min(1.,(sample_point1.pos[0]-150)/300.));
double t1=std::max(0.,std::min(1.,(sample_point2.pos[0]-150)/300.));
Path P;
P.append(B);
if (toggles[0].on) {
if (toggles[1].on)
cairo_curve(cr, P.portion(t0,t1)[0]);
else
cairo_path(cr, P.portion(t0,t1));
} else
cairo_d2_sb(cr, portion(B,t0,t1));
cairo_set_source_rgba (cr, 0.5, 0.2, 0., 0.8);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save,timer_stream);
}
示例7: draw
virtual void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save) {
cairo_set_line_width (cr, 0.5);
cairo_set_source_rgba (cr, 0., 0., 0, 1);
D2<SBasis> A = psh.asBezier();
Rect Ar = *bounds_fast(A);
cairo_d2_sb(cr, A);
cairo_stroke(cr);
std::vector<std::pair<double, double> > all_si =
find_self_intersections(A);
cairo_stroke(cr);
cairo_set_source_rgba (cr, 1., 0., 1, 1);
for(unsigned i = 0; i < all_si.size(); i++) {
draw_handle(cr, A(all_si[i].first));
}
cairo_stroke(cr);
*notify << "total intersections: " << all_si.size();
Toy::draw(cr, notify, width, height, save);
}
示例8: draw
void draw(cairo_t *cr,
std::ostringstream *notify,
int width, int height, bool save, std::ostringstream *timer_stream) {
if (first_time)
{
first_time = false;
sliders[0].geometry(Point(50, 50), 100);
}
size_t const num_points = static_cast<size_t>(sliders[0].value());
D2<SBasis> B1 = b_handle.asBezier();
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
// testing fuse_nearby_ends
std::vector< Piecewise<D2<SBasis> > > pieces;
pieces = fuse_nearby_ends(split_at_discontinuities(B),9);
Piecewise<D2<SBasis> > C;
for (unsigned i=0; i<pieces.size(); i++){
C.concat(pieces[i]);
}
// testing fuse_nearby_ends
cairo_set_line_width (cr, 2.);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
//cairo_d2_sb(cr, B1);
//cairo_pw_d2_sb(cr, C);
//cairo_pw_d2_sb(cr, B);
cairo_stroke(cr);
Timer tm;
Timer::Time als_time = tm.lap();
cairo_set_source_rgba (cr, 0., 0., 0.9, 1);
//dot_plot(cr,uniform_B);
cairo_stroke(cr);
std::cout << B[0] << std::endl;
Geom::Affine translation;
Geom::Path original_path;
//original_bezier.append(B[0]);
//original_bezier.appendNew<CubicBezier> (B[0]);
CubicBezier original_bezier(b_handle.pts);
original_path.append(original_bezier);
std::vector<double> initial_t;
std::vector<Geom::Point> curve_points;
if (randomize_times) {
std::uniform_real_distribution<double> dist_t(0,1);
for (size_t ii = 0; ii < num_points; ++ii) {
double const t = dist_t(generator);
initial_t.push_back(t);
}
std::sort(initial_t.begin(), initial_t.end());
double const min = initial_t.front();
double const max = initial_t.back();
for (auto& t : initial_t) {
t = (t-min)/(max-min);
}
for (auto const t : initial_t) {
curve_points.push_back(original_bezier.pointAt(t));
}
}
else {
for (size_t ii = 0; ii < num_points; ++ii) {
double const t = static_cast<double>(ii) / (num_points-1);
Geom::Point const p = original_bezier.pointAt(t);
initial_t.push_back(t);
curve_points.push_back(p);
}
}
cairo_set_source_rgba (cr, 0., 0., .9, 1);
cairo_path(cr, original_path);
draw_text(cr, original_path.initialPoint(), "original curve and old fit");
Geom::CubicBezier fitted_new;
Geom::CubicBezier fitted_new_a;
Geom::Point very_old_version_raw[4];
bezier_fit_cubic(very_old_version_raw, curve_points.data(), curve_points.size(), 0.);
Geom::CubicBezier very_old_bezier(
very_old_version_raw[0],
very_old_version_raw[1],
very_old_version_raw[2],
very_old_version_raw[3]
);
Geom::Path very_old_version_path;
very_old_version_path.append(very_old_bezier);
cairo_set_source_rgba (cr, .7, .7, 0., 1);
cairo_stroke(cr);
cairo_path(cr, very_old_version_path);
cairo_set_source_rgba (cr, 0., 0., .9, 1);
cairo_stroke(cr);
//.........这里部分代码省略.........
示例9: draw
virtual void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timing_stream) {
cairo_set_source_rgba (cr, 0., 0., 0, 1);
cairo_set_line_width (cr, 1);
D2<SBasis> B = bez_handle.asBezier();
cairo_d2_sb(cr, B);
cairo_stroke(cr);
cairo_set_source_rgba (cr, 0.25, 0.5, 0, 0.8);
double tol = 0.01;
bool time_operations = true;
if(time_operations) {
std::string units_string("us");
Timer tm;
tm.ask_for_timeslice();
tm.start();
Piecewise<SBasis> als = arcLengthSb(B, tol);
Timer::Time als_time = tm.lap();
*timing_stream << "arcLengthSb based "
<< ", time = " << als_time
<< units_string << std::endl;
tm.start();
Piecewise<SBasis> als2 = arcLengthSb2(Piecewise<D2<SBasis> >(B), 0.01);
Timer::Time als2_time = tm.lap();
*timing_stream << "arcLengthSb2 based "
<< ", time = " << als2_time
<< units_string << std::endl;
double abs_error = 0;
double integrating_arc_length = 0;
tm.start();
length_integrating(B, integrating_arc_length, abs_error, 1e-10);
Timer::Time li_time = tm.lap();
*timing_stream << "gsl integrating "
<< ", time = " << li_time
<< units_string << std::endl;
}
Piecewise<SBasis> als = arcLengthSb(B, tol);
Piecewise<SBasis> als2 = arcLengthSb2(Piecewise<D2<SBasis> >(B), 0.01);
cairo_d2_pw_sb(cr, D2<Piecewise<SBasis> >(Piecewise<SBasis>(SBasis(Linear(0, width))) , Piecewise<SBasis>(Linear(height-5)) - Piecewise<SBasis>(als)) );
double abs_error = 0;
double integrating_arc_length = 0;
length_integrating(B, integrating_arc_length, abs_error, 1e-10);
*notify << "arc length = " << integrating_arc_length << "; abs error = " << abs_error << std::endl;
double als_arc_length = als.segs.back().at1();
*notify << "arc length = " << als_arc_length << "; error = " << als_arc_length - integrating_arc_length << std::endl;
double als_arc_length2 = als2.segs.back().at1();
*notify << "arc length2 = " << als_arc_length2 << "; error = " << als_arc_length2 - integrating_arc_length << std::endl;
{
double err = fabs(als_arc_length - integrating_arc_length);
double scale = 10./err;
Piecewise<D2<SBasis> > dM = derivative(Piecewise<D2<SBasis> >(B));
Piecewise<SBasis> ddM = dot(dM,dM);
Piecewise<SBasis> dMlength = sqrt(ddM,tol,3);
double plot_width = (width - 200);
Point org(100,height - 200);
cairo_move_to(cr, org);
for(double t = 0; t < 1; t += 0.01) {
cairo_line_to(cr, org + Point(t*plot_width, scale*(sqrt(ddM.valueAt(t)) - dMlength.valueAt(t))));
}
cairo_move_to(cr, org);
cairo_line_to(cr, org+Point(plot_width, 0));
cairo_stroke(cr);
draw_number(cr, org, scale);
}
Toy::draw(cr, notify, width, height, save,timing_stream);
}
示例10: draw
void draw(cairo_t *cr,
std::ostringstream *notify,
int width, int height, bool save, std::ostringstream *timer_stream) {
srand(10);
for(unsigned i=0; i<NB_SLIDER; i++){
adjuster[i].pos[X] = 30+i*20;
if (adjuster[i].pos[Y]<100) adjuster[i].pos[Y] = 100;
if (adjuster[i].pos[Y]>400) adjuster[i].pos[Y] = 400;
cairo_move_to(cr, Point(30+i*20,100));
cairo_line_to(cr, Point(30+i*20,400));
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0., 0., 1);
cairo_stroke(cr);
}
double tol = (400-adjuster[0].pos[Y])/300.*5+0.05;
double tau = (400-adjuster[1].pos[Y])/300.;
// double scale_topback = (250-adjuster[2].pos[Y])/150.*5;
// double scale_botfront = (250-adjuster[3].pos[Y])/150.*5;
// double scale_botback = (250-adjuster[4].pos[Y])/150.*5;
// double growth = 1+(250-adjuster[5].pos[Y])/150.*.1;
// double rdmness = 1+(400-adjuster[6].pos[Y])/300.*.9;
// double bend_amount = (250-adjuster[7].pos[Y])/300.*100.;
b1_handle.pts.back() = b2_handle.pts.front();
b1_handle.pts.front() = b2_handle.pts.back();
D2<SBasis> B1 = b1_handle.asBezier();
D2<SBasis> B2 = b2_handle.asBezier();
cairo_set_line_width(cr, 0.3);
cairo_set_source_rgba(cr, 0, 0, 0, 1);
cairo_d2_sb(cr, B1);
cairo_d2_sb(cr, B2);
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0., 0., 1);
cairo_stroke(cr);
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
B.continuousConcat(Piecewise<D2<SBasis> >(B2));
Piecewise<SBasis> are;
Point centroid_tmp(0,0);
are = integral(dot(B, rot90(derivative(B))))*0.5;
are = (are - are.firstValue())*(height/10) / (are.lastValue() - are.firstValue());
D2<Piecewise<SBasis> > are_graph(Piecewise<SBasis>(Linear(0, width)), are );
std::cout << are.firstValue() << "," << are.lastValue() << std::endl;
cairo_save(cr);
cairo_d2_pw_sb(cr, are_graph);
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0., 0., 1);
cairo_stroke(cr);
cairo_restore(cr);
#if 0
std::vector<Piecewise<D2<SBasis> > >f = split_at_discontinuities(B);
std::list<Point> p = toPoly( f, tol);
uncross(p);
cairo_move_to(cr, p.front());
for (std::list<Point>::iterator pt = p.begin(); pt!=p.end(); ++pt){
cairo_line_to(cr, *pt);
//if (i++>p.size()*tau) break;
}
cairo_set_line_width (cr, 3);
cairo_set_source_rgba (cr, 1., 0., 0., .5);
cairo_stroke(cr);
if ( p.size()<3) return;
double tot_area = 0;
std::list<Point>::iterator a = p.begin(), b=a;
b++;
while(b!=p.end()){
tot_area += ((*b)[X]-(*a)[X]) * ((*b)[Y]+(*a)[Y])/2;
a++;b++;
}
bool clockwise = tot_area < 0;
std::vector<Triangle> tri;
int nbiter =0;
triangulate(p,tri,clockwise);
cairo_set_source_rgba (cr, 1., 1., 0., 1);
cairo_stroke(cr);
for (unsigned i=0; i<tri.size(); i++){
cairo_move_to(cr, tri[i].a);
cairo_line_to(cr, tri[i].b);
cairo_line_to(cr, tri[i].c);
cairo_line_to(cr, tri[i].a);
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0., .9, .5);
cairo_stroke(cr);
cairo_move_to(cr, tri[i].a);
cairo_line_to(cr, tri[i].b);
cairo_line_to(cr, tri[i].c);
cairo_line_to(cr, tri[i].a);
cairo_set_source_rgba (cr, 0.5, 0., .9, .1);
cairo_fill(cr);
}
//.........这里部分代码省略.........
示例11: draw
void draw(cairo_t *cr,
std::ostringstream *notify,
int width, int height, bool save, std::ostringstream *timer_stream) {
D2<SBasis> B1 = b1_handle.asBezier();
D2<SBasis> B2 = b2_handle.asBezier();
D2<Piecewise<SBasis> >B;
B[X].concat(Piecewise<SBasis>(B1[X]));
B[X].concat(Piecewise<SBasis>(B2[X]));
B[Y].concat(Piecewise<SBasis>(B1[Y]));
B[Y].concat(Piecewise<SBasis>(B2[Y]));
//-----------------------------------------------------
#if 0
Frame frame;
frame.O = Point(50,400);
frame.x = Point(300,0);
frame.y = Point(120,-75);
frame.z = Point(0,-300);
SBasisOf<SBasisOf<double> > u,v,cst;
cst.push_back(LinearOf<SBasisOf<double> >(SBasisOf<double>(LinearOf<double>(1,1))));
u.push_back(LinearOf<SBasisOf<double> >(SBasisOf<double>(LinearOf<double>(0,1))));
v.push_back(LinearOf<SBasisOf<double> >(SBasisOf<double>(LinearOf<double>(0,0)),
SBasisOf<double>(LinearOf<double>(1,1))));
plot3d(cr, integral(v,1) ,frame);
plot3d(cr, v ,frame);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
cairo_stroke(cr);
plot3d(cr, Linear(0,1), Linear(0), Linear(0), frame);
plot3d(cr, Linear(0), Linear(0,1), Linear(0), frame);
plot3d(cr, Linear(0), Linear(0), Linear(0,1), frame);
plot3d(cr, Linear(0,1), Linear(1), Linear(0), frame);
plot3d(cr, Linear(1), Linear(0,1), Linear(0), frame);
cairo_set_source_rgba (cr, 0., 0.0, 0.9, 1);
cairo_stroke(cr);
#endif
//-----------------------------------------------------
SBasisOf<double> smoother;
smoother.push_back(LinearOf<double>(0.));
smoother.push_back(LinearOf<double>(0.));
smoother.push_back(LinearOf<double>(30.));//could be less degree hungry!
adjuster.pos[X] = 400;
if(adjuster.pos[Y]>400) adjuster.pos[Y] = 400;
if(adjuster.pos[Y]<100) adjuster.pos[Y] = 100;
double scale=(400.-adjuster.pos[Y])/300+.01;
D2<Piecewise<SBasis> > smoothB1,smoothB2;
smoothB1[X] = convole(toSBasisOfDouble(B1[X]),Interval(0,4),smoother/scale,Interval(-scale/2,scale/2));
smoothB1[Y] = convole(toSBasisOfDouble(B1[Y]),Interval(0,4),smoother/scale,Interval(-scale/2,scale/2));
smoothB1[X].push(Linear(0.), 8+scale/2);
smoothB1[Y].push(Linear(0.), 8+scale/2);
smoothB2[X] = Piecewise<SBasis>(Linear(0));
smoothB2[X].setDomain(Interval(-scale/2,4-scale/2));
smoothB2[Y] = smoothB2[X];
smoothB2[X].concat(convole(toSBasisOfDouble(B2[X]),Interval(4,8),smoother/scale,Interval(-scale/2,scale/2)));
smoothB2[Y].concat(convole(toSBasisOfDouble(B2[Y]),Interval(4,8),smoother/scale,Interval(-scale/2,scale/2)));
Piecewise<D2<SBasis> > smoothB;
smoothB = sectionize(smoothB1)+sectionize(smoothB2);
//cairo_d2_sb(cr, B1);
//cairo_d2_sb(cr, B2);
cairo_pw_d2_sb(cr, smoothB);
cairo_move_to(cr,100,400);
cairo_line_to(cr,500,400);
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0., 0., 1);
cairo_stroke(cr);
Piecewise<SBasis>bx = Piecewise<SBasis>(B1[X]);
bx.setDomain(Interval(0,4));
Piecewise<SBasis>smth = Piecewise<SBasis>(toSBasis(smoother));
smth.setDomain(Interval(-scale/2,scale/2));
cairo_d2_sb(cr, B1);
plot_graph(cr, bx, 100, 1);
plot_graph(cr, smth/scale, 100, 100);
plot_graph(cr, smoothB1[X],100,1);
//cairo_pw_d2_sb(cr, Piecewise<D2<SBasis> >(B1) );
//cairo_pw_d2_sb(cr, sectionize(smoothB1));
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0.7, 0.2, 0., 1);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save,timer_stream);
}