]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" | |
3 | xmlns:v="urn:schemas-microsoft-com:vml" | |
4 | xmlns:o="urn:schemas-microsoft-com:office:office" | |
5 | xmlns:(null)1="http://www.w3.org/TR/REC-html40" lang="en"> | |
6 | <head> | |
7 | <!-- | |
8 | Copyright 2009-2010 Intel Corporation | |
9 | license banner | |
10 | --> | |
11 | <title>Boost Polygon Library: Polygon Concept</title> | |
12 | <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /> | |
13 | <!-- <link type="text/css" rel="stylesheet" href="adobe_source.css"> --> | |
14 | </head> | |
15 | <body> | |
16 | <table style="margin: 0pt; padding: 0pt; width: 100%;" border="0" | |
17 | cellpadding="0" cellspacing="0"> | |
18 | <tbody> | |
19 | <tr> | |
20 | <td style="background-color: rgb(238, 238, 238);" nowrap="1" | |
21 | valign="top"> | |
22 | <div style="padding: 5px;" align="center"> <img | |
23 | src="images/boost.png" border="0" height="86" width="277" /><a | |
24 | title="www.boost.org home page" href="http://www.boost.org/" | |
25 | tabindex="2" style="border: medium none ;"> </a> </div> | |
26 | <div style="margin: 5px;"> | |
27 | <h3 class="navbar">Contents</h3> | |
28 | <ul> | |
29 | <li><a href="index.htm">Boost.Polygon Main Page</a></li> | |
30 | <li><a href="gtl_design_overview.htm">Design Overview</a></li> | |
31 | <li><a href="gtl_isotropy.htm">Isotropy</a></li> | |
32 | <li><a href="gtl_coordinate_concept.htm">Coordinate Concept</a></li> | |
33 | <li><a href="gtl_interval_concept.htm">Interval Concept</a></li> | |
34 | <li><a href="gtl_point_concept.htm">Point Concept</a></li> | |
35 | <li><a href="gtl_segment_concept.htm">Segment Concept</a></li> | |
36 | <li><a href="gtl_rectangle_concept.htm">Rectangle Concept</a></li> | |
37 | <li><a href="gtl_polygon_90_concept.htm">Polygon 90 Concept</a></li> | |
38 | <li><a href="gtl_polygon_90_with_holes_concept.htm">Polygon 90 | |
39 | With Holes Concept</a></li> | |
40 | <li><a href="gtl_polygon_45_concept.htm">Polygon 45 Concept</a></li> | |
41 | <li><a href="gtl_polygon_45_with_holes_concept.htm">Polygon 45 | |
42 | With Holes Concept</a></li> | |
43 | <li>Polygon Concept</li> | |
44 | <li><a href="gtl_polygon_with_holes_concept.htm">Polygon With | |
45 | Holes Concept</a></li> | |
46 | <li><a href="gtl_polygon_90_set_concept.htm">Polygon 90 Set | |
47 | Concept</a></li> | |
48 | <li><a href="gtl_polygon_45_set_concept.htm">Polygon 45 Set | |
49 | Concept</a></li> | |
50 | <li><a href="gtl_polygon_set_concept.htm">Polygon Set Concept</a></li> | |
51 | <li><a href="gtl_connectivity_extraction_90.htm">Connectivity | |
52 | Extraction 90</a></li> | |
53 | <li><a href="gtl_connectivity_extraction_45.htm">Connectivity | |
54 | Extraction 45</a></li> | |
55 | <li><a href="gtl_connectivity_extraction.htm">Connectivity | |
56 | Extraction</a></li> | |
57 | <li><a href="gtl_property_merge_90.htm">Property Merge 90</a></li> | |
58 | <li><a href="gtl_property_merge_45.htm">Property Merge 45</a></li> | |
59 | <li><a href="gtl_property_merge.htm">Property Merge</a></li> | |
60 | <li><a href="voronoi_main.htm">Voronoi Main Page<br /> | |
61 | </a></li> | |
62 | <li><a href="voronoi_benchmark.htm">Voronoi Benchmark</a><br /> | |
63 | </li> | |
64 | <li><a href="voronoi_builder.htm">Voronoi Builder</a></li> | |
65 | <li><a href="voronoi_diagram.htm">Voronoi Diagram</a></li> | |
66 | </ul> | |
67 | <h3 class="navbar">Other Resources</h3> | |
68 | <ul> | |
69 | <li><a href="GTL_boostcon2009.pdf">GTL Boostcon 2009 Paper</a></li> | |
70 | <li><a href="GTL_boostcon_draft03.pdf">GTL Boostcon 2009 | |
71 | Presentation</a></li> | |
72 | <li><a href="analysis.htm">Performance Analysis</a></li> | |
73 | <li><a href="gtl_tutorial.htm">Layout Versus Schematic Tutorial</a></li> | |
74 | <li><a href="gtl_minkowski_tutorial.htm">Minkowski Sum Tutorial</a></li> | |
75 | <li><a href="voronoi_basic_tutorial.htm">Voronoi Basic Tutorial</a></li> | |
76 | <li><a href="voronoi_advanced_tutorial.htm">Voronoi Advanced | |
77 | Tutorial</a></li> | |
78 | </ul> | |
79 | </div> | |
80 | <h3 class="navbar">Polygon Sponsor</h3> | |
81 | <div style="padding: 5px;" align="center"> <img | |
82 | src="images/intlogo.gif" border="0" height="51" width="127" /><a | |
83 | title="www.adobe.com home page" href="http://www.adobe.com/" | |
84 | tabindex="2" style="border: medium none ;"> </a> </div> | |
85 | </td> | |
86 | <td | |
87 | style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" | |
88 | valign="top" width="100%"> | |
89 | <!-- End Header --><br /> | |
90 | <p> | |
91 | </p> | |
92 | <h1>Polygon Concept</h1> | |
93 | <p> </p> | |
94 | <p>The polygon concept tag is <font face="Courier New"> | |
95 | polygon_concept</font></p> | |
96 | <p> To register a user defined type as a model of <font | |
97 | face="Times New Roman">polygon </font>concept, specialize the | |
98 | geometry concept meta-function for that type. In the example | |
99 | below CPolygon is registered as a model of polygon concept.</p> | |
100 | <p> <font face="Courier New">template <><br /> | |
101 | struct geometry_concept<CPolygon> { typedef polygon_concept type; | |
102 | };</font></p> | |
103 | <p> <font face="Times New Roman">The semantic of a polygon is | |
104 | that it can provide iterators over the points that represent its | |
105 | vertices. It is acceptable to have the last edge explict with the | |
106 | first and last point equal to each other or implied by this segement | |
107 | that would connect the first and last point. A mutable polygon | |
108 | must also be able to set its geometry based on an interator range over | |
109 | such points. A std::vector<point_data<int> > or | |
110 | std::list<point_data<int> > could be made models of | |
111 | polygon_concept by simply providing access to their iterators through | |
112 | traits. Library functions that create polygon objects require | |
113 | that those objects provide a default constructor.</font></p> | |
114 | <p> <font face="Times New Roman">Below is shown the default | |
115 | polygon traits. Specialization of these traits is required for | |
116 | types that don't conform to the default behavior. Note that these | |
117 | same traits are also used by several other polygon concepts through | |
118 | SFINE enable template parameter. The SFINE enable parameter also | |
119 | allows the library to provide default specialization that work for any | |
120 | object that models the 90 degree polygon concepts.</font></p> | |
121 | <p><font face="Courier New">template <typename T, typename | |
122 | enable = gtl_yes><br /> | |
123 | struct polygon_traits {};<br /> | |
124 | <br /> | |
125 | template <typename T><br /> | |
126 | struct polygon_traits<T, <br /> | |
127 | typename gtl_or_4<<br /> | |
128 | typename gtl_same_type<typename | |
129 | geometry_concept<T>::type, polygon_concept>::type,<br /> | |
130 | typename gtl_same_type<typename | |
131 | geometry_concept<T>::type, polygon_concept>::type,<br /> | |
132 | typename gtl_same_type<typename | |
133 | geometry_concept<T>::type, polygon_with_holes_concept>::type,<br /> | |
134 | typename gtl_same_type<typename | |
135 | geometry_concept<T>::type, polygon_with_holes_concept>::type<br /> | |
136 | >::type> {<br /> | |
137 | typedef typename T::coordinate_type | |
138 | coordinate_type;<br /> | |
139 | typedef typename T::iterator_type | |
140 | iterator_type;<br /> | |
141 | typedef typename T::point_type point_type;<br /> | |
142 | static inline iterator_type begin_points(const | |
143 | T& t) {<br /> | |
144 | return t.begin();<br /> | |
145 | }<br /> | |
146 | static inline iterator_type end_points(const | |
147 | T& t) {<br /> | |
148 | return t.end();<br /> | |
149 | }<br /> | |
150 | static inline unsigned int size(const T& | |
151 | t) {<br /> | |
152 | return t.size();<br /> | |
153 | }<br /> | |
154 | static inline winding_direction winding(const | |
155 | T& t) {<br /> | |
156 | return | |
157 | unknown_winding;<br /> | |
158 | }<br /> | |
159 | };</font></p> | |
160 | <p><font face="Courier New">template <typename T, typename | |
161 | enable = void><br /> | |
162 | struct polygon_mutable_traits {<br /> | |
163 | template <typename iT><br /> | |
164 | static inline T& set_points(T& t, iT | |
165 | input_begin, iT input_end) {<br /> | |
166 | | |
167 | t.set(input_begin, input_end);<br /> | |
168 | return t;<br /> | |
169 | }<br /> | |
170 | };</font></p> | |
171 | <p>Example code <a href="gtl_custom_polygon.htm">custom_polygon.cpp</a> | |
172 | demonstrates mapping a user defined polygon class to the library | |
173 | polygon_concept</p> | |
174 | <p>An object that is a model of <font face="Courier New"> | |
175 | polygon_concept</font> can be viewed as a model of any of its | |
176 | refinements if it is determined at runtime to conform to the | |
177 | restriction of those concepts. This concept casting is | |
178 | accomplished through the | |
179 | <font face="Courier New">view_as<>()</font> function.</p> | |
180 | <p><font face="Courier New">view_as<rectangle_concept>(polygon_object)</font><br /> | |
181 | <font face="Courier New">view_as<polygon_90_concept>(polygon_object)</font><br /> | |
182 | <font face="Courier New">view_as<polygon_45_concept>(polygon_object)</font></p> | |
183 | <p>The return value of <font face="Courier New">view_as<>()</font> | |
184 | can be passed into any interface that expects an object of the | |
185 | conceptual type specified in its template parameter. </p> | |
186 | <h2>Functions</h2> | |
187 | <table id="table1" border="1" width="100%"> | |
188 | <tbody> | |
189 | <tr> | |
190 | <td width="586"><font face="Courier New">template | |
191 | <typename T><br /> | |
192 | point_iterator_type <b>begin_points</b>(const T& polygon)</font></td> | |
193 | <td><font face="Times New Roman">Expects a model of | |
194 | polygon. Returns the begin iterator over the range of points that | |
195 | correspond to vertices of the polygon.</font></td> | |
196 | </tr> | |
197 | <tr> | |
198 | <td width="586"><font face="Courier New">template | |
199 | <typename T><br /> | |
200 | point_iterator_type <b>end_points</b>(const T& polygon)</font></td> | |
201 | <td><font face="Times New Roman">Expects a model of | |
202 | polygon. Returns the end iterator over the range of points that | |
203 | correspond to vertices of the polygon.</font></td> | |
204 | </tr> | |
205 | <tr> | |
206 | <td width="586"><font face="Courier New">template | |
207 | <typename T, typename iterator><br /> | |
208 | void <b>set_points</b>(T& polygon, iterator b, iterator e)</font></td> | |
209 | <td><font face="Times New Roman">Expects a model of | |
210 | polygon. Sets the polygon to the point data range [b,e) | |
211 | that corresponds to vertices of a manhattan polygon.</font></td> | |
212 | </tr> | |
213 | <tr> | |
214 | <td width="586"><font face="Courier New">template | |
215 | <typename T><br /> | |
216 | unsigned int <b>size</b>(const T& polygon)</font></td> | |
217 | <td><font face="Times New Roman">Returns the number of | |
218 | edges in the polygon.</font></td> | |
219 | </tr> | |
220 | <tr> | |
221 | <td width="586"><font face="Courier New">template | |
222 | <typename T1, typename T2><br /> | |
223 | T1& <b>assign</b>(T1& left, const T2& right)</font></td> | |
224 | <td>Copies data from right object that models polygon into | |
225 | left object that models polygon.</td> | |
226 | </tr> | |
227 | <tr> | |
228 | <td width="586"><font face="Courier New">template | |
229 | <typename T, typename point_type><br /> | |
230 | bool <b>contains</b>(const T&, const point_type& point, <br /> | |
231 | | |
232 | bool consider_touch=true)</font></td> | |
233 | <td>Given an object that models polygon and an object that | |
234 | models point, returns true if the polygon contains the point. If | |
235 | the consider_touch flag is true will return true if the point lies | |
236 | along the boundary of the polygon. Linear wrt. vertices.</td> | |
237 | </tr> | |
238 | <tr> | |
239 | <td width="586"><font face="Courier New">// get the center | |
240 | coordinate<br /> | |
241 | template <typename T, typename point_type><br /> | |
242 | void <b>center</b>(point_type& p, const T& polygon)</font></td> | |
243 | <td>Sets object that models point to the center point of | |
244 | the bounding box of an object that models polygon. Linear wrt. | |
245 | vertices.</td> | |
246 | </tr> | |
247 | <tr> | |
248 | <td width="586"><font face="Courier New">template | |
249 | <typename T, typename rectangle_type><br /> | |
250 | bool <b>extents</b>(rectangle_type& bbox, const T& polygon)</font></td> | |
251 | <td>Sets object that models rectangle to the bounding box | |
252 | of an object that models polygon and returns true. Returns false | |
253 | and leaves bbox unchanged if polygon is empty. Linear wrt. | |
254 | vertices.</td> | |
255 | </tr> | |
256 | <tr> | |
257 | <td width="586"><font face="Courier New">template | |
258 | <typename T><br /> | |
259 | area_type <b>area</b>(const T& polygon)</font></td> | |
260 | <td>Returns the area of an object that models | |
261 | polygon. Linear wrt. vertices.</td> | |
262 | </tr> | |
263 | <tr> | |
264 | <td width="586"><font face="Courier New">template | |
265 | <typename T><br /> | |
266 | direction_1d <b>winding</b>(const T& polygon)</font></td> | |
267 | <td>Returns the winding direction of an object that models | |
268 | polygon, LOW == CLOCKWISE, HIGH = COUNTERCLOCKWISE. Complexity | |
269 | depends upon winding trait.</td> | |
270 | </tr> | |
271 | <tr> | |
272 | <td width="586"><font face="Courier New">template | |
273 | <typename T><br /> | |
274 | coordinate_distance <b>perimeter</b>(const T& polygon)</font></td> | |
275 | <td>Returns the perimeter length of an object that models | |
276 | polygon. Linear wrt. vertices.</td> | |
277 | </tr> | |
278 | <tr> | |
279 | <td width="586"><font face="Courier New">template | |
280 | <typename T, typename transform_type><br /> | |
281 | T& <b>transform</b>(T& polygon, const transform_type&)</font></td> | |
282 | <td>Applies transform() on the vertices of polygon and sets | |
283 | the polygon to that described by the result of transforming its | |
284 | vertices. Linear wrt. vertices.</td> | |
285 | </tr> | |
286 | <tr> | |
287 | <td width="586"><font face="Courier New">template | |
288 | <typename T><br /> | |
289 | T& <b>scale_up</b>(T& polygon, unsigned_area_type factor)</font></td> | |
290 | <td>Scales up coordinate of an object that models polygon | |
291 | by unsigned factor. Linear wrt. vertices.</td> | |
292 | </tr> | |
293 | <tr> | |
294 | <td width="586"><font face="Courier New">template | |
295 | <typename T><br /> | |
296 | T& <b>scale_down</b>(T& polygon, unsigned_area_type factor)</font></td> | |
297 | <td>Scales down coordinates of an object that models | |
298 | polygon by unsigned factor. Linear wrt. vertices.</td> | |
299 | </tr> | |
300 | <tr> | |
301 | <td width="586"><font face="Courier New">template | |
302 | <typename T, scaling_type><br /> | |
303 | T& <b>scale</b>(T& rectangle, double scaling) </font></td> | |
304 | <td>Scales coordinates of an object that models polygon by | |
305 | floating point factor. Linear wrt. vertices.</td> | |
306 | </tr> | |
307 | <tr> | |
308 | <td width="586"><font face="Courier New">template | |
309 | <typename T><br /> | |
310 | T& <b>move</b>(T& polygon, orientation_2d,<br /> | |
311 | coordinate_difference | |
312 | displacement)</font></td> | |
313 | <td>Adds displacement value to coordinate indicated by | |
314 | orientation_2d of vertices of an object that models polygon . | |
315 | Linear wrt. vertices.</td> | |
316 | </tr> | |
317 | <tr> | |
318 | <td width="586"><font face="Courier New">template | |
319 | <typename polygon_type, typename point_type><br /> | |
320 | polygon_type& <b>convolve</b>(polygon_type& polygon,<br /> | |
321 | | |
322 | const point_type& point)</font></td> | |
323 | <td>Convolves coordinate values of point with vertices of | |
324 | an object that models polygon. Linear wrt. vertices.</td> | |
325 | </tr> | |
326 | </tbody> | |
327 | </table> | |
328 | <h1>Polygon Data</h1> | |
329 | <p> </p> | |
330 | <p>The library provides a model of polygon concept declared | |
331 | <font face="Courier New">template<typename T> polygon_data </font>where | |
332 | T is the coordinate type.</p> | |
333 | <p>This data type is used internally when a polygon is needed and | |
334 | is available to the library user who finds it convenient to use a | |
335 | library polygon data type instead of providing their own. The | |
336 | data type is implemented to be convenient to use with the library | |
337 | traits.</p> | |
338 | <p>Example code <a href="gtl_polygon_usage.htm">polygon_usage.cpp</a> | |
339 | demonstrates using the library provided polygon data types and functions</p> | |
340 | <h2>Members</h2> | |
341 | <table id="table2" border="1" width="100%"> | |
342 | <tbody> | |
343 | <tr> | |
344 | <td width="586"><b><font face="Courier New">geometry_type</font></b></td> | |
345 | <td><font face="Times New Roman">polygon_concept</font></td> | |
346 | </tr> | |
347 | <tr> | |
348 | <td width="586"><b><font face="Courier New">coordinate_type</font></b></td> | |
349 | <td><font face="Times New Roman">T</font></td> | |
350 | </tr> | |
351 | <tr> | |
352 | <td width="586"><b><font face="Courier New">iterator_type</font></b></td> | |
353 | <td>Iterator over vertices point_data<T> vertices of | |
354 | polygon</td> | |
355 | </tr> | |
356 | <tr> | |
357 | <td width="586"><font face="Courier New"><b>polygon_data</b>()</font></td> | |
358 | <td><font face="Times New Roman">Default constructs the </font>polygon.</td> | |
359 | </tr> | |
360 | <tr> | |
361 | <td width="586"><font face="Courier New"><b>polygon_data</b>(const | |
362 | polygon_data& that)</font></td> | |
363 | <td><font face="Times New Roman">Copy construct</font></td> | |
364 | </tr> | |
365 | <tr> | |
366 | <td width="586"><font face="Courier New">polygon_data& <b>operator=</b>(const | |
367 | polygon_data& that)</font></td> | |
368 | <td>Assignment operator.</td> | |
369 | </tr> | |
370 | <tr> | |
371 | <td width="586"><font face="Courier New">template | |
372 | <typename T2><b> <br /> | |
373 | </b>polygon_data& <b>operator=</b>(const T2& that) | |
374 | const</font></td> | |
375 | <td>Assign from an object that is a model of polygon.</td> | |
376 | </tr> | |
377 | <tr> | |
378 | <td width="586"><font face="Courier New">iterator_type <b>begin</b>() | |
379 | const</font></td> | |
380 | <td>Get the begin iterator over vertices of the polygon.</td> | |
381 | </tr> | |
382 | <tr> | |
383 | <td width="586"><font face="Courier New">iterator_type <b>end</b>() | |
384 | const</font></td> | |
385 | <td>Get the end iterator over vertices of the polygon.</td> | |
386 | </tr> | |
387 | <tr> | |
388 | <td width="586"><font face="Courier New">std::size_t <b>size</b>() | |
389 | const</font></td> | |
390 | <td>Get the number of elements in the sequence stored to | |
391 | the polygon, usually equal to the number of edges of the polygon.</td> | |
392 | </tr> | |
393 | <tr> | |
394 | <td width="586"><font face="Courier New">template | |
395 | <typename iT><b> <br /> | |
396 | </b>void <b>set</b>(iT begin_points, iT end_points)</font></td> | |
397 | <td>Sets the polygon to the iterator range of points. | |
398 | </td> | |
399 | </tr> | |
400 | </tbody> | |
401 | </table> | |
402 | </td> | |
403 | </tr> | |
404 | <tr> | |
405 | <td style="background-color: rgb(238, 238, 238);" nowrap="1" | |
406 | valign="top"> </td> | |
407 | <td | |
408 | style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" | |
409 | valign="top" width="100%"> | |
410 | <table class="docinfo" id="table3" frame="void" rules="none"> | |
411 | <colgroup> <col class="docinfo-name" /><col | |
412 | class="docinfo-content" /> </colgroup> <tbody valign="top"> | |
413 | <tr> | |
414 | <th class="docinfo-name">Copyright:</th> | |
415 |