diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 5e8e763f5dc415d71769d08e7d024f3ee66c43d5..8ce1c293543772cb9dee64297191359d2b1fdf42 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -138,6 +138,35 @@ cubic_bbox (Geom::Coord x000, Geom::Coord y000, Geom::Coord x001, Geom::Coord y0 } } +bool +geom_pathv_compare(Geom::PathVector apv, Geom::PathVector bpv, double precission) +{ + size_t totala = apv.curveCount(); + size_t totalb = bpv.curveCount(); + if (totala != totalb) { + return false; + } + std::vector pos; + for (size_t i = 0; i < apv.curveCount(); i++) { + Geom::Point pointa = apv.pointAt(float(i)+0.2); + Geom::Point pointb = bpv.pointAt(float(i)+0.2); + Geom::Point pointc = apv.pointAt(float(i)+0.4); + Geom::Point pointd = bpv.pointAt(float(i)+0.4); + Geom::Point pointe = apv.pointAt(float(i)); + Geom::Point pointf = bpv.pointAt(float(i)); + if (!Geom::are_near(pointa[Geom::X], pointb[Geom::X], precission) || + !Geom::are_near(pointa[Geom::Y], pointb[Geom::Y], precission) || + !Geom::are_near(pointc[Geom::X], pointd[Geom::X], precission) || + !Geom::are_near(pointc[Geom::Y], pointd[Geom::Y], precission) || + !Geom::are_near(pointe[Geom::X], pointf[Geom::X], precission) || + !Geom::are_near(pointe[Geom::Y], pointf[Geom::Y], precission)) + { + return false; + } + } + return true; +} + Geom::OptRect bounds_fast_transformed(Geom::PathVector const & pv, Geom::Affine const & t) { diff --git a/src/helper/geom.h b/src/helper/geom.h index 58f323efee45eb133d8512d2c2b530dac77e04ec..e33a39f0b9da89db21e66d41d9d078a961fcf7ab 100644 --- a/src/helper/geom.h +++ b/src/helper/geom.h @@ -28,6 +28,7 @@ void pathv_matrix_point_bbox_wind_distance ( Geom::PathVector const & pathv, Geo size_t count_pathvector_nodes(Geom::PathVector const &pathv ); size_t count_path_nodes(Geom::Path const &path); +bool geom_path_compare(Geom::PathVector apv, Geom::PathVector bpv, double precission = 0.001); Geom::PathVector pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ); Geom::PathVector pathv_to_linear( Geom::PathVector const &pathv, double maxdisp ); Geom::PathVector pathv_to_cubicbezier( Geom::PathVector const &pathv); diff --git a/src/object/sp-ellipse.cpp b/src/object/sp-ellipse.cpp index ac216e1e0a7ff61a31b0a2142d6080c63bd8f6b0..8bed6f32c5fab44994ec4dad34dd80bc8e8fbd35 100644 --- a/src/object/sp-ellipse.cpp +++ b/src/object/sp-ellipse.cpp @@ -21,7 +21,7 @@ #include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" - +#include "helper/geom.h" #include <2geom/angle.h> #include <2geom/circle.h> #include <2geom/ellipse.h> @@ -476,9 +476,9 @@ void SPGenericEllipse::set_shape() /* Reset the shape's curve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ auto const before = this->curveBeforeLPE(); - if (before && before->get_pathvector() != c->get_pathvector()) { + if (before && !geom_pathv_compare(before->get_pathvector(), c->get_pathvector(), 0.01)) { setCurveBeforeLPE(std::move(c)); - sp_lpe_item_update_patheffect(this, true, false); + sp_lpe_item_update_patheffect(this, false, false); return; } diff --git a/src/object/sp-rect.cpp b/src/object/sp-rect.cpp index 641c3069d18304d066b5f1cc48d11fb0380b756f..a03cb4a236137c2e7841dc67ab2659b0d104e877 100644 --- a/src/object/sp-rect.cpp +++ b/src/object/sp-rect.cpp @@ -22,6 +22,7 @@ #include "sp-guide.h" #include "preferences.h" #include "svg/svg.h" +#include "helper/geom.h" #include #define noRECT_VERBOSE @@ -287,9 +288,9 @@ void SPRect::set_shape() { * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ auto const before = this->curveBeforeLPE(); - if (before && before->get_pathvector() != c->get_pathvector()) { + if (before && !geom_pathv_compare(before->get_pathvector(), c->get_pathvector(), 0.01)) { setCurveBeforeLPE(std::move(c)); - sp_lpe_item_update_patheffect(this, true, false); + sp_lpe_item_update_patheffect(this, false, false); return; } if (this->hasPathEffectOnClipOrMaskRecursive(this)) { diff --git a/src/object/sp-spiral.cpp b/src/object/sp-spiral.cpp index 10872057040ed4dc901129f628bd0425b807ce69..78082859a79e1633ed47bcee5225018b6d1b00d6 100644 --- a/src/object/sp-spiral.cpp +++ b/src/object/sp-spiral.cpp @@ -23,6 +23,7 @@ #include "display/curve.h" #include #include "xml/repr.h" +#include "helper/geom.h" #include "document.h" #include "sp-spiral.h" @@ -345,9 +346,9 @@ void SPSpiral::set_shape() { * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ auto const before = this->curveBeforeLPE(); - if (before && before->get_pathvector() != c->get_pathvector()) { + if (before && !geom_pathv_compare(before->get_pathvector(), c->get_pathvector(), 0.01)) { setCurveBeforeLPE(std::move(c)); - sp_lpe_item_update_patheffect(this, true, false); + sp_lpe_item_update_patheffect(this, false, false); return; } diff --git a/src/object/sp-star.cpp b/src/object/sp-star.cpp index 0fa820cca01960075e4521e16b5cde4b62addfbe..df8c790ba4c94da6f4bd2c50ff51488bf2e176c8 100644 --- a/src/object/sp-star.cpp +++ b/src/object/sp-star.cpp @@ -26,6 +26,7 @@ #include "document.h" #include "sp-star.h" +#include "helper/geom.h" #include SPStar::SPStar() : SPShape() , @@ -427,9 +428,9 @@ void SPStar::set_shape() { * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ auto const before = this->curveBeforeLPE(); - if (before && before->get_pathvector() != c->get_pathvector()) { + if (before && !geom_pathv_compare(before->get_pathvector(), c->get_pathvector(), 0.01)) { setCurveBeforeLPE(std::move(c)); - sp_lpe_item_update_patheffect(this, true, false); + sp_lpe_item_update_patheffect(this, false, false); return; }