mirror of
https://github.com/boostorg/polygon.git
synced 2026-02-15 01:12:10 +00:00
398 lines
18 KiB
HTML
398 lines
18 KiB
HTML
<!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. In the example below CPoint is registered as a model of
|
||
point concept.<p>
|
||
<font face="Courier New">template <><br>
|
||
struct geometry_concept<CPoint> { 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. A std::pair<int, int>, boost::tuple<int, int> or boost::array<int, 2>
|
||
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.
|
||
Specialization of these traits is required for types that don't conform to the
|
||
default behavior.</font><p>
|
||
template <typename T><br>
|
||
struct point_traits {<br>
|
||
typedef typename T::coordinate_type coordinate_type;<br>
|
||
<br>
|
||
static inline coordinate_type get(const T& point,
|
||
orientation_2d orient) {<br>
|
||
return point.get(orient);
|
||
<br>
|
||
}<br>
|
||
};<br>
|
||
<br>
|
||
template <typename T><br>
|
||
struct point_mutable_traits {<br>
|
||
static inline void set(T& point, orientation_2d orient,
|
||
typename point_traits<T>::coordinate_type value) {<br>
|
||
point.set(orient, value);
|
||
<br>
|
||
}<br>
|
||
static inline T construct(typename point_traits<T>::coordinate_type
|
||
x_value, typename point_traits<T>::coordinate_type y_value) {<br>
|
||
return T(x_value, y_value);
|
||
<br>
|
||
}<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 <typename T><br>
|
||
coordinate_type <b>get</b>(const T& point, orientation_2d)</font></td>
|
||
<td><font face="Times New Roman">Expects a model of point. Returns
|
||
the x or y coordinate of the point, depending on the orientation_2d
|
||
value.</font><font face="Courier New"><br>
|
||
</font></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="586"><font face="Courier New">template <typename T, typename
|
||
coordinate_type><br>
|
||
void <b>set</b>(T& point, orientation_2d, coordinate_type)</font></td>
|
||
<td><font face="Times New Roman">Expects a model of point.
|
||
Sets the x or y coordinate of the point to the coordinate, depending on
|
||
the orientation_2d value. </font></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="586"><font face="Courier New">template <typename T><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 <typename T1, typename
|
||
T2><br>
|
||
T1& <b>assign</b>(T1& left, const T2& 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 <typename T, typename
|
||
T2><br>
|
||
bool <b>equivalence</b>(const T& point1, const T2& 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 <typename point_type><br>
|
||
coordinate_type <b>x</b>(const point_type& 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 <typename point_type><br>
|
||
coordinate_type <b>y</b>(const point_type& 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 <typename point_type><br>
|
||
void <b>x</b>(point_type& point, coordinate_type )</font></td>
|
||
<td>Sets the x coordinate of the object that models point to the
|
||
coordinate value. </td>
|
||
</tr>
|
||
<tr>
|
||
<td width="586"><font face="Courier New">template <typename point_type><br>
|
||
void <b>y</b>(point_type& point, coordinate_type )</font></td>
|
||
<td>Sets the y coordinate of the object that models point to the
|
||
coordinate value. </td>
|
||
</tr>
|
||
<tr>
|
||
<td width="586"><font face="Courier New">template <typename point_type><br>
|
||
point_type& <b>scale_up</b>(point_type& point, <br>
|
||
|
||
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 <typename point_type><br>
|
||
point_type& <b>scale_down</b>(point_type& point, <br>
|
||
|
||
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 <typename point_type,
|
||
typename scaling_type><br>
|
||
point_type& <b>scale</b>(point_type& point,<br>
|
||
|
||
const scaling_type& 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 <typename point_type,
|
||
typename transform_type><br>
|
||
point_type& <b>transform</b>(point_type& point,<br>
|
||
|
||
const transform_type& 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 <typename point_type><br>
|
||
point_type& <b>move</b>(point_type& point, orientation_2d<br>
|
||
|
||
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 <typename T1, typename
|
||
T2><br>
|
||
T1& <b>convolve</b>(T1& a, const T2& 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 <typename T1, typename
|
||
T2><br>
|
||
T1& <b>deconvolve</b>(T1& a, const T2& 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 <typename T1, typename
|
||
T2><br>
|
||
coordinate_distance <b>euclidean_distance</b>(const T1&,<br>
|
||
|
||
const T2&)</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 <typename T><br>
|
||
coordinate_difference <b>euclidean_distance</b>(const T&,<br>
|
||
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 <typename T1, typename
|
||
T2><br>
|
||
coordinate_difference <b>manhattan_distance</b>(const T1&,<br>
|
||
|
||
const T2&)</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 <typename T1, typename
|
||
T2><br>
|
||
coordinate_difference <b>distance_squared</b>(const T1&,<br>
|
||
|
||
const T2&)</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<typename T> 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. 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& <b>operator=</b>(const
|
||
point_data& that)</font></td>
|
||
<td>Assignment operator.</td>
|
||
</tr>
|
||
<tr>
|
||
<td width="586"><font face="Courier New">template <typename T2><b>
|
||
<br> </b>point_data& <b>operator=</b>(const T2& 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 <typename T2><b>
|
||
<br> </b>bool<b>
|
||
operator==</b>(const T2& 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 <typename T2><b>
|
||
<br> </b>bool<b>
|
||
operator!=</b>(const T2& 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 <typename T2><b>
|
||
<br> </b>bool<b>
|
||
operator<</b>(const T2& 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 <typename T2><b>
|
||
<br> </b>bool<b>
|
||
operator<=</b>(const T2& 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 <typename T2><b>
|
||
<br> </b>bool<b>
|
||
operator></b>(const T2& 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 <typename T2><b>
|
||
<br> </b>bool<b>
|
||
operator>=</b>(const T2& 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">
|
||
</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 <20> 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> |