| <!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> |
| <!-- |
| 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" /> |
| <!-- <link type="text/css" rel="stylesheet" href="adobe_source.css"> --> |
| </head> |
| <body> |
| <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 |
| src="images/boost.png" border="0" height="86" width="277" /><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_segment_concept.htm">Segment Concept</a></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> |
| <li><a href="voronoi_main.htm">Voronoi Main Page<br /> |
| </a></li> |
| <li><a href="voronoi_benchmark.htm">Voronoi Benchmark</a><br /> |
| </li> |
| <li><a href="voronoi_builder.htm">Voronoi Builder</a></li> |
| <li><a href="voronoi_diagram.htm">Voronoi Diagram</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> |
| <li><a href="voronoi_basic_tutorial.htm">Voronoi Basic Tutorial</a></li> |
| <li><a href="voronoi_advanced_tutorial.htm">Voronoi Advanced |
| Tutorial</a></li> |
| </ul> |
| </div> |
| <h3 class="navbar">Polygon Sponsor</h3> |
| <div style="padding: 5px;" align="center"> <img |
| src="images/intlogo.gif" border="0" height="51" width="127" /><a |
| title="www.adobe.com home page" href="http://www.adobe.com/" |
| tabindex="2" style="border: medium none ;"> </a> </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> |
| <p> The point concept tag is <font face="Courier New"> |
| point_concept</font></p> |
| <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 <span |
| style="font-family: Courier New,Courier,monospace;">CPoint</span> is |
| registered as a model of point concept.</p> |
| <p> <font face="Courier New">template <><br /> |
| struct geometry_concept<CPoint> { typedef point_concept type; };</font></p> |
| <p> 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.</p> |
| <p> Below is shown the default point traits. Specialization |
| of these traits is required for types that don't conform to the default |
| behavior.</p> |
| <p style="font-family: Courier New,Courier,monospace;"> template |
| <typename T><br /> |
| struct point_traits {<br /> |
| typedef typename T::coordinate_type |
| coordinate_type;<br /> |
| <br /> |
| static 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 /> |
| typedef typename T::coordinate_type |
| coordinate_type;<br /> |
| <br /> |
| static void set(T& point, orientation_2d |
| orient, typename point_traits<T>::coordinate_type value) {<br /> |
| |
| point.set(orient, value); |
| <br /> |
| }<br /> |
| static T construct(typename |
| point_traits<T>::coordinate_type x_value,<br /> |
| |
| typename point_traits<T>::coordinate_type y_value) {<br /> |
| return |
| T(x_value, y_value); |
| <br /> |
| }<br /> |
| };</p> |
| <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</p> |
| <h2>Functions</h2> |
| <table id="table1" border="1" width="100%"> |
| <tbody> |
| <tr> |
| <td width="586"><font face="Courier New">template |
| <typename PointType><br /> |
| coordinate_type <b>get</b>(const PointType& point,<br /> |
| |
| orientation_2d)</font></td> |
| <td>Expects a model of point. Returns the x or y coordinate |
| of the point, depending on the orientation_2d value.<br /> |
| </td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New">template |
| <typename PointType><br /> |
| void <b>set</b>(PointType& point, orientation_2d,<br /> |
| coordinate_type)</font></td> |
| <td>Expects a model of point. Sets the x or y coordinate of |
| the point to the coordinate, depending on the orientation_2d |
| value. </td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New">template |
| <typename PointType><br /> |
| PointType <b>construct</b>(coordinate_type x,<br /> |
| |
| 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 PointType1, typename PointType2><br /> |
| PointType1& <b>assign</b>(PointType1& left,<br /> |
| |
| const PointType2& 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 PointType1, typename PointType2><br /> |
| bool <b>equivalence</b>(const </font><font face="Courier New">PointType1</font><font |
| face="Courier New">& point1,<br /> |
| |
| const </font><font face="Courier New">PointType2</font><font |
| face="Courier New">& 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 PointType><br /> |
| coordinate_type <b>x</b>(const </font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">><br /> |
| coordinate_type <b>y</b>(const </font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">><br /> |
| void <b>x</b>(p</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">><br /> |
| void <b>y</b>(</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">><br /> |
| point_type& <b>scale_up</b>(</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">><br /> |
| point_type& <b>scale_down</b>(</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">, typename scaling_type><br /> |
| point_type& <b>scale</b>(</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">, typename transform_type><br /> |
| point_type& <b>transform</b>(</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">><br /> |
| point_type& <b>move</b>(</font><font face="Courier New">PointType</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">1, typename PointType2><br /> |
| </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">& <b>convolve</b>(</font><font |
| face="Courier New">PointType</font><font face="Courier New">1</font><font |
| face="Courier New">& a,<br /> |
| |
| const </font><font face="Courier New">PointType2</font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">, typename </font><font |
| face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">><br /> |
| </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">,</font><font |
| face="Courier New">& <b>deconvolve</b>(</font><font |
| face="Courier New">PointType</font><font face="Courier New">1</font><font |
| face="Courier New">& a,<br /> |
| |
| const </font><font face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">></font><font |
| face="Courier New">& 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 </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">, typename </font><font |
| face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">><br /> |
| distance_type <b>euclidean_distance</b>(<br /> |
| const </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">&, const </font><font |
| face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">&)</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 <</font><font |
| face="Courier New">typename </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">, typename </font><font |
| face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">><br /> |
| coordinate_difference <b>euclidean_distance</b>(<br /> |
| const </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">&, </font><font |
| face="Courier New">const PointType</font><span |
| style="font-family: Courier New;">2&,</span><font |
| face="Courier New"> orientation_2d)</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 <</font><font |
| face="Courier New">typename </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">, typename </font><font |
| face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">><br /> |
| coordinate_difference <b>manhattan_distance</b>(<br /> |
| </font><font face="Courier New">const </font><font |
| face="Courier New">PointType</font><font face="Courier New">1</font><font |
| face="Courier New">&, </font><font face="Courier New">const |
| PointType</font><span style="font-family: Courier New;">2&</span><font |
| face="Courier New">)</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 <</font><font |
| face="Courier New">typename </font><font face="Courier New">PointType</font><font |
| face="Courier New">1</font><font face="Courier New">, typename </font><font |
| face="Courier New">PointType</font><span |
| style="font-family: Courier New;">2</span><font face="Courier New">><br /> |
| coordinate_difference <b>distance_squared</b>(<br /> |
| </font><font face="Courier New">const </font><font |
| face="Courier New">PointType</font><font face="Courier New">1</font><font |
| face="Courier New">&, </font><font face="Courier New">const |
| PointType</font><span style="font-family: Courier New;">2&</span><font |
| face="Courier New">)</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> |
| </tbody> |
| </table> |
| <h1>Point Data</h1> |
| <p> </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 id="table2" border="1" width="100%"> |
| <tbody> |
| <tr> |
| <td width="586"><b><font face="Courier New">coordinate_type</font></b></td> |
| <td>T</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New"><b>point_data</b>()</font></td> |
| <td>Default constructs the two coordinate values of the |
| point.</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New"><b>point_data</b>(T |
| x, T y)</font></td> |
| <td>Constructs an interval with two coordinates.</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New"><b>point_data</b>(const |
| point_data& that)</font></td> |
| <td>Copy construct</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 PointType><br /> |
| point_data& <b>operator=</b>(const PointType& 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">bool<b> operator==</b>(const |
| </font><font face="Courier New">point_data</font><font |
| face="Courier New">& that) const</font></td> |
| <td>Equality operator overload.<br /> |
| </td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New">bool<b> operator!=</b>(const |
| </font><font face="Courier New">point_data</font><font |
| face="Courier New">& that) const</font></td> |
| <td>Inequality operator overload.</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New"><b> </b>bool<b> |
| operator<</b>(const </font><font face="Courier New">point_data</font><font |
| face="Courier New">& that) const</font></td> |
| <td>Compares y coordinates then x coordinates to break ties.</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New"><b> </b>bool<b> |
| operator<=</b>(const </font><font face="Courier New">point_data</font><font |
| face="Courier New">& that) const</font></td> |
| <td>Compares y coordinates then x coordinates to break ties.</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New"><b> </b>bool<b> |
| operator></b>(const </font><font face="Courier New">point_data</font><font |
| face="Courier New">& that) const</font></td> |
| <td>Compares low coordinates then high coordinates to break |
| ties.</td> |
| </tr> |
| <tr> |
| <td width="586"><font face="Courier New">bool<b> |
| operator>=</b>(const </font><font face="Courier New">point_data</font><font |
| face="Courier New">& 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> |
| </tbody> |
| </table> |
| </td> |
| </tr> |
| <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" id="table3" frame="void" rules="none"> |
| <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> |
| </tbody> |
| </table> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </body> |
| </html> |