n-art-bpath-2geom.cpp revision 29684a16b6c92bee28a94fdc2607bcc143950fa8
#define SEEN_LIBNR_N_ART_BPATH_2GEOM_CPP
/** \file
* Contains functions to convert from NArtBpath to 2geom's Path
*
* 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/n-art-bpath-2geom.h"
#include <glib.h>
#define LPE_USE_2GEOM_CONVERSION
//##########################################################
#include <iostream>
#include <sstream>
#include <string>
#include <boost/format.hpp>
}
else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast<Geom::QuadraticBezier const *>(c)) {
}
}
// else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::SVGEllipticalArc *>(c)) {
// //get at the innards and spit them out as svgd
// }
else {
//this case handles sbasis as well as all other curve types
//recurse to convert the new path resulting from the sbasis to svgd
curve_to_svgd(f, &(*iter));
}
}
}
if(f == NULL) {
f << "ERRRRRRORRRRR";
return;
}
curve_to_svgd(f, &(*iter));
}
if(p.closed())
f << "Z ";
}
write_svgd(f, *it);
}
}
//##########################################################
#ifndef LPE_USE_2GEOM_CONVERSION
static
}
using namespace Geom;
class OldPathBuilder {
public:
}
}
_current_point = p1;
}
void pushLineRel(Point const &p0, Point const &p1) { pushLine(p0 + _current_point, p1 + _current_point); }
}
void pushHorizontal(Coord y) {
}
void pushVertical(Coord x) {
}
void pushQuadraticRel(Point const &p1, Point const &p2) { pushQuadratic(p1 + _current_point, p2 + _current_point); }
_current_point = p2;
}
}
}
}
_current_point = p3;
}
}
}
/*
void pushEllipseRel(Point const &radii, double rotation, bool large, bool sweep, Point const &end) {
pushEllipse(radii, rotation, large, sweep, end + _current_point);
}
void pushEllipse(Point const &radii, double rotation, bool large, bool sweep, Point const &end) {
if (!_current_path) startPath(_current_point);
_current_path->append(SVGEllipticalArc(_current_point, radii[0], radii[1], rotation, large, sweep, end));
_current_point = end;
}
void pushEllipseRel(Point const &initial, Point const &radii, double rotation, bool large, bool sweep, Point const &end) {
pushEllipse(initial + _current_point, radii, rotation, large, sweep, end + _current_point);
}
void pushEllipse(Point const &initial, Point const &radii, double rotation, bool large, bool sweep, Point const &end) {
if(initial != _current_point) startPath(initial);
pushEllipse(radii, rotation, large, sweep, end);
}*/
}
} else if (_current_point != initial) {
/* in this case there are three possible options
1. connect the points with tiny line segments
this may well translate into bug reports from
users claiming "duplicate or extraneous nodes"
2. fudge the initial point of the multidimsb
we've chosen to do this here but question the
numerical stability of this decision
3. translate the whole sbasis so that initial is coincident
with _current_point. this could very well lead
to an accumulation of error for paths that expect
to meet in the end.
perhaps someday an option could be made to allow
the user to choose between these alternatives
if the need arises
*/
sb[X][0][0] = _current_point[X];
sb[Y][0][0] = _current_point[Y];
}
}
void closePath() {
if (_current_path) {
_current_path->close(true);
}
}
private:
double _continuity_tollerance;
};
static
assert(s);
char mode = 0;
double nums[7];
int cur = 0;
while(!s.eof()) {
char ch;
s >> ch;
cur = 0;
continue;
s.unget();
//TODO: use something else, perhaps. Unless the svg path number spec matches scan.
cur++;
}
switch(mode) {
//FIXME: "If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands."
case 'm':
if(cur >= 2) {
cur = 0;
}
break;
case 'M':
if(cur >= 2) {
cur = 0;
}
break;
case 'l':
if(cur >= 2) {
cur = 0;
}
break;
case 'L':
if(cur >= 2) {
cur = 0;
}
break;
case 'h':
if(cur >= 1) {
cur = 0;
}
break;
case 'H':
if(cur >= 1) {
cur = 0;
}
break;
case 'v':
if(cur >= 1) {
cur = 0;
}
break;
case 'V':
if(cur >= 1) {
cur = 0;
}
break;
case 'c':
if(cur >= 6) {
cur = 0;
}
break;
case 'C':
if(cur >= 6) {
cur = 0;
}
break;
case 'q':
if(cur >= 4) {
cur = 0;
}
break;
case 'Q':
if(cur >= 4) {
cur = 0;
}
break;
case 'a':
if(cur >= 7) {
//builder.pushEllipseRel(point(nums, 0), nums[2], nums[3] > 0, nums[4] > 0, point(nums, 5));
cur = 0;
}
break;
case 'A':
if(cur >= 7) {
//builder.pushEllipse(point(nums, 0), nums[2], nums[3] > 0, nums[4] > 0, point(nums, 5));
cur = 0;
}
break;
case 'z':
case 'Z':
break;
}
}
}
#endif
//##########################################################
SVGD_to_2GeomPath (char const *svgd)
{
#ifdef LPE_USE_2GEOM_CONVERSION
try {
}
catch (std::runtime_error e) {
}
#else
#endif
return pathv;
}
{
if (!svgpath) {
g_warning("BPath_to_2GeomPath - empty path returned");
return pathv;
}
return pathv;
}
char *
{
return svgd;
}
{
return bpath;
}
/*
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 :