lpe-knot.cpp revision 796e4d207811b40c36945baeb5228870ed6a901b
#define INKSCAPE_LPE_KNOT_CPP
/** \file
* LPE <knot> implementation
*/
/*
* Authors:
* JF Barraud
*
* Copyright (C) JF Barraud 2007 <jf.barraud@gmail.com>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-knot.h"
namespace Inkscape {
namespace LivePathEffect {
// initialise your parameters here:
interruption_width(_("Gap width"), _("The width of the gap in the path where it self-intersects"), "interruption_width", &wr, this, 10)
{
// register all your parameters here, so Inkscape knows which parameters this effect has:
}
{
}
//remove an interval from an union of intervals.
}
return ret;
}
using namespace Geom;
}
//return Interval(t0-0.1,t0+0.1);
}
//Just a try; this should be moved to 2geom if ever it works.
//is the current curve a cubic bezier?
//is there a crossing in the polygon?
//split the curve where the tangent is parallel to the chord through end points.
double t; //where to split; solution of 3*at^2-(a+c)t +c = 0.
//TODO: don't we have a clean deg 2 equation solver?...
if (fabs(a)<.0001){
t = .5;
}else{
double delta = a*a-a*c+c*c;
}
//TODO: shouldn't Path have subdivide method?
}else{//cubic bezier but no crossing.
}
}else{//not cubic bezier.
}
}
}
return ret;
}
{
using namespace Geom;
double width = interruption_width;
for (unsigned i = 0; i < crossingTable.size(); i++){
//TODO: handle closed curves...
//TODO: select dir according to a parameter...
}
}
}
}
}
return path_out;
}
/*
Geom::Piecewise<Geom::D2<Geom::SBasis> >
addLinearEnds (Geom::Piecewise<Geom::D2<Geom::SBasis> > & m){
using namespace Geom;
Piecewise<D2<SBasis> > output;
Piecewise<D2<SBasis> > start;
Piecewise<D2<SBasis> > end;
double x,y,vx,vy;
x = m.segs.front()[0].at0();
y = m.segs.front()[1].at0();
start = Piecewise<D2<SBasis> >(D2<SBasis>(Linear (x-vx,x),Linear (y-vy,y)));
start.offsetDomain(m.cuts.front()-1.);
x = m.segs.back()[0].at1();
y = m.segs.back()[1].at1();
end = Piecewise<D2<SBasis> >(D2<SBasis>(Linear (x,x+vx),Linear (y,y+vy)));
//end.offsetDomain(m.cuts.back());
output = start;
output.concat(m);
output.concat(end);
return output;
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEKnot::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in)
{
using namespace Geom;
Piecewise<D2<SBasis> > output;
Piecewise<D2<SBasis> > m = addLinearEnds(pwd2_in);
Piecewise<D2<SBasis> > v = derivative(pwd2_in);
Piecewise<D2<SBasis> > n = unitVector(v);
// // -------- Pleins et delies vs courbure ou direction...
// Piecewise<D2<SBasis> > a = derivative(v);
// Piecewise<SBasis> a_cross_n = cross(a,n);
// Piecewise<SBasis> v_dot_n = dot(v,n);
// //Piecewise<D2<SBasis> > rfrac = sectionize(D2<Piecewise<SBasis> >(a_cross_n,v_dot_n));
// //Piecewise<SBasis> h = atan2(rfrac)*interruption_width;
// Piecewise<SBasis> h = reciprocal(curvature(pwd2_in))*interruption_width;
//
// // Piecewise<D2<SBasis> > dir = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(0),Linear(-1)));
// // Piecewise<SBasis> h = dot(n,dir)+1.;
// // h *= h*(interruption_width/4.);
//
// n = rot90(n);
// output = pwd2_in+h*n;
// output.concat(pwd2_in-h*n);
//
// //-----------
//output.concat(m);
return output;
}
*/
/* ######################## */
} //namespace LivePathEffect (setq default-directory "c:/Documents And Settings/jf/Mes Documents/InkscapeSVN")
} /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :