Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / live_effects / lpe-knot.cpp
index bd9c0ca68b1c12a038bd78c6391ec1fc4164cdce..678bbf8ba070a0aaad8c2b9f69e8f36e5b507fce 100644 (file)
  */
 
 #include "live_effects/lpe-knot.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
 
 #include <2geom/path.h>
-//#include <2geom/sbasis.h>
-//#include <2geom/sbasis-geometric.h>
-//#include <2geom/bezier-to-sbasis.h>
-//#include <2geom/sbasis-to-bezier.h>
 #include <2geom/d2.h>
-//#include <2geom/sbasis-math.h>
-//#include <2geom/piecewise.h>
 #include <2geom/crossing.h>
 #include <2geom/path-intersection.h>
 
@@ -32,7 +24,7 @@ namespace LivePathEffect {
 LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) :
     Effect(lpeobject),
     // initialise your parameters here:
-    interruption_width(_("Interruption width"), _("Howmuch the lower strand is obscured by the upper."), "interruption_width", &wr, this, 10)
+    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:
     registerParameter( dynamic_cast<Parameter *>(&interruption_width) );
@@ -70,7 +62,7 @@ findShadowedTime(Geom::Path &patha,
     if(curveidx == pathb.size() && timeoncurve == 0) { curveidx--; timeoncurve = 0.99999;}
     assert(curveidx >= 0 && curveidx < pathb.size());
     
-    std::vector<Point> MV = pathb[unsigned(curveidx)].pointAndDerivatives(timeoncurve,2);
+    std::vector<Point> MV = pathb[unsigned(curveidx)].pointAndDerivatives(timeoncurve,1);
     Point T = unit_vector(MV.at(1));
     Point N = T.cw();
     Point A = MV.at(0)-10*width*T, B = MV.at(0)+10*width*T;
@@ -101,13 +93,13 @@ findShadowedTime(Geom::Path &patha,
 
 //Just a try; this should be moved to 2geom if ever it works.
 std::vector<Geom::Path>
-split_loopy_bezier (std::vector<Geom::Path> & path_in){
+split_loopy_bezier (std::vector<Geom::Path> const & path_in){
 
     std::vector<Geom::Path> ret; 
-    std::vector<Geom::Path>::iterator pi=path_in.begin();
+    std::vector<Geom::Path>::const_iterator pi=path_in.begin();
     for(; pi != path_in.end(); pi++) {
         ret.push_back(Geom::Path());
-        for (Geom::Path::iterator curve(pi->begin()),end(pi->end()); curve != end; ++curve){
+        for (Geom::Path::const_iterator curve(pi->begin()),end(pi->end()); curve != end; ++curve){
 
             //is the current curve a cubic bezier?
             if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(&(*curve))){
@@ -149,13 +141,13 @@ split_loopy_bezier (std::vector<Geom::Path> & path_in){
 
 
 std::vector<Geom::Path>
-LPEKnot::doEffect_path (std::vector<Geom::Path> & path_in)
+LPEKnot::doEffect_path (std::vector<Geom::Path> const & input_path)
 {
     using namespace Geom;
     std::vector<Geom::Path> path_out;
     double width = interruption_width;
-    
-    path_in = split_loopy_bezier(path_in);
+
+    std::vector<Geom::Path> path_in = split_loopy_bezier(input_path);
 
     CrossingSet crossingTable = crossings_among(path_in);
     for (unsigned i = 0; i < crossingTable.size(); i++){