lpe-knot.cpp revision 74ed5bd66f5d8a1465b69bd0450f2af030b638f0
#define INKSCAPE_LPE_KNOT_CPP
/** \file
* LPE <knot> implementation
*/
/*
* Authors:
* Johan Engelen
*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-knot.h"
#include <libnr/n-art-bpath.h>
// You might need to include other 2geom files. You can add them here:
namespace Inkscape {
namespace LivePathEffect {
// initialise your parameters here:
interruption_width(_("Interruption width"), _("Howmuch the lower strand is obscured by the upper."), "interruption_width", &wr, this, 1.2)
{
// register all your parameters here, so Inkscape knows which parameters this effect has:
}
{
}
/* ########################
* Choose to implement one of the doEffect functions. You can delete or comment out the others.
*/
/*
void
LPEKnot::doEffect (SPCurve * curve)
{
// spice this up to make the effect actually *do* something!
}
NArtBpath *
LPEKnot::doEffect_nartbpath (NArtBpath * path_in)
{
NArtBpath *path_out;
unsigned ret = 0;
while ( path_in[ret].code != NR_END ) {
++ret;
}
unsigned len = ++ret;
path_out = g_new(NArtBpath, len);
memcpy(path_out, path_in, len * sizeof(NArtBpath)); // spice this up to make the effect actually *do* something!
return path_out;
}
*/
}
return ret;
}
using namespace Geom;
}
//return Interval(t0-0.1,t0+0.1);
}
{
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...
}
}
}
}
// std::vector<Point> MV = path_in[0][0].pointAndDerivatives(crossingTable[0][0].getTime(0),2);
// Point U = unit_vector(MV[1]);
// Point N = U.cw();
// Point A = MV[0]-10.*width*U, B = MV[0]+10*width*U;
// Geom::Path cutter;
// cutter = Geom::Path();
// cutter.append( LineSegment(A+width*N,B+width*N));
// path_out.push_back(cutter);
// cutter = Geom::Path();
// cutter.append( LineSegment(A-width*N,B-width*N));
// path_out.push_back(cutter);
}
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 :