diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2009-04-12 12:59:26 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2009-04-12 12:59:26 +0000 |
| commit | f917248c6e109da63a0703e85520bac7318d4f39 (patch) | |
| tree | 693d3357e750f360ae68791f3c093ea090567c81 /src/box3d.cpp | |
| parent | Fix snapping during constrained translation, when only snapping the node clos... (diff) | |
| download | inkscape-f917248c6e109da63a0703e85520bac7318d4f39.tar.gz inkscape-f917248c6e109da63a0703e85520bac7318d4f39.zip | |
Use the line intersection routines in 2geom/line.h instead of the deprecated ones in 2geom/geom.h. (I know we're in a refactoring freeze, but this one I was already working on before this freeze was announced and it's quite safe IMHO. It's only a small change in 2geom's API and can hardly do any real harm. I will not refactor anything else until after the v0.47 release, promised!)
(bzr r7688)
Diffstat (limited to 'src/box3d.cpp')
| -rw-r--r-- | src/box3d.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp index 34ce7a27f..5cffa66d9 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -31,7 +31,7 @@ #include "line-geometry.h" #include "persp3d-reference.h" #include "uri.h" -#include <2geom/geom.h> +#include <2geom/line.h> #include "sp-guide.h" #include "sp-namedview.h" #include "preferences.h" @@ -675,17 +675,32 @@ void box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, static bool box3d_half_line_crosses_joining_line (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D) { - Geom::Point E; // the point of intersection Geom::Point n0 = (B - A).ccw(); double d0 = dot(n0,A); Geom::Point n1 = (D - C).ccw(); double d1 = dot(n1,C); - Geom::IntersectorKind intersects = Geom::line_intersection(n0, d0, n1, d1, E); - if (intersects == Geom::coincident || intersects == Geom::parallel) { + + Geom::Line lineAB(A,B); + Geom::Line lineCD(C,D); + + Geom::OptCrossing inters = Geom::OptCrossing(); // empty by default + try + { + inters = Geom::intersection(lineAB, lineCD); + } + catch (Geom::InfiniteSolutions e) + { + // We're probably dealing with parallel lines, so they don't really cross + return false; + } + + if (!inters) { return false; } + Geom::Point E = lineAB.pointAt((*inters).ta); // the point of intersection + if ((dot(C,n0) < d0) == (dot(D,n0) < d0)) { // C and D lie on the same side of the line AB return false; |
