From f45e886fef31d000e419216ecb8732b772876455 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 9 Nov 2007 09:48:27 +0000 Subject: Renaming classes: SnappedLine -> SnappedLineSegment, and SnappedInfiniteLine -> SnappedLine (bzr r4048) --- src/snapped-line.cpp | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'src/snapped-line.cpp') diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index 9c7697dc8..663da2e8a 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -1,6 +1,6 @@ /** * \file src/snapped-line.cpp - * \brief SnappedInfiniteLine class. + * \brief SnappedLine class. * * Authors: * Diederik van Lierop @@ -12,7 +12,7 @@ #include "geom.h" #include "libnr/nr-values.h" -Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line) +Inkscape::SnappedLineSegment::SnappedLineSegment(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line) : _start_point_of_line(start_point_of_line), _end_point_of_line(end_point_of_line) { _distance = snapped_distance; @@ -20,7 +20,7 @@ Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_di _at_intersection = false; } -Inkscape::SnappedLine::SnappedLine() +Inkscape::SnappedLineSegment::SnappedLineSegment() { _start_point_of_line = NR::Point(0,0); _end_point_of_line = NR::Point(0,0); @@ -30,11 +30,11 @@ Inkscape::SnappedLine::SnappedLine() } -Inkscape::SnappedLine::~SnappedLine() +Inkscape::SnappedLineSegment::~SnappedLineSegment() { } -Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) const +Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegment const &line) const { //TODO: Diederik, implement the intersection NR::Point const intersection = NR::Point(NR_HUGE, NR_HUGE); @@ -55,7 +55,7 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) -Inkscape::SnappedInfiniteLine::SnappedInfiniteLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line) +Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line) : _normal_to_line(normal_to_line), _point_on_line(point_on_line) { _distance = snapped_distance; @@ -63,7 +63,7 @@ Inkscape::SnappedInfiniteLine::SnappedInfiniteLine(NR::Point snapped_point, NR:: _at_intersection = false; } -Inkscape::SnappedInfiniteLine::SnappedInfiniteLine() +Inkscape::SnappedLine::SnappedLine() { _normal_to_line = NR::Point(0,0); _point_on_line = NR::Point(0,0); @@ -72,13 +72,13 @@ Inkscape::SnappedInfiniteLine::SnappedInfiniteLine() _at_intersection = false; } -Inkscape::SnappedInfiniteLine::~SnappedInfiniteLine() +Inkscape::SnappedLine::~SnappedLine() { } -Inkscape::SnappedPoint Inkscape::SnappedInfiniteLine::intersect(SnappedInfiniteLine const &line) const +Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) const { - // Calculate the intersection of to infinite lines, which are both within snapping range + // Calculate the intersection of to lines, which are both within snapping range // The point of intersection should be considered for snapping, but might be outside the snapping range NR::Point intersection = NR::Point(NR_HUGE, NR_HUGE); @@ -87,11 +87,6 @@ Inkscape::SnappedPoint Inkscape::SnappedInfiniteLine::intersect(SnappedInfiniteL IntersectorKind result = intersector_line_intersection(getNormal(), getConstTerm(), line.getNormal(), line.getConstTerm(), intersection); - /*std::cout << "n0 = " << getNormal() << std::endl; - std::cout << "n1 = " << line.getNormal() << std::endl; - std::cout << "c0 = " << getConstTerm() << std::endl; - std::cout << "c1 = " << line.getConstTerm() << std::endl;*/ - if (result == INTERSECTS) { /* The relevant snapped distance is the distance to the closest snapped line, not the distance to the intersection. For example, when a box is almost aligned with a grid @@ -105,17 +100,15 @@ Inkscape::SnappedPoint Inkscape::SnappedInfiniteLine::intersect(SnappedInfiniteL //std::cout << "Intersected nicely, now getSIL distance = " << distance << std::endl; } - //std::cout << "getSIL distance = " << distance << std::endl; - return SnappedPoint(intersection, distance, result == INTERSECTS); } -// search for the closest snapped infinite line -bool getClosestSIL(std::list &list, Inkscape::SnappedInfiniteLine &result) +// search for the closest snapped line +bool getClosestSL(std::list &list, Inkscape::SnappedLine &result) { bool success = false; - for (std::list::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list::const_iterator i = list.begin(); i != list.end(); i++) { if ((i == list.begin()) || (*i).getDistance() < result.getDistance()) { result = *i; success = true; @@ -125,13 +118,13 @@ bool getClosestSIL(std::list &list, Inkscape::Sna return success; } -// search for the closest intersection of two snapped infinite lines, which are both member of the same collection -bool getClosestIntersectionSIL(std::list &list, Inkscape::SnappedPoint &result) +// search for the closest intersection of two snapped lines, which are both member of the same collection +bool getClosestIntersectionSL(std::list &list, Inkscape::SnappedPoint &result) { bool success = false; - for (std::list::const_iterator i = list.begin(); i != list.end(); i++) { - std::list::const_iterator j = i; + for (std::list::const_iterator i = list.begin(); i != list.end(); i++) { + std::list::const_iterator j = i; j++; for (; j != list.end(); j++) { Inkscape::SnappedPoint sp = (*i).intersect(*j); @@ -148,13 +141,13 @@ bool getClosestIntersectionSIL(std::list &list, I return success; } -// search for the closest intersection of two snapped infinite lines, which are in two different collections -bool getClosestIntersectionSIL(std::list &list1, std::list &list2, Inkscape::SnappedPoint &result) +// search for the closest intersection of two snapped lines, which are in two different collections +bool getClosestIntersectionSL(std::list &list1, std::list &list2, Inkscape::SnappedPoint &result) { bool success = false; - for (std::list::const_iterator i = list1.begin(); i != list1.end(); i++) { - for (std::list::const_iterator j = list2.begin(); j != list2.end(); j++) { + for (std::list::const_iterator i = list1.begin(); i != list1.end(); i++) { + for (std::list::const_iterator j = list2.begin(); j != list2.end(); j++) { Inkscape::SnappedPoint sp = (*i).intersect(*j); if (sp.getAtIntersection()) { if (!success || sp.getDistance() < result.getDistance()) { -- cgit v1.2.3