lpe-powerstroke.cpp revision 7ef929c9f7a586c21eacd035f6c0ebf7af3cf36d
#define INKSCAPE_LPE_POWERSTROKE_CPP
/** \file
* @brief PowerStroke LPE implementation. Creates curves with modifiable stroke width.
*/
/* Authors:
* Johan Engelen <j.b.c.engelen@utwente.nl>
*
* Copyright (C) 2010 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-powerstroke.h"
#include "sp-shape.h"
#include "live_effects/bezctx.h"
#include "live_effects/bezctx_intf.h"
#include "live_effects/spiro.h"
/// @TODO Move this to 2geom
namespace Geom {
namespace Interpolate {
enum InterpolatorType {
};
class Interpolator {
public:
Interpolator() {};
virtual ~Interpolator() {};
// virtual Piecewise<D2<SBasis> > interpolateToPwD2Sb(std::vector<Point> points) = 0;
private:
Interpolator(const Interpolator&);
Interpolator& operator=(const Interpolator&);
};
class Linear : public Interpolator {
public:
Linear() {};
virtual ~Linear() {};
}
return path;
};
private:
};
// this class is terrible
class CubicBezierFit : public Interpolator {
public:
CubicBezierFit() {};
virtual ~CubicBezierFit() {};
// worst case gives us 2 segment per point
for (unsigned i = 0; i < n_points; ++i) {
}
double tolerance_sq = 0; // this value is just a random guess
if ( n_segs > 0)
{
for (int c = 0; c < n_segs; c++) {
}
}
g_free(b);
return fit;
};
private:
CubicBezierFit(const CubicBezierFit&);
CubicBezierFit& operator=(const CubicBezierFit&);
};
/// @todo invent name for this class
class CubicBezierJohan : public Interpolator {
public:
CubicBezierJohan() {};
virtual ~CubicBezierJohan() {};
}
return fit;
};
private:
CubicBezierJohan(const CubicBezierJohan&);
CubicBezierJohan& operator=(const CubicBezierJohan&);
};
class SpiroInterpolator : public Interpolator {
public:
SpiroInterpolator() {};
virtual ~SpiroInterpolator() {};
for (unsigned int i = 0; i < len; ++i) {
controlpoints[i].x = points[i][X];
}
free(s);
return fit;
};
private:
typedef struct {
int is_open;
} bezctx_ink;
{
}
else {
g_message("spiro moveto not finite");
}
#endif
}
{
}
else {
g_message("spiro lineto not finite");
}
#endif
}
{
}
else {
g_message("spiro quadto not finite");
}
#endif
}
{
}
else {
g_message("spiro curveto not finite");
}
#endif
}
bezctx *
}
SpiroInterpolator(const SpiroInterpolator&);
SpiroInterpolator& operator=(const SpiroInterpolator&);
};
switch (type) {
case INTERP_LINEAR:
case INTERP_CUBICBEZIER:
case INTERP_CUBICBEZIER_JOHAN:
case INTERP_SPIRO:
default:
}
}
} //namespace Interpolate
} //namespace Geom
namespace Inkscape {
namespace LivePathEffect {
};
static const Util::EnumDataConverter<unsigned> InterpolatorTypeConverter(InterpolatorTypeData, sizeof(InterpolatorTypeData)/sizeof(*InterpolatorTypeData));
sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true),
interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN)
{
show_orig_path = true;
/// @todo offset_points are initialized with empty path, is that bug-save?
}
{
}
void
{
}
{
}
{
using namespace Geom;
// see if we should treat the path as being closed.
bool closed_path = false;
closed_path = true;
}
if (!closed_path) {
// perhaps use std::list instead of std::vector?
// first and last point coincide with input path (for now at least)
}
if (sort_points) {
}
// create stroke path where points (x,y) := (t, offset)
Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value()));
delete interpolator;
strokepath.close();
} else {
// path is closed
// perhaps use std::list instead of std::vector?
if (sort_points) {
}
// add extra points for interpolation between first and last point
// create stroke path where points (x,y) := (t, offset)
Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value()));
delete interpolator;
// output 2 separate paths
// find time values for which x lies outside path domain
// and only take portion of x and y that lies within those time values
}
x = reverse(x);
y = reverse(y);
}
return output;
}
/* ######################## */
} //namespace LivePathEffect
} /* 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:fileencoding=utf-8:textwidth=99 :