From df69f3dfcda3daf6007802719b1d393fcdce4c13 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 11 Aug 2014 00:12:33 +0200 Subject: Better helper paths in simplify LPE sugested by suv (bzr r13341.1.132) --- src/live_effects/lpe-simplify.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/live_effects/lpe-simplify.cpp') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 1a02375cd..7334c8588 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -209,7 +209,7 @@ LPESimplify::generateHelperPath(Geom::PathVector result) drawHandle((*cubic)[1]); drawHandle((*cubic)[2]); drawHandleLine((*cubic)[0],(*cubic)[1]); - drawHandleLine((*cubic)[2],(*cubic)[3]); + drawHandleLine((*cubic)[3],(*cubic)[2]); } } if(nodes){ @@ -224,7 +224,7 @@ LPESimplify::generateHelperPath(Geom::PathVector result) drawHandle((*cubic)[1]); drawHandle((*cubic)[2]); drawHandleLine((*cubic)[0],(*cubic)[1]); - drawHandleLine((*cubic)[2],(*cubic)[3]); + drawHandleLine((*cubic)[3],(*cubic)[2]); } } if(nodes){ @@ -238,13 +238,12 @@ LPESimplify::drawNode(Geom::Point p) { double r = helper_size/0.67; char const * svgd; - svgd = "M 0.999993,0.5 C 1.000065,0.7757576 0.7761859,1 0.4999926,1 0.2237994,1 -7.933901e-5,0.7757576 -7.339015e-6,0.5 -7.933901e-5,0.2242424 0.2237994,0 0.4999926,0 0.7761859,0 1.000065,0.2242424 0.999993,0.5 Z m -0.058561,0 C 0.9414949,0.74327 0.7438375,0.9416286 0.4999928,0.9416286 0.2561481,0.9416286 0.0584908,0.74327 0.0585543,0.5 0.0584908,0.25673 0.2561481,0.0583714 0.4999928,0.0583714 0.7438375,0.0583714 0.9414949,0.25673 0.9414313,0.5 Z m -0.3828447,0 c 8.5e-6,0.030303 -0.026228,0.060606 -0.058593,0.060606 -0.032366,0 -0.058603,-0.030303 -0.058593,-0.060606 -8.5e-6,-0.030303 0.026227,-0.060606 0.058593,-0.060606 0.032366,0 0.058603,0.030303 0.058593,0.060606 z"; + svgd = "M 0,-4.270368e-5 1,-4.270368e-5 1,0.9999573 0,0.9999573 Z M 0.5585873,0.5 C 0.5585958,0.530303 0.5323593,0.560606 0.4999943,0.560606 0.4676283,0.560606 0.4413913,0.530303 0.4414013,0.5 0.4413928,0.469697 0.4676283,0.439394 0.4999943,0.439394 0.5323603,0.439394 0.5585973,0.469697 0.5585873,0.5 Z""; Geom::PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Geom::Affine(r,0,0,r,0,0); pathv += p - Geom::Point(0.5*r,0.5*r); hp.push_back(pathv[0]); hp.push_back(pathv[1]); - hp.push_back(pathv[2]); } void @@ -265,6 +264,11 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2) { Geom::Path path; path.start( p ); + if(helper_size > 0.0){ + double diameter = helper_size/0.67; + Geom::Ray ray2(p, p2); + p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); + } path.appendNew( p2 ); hp.push_back(path); } -- cgit v1.2.3 From e4b4e65a3ef6341de82cb314a1339167df2dec19 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 11 Aug 2014 00:31:26 +0200 Subject: fix bug pointed by suv (bzr r13341.1.133) --- src/live_effects/lpe-simplify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects/lpe-simplify.cpp') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 7334c8588..a001069b9 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -238,7 +238,7 @@ LPESimplify::drawNode(Geom::Point p) { double r = helper_size/0.67; char const * svgd; - svgd = "M 0,-4.270368e-5 1,-4.270368e-5 1,0.9999573 0,0.9999573 Z M 0.5585873,0.5 C 0.5585958,0.530303 0.5323593,0.560606 0.4999943,0.560606 0.4676283,0.560606 0.4413913,0.530303 0.4414013,0.5 0.4413928,0.469697 0.4676283,0.439394 0.4999943,0.439394 0.5323603,0.439394 0.5585973,0.469697 0.5585873,0.5 Z""; + svgd = "M 0,-4.270368e-5 1,-4.270368e-5 1,0.9999573 0,0.9999573 Z M 0.5585873,0.5 C 0.5585958,0.530303 0.5323593,0.560606 0.4999943,0.560606 0.4676283,0.560606 0.4413913,0.530303 0.4414013,0.5 0.4413928,0.469697 0.4676283,0.439394 0.4999943,0.439394 0.5323603,0.439394 0.5585973,0.469697 0.5585873,0.5 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Geom::Affine(r,0,0,r,0,0); pathv += p - Geom::Point(0.5*r,0.5*r); -- cgit v1.2.3 From 34efde17371ebac38ad634b81496fc578357fc1e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 11 Aug 2014 03:38:48 +0200 Subject: Simplify original paths on helper paths pointed by Liam. Also used arcs for handles pointed by suv (bzr r13341.1.134) --- src/live_effects/lpe-simplify.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/live_effects/lpe-simplify.cpp') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index a001069b9..c4c2d449b 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -238,7 +238,7 @@ LPESimplify::drawNode(Geom::Point p) { double r = helper_size/0.67; char const * svgd; - svgd = "M 0,-4.270368e-5 1,-4.270368e-5 1,0.9999573 0,0.9999573 Z M 0.5585873,0.5 C 0.5585958,0.530303 0.5323593,0.560606 0.4999943,0.560606 0.4676283,0.560606 0.4413913,0.530303 0.4414013,0.5 0.4413928,0.469697 0.4676283,0.439394 0.4999943,0.439394 0.5323603,0.439394 0.5585973,0.469697 0.5585873,0.5 Z"; + svgd = "M 0.55,0.5 A 0.05,0.05 0 0 1 0.5,0.55 0.05,0.05 0 0 1 0.45,0.5 0.05,0.05 0 0 1 0.5,0.45 0.05,0.05 0 0 1 0.55,0.5 Z M 0,0 1,0 1,1 0,1 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Geom::Affine(r,0,0,r,0,0); pathv += p - Geom::Point(0.5*r,0.5*r); @@ -251,7 +251,7 @@ LPESimplify::drawHandle(Geom::Point p) { double r = helper_size/0.67; char const * svgd; - svgd = "M 0.6999623,0.35 C 0.7000128,0.5430303 0.5433044,0.7 0.3499775,0.7 0.1566506,0.7 -5.778776e-5,0.5430303 -7.344202e-6,0.35 -5.778776e-5,0.1569697 0.1566506,0 0.3499775,0 0.5433044,0 0.7000128,0.1569697 0.6999623,0.35 Z"; + svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Geom::Affine(r,0,0,r,0,0); pathv += p - Geom::Point(0.35*r,0.35*r); -- cgit v1.2.3 From 50ab28bfaaf986c4dd0cc363cc3c9cd0f15b82c2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 11 Aug 2014 05:11:03 +0200 Subject: Code refactor: now helper paths draw ok when handle is degenerate or cirle handle is biger then the distance to node. also remove code duplication at loop (bzr r13341.1.136) --- src/live_effects/lpe-simplify.cpp | 50 +++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'src/live_effects/lpe-simplify.cpp') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index c4c2d449b..a817f30f1 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -202,33 +202,27 @@ LPESimplify::generateHelperPath(Geom::PathVector result) if(nodes){ drawNode(curve_it1->initialPoint()); } - while (curve_it2 != curve_endit) { - cubic = dynamic_cast(&*curve_it1); - if (cubic) { - if(handles){ - drawHandle((*cubic)[1]); - drawHandle((*cubic)[2]); - drawHandleLine((*cubic)[0],(*cubic)[1]); - drawHandleLine((*cubic)[3],(*cubic)[2]); + while (curve_it1 != curve_endit) { + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + if(handles) { + if(!are_near((*cubic)[0],(*cubic)[1])){ + drawHandle((*cubic)[1]); + drawHandleLine((*cubic)[0],(*cubic)[1]); + } + if(!are_near((*cubic)[3],(*cubic)[2])){ + drawHandle((*cubic)[2]); + drawHandleLine((*cubic)[3],(*cubic)[2]); + } + } + } + if(nodes) { + drawNode(curve_it1->finalPoint()); + } + ++curve_it1; + if(curve_it2 != curve_endit){ + ++curve_it2; } - } - if(nodes){ - drawNode(curve_it1->finalPoint()); - } - ++curve_it1; - ++curve_it2; - } - cubic = dynamic_cast(&*curve_it1); - if (cubic) { - if(handles){ - drawHandle((*cubic)[1]); - drawHandle((*cubic)[2]); - drawHandleLine((*cubic)[0],(*cubic)[1]); - drawHandleLine((*cubic)[3],(*cubic)[2]); - } - } - if(nodes){ - drawNode(curve_it1->finalPoint()); } } } @@ -264,8 +258,8 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2) { Geom::Path path; path.start( p ); - if(helper_size > 0.0){ - double diameter = helper_size/0.67; + double diameter = helper_size/0.67; + if(helper_size > 0.0 && Geom::distance(p,p2) > (diameter * 0.35)){ Geom::Ray ray2(p, p2); p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); } -- cgit v1.2.3