summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-knot.cpp3
-rw-r--r--src/live_effects/lpe-powerstroke.cpp104
-rw-r--r--src/live_effects/lpe-rough-hatches.cpp8
3 files changed, 58 insertions, 57 deletions
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index 7a66b80c9..7ec103a85 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -94,7 +94,8 @@ findShadowedTime(Geom::Path const &patha, std::vector<Geom::Point> const &pt_and
using namespace Geom;
Point T = unit_vector(pt_and_dir[1]);
Point N = T.cw();
- Point A = pt_and_dir[0]-3*width*T, B = A+6*width*T;
+ //Point A = pt_and_dir[0] - 3 * width * T;
+ //Point B = A+6*width*T;
Affine mat = from_basis( T, N, pt_and_dir[0] );
mat = mat.inverse();
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index a9cf22f6a..44f9b9eb0 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -209,7 +209,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
Geom::Piecewise<Geom::SBasis> const & y, // width path
LineJoinType jointype,
double miter_limit,
- bool forward_direction,
+ bool /*forward_direction*/,
double tol=Geom::EPSILON)
{
/* per definition, each discontinuity should be fixed with a join-ending, as defined by linejoin_type
@@ -238,10 +238,10 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
Geom::Point discontinuity_vec = B[i].at0() - B[prev_i].at1();
bool on_outside = ( dot(tang1, discontinuity_vec) >= 0. );
- switch (jointype) {
- case LINEJOIN_ROUND: {
- if (on_outside) {
- // we are on the outside: round corner
+ if (on_outside) {
+ // we are on the outside: add some type of join!
+ switch (jointype) {
+ case LINEJOIN_ROUND: {
/* for constant width paths, the rounding is a circular arc (rx == ry),
for non-constant width paths, the rounding can be done with an ellipse but is hard and ambiguous.
The elliptical arc should go through the discontinuity's start and end points (of course!)
@@ -258,30 +258,23 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
break;
}
- Geom::Ellipse ellipse = find_ellipse(B[prev_i].at1(), B[i].at0(), *O);
+ Geom::Ellipse ellipse;
+ try {
+ ellipse = find_ellipse(B[prev_i].at1(), B[i].at0(), *O);
+ }
+ catch (Geom::LogicalError &e) {
+ // 2geom did not find a fitting ellipse, this happens for weird thick paths :)
+ // do bevel, and break
+ pb.lineTo(B[i].at0());
+ break;
+ }
+
pb.arcTo( ellipse.ray(Geom::X), ellipse.ray(Geom::Y), ellipse.rot_angle(),
false, width < 0, B[i].at0() );
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
- }
- break;
- }
-/* case LINEJOIN_NONE: {
- if ( on_outside ) {
- // we are on the outside
- Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width;
- pb.lineTo(point_on_path);
- pb.lineTo(B[i].at0());
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
- }
- } */
- case LINEJOIN_EXTRP_MITER: {
- if (on_outside) {
- // we are on the outside, do something complicated to make it look good ;)
+ break;
+ }
+ case LINEJOIN_EXTRP_MITER: {
Geom::D2<Geom::SBasis> newcurve1 = B[prev_i] * Geom::reflection(rot90(tang1), B[prev_i].at1());
Geom::CubicBezier bzr1 = sbasis_to_cubicbezier( reverse(newcurve1) );
@@ -306,17 +299,9 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
pb.curveTo(sub2.second[1], sub2.second[2], sub2.second[3]);
}
}
-
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
+ break;
}
- break;
- }
- case LINEJOIN_MITER: {
- if (on_outside) {
- // we are on the outside, do something complicated to make it look good ;)
-
+ case LINEJOIN_MITER: {
boost::optional<Geom::Point> p = intersection_point( B[prev_i].at1(), tang1,
B[i].at0(), tang2 );
if (p) {
@@ -329,14 +314,9 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
}
}
pb.lineTo(B[i].at0());
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
+ break;
}
- break;
- }
- case LINEJOIN_SPIRO: {
- if (on_outside) {
+ case LINEJOIN_SPIRO: {
Geom::Point direction = B[i].at0() - B[prev_i].at1();
double tang1_sign = dot(direction,tang1);
double tang2_sign = dot(direction,tang2);
@@ -358,19 +338,39 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
Geom::Path spiro;
Spiro::spiro_run(controlpoints, 4, spiro);
pb.append(spiro.portion(1,spiro.size_open()-1), Geom::Path::STITCH_DISCONTINUOUS);
+ break;
+ }
+ case LINEJOIN_BEVEL:
+ default:
+ pb.lineTo(B[i].at0());
+ break;
+ }
+
+ build_from_sbasis(pb, B[i], tol, false);
+
+ } else {
+ // we are on inside of corner!
+ Geom::Path bzr1 = path_from_sbasis( B[prev_i], tol );
+ Geom::Path bzr2 = path_from_sbasis( B[i], tol );
+ Geom::Crossings cross = crossings(bzr1, bzr2);
+ if (cross.size() != 1) {
+ // empty crossing or too many crossings: default to bevel
+ pb.lineTo(B[i].at0());
+ pb.append(bzr2, Geom::Path::STITCH_DISCONTINUOUS);
} else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
+ // :-) quick hack:
+ for (unsigned i=0; i < bzr1.size_open(); ++i) {
+ pb.backspace();
+ }
+
+ pb.append( bzr1.portion(0, cross[0].ta), Geom::Path::STITCH_DISCONTINUOUS );
+ pb.append( bzr2.portion(cross[0].tb, bzr2.size_open()), Geom::Path::STITCH_DISCONTINUOUS );
}
- break;
- }
- case LINEJOIN_BEVEL:
- default:
- pb.lineTo(B[i].at0());
- break;
}
+ } else {
+ build_from_sbasis(pb, B[i], tol, false);
}
- build_from_sbasis(pb, B[i], tol, false);
+
prev_i = i;
}
pb.finish();
diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp
index f9ab72373..fb3d143aa 100644
--- a/src/live_effects/lpe-rough-hatches.cpp
+++ b/src/live_effects/lpe-rough-hatches.cpp
@@ -440,8 +440,8 @@ LPERoughHatches::smoothSnake(std::vector<std::vector<Point> > const &linearSnake
for (unsigned comp=0; comp<linearSnake.size(); comp++){
if (linearSnake[comp].size()>=2){
Point last_pt = linearSnake[comp][0];
- Point last_top = linearSnake[comp][0];
- Point last_bot = linearSnake[comp][0];
+ //Point last_top = linearSnake[comp][0];
+ //Point last_bot = linearSnake[comp][0];
Point last_hdle = linearSnake[comp][0];
Point last_top_hdle = linearSnake[comp][0];
Point last_bot_hdle = linearSnake[comp][0];
@@ -482,8 +482,8 @@ LPERoughHatches::smoothSnake(std::vector<std::vector<Point> > const &linearSnake
if ( fat_output.get_value() ){
//double scaled_width = double((is_top ? stroke_width_top : stroke_width_bot))/(pt1[X]-pt0[X]);
- double scaled_width = 1./(pt1[X]-pt0[X]);
- Point hdle_offset = (pt1-pt0)*scaled_width;
+ //double scaled_width = 1./(pt1[X]-pt0[X]);
+ //Point hdle_offset = (pt1-pt0)*scaled_width;
Point inside = new_pt;
Point inside_hdle_in;
Point inside_hdle_out;