blob: 993d4caa7446bec488cc820338d1c5140c538663 [file] [log] [blame]
<!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" 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"><head><!--
Copyright 2009-2010 Intel Corporation
license banner
-->
<title>Boost Polygon Library: Point Concept</title>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<table style="margin: 0pt; padding: 0pt; width: 100%;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
<div style="padding: 5px;" align="center">
<img border="0" src="images/boost.png" width="277" height="86"><a title="www.boost.org home page" href="http://www.boost.org/" tabindex="2" style="border: medium none ;">
</a>
</div>
<div style="margin: 5px;">
<h3 class="navbar">Contents</h3>
<ul>
<li><a href="index.htm">Boost.Polygon Main Page</a></li>
<li><a href="gtl_design_overview.htm">Design Overview</a></li>
<li><a href="gtl_isotropy.htm">Isotropy</a></li>
<li><a href="gtl_coordinate_concept.htm">Coordinate Concept</a></li>
<li><a href="gtl_interval_concept.htm">Interval Concept</a></li>
<li>Point Concept</li>
<li><a href="gtl_rectangle_concept.htm">Rectangle Concept</a></li>
<li><a href="gtl_polygon_90_concept.htm">Polygon 90 Concept</a></li>
<li><a href="gtl_polygon_90_with_holes_concept.htm">Polygon 90 With Holes Concept</a></li>
<li><a href="gtl_polygon_45_concept.htm">Polygon 45 Concept</a></li>
<li><a href="gtl_polygon_45_with_holes_concept.htm">Polygon 45 With Holes Concept</a></li>
<li><a href="gtl_polygon_concept.htm">Polygon Concept</a></li>
<li><a href="gtl_polygon_with_holes_concept.htm">Polygon With Holes Concept</a></li>
<li><a href="gtl_polygon_90_set_concept.htm">Polygon 90 Set Concept</a></li>
<li><a href="gtl_polygon_45_set_concept.htm">Polygon 45 Set Concept</a></li>
<li><a href="gtl_polygon_set_concept.htm">Polygon Set Concept</a></li>
<li><a href="gtl_connectivity_extraction_90.htm">Connectivity Extraction 90</a></li>
<li><a href="gtl_connectivity_extraction_45.htm">Connectivity Extraction 45</a></li>
<li><a href="gtl_connectivity_extraction.htm">Connectivity Extraction</a></li>
<li><a href="gtl_property_merge_90.htm">Property Merge 90</a></li>
<li><a href="gtl_property_merge_45.htm">Property Merge 45</a></li>
<li><a href="gtl_property_merge.htm">Property Merge</a></li>
</ul>
<h3 class="navbar">Other Resources</h3>
<ul>
<li><a href="GTL_boostcon2009.pdf">GTL Boostcon 2009 Paper</a></li>
<li><a href="GTL_boostcon_draft03.pdf">GTL Boostcon 2009
Presentation</a></li>
<li><a href="analysis.htm">Performance Analysis</a></li>
<li><a href="gtl_tutorial.htm">Layout Versus Schematic Tutorial</a></li>
<li><a href="gtl_minkowski_tutorial.htm">Minkowski Sum Tutorial</a></li>
</ul>
</div>
<h3 class="navbar">Polygon Sponsor</h3>
<div style="padding: 5px;" align="center">
<img border="0" src="images/intlogo.gif" width="127" height="51">
</div>
</td>
<td style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" valign="top" width="100%">
<!-- End Header -->
<br>
<p>
</p><h1>Point Concept</h1>
<p>
<p>
The point concept tag is <font face="Courier New">
point_concept</font><p>
To register a user defined type as a model of point concept, specialize the
geometry concept meta-function for that type.&nbsp; In the example below CPoint is registered as a model of
point&nbsp; concept.<p>
<font face="Courier New">template &lt;&gt;<br>
struct geometry_concept&lt;CPoint&gt; { typedef point_concept type; };</font><p>
<font face="Times New Roman">The semantic of a point is that it has an x and y
coordinate.&nbsp; A std::pair&lt;int, int&gt;, boost::tuple&lt;int, int&gt; or boost::array&lt;int, 2&gt;
could all be made models of point by simply providing indirect access to their
elements through traits, however, these objects cannot be made a model of both
point and interval in the same compilation unit, for obvious reason that
duplicate specialization of the geometry_concept struct is illegal, but also
because it would make overloading generic function by concept ambiguous if a
type modeled more than one concept.</font><p>
<font face="Times New Roman">Below is shown the default point traits.&nbsp;
Specialization of these traits is required for types that don't conform to the
default behavior.</font><p>
template &lt;typename T&gt;<br>
struct point_traits {<br>
&nbsp;&nbsp;&nbsp;&nbsp; typedef typename T::coordinate_type coordinate_type;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; static inline coordinate_type get(const T&amp; point,
orientation_2d orient) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return point.get(orient);
<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
};<br>
<br>
template &lt;typename T&gt;<br>
struct point_mutable_traits {<br>
&nbsp;&nbsp;&nbsp;&nbsp; static inline void set(T&amp; point, orientation_2d orient,
typename point_traits&lt;T&gt;::coordinate_type value) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point.set(orient, value);
<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp; static inline T construct(typename point_traits&lt;T&gt;::coordinate_type
x_value, typename point_traits&lt;T&gt;::coordinate_type y_value) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return T(x_value, y_value);
<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
};<p>
Example code <a href="gtl_custom_point.htm">custom_point.cpp</a> demonstrates
how to map a
user defined point class to the library point_concept<h2>Functions</h2>
<table border="1" width="100%" id="table1">
<tr>
<td width="586"><font face="Courier New">template &lt;typename T&gt;<br>
coordinate_type <b>get</b>(const T&amp; point, orientation_2d)</font></td>
<td><font face="Times New Roman">Expects a model of point.&nbsp; Returns
the x or y coordinate of the point, depending on the orientation_2d
value.</font><font face="Courier New"><br>
&nbsp;</font></td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T, typename
coordinate_type&gt;<br>
void <b>set</b>(T&amp; point, orientation_2d, coordinate_type)</font></td>
<td><font face="Times New Roman">Expects a model of point.&nbsp;&nbsp;
Sets the x or y coordinate of the point to the coordinate, depending on
the orientation_2d&nbsp; value. </font></td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T&gt;<br>
T <b>construct</b>(coordinate_type x, coordinate_type y)</font></td>
<td>Construct an object that is a model of point given x and y
coordinate values.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T1, typename
T2&gt;<br>
T1&amp; <b>assign</b>(T1&amp; left, const T2&amp; right)</font></td>
<td>Copies data from right object that models point into left object
that models point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T, typename
T2&gt;<br>
bool <b>equivalence</b>(const T&amp; point1, const T2&amp; point2)</font></td>
<td>Given two objects that model point, compares and returns true if
their x and y values are respectively equal to each other.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
coordinate_type <b>x</b>(const point_type&amp; point)</font></td>
<td>Returns the x coordinate of an object that models point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
coordinate_type <b>y</b>(const point_type&amp; point)</font></td>
<td>Returns the y coordinate of an object that models point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
void <b>x</b>(point_type&amp; point, coordinate_type )</font></td>
<td>Sets the x coordinate of the object that models point to the
coordinate value.&nbsp; </td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
void <b>y</b>(point_type&amp; point, coordinate_type )</font></td>
<td>Sets the y coordinate of the object that models point to the
coordinate value.&nbsp; </td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
point_type&amp; <b>scale_up</b>(point_type&amp; point, <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
unsigned_area_type factor)</font></td>
<td>Multiplies x and y coordinate of an object that models point by
unsigned factor.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
point_type&amp; <b>scale_down</b>(point_type&amp; point, <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
unsigned_area_type factor)</font></td>
<td>Divides x and y coordinate of an object that models point by
unsigned factor.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type,
typename scaling_type&gt;<br>
point_type&amp; <b>scale</b>(point_type&amp; point,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const scaling_type&amp; factor) </font></td>
<td>Calls the scale member function of scaling type on the x and y value
of an object that models point and sets the point to the scaled values.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type,
typename transform_type&gt;<br>
point_type&amp; <b>transform</b>(point_type&amp; point,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const transform_type&amp; transform) </font></td>
<td>Calls the transform member function of transform type on the x and y
value of an object that models point and sets the point to the
transformed values.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename point_type&gt;<br>
point_type&amp; <b>move</b>(point_type&amp; point, orientation_2d<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
coordinate_difference displacement)</font></td>
<td>Adds displacement value to the coordinate of an object that models
point indicated by the orientation_2d.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T1, typename
T2&gt;<br>
T1&amp; <b>convolve</b>(T1&amp; a, const T2&amp; b)</font></td>
<td>Adds x coordinate of b to x coordinate of a and adds y coordinate of
b to y coordinate of a.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T1, typename
T2&gt;<br>
T1&amp; <b>deconvolve</b>(T1&amp; a, const T2&amp; b)</font></td>
<td>Subtracts x coordinate of b from x coordinate of a and subtracts y
coordinate of b from y coordinate of a. </td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T1, typename
T2&gt;<br>
coordinate_distance <b>euclidean_distance</b>(const T1&amp;,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const T2&amp;)</font></td>
<td>Returns the distance from an object that models point to a second
object that models point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T&gt;<br>
coordinate_difference <b>euclidean_distance</b>(const T&amp;,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; orientation_2d,
coordinate_type)</font></td>
<td>Returns the distance from an object that models point to a
coordinate in the given orientation_2d.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T1, typename
T2&gt;<br>
coordinate_difference <b>manhattan_distance</b>(const T1&amp;,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const T2&amp;)</font></td>
<td>Returns the distance in x plus the distance in y from an object that
models point to a second object that models point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T1, typename
T2&gt;<br>
coordinate_difference <b>distance_squared</b>(const T1&amp;,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const T2&amp;)</font></td>
<td>Returns the square of the distance in x plus the square of the
distance in y from an object that models point to a second object that
models point.</td>
</tr>
</table>
<h1>Point Data</h1>
<p>
<p>The library provides a model of point concept declared
<font face="Courier New">
template&lt;typename T&gt; point_data </font>where T is the coordinate type.</p>
<p>This data type is used internally when a point is needed and is available to
the library user who finds it convenient to use a library point data type
instead of providing their own.&nbsp; The data type is implemented to be
convenient to use with the library traits.</p>
<p>Example code <a href="gtl_point_usage.htm">point_usage.cpp</a> demonstrates using the
library provided point data type and functions</p>
<h2>Members</h2>
<table border="1" width="100%" id="table2">
<tr>
<td width="586"><b><font face="Courier New">geometry_type</font></b></td>
<td><font face="Times New Roman">point_concept</font></td>
</tr>
<tr>
<td width="586"><b><font face="Courier New">coordinate_type</font></b></td>
<td><font face="Times New Roman">T</font></td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b>point_data</b>()</font></td>
<td><font face="Times New Roman">Default constructs the two coordinate
values of the </font>point<font face="Times New Roman">.</font></td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b>point_data</b>(T x, T y)</font></td>
<td><font face="Times New Roman">Constructs an interval with two
coordinates.</font></td>
</tr>
<tr>
<td width="586"><font face="Courier New"><b>point_data</b>(const point_data*
that)</font></td>
<td><font face="Times New Roman">Copy construct</font></td>
</tr>
<tr>
<td width="586"><font face="Courier New">point_data&amp; <b>operator=</b>(const
point_data&amp; that)</font></td>
<td>Assignment operator.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>&nbsp;
<br> </b>point_data&amp; <b>operator=</b>(const T2&amp; that) const</font></td>
<td>Assign from an object that is a model of point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>
<br> </b>bool<b>
operator==</b>(const T2&amp; that) const</font></td>
<td>Compare equality to an object that is a model of point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>
<br> </b>bool<b>
operator!=</b>(const T2&amp; that) const</font></td>
<td>Compare inequality to an object that is a model of point.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>
<br> </b>bool<b>
operator&lt;</b>(const T2&amp; that) const</font></td>
<td>Compares y coordinates then x coordinates to break ties.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>
<br> </b>bool<b>
operator&lt;=</b>(const T2&amp; that) const</font></td>
<td>Compares y coordinates then x coordinates to break ties.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>
<br> </b>bool<b>
operator&gt;</b>(const T2&amp; that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">template &lt;typename T2&gt;<b>
<br> </b>bool<b>
operator&gt;=</b>(const T2&amp; that) const</font></td>
<td>Compares low coordinates then high coordinates to break ties.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">T <b>get</b>(orientation_2d
orient) const</font></td>
<td>Get the coordinate in the given orientation.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">T <b>x</b>() const</font></td>
<td>Get the coordinate in the horizontal orientation.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">T <b>y</b>() const</font></td>
<td>Get the coordinate in the vertical orientation.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">void <b>set</b>(orientation_2d
orient, T value)</font></td>
<td>Sets the coordinate in the given orientation to the value.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">void <b>x</b>(T value)</font></td>
<td>Sets the coordinate in the horizontal orientation to the value.</td>
</tr>
<tr>
<td width="586"><font face="Courier New">void <b>y</b>(T value)</font></td>
<td>Sets the coordinate in the vertical orientation to the value.</td>
</tr>
</table>
<tr>
<td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
&nbsp;</td>
<td style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" valign="top" width="100%">
<table class="docinfo" rules="none" frame="void" id="table3">
<colgroup>
<col class="docinfo-name"><col class="docinfo-content">
</colgroup>
<tbody vAlign="top">
<tr>
<th class="docinfo-name">Copyright:</th>
<td>Copyright © Intel Corporation 2008-2010.</td>
</tr>
<tr class="field">
<th class="docinfo-name">License:</th>
<td class="field-body">Distributed under the Boost Software License,
Version 1.0. (See accompanying file <tt class="literal">
<span class="pre">LICENSE_1_0.txt</span></tt> or copy at
<a class="reference" target="_top" href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>)</td>
</tr>
</table>
</html>