|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78291 - in sandbox/gtl: boost/polygon doc libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-05-01 07:34:08
Author: asydorchuk
Date: 2012-05-01 07:34:07 EDT (Tue, 01 May 2012)
New Revision: 78291
URL: http://svn.boost.org/trac/boost/changeset/78291
Log:
Updating tests/docs/sources for segment concept.
Text files modified:
sandbox/gtl/boost/polygon/segment_concept.hpp | 187 +++++++++++++++++----------------------
sandbox/gtl/doc/gtl_segment_concept.htm | 154 +++++++++++++++++---------------
sandbox/gtl/libs/polygon/test/polygon_segment_test.cpp | 59 +++++++++--
3 files changed, 207 insertions(+), 193 deletions(-)
Modified: sandbox/gtl/boost/polygon/segment_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/segment_concept.hpp (original)
+++ sandbox/gtl/boost/polygon/segment_concept.hpp 2012-05-01 07:34:07 EDT (Tue, 01 May 2012)
@@ -534,7 +534,46 @@
return segment;
}
-struct y_s_e_intersects : gtl_yes {};
+ struct y_s_abuts1 : gtl_yes {};
+
+ template <typename Segment1, typename Segment2>
+ typename enable_if<
+ typename gtl_and_3<
+ y_s_abuts1,
+ typename is_segment_concept<
+ typename geometry_concept<Segment1>::type
+ >::type,
+ typename is_segment_concept<
+ typename geometry_concept<Segment2>::type
+ >::type
+ >::type,
+ bool
+ >::type
+ abuts(const Segment1& segment1, const Segment2& segment2, direction_1d dir) {
+ return dir.to_int() ? equivalence(low(segment2) , high(segment1)) :
+ equivalence(low(segment1) , high(segment2));
+ }
+
+ struct y_s_abuts2 : gtl_yes {};
+
+ template <typename Segment1, typename Segment2>
+ typename enable_if<
+ typename gtl_and_3<
+ y_s_abuts2,
+ typename is_segment_concept<
+ typename geometry_concept<Segment1>::type
+ >::type,
+ typename is_segment_concept<
+ typename geometry_concept<Segment2>::type
+ >::type
+ >::type,
+ bool
+ >::type
+ abuts(const Segment1& segment1, const Segment2& segment2) {
+ return abuts(segment1, segment2, HIGH) || abuts(segment1, segment2, LOW);
+ }
+
+ struct y_s_e_intersects : gtl_yes {};
template <typename Segment1, typename Segment2>
typename enable_if<
@@ -568,6 +607,48 @@
typename paf::half_edge(l2, h2));
}
+ struct y_s_intersect : gtl_yes {};
+
+ // Set point to the intersection of segment and b
+ template <typename Point, typename Segment1, typename Segment2>
+ typename enable_if<
+ typename gtl_and_4<
+ y_s_intersect,
+ typename is_mutable_point_concept<
+ typename geometry_concept<Point>::type
+ >::type,
+ typename is_segment_concept<
+ typename geometry_concept<Segment1>::type
+ >::type,
+ typename is_segment_concept<
+ typename geometry_concept<Segment2>::type
+ >::type
+ >::type,
+ bool
+ >::type
+ intersection(Point& intersection,
+ const Segment1& segment1,
+ const Segment2& segment2,
+ bool projected = false,
+ bool round_closest = false) {
+ typedef polygon_arbitrary_formation<
+ typename segment_coordinate_type<Segment1>::type
+ > paf;
+ typename paf::Point pt;
+ typename paf::Point l1, h1, l2, h2;
+ assign(l1, low(segment1));
+ assign(h1, high(segment1));
+ assign(l2, low(segment2));
+ assign(h2, high(segment2));
+ typename paf::half_edge he1(l1, h1), he2(l2, h2);
+ typename paf::compute_intersection_pack pack;
+ if (pack.compute_intersection(pt, he1, he2, projected, round_closest)) {
+ assign(intersection, pt);
+ return true;
+ }
+ return false;
+ }
+
struct y_s_e_dist : gtl_yes {};
template <typename Segment, typename Point>
@@ -638,110 +719,6 @@
return (subres1 < subres2) ? subres1 : subres2;
}
- struct y_s_abuts1 : gtl_yes {};
-
- template <typename Segment1, typename Segment2>
- typename enable_if<
- typename gtl_and_3<
- y_s_abuts1,
- typename is_segment_concept<
- typename geometry_concept<Segment1>::type
- >::type,
- typename is_segment_concept<
- typename geometry_concept<Segment2>::type
- >::type
- >::type,
- bool
- >::type
- abuts(const Segment1& segment1, const Segment2& segment2, direction_1d dir) {
- return dir.to_int() ? equivalence(low(segment2) , high(segment1)) :
- equivalence(low(segment1) , high(segment2));
- }
-
- struct y_s_abuts2 : gtl_yes {};
-
- template <typename Segment1, typename Segment2>
- typename enable_if<
- typename gtl_and_3<
- y_s_abuts2,
- typename is_segment_concept<
- typename geometry_concept<Segment1>::type
- >::type,
- typename is_segment_concept<
- typename geometry_concept<Segment2>::type
- >::type
- >::type,
- bool
- >::type
- abuts(const Segment1& segment1, const Segment2& segment2) {
- return abuts(segment1, segment2, HIGH) || abuts(segment1, segment2, LOW);
- }
-
- struct y_s_e_bintersect : gtl_yes {};
-
- template <typename Segment1, typename Segment2>
- typename enable_if<
- typename gtl_and_3<
- y_s_e_bintersect,
- typename is_segment_concept<
- typename geometry_concept<Segment1>::type
- >::type,
- typename is_segment_concept<
- typename geometry_concept<Segment2>::type
- >::type
- >::type,
- bool
- >::type
- boundaries_intersect(const Segment1& segment1, const Segment2& segment2,
- bool consider_touch = true) {
- return (contains(segment1, low(segment2), consider_touch) ||
- contains(segment1, high(segment2), consider_touch)) &&
- (contains(segment2, low(segment1), consider_touch) ||
- contains(segment2, high(segment1), consider_touch));
- }
-
- struct y_s_intersect : gtl_yes {};
-
- // Set point to the intersection of segment and b
- template <typename Point, typename Segment1, typename Segment2>
- typename enable_if<
- typename gtl_and_4<
- y_s_intersect,
- typename is_mutable_point_concept<
- typename geometry_concept<Point>::type
- >::type,
- typename is_segment_concept<
- typename geometry_concept<Segment1>::type
- >::type,
- typename is_segment_concept<
- typename geometry_concept<Segment2>::type
- >::type
- >::type,
- bool
- >::type
- intersection(Point& intersection,
- const Segment1& segment1,
- const Segment2& segment2,
- bool projected = false,
- bool round_closest = false) {
- typedef polygon_arbitrary_formation<
- typename segment_coordinate_type<Segment1>::type
- > paf;
- typename paf::Point pt;
- typename paf::Point l1, h1, l2, h2;
- assign(l1, low(segment1));
- assign(h1, high(segment1));
- assign(l2, low(segment2));
- assign(h2, high(segment2));
- typename paf::half_edge he1(l1, h1), he2(l2, h2);
- typename paf::compute_intersection_pack pack;
- if (pack.compute_intersection(pt, he1, he2, projected, round_closest)) {
- assign(intersection, pt);
- return true;
- }
- return false;
- }
-
template <class T>
template <class Segment>
segment_data<T>& segment_data<T>::operator=(const Segment& rvalue) {
Modified: sandbox/gtl/doc/gtl_segment_concept.htm
==============================================================================
--- sandbox/gtl/doc/gtl_segment_concept.htm (original)
+++ sandbox/gtl/doc/gtl_segment_concept.htm 2012-05-01 07:34:07 EDT (Tue, 01 May 2012)
@@ -1,5 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"><head><!--
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"><head>
+<!--
Copyright 2009-2010 Intel Corporation
license banner
--><title>Boost Polygon Library: Segment Concept</title>
@@ -9,6 +10,8 @@
+
+
@@ -88,7 +91,7 @@
<h1>Segment Concept</h1>
<p> </p>
<p> The segment concept tag is <font face="Courier New">segment_concept</font></p>
- <p> To register a user defined type as a model of segment
+ <p> To register a user defined type as a model of the segment
concept, specialize the geometry concept meta-function for that
type. In the example below CSegment is registered as a model of
the segment concept.</p>
@@ -96,10 +99,9 @@
struct geometry_concept<</font>CSegment<font face="Courier New">>
{ typedef segment_concept type; };</font></p>
<p> The semantic of a segment is
-that it has an low and high point. A
-std::pair<std::pair<int, int>, std::pair<int,int>>,
-boost::tuple<boost::tuple<int, int>, boost::tuple<int,
-int>> or boost::array<int, 4> could all be made models of
+that it has a low and high point. A
+std::pair<Point, Point>,
+boost::tuple<Point, Point> or boost::array<Point, 2> could all be made models of
segment by simply providing indirect access to their elements through
traits, however, these objects cannot be made a model of both segment
and interval in the same compilation unit, for obvious reason that
@@ -107,9 +109,10 @@
also because it would make overloading generic function by concept
ambiguous if a type modeled more than one concept.</p>
<p> Below is shown the default
-segment traits. Specialization of these traits is required for
+segment traits. Specialization of these traits is required for
types that don't conform to the default behavior.</p>
+
<p><span style="font-family: Courier New,Courier,monospace;"><span style="font-family: Courier New,Courier,monospace;">template <typename Segment></span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;">struct segment_traits {</span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;"> typedef typename Segment::coordinate_type coordinate_type;</span><br style="font-family: Courier New,Courier,monospace;" />
@@ -120,8 +123,8 @@
<span style="font-family: Courier New,Courier,monospace;"> }</span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;">};</span><br />
<br /><span style="font-family: Courier New,Courier,monospace;">template <typename Segment><br />
-struct segment_mutable_traits {</span></span></p>
- <p><span style="font-family: Courier New,Courier,monospace;"><span style="font-family: Courier New,Courier,monospace;"> typedef typename segment_traits<Segment>::point_type point_type;<br />
+struct segment_mutable_traits {<br />
+ typedef typename segment_traits<Segment>::point_type point_type;<br />
<br />
static inline void set(Segment& segment, direction_1d dir, const point_type& point) {<br />
segment.set(dir, p);<br />
@@ -151,24 +154,24 @@
void <b>set</b>(</font><font face="Courier New">Segment</font><font face="Courier New">& segment, direction_1d dir,<br />
const Point& </font><span style="font-family: Courier New;">point</span><font face="Courier New">)</font></td>
<td>Sets the low or high endpoint of an object that models a segment to an object that models a
-point, depending on the direction_1d value.</td>
+point, depending on the direction_1d value.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template <typename Segment, typename Point1, typename Point2><br />
Segment<b> construct</b>(const Point1& low, const Point2& high)</font></td>
- <td>Construct an object that is a model of segment given the two objects that are models of point.</td>
+ <td>Constructs an object that is a model of segment given the two objects that are models of point.</td>
</tr>
<tr>
- <td style="vertical-align: top;"><font face="Courier New">template <typename Segment1, typename </font><font face="Courier New">Segment2</font><font face="Courier New">><br /></font><font face="Courier New">Segment1</font><font face="Courier New"> <span style="font-weight: bold;">copy_construct</span>(const </font><font face="Courier New">Segment2</font><font face="Courier New">& segment)</font></td>
- <td style="vertical-align: middle; text-align: left;">Copy construct an object that is a model of segment given another segment.</td>
+ <td><font face="Courier New">template <typename Segment1, typename </font><font face="Courier New">Segment2</font><font face="Courier New">><br /></font><font face="Courier New">Segment1</font><font face="Courier New"> <span style="font-weight: bold;">copy_construct</span>(const </font><font face="Courier New">Segment2</font><font face="Courier New">& segment)</font></td>
+ <td style="text-align: left;">Copy constructs an object that is a model of segment given another segment.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template
<typename </font><font face="Courier New">Segment1</font><font face="Courier New">, typename </font><font face="Courier New">Segment2></font><br />
<font face="Courier New">Segment1</font><font face="Courier New">& <b>assign</b>(</font><font face="Courier New">Segment1</font><font face="Courier New">& segment1,<br />
const </font><font face="Courier New">Segment2</font><font face="Courier New">& segment2)</font></td>
- <td>Copies data from the right object that models segment into
-the left object that models segment.</td>
+ <td>Copies data from the second object that models a segment into
+the first object that models a segment.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template
@@ -176,20 +179,21 @@
bool <b>equivalence</b>(const </font><font face="Courier New">Segment1</font><font face="Courier New">& segment1,<br />
const </font><font face="Courier New">Segment1</font><font face="Courier New">& segment2)</font></td>
<td>Given two objects that model a segment, compares and
-returns true if their low and high values are respectively equal to each
-other.</td>
+returns true if their low and high values are respectively equal.</td>
</tr>
<tr>
- <td style="vertical-align: top;"><span style="font-family: Courier New,Courier,monospace;">template <typename Segment, typename Point></span><br style="font-family: Courier New,Courier,monospace;" />
- <span style="font-family: Courier New,Courier,monospace;">bool </span><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">on_above_or_below</span><span style="font-family: Courier New,Courier,monospace;">(const </span><span style="font-family: Courier New,Courier,monospace;">Segment</span><span style="font-family: Courier New,Courier,monospace;">& segment,</span><br style="font-family: Courier New,Courier,monospace;" />
- <span style="font-family: Courier New,Courier,monospace;">
+ <td><span style="font-family: Courier New,Courier,monospace;">template <typename Segment, typename Point></span><br style="font-family: Courier New,Courier,monospace;" />
+ <span style="font-family: Courier New,Courier,monospace;">int </span><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">on_above_or_below</span><span style="font-family: Courier New,Courier,monospace;">(const </span><span style="font-family: Courier New,Courier,monospace;">Segment</span><span style="font-family: Courier New,Courier,monospace;">& segment,</span><br style="font-family: Courier New,Courier,monospace;" />
+ <span style="font-family: Courier New,Courier,monospace;">
const Point& point)</span><br />
</td>
- <td>Returns false if an object that is a model of segment and an object that is a model of point are collinear, else true.<br />
+ <td>Returns 0 if an object that is a model of segment and an object that is a model of point are collinear.<br />
+Returns 1 if the point object lies to the left of the segment object.<br />
+Returns -1 if the point object lies to the right of the segment object.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top;"><span style="font-family: Courier New,Courier,monospace;">template <typename </span><font face="Courier New">Segment, typename Point</font><span style="font-family: Courier New,Courier,monospace;">></span><br style="font-family: Courier New,Courier,monospace;" />
+ <td><span style="font-family: Courier New,Courier,monospace;">template <typename </span><font face="Courier New">Segment, typename Point</font><span style="font-family: Courier New,Courier,monospace;">></span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;">bool </span><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">contains</span><span style="font-family: Courier New,Courier,monospace;">(const </span><font face="Courier New">Segment</font><span style="font-family: Courier New,Courier,monospace;">& segment,</span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;"> const Point& value,</span><span style="font-family: Courier New,Courier,monospace;"> bool consider_touch)</span><br />
</td>
@@ -197,46 +201,46 @@
</td>
</tr>
<tr>
- <td style="vertical-align: top;"><span style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2></span><br style="font-family: Courier New,Courier,monospace;" />
+ <td><span style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2></span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;">bool </span><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">contains</span><span style="font-family: Courier New,Courier,monospace;">(const </span><span style="font-family: Courier New,Courier,monospace;">Segment1</span><span style="font-family: Courier New,Courier,monospace;">& segment1,</span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;"> const </span><span style="font-family: Courier New,Courier,monospace;">Segment</span><span style="font-family: Courier New,Courier,monospace;">2& segment2,</span> <span style="font-family: Courier New,Courier,monospace;">bool consider_touch)</span></td>
- <td>Returns true if the first of the objects contains the second one, else false. Both objects represent a model of segment.<br />
+ <td>Returns true if the first object contains the second one, else false. Both objects model a segment.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>><br />
+ <td style="font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>><br />
point_type <span style="font-weight: bold;">low</span>(const <span style="font-family: Courier New,Courier,monospace;">Segment</span>& segment)<br />
</td>
<td>Returns the low endpoint of an object that is a model of segment.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>><br />
+ <td style="font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>><br />
point_type <span style="font-weight: bold;">high</span>(const <span style="font-family: Courier New,Courier,monospace;">Segment</span>& segment)</td>
<td>Returns the high endpoint of an object that is a model of segment.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>><br />
+ <td style="font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>><br />
point_type <span style="font-weight: bold;">center</span>(const <span style="font-family: Courier New,Courier,monospace;">Segment</span>& segment)</td>
<td>Returns the central point of an object that is a model of segment.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>, typename Point><br />void <span style="font-weight: bold;">low</span>(<span style="font-family: Courier New,Courier,monospace;">Segment</span>& segment, const Point& point)</td>
+ <td style="font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment</span>, typename Point><br />void <span style="font-weight: bold;">low</span>(<span style="font-family: Courier New,Courier,monospace;">Segment</span>& segment, const Point& point)</td>
<td>Sets the low endpoint of an object that is a model of segment.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment, typename Point</span>><br />
+ <td style="font-family: Courier New,Courier,monospace;">template <typename <span style="font-family: Courier New,Courier,monospace;">Segment, typename Point</span>><br />
void <span style="font-weight: bold;">high</span>(<span style="font-family: Courier New,Courier,monospace;">Segment</span>& segment, const Point& point)</td>
<td>Sets the high endpoint of an object that is a model of segment.<br />
</td>
</tr>
<tr>
- <td style="vertical-align: top;"><span style="font-family: Courier New,Courier,monospace;">template <typename </span><span style="font-family: Courier New,Courier,monospace;">Segment</span><span style="font-family: Courier New,Courier,monospace;">></span><br style="font-family: Courier New,Courier,monospace;" />
+ <td><span style="font-family: Courier New,Courier,monospace;">template <typename </span><span style="font-family: Courier New,Courier,monospace;">Segment</span><span style="font-family: Courier New,Courier,monospace;">></span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;">distance_type <span style="font-weight: bold;">length</span>(const </span><span style="font-family: Courier New,Courier,monospace;">Segment</span><span style="font-family: Courier New,Courier,monospace;">& segment)</span><br />
</td>
<td>Returns length of an object that is a model of segment.<br />
@@ -278,7 +282,7 @@
<typename </font><span style="font-family: Courier New,Courier,monospace;">Segment</span><font face="Courier New">><br />
</font><span style="font-family: Courier New,Courier,monospace;">Segment</span><font face="Courier New">& <b>move</b>(</font><span style="font-family: Courier New,Courier,monospace;">Segment</span><font face="Courier New">& segment, orientation_2d<br />
coordinate_difference displacement)</font></td>
- <td>Adds displacement value to the coordinates of both endpoints of an object
+ <td>Adds displacement value to the x or y coordinates of both endpoints of an object
that is a model of segment indicated by the orientation_2d.</td>
</tr>
<tr>
@@ -295,61 +299,63 @@
<td>Deconvolves both endpoints of an object that models a segment with an object that models a point. </td>
</tr>
<tr>
- <td width="586"><font face="Courier New">template
-<typename </font><span style="font-family: Courier New,Courier,monospace;">Segment, typename Point</span><font face="Courier New">><br />distance_type <b>euclidean_distance</b>(<br />
- const </font><span style="font-family: Courier New,Courier,monospace;">Segment</span><font face="Courier New">& segment, const Point& point)</font></td>
- <td>Returns distance from an object that is a model of segment
-to an object that is a model of point.</td>
+ <td style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2><br />
+
+
+bool <span style="font-weight: bold;">abuts</span>(const Segment1& segment1,<br />
+
+
+ const Segment2& segment2, direction_1d dir)</td>
+ <td>Returns true if two objects that model a segment abut, depending on the direction_1d value.</td>
</tr>
<tr>
- <td style="vertical-align: top;"><font face="Courier New">template
-<typename Segment1, typename </font><font face="Courier New">Segment2</font><font face="Courier New">><br />distance_type <b>euclidean_distance</b>(<br />
- const </font><font face="Courier New">Segment1</font><font face="Courier New">& segment1, const </font><font face="Courier New">Segment2</font><font face="Courier New">& segment2)</font></td>
- <td style="vertical-align: middle;">Returns distance between two objects that are models of segment.</td>
+ <td style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2><br />
+
+bool <span style="font-weight: bold;">abuts</span>(const Segment1& segment1,<br />
+
+ const Segment2& segment2)</td>
+ <td>Returns true if two objects that model a segment abut: either the first one to the second one or vice versa.</td>
</tr>
+
+
<tr>
- <td style="vertical-align: top;"><span style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2></span><br style="font-family: Courier New,Courier,monospace;" />
+ <td><span style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2></span><br style="font-family: Courier New,Courier,monospace;" />
<span style="font-family: Courier New,Courier,monospace;">bool <span style="font-weight: bold;">intersects</span>(const Segment1& segment1,</span><br style="font-family: Courier New,Courier,monospace;" />
- <span style="font-family: Courier New,Courier,monospace;"> const Segment2& segment2)</span><br />
+ <span style="font-family: Courier New,Courier,monospace;"> const Segment2& segment2,<br />
+ bool consider_touch)</span><br />
</td>
<td>Returns true if two objects that model a segment intersect, else false.<br />
</td>
</tr>
+
<tr>
- <td style="vertical-align: top;"><span style="font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2></span><br style="font-family: Courier New,Courier,monospace;" />
+ <td style="font-family: Courier New,Courier,monospace;">template <typename Point, typename Segment1, typename Segment2><br />
- <span style="font-family: Courier New,Courier,monospace;">bool <span style="font-weight: bold;">boundaries_intersect</span>(<br />
- const Segment1& segment1,</span><span style="font-family: Courier New,Courier,monospace;"> const Segment2& segment2)</span>
- </td>
- <td>Returns true if two objects that model a segment are collinear and overlap, else false.<br />
- </td>
- </tr>
- <tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2><br />
+bool <span style="font-weight: bold;">intersection</span>(Point& point,<br />
-bool <span style="font-weight: bold;">abuts</span>(const Segment1& segment1,<br />
+ const Segment1& segment1, const Segment2& segment2,<br />
- const Segment2& segment2, direction_1d dir)</td>
- <td>Returns true if two objects that model a segment abut, depending on the direction_1d value.<br />
+ bool projected = false, bool round_closest = false)</td>
+ <td>Returns
+true and computes the intersection point of the two objects that model
+a segment in case those intersect, else returns false.
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename Segment1, typename Segment2><br />
-bool <span style="font-weight: bold;">abuts</span>(const Segment1& segment1,<br />
- const Segment2& segment2)<br />
+ <td style="font-family: Courier New,Courier,monospace;"><font face="Courier New">template
+<typename </font><span style="font-family: Courier New,Courier,monospace;">Segment, typename Point</span><font face="Courier New">><br />distance_type <b>euclidean_distance</b>(<br />
+ const </font><span style="font-family: Courier New,Courier,monospace;">Segment</span><font face="Courier New">& segment, const Point& point)</font>
</td>
- <td>Returns true if two objects that model a segment abut: either the first one to the second one or vice versa.<br />
+ <td>Returns distance from an object that is a model of segment
+to an object that is a model of point.
</td>
</tr>
<tr>
- <td style="vertical-align: top; font-family: Courier New,Courier,monospace;">template <typename Point, typename Segment1, typename Segment2><br />
-bool <span style="font-weight: bold;">intersection</span>(Point& point,<br />
- const Segment1& segment1, const Segment2& segment2,<br />
- bool projected = false, bool round_closest = false)<br />
+ <td style="font-family: Courier New,Courier,monospace;"><font face="Courier New">template
+<typename Segment1, typename </font><font face="Courier New">Segment2</font><font face="Courier New">><br />distance_type <b>euclidean_distance</b>(<br />
+ const </font><font face="Courier New">Segment1</font><font face="Courier New">& segment1, const </font><font face="Courier New">Segment2</font><font face="Courier New">& segment2)</font>
</td>
- <td>Returns
-true and computes the intersection point of the two objects that model
-a segment. If those don't intersect returns false.<br />
+ <td>Returns distance between two objects that are models of segment.
</td>
</tr>
@@ -367,9 +373,9 @@
library segment data type instead of providing their own. The data
type is implemented to be convenient to use with the library traits.</p>
<p>Example code segment_usage.cpp
-demonstrates using the library provided segment data type and functions</p>
+demonstrates using the library provided segment data type and functions.</p>
<h2>Members</h2>
- <table id="table2" border="1" width="100%">
+ <table style="width: 100%;" id="table2" border="1">
<tbody>
<tr>
<td width="586"><b><font face="Courier New">geometry_type</font></b></td>
@@ -380,8 +386,8 @@
<td>T</td>
</tr>
<tr>
- <td style="vertical-align: top;"><b><font face="Courier New">point_type</font></b></td>
- <td style="vertical-align: top;">point_data<T><br />
+ <td><b><font face="Courier New">point_type</font></b></td>
+ <td>point_data<T><br />
</td>
</tr>
<tr>
@@ -417,27 +423,27 @@
</tr>
<tr>
<td width="586"><font face="Courier New"><b> </b>bool<b> operator<</b>(const segment_data& that) const</font></td>
- <td>Less operator overload. Compares low endpoint then high endpoint to break ties.<br />
+ <td>Less operator overload. Compares low endpoints then high endpoints to break ties.<br />
</td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b> </b>bool<b> operator<=</b>(const segment_data& that) const</font></td>
- <td>Less or equal operator overload. Compares low endpoint then high endpoint to break ties.<br />
+ <td>Less or equal operator overload. Compares low endpoints then high endpoints to break ties.<br />
</td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b> </b>bool<b> operator></b>(const segment_data& that) const</font></td>
- <td>Greater operator overload. Compares low endpoint then high endpoint to break ties.<br />
+ <td>Greater operator overload. Compares low endpoints then high endpoints to break ties.<br />
</td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b> </b>bool<b> operator>=</b>(const segment_data& that) const</font></td>
- <td>Greater or equal operator overload. Compares low endpoint then high endpoint to break ties.<br />
+ <td>Greater or equal operator overload. Compares low endpoints then high endpoints to break ties.<br />
</td>
</tr>
<tr>
<td width="586"><font face="Courier New">point_type <b>get</b>(direction_1d dir) const</font></td>
- <td>Retrieves the low/high endpoint considering direction.</td>
+ <td>Retrieves the low/high endpoint considering direction value.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">point_type <span style="font-weight: bold;">low</span>() const</font></td>
Modified: sandbox/gtl/libs/polygon/test/polygon_segment_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/polygon_segment_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/polygon_segment_test.cpp 2012-05-01 07:34:07 EDT (Tue, 01 May 2012)
@@ -47,7 +47,6 @@
BOOST_CHECK(segment1 == segment2);
}
-
BOOST_AUTO_TEST_CASE_TEMPLATE(segment_traits_test, T, test_types) {
typedef point_data<T> point_type ;
typedef segment_data<T> segment_type;
@@ -294,6 +293,46 @@
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
+ segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(1, 2));
+ segment_type segment2 = construct<segment_type>(point_type(1, 2), point_type(2, 4));
+ segment_type segment3 = construct<segment_type>(point_type(2, 4), point_type(0, 4));
+ segment_type segment4 = construct<segment_type>(point_type(0, 4), point_type(0, 0));
+
+ BOOST_CHECK(abuts(segment1, segment2, HIGH));
+ BOOST_CHECK(abuts(segment2, segment3, HIGH));
+ BOOST_CHECK(abuts(segment3, segment4, HIGH));
+ BOOST_CHECK(abuts(segment4, segment1, HIGH));
+
+ BOOST_CHECK(!abuts(segment1, segment2, LOW));
+ BOOST_CHECK(!abuts(segment2, segment3, LOW));
+ BOOST_CHECK(!abuts(segment3, segment4, LOW));
+ BOOST_CHECK(!abuts(segment4, segment1, LOW));
+
+ BOOST_CHECK(abuts(segment2, segment1));
+ BOOST_CHECK(abuts(segment3, segment2));
+ BOOST_CHECK(abuts(segment4, segment3));
+ BOOST_CHECK(abuts(segment1, segment4));
+
+ BOOST_CHECK(!abuts(segment1, segment3));
+ BOOST_CHECK(!abuts(segment2, segment4));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test8, T, test_types) {
+ typedef point_data<T> point_type;
+ typedef Segment<T> segment_type;
+
+ point_type point;
+ segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(2, 2));
+ segment_type segment2 = construct<segment_type>(point_type(1, 1), point_type(3, 3));
+
+ BOOST_CHECK(!intersection(point, segment1, segment2));
+ BOOST_CHECK(intersects(segment1, segment2));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test9, T, test_types) {
+ typedef point_data<T> point_type;
+ typedef Segment<T> segment_type;
+
point_type point1(1, 2);
point_type point2(7, 10);
segment_type segment1 = construct<segment_type>(point1, point2);
@@ -306,7 +345,7 @@
BOOST_CHECK(euclidean_distance(segment1, point_type(8, 3)) == 5.0);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test8, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test10, T, test_types) {
typedef point_data<T> point_type;
typedef Segment<T> segment_type;
@@ -314,6 +353,8 @@
segment_type segment2 = construct<segment_type>(point_type(2, 0), point_type(0, 2));
segment_type segment3 = construct<segment_type>(point_type(1, -7), point_type(10, 5));
segment_type segment4 = construct<segment_type>(point_type(7, 7), point_type(10, 11));
+ segment_type segment5 = construct<segment_type>(point_type(1, 1), point_type(-1, 3));
+ segment_type segment6 = construct<segment_type>(point_type(0, 0), point_type(1, 1));
BOOST_CHECK(intersects(segment1, segment2, false));
BOOST_CHECK(euclidean_distance(segment1, segment2) == 0.0);
@@ -321,16 +362,6 @@
BOOST_CHECK(euclidean_distance(segment1, segment3) == 5.0);
BOOST_CHECK(!intersects(segment1, segment4, true));
BOOST_CHECK(euclidean_distance(segment1, segment4) == 5.0);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test9, T, test_types) {
- typedef point_data<T> point_type;
- typedef Segment<T> segment_type;
-
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test10, T, test_types) {
- typedef point_data<T> point_type;
- typedef Segment<T> segment_type;
-
+ BOOST_CHECK(intersects(segment2, segment5, false));
+ BOOST_CHECK(intersects(segment2, segment6, false));
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk