X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-polygon.cpp;h=014c68c9b75652ba8af992a904325b2c0daca8db;hb=f81b968b117e5668618300e85ca5ceaa925b6065;hp=88b155e8e6761060069d3990c3476b983085b23f;hpb=1d41cfe7f3bfb712aa528c5b59a39e1c5b791fbb;p=inkscape.git diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 88b155e8e..014c68c9b 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -18,7 +18,10 @@ #include "sp-polygon.h" #include "display/curve.h" #include -#include "libnr/n-art-bpath.h" +#include <2geom/pathvector.h> +#include <2geom/bezier-curve.h> +#include <2geom/hvlinesegment.h> +#include "helper/geom-curves.h" #include "svg/stringstream.h" #include "xml/repr.h" #include "document.h" @@ -87,27 +90,21 @@ static void sp_polygon_build(SPObject *object, SPDocument *document, Inkscape::X /* * sp_svg_write_polygon: Write points attribute for polygon tag. - * @bpath: - * + * pathv may only contain paths with only straight line segments * Return value: points attribute string. */ -static gchar *sp_svg_write_polygon(const NArtBpath *bpath) +static gchar *sp_svg_write_polygon(Geom::PathVector const & pathv) { - g_return_val_if_fail(bpath != NULL, NULL); - Inkscape::SVGOStringStream os; - for (int i = 0; bpath[i].code != NR_END; i++) { - switch (bpath [i].code) { - case NR_LINETO: - case NR_MOVETO: - case NR_MOVETO_OPEN: - os << bpath [i].x3 << "," << bpath [i].y3 << " "; - break; - - case NR_CURVETO: - default: - g_assert_not_reached(); + for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) { + if ( is_straight_curve(*cit) ) + { + os << cit->finalPoint()[0] << "," << cit->finalPoint()[1] << " "; + } else { + g_error("sp_svg_write_polygon: polygon path contains non-straight line segments"); + } } } @@ -126,8 +123,7 @@ static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::Do } /* We can safely write points here, because all subclasses require it too (Lauris) */ - NArtBpath const * abp = shape->curve->get_bpath(); - gchar *str = sp_svg_write_polygon(abp); + gchar *str = sp_svg_write_polygon(shape->curve->get_pathvector()); repr->setAttribute("points", str); g_free(str);