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">
8 Copyright 2009-2010 Intel Corporation
11 <title>Boost Polygon Library: Polygon
90 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"> -->
16 <table style=
"margin: 0pt; padding: 0pt; width: 100%;" border=
"0"
17 cellpadding=
"0" cellspacing=
"0">
20 <td style=
"background-color: rgb(238, 238, 238);" nowrap=
"1"
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>
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>Polygon
90 Concept
</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><a href=
"gtl_polygon_concept.htm">Polygon Concept
</a></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
48 <li><a href=
"gtl_polygon_45_set_concept.htm">Polygon
45 Set
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
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 />
62 <li><a href=
"voronoi_benchmark.htm">Voronoi Benchmark
</a><br />
64 <li><a href=
"voronoi_builder.htm">Voronoi Builder
</a></li>
65 <li><a href=
"voronoi_diagram.htm">Voronoi Diagram
</a></li>
67 <h3 class=
"navbar">Other Resources
</h3>
69 <li><a href=
"GTL_boostcon2009.pdf">GTL Boostcon
2009 Paper
</a></li>
70 <li><a href=
"GTL_boostcon_draft03.pdf">GTL Boostcon
2009
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
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>
87 style=
"padding-left: 10px; padding-right: 10px; padding-bottom: 10px;"
88 valign=
"top" width=
"100%">
89 <!-- End Header --><br />
92 <h1>Polygon
90 Concept
</h1>
94 <p>The polygon_90 concept tag is
<font face=
"Courier New">
95 polygon_90_concept
</font></p>
96 <p> To register a user defined type as a model of
<font
97 face=
"Times New Roman">polygon_90
</font>concept, specialize the
98 geometry concept meta-function for that type.
In the example
99 below CPolygon90 is registered as a model of polygon_90
concept.
</p>
100 <p> <font face=
"Courier New">template
<><br />
101 struct geometry_concept
<CPolygon90
> { typedef polygon_90_concept
103 <p> <font face=
"Times New Roman">The semantic of a polygon_90 is
104 that it can provide iterators over the x and y coordinates that
105 correspond to its horizontal and vertical sides, starting with an x
106 coordinate.
A mutable polygon_90 must also be able to set its
107 geometry based on an interator range over such coordinates.
Since
108 most polygons use vertex points in internal storage iterator adaptors
109 for converting to and from point sequences are provided in
110 iterator_points_to_compact.hpp and iterator_compact_to_points.hpp to
111 aid in the specialization of polygon_90_traits.
A
112 std::vector
<int
> or std::list
<int
> could be made models of
113 polygon_90_concept by simply providing access to their iterators
114 through traits.
Library functions that create polygon objects
115 require that those objects provide a default constructor.
</font></p>
116 <p> <font face=
"Times New Roman">Below is shown the default
117 polygon traits.
Specialization of these traits is required for
118 types that don't conform to the default behavior.
Note that these
119 traits are also used by the polygon_90_with_holes concept.
</font></p>
120 <p><font face=
"Courier New">template
<typename T
><br />
121 struct polygon_90_traits {
<br />
122 typedef typename T::coordinate_type
123 coordinate_type;
<br />
124 typedef typename T::compact_iterator_type
125 compact_iterator_type;
<br />
126 static inline compact_iterator_type
127 begin_compact(const T
& t) {
<br />
128 return
129 t.begin_compact();
<br />
130 }
<br />
131 static inline compact_iterator_type
132 end_compact(const T
& t) {
<br />
133 return
134 t.end_compact();
<br />
135 }
<br />
136 static inline unsigned int size(const T
&
138 return t.size();
<br />
139 }
<br />
140 static inline winding_direction winding(const
142 return
143 unknown_winding;
<br />
144 }
<br />
146 <p><font face=
"Courier New">template
<typename T
><br />
147 struct polygon_90_mutable_traits {
<br />
148 template
<typename iT
><br />
149 static inline T
& set_compact(T
& t, iT
150 input_begin, iT input_end) {
<br />
151
152 t.set_compact(input_begin, input_end);
<br />
153 return t;
<br />
154 }
</font><br />
155 <font face=
"Courier New">};
</font></p>
156 <p>An object that is a model of
<font face=
"Courier New">
157 polygon_90_concept
</font> can be viewed as a model of any of its
158 refinements if it is determined at runtime to conform to the
159 restriction of those concepts.
This concept casting is
160 accomplished through the
161 <font face=
"Courier New">view_as
<>()
</font> function.
</p>
162 <p><font face=
"Courier New">view_as
<rectangle_concept
>(polygon_90_object)
</font></p>
163 <p>The return value of
<font face=
"Courier New">view_as
<>()
</font>
164 can be passed into any interface that expects an object of the
165 conceptual type specified in its template parameter.
</p>
167 <table id=
"table1" border=
"1" width=
"100%">
170 <td width=
"586"><font face=
"Courier New">template
171 <typename T
><br />
172 compact_iterator_type
<b>begin_compact
</b>(const T
& polygon)
</font></td>
173 <td><font face=
"Times New Roman">Expects a model of
174 polygon_90.
Returns the begin iterator over the range of
175 coordinates that correspond to horizontal and vertical edges.
</font></td>
178 <td width=
"586"><font face=
"Courier New">template
179 <typename T
><br />
180 compact_iterator_type
<b>end_compact
</b>(const T
& polygon)
</font></td>
181 <td><font face=
"Times New Roman">Expects a model of
182 polygon_90.
Returns the end iterator over the range of
183 coordinates that correspond to horizontal and vertical edges.
</font></td>
186 <td width=
"586"><font face=
"Courier New">template
187 <typename T
><br />
188 point_iterator_type
<b>begin_points
</b>(const T
& polygon)
</font></td>
189 <td><font face=
"Times New Roman">Expects a model of
190 polygon_90.
Returns the begin iterator over the range of points
191 that correspond to vertices of the polygon.
</font></td>
194 <td width=
"586"><font face=
"Courier New">template
195 <typename T
><br />
196 point_iterator_type
<b>end_points
</b>(const T
& polygon)
</font></td>
197 <td><font face=
"Times New Roman">Expects a model of
198 polygon_90.
Returns the end iterator over the range of points
199 that correspond to vertices of the polygon.
</font></td>
202 <td width=
"586"><font face=
"Courier New">template
203 <typename T, typename iterator
><br />
204 void
<b>set_compact
</b>(T
& polygon, iterator b, iterator e)
</font></td>
205 <td><font face=
"Times New Roman">Expects a model of
206 polygon_90.
Sets the polygon to the coordinate data range
207 [b,e) that corresponds to .horizontal and vertical edges.
</font></td>
210 <td width=
"586"><font face=
"Courier New">template
211 <typename T, typename iterator
><br />
212 void
<b>set_points
</b>(T
& polygon, iterator b, iterator e)
</font></td>
213 <td><font face=
"Times New Roman">Expects a model of
214 polygon_90.
Sets the polygon to the point data range [b,e)
215 that corresponds to vertices of a manhattan polygon.
216 Non-manhattan edges between successive input points results in
217 undefined behavior.
</font></td>
220 <td width=
"586"><font face=
"Courier New">template
221 <typename T
><br />
222 unsigned int
<b>size
</b>(const T
& polygon)
</font></td>
223 <td><font face=
"Times New Roman">Returns the number of
224 edges in the polygon.
</font></td>
227 <td width=
"586"><font face=
"Courier New">template
228 <typename T1, typename T2
><br />
229 T1
& <b>assign
</b>(T1
& left, const T2
& right)
</font></td>
230 <td>Copies data from right object that models polygon_90
231 into left object that models polygon_90.
</td>
234 <td width=
"586"><font face=
"Courier New">template
235 <typename T, typename point_type
><br />
236 bool
<b>contains
</b>(const T
&, const point_type
& point,
<br />
237
238 bool consider_touch=true)
</font></td>
239 <td>Given an object that models polygon_90 and an object
240 that models point, returns true if the polygon contains the
241 point.
If the consider_touch flag is true will return true if the
242 point lies along the boundary of the polygon.
Linear wrt.
246 <td width=
"586"><font face=
"Courier New">// get the center
248 template
<typename T, typename point_type
><br />
249 void
<b>center
</b>(point_type
& p, const T
& polygon)
</font></td>
250 <td>Sets object that models point to the center point of
251 the bounding box of an object that models polygon_90.
Linear wrt.
255 <td width=
"586"><font face=
"Courier New">template
256 <typename T, typename rectangle_type
><br />
257 bool
<b>extents
</b>(rectangle_type
& bbox, const T
& polygon)
</font></td>
258 <td>Sets object that models rectangle to the bounding box
259 of an object that models polygon_90 and returns true.
Returns
260 false and leaves bbox unchanged if polygon is empty.
Linear wrt.
264 <td width=
"586"><font face=
"Courier New">template
265 <typename T
><br />
266 manhattan_area_type
<b>area
</b>(const T
& polygon)
</font></td>
267 <td>Returns the area of an object that models
268 polygon_90.
Linear wrt. vertices.
</td>
271 <td width=
"586"><font face=
"Courier New">template
272 <typename T
><br />
273 direction_1d
<b>winding
</b>(const T
& polygon)
</font></td>
274 <td>Returns the winding direction of an object that models
275 polygon_90, LOW == CLOCKWISE, HIGH = COUNTERCLOCKWISE.
Complexity
276 depends upon winding trait.
</td>
279 <td width=
"586"><font face=
"Courier New">template
280 <typename T
><br />
281 coordinate_difference
<b>perimeter
</b>(const T
& polygon)
</font></td>
282 <td>Returns the perimeter length of an object that models
283 polygon_90.
Linear wrt. vertices.
</td>
286 <td width=
"586"><font face=
"Courier New">template
287 <typename T, typename transform_type
><br />
288 T
& <b>transform
</b>(T
& polygon, const transform_type
&)
</font></td>
289 <td>Applies transform() on the vertices of polygon and sets
290 the polygon to that described by the result of transforming its
291 vertices.
Linear wrt. vertices.
</td>
294 <td width=
"586"><font face=
"Courier New">template
295 <typename T
><br />
296 T
& <b>scale_up
</b>(T
& polygon, unsigned_area_type factor)
</font></td>
297 <td>Scales up coordinate of an object that models
298 polygon_90 by unsigned factor.
Linear wrt. vertices.
</td>
301 <td width=
"586"><font face=
"Courier New">template
302 <typename T
><br />
303 T
& <b>scale_down
</b>(T
& polygon, unsigned_area_type factor)
</font></td>
304 <td>Scales down coordinates of an object that models
305 polygon_90 by unsigned factor.
Linear wrt. vertices.
</td>
308 <td width=
"586"><font face=
"Courier New">template
309 <typename T, scaling_type
><br />
310 T
& <b>scale
</b>(T
& rectangle, double scaling)
</font></td>
311 <td>Scales coordinates of an object that models polygon_90
312 by floating point factor.
Linear wrt. vertices.
</td>
315 <td width=
"586"><font face=
"Courier New">template
316 <typename T
><br />
317 T
& <b>move
</b>(T
& polygon, orientation_2d,
<br />
318 coordinate_difference
319 displacement)
</font></td>
320 <td>Adds displacement value to coordinate indicated by
321 orientation_2d of vertices of an object that models polygon_90 .
322 Linear wrt. vertices.
</td>
325 <td width=
"586"><font face=
"Courier New">template
326 <typename polygon_type, typename point_type
><br />
327 polygon_type
& <b>convolve
</b>(polygon_type
& polygon,
<br />
328
329 const point_type
& point)
</font></td>
330 <td>Convolves coordinate values of point with vertices of
331 an object that models polygon_90.
Linear wrt. vertices.
</td>
335 <h1>Polygon
90 Data
</h1>
337 <p>The library provides a model of polygon
90 concept declared
338 <font face=
"Courier New">template
<typename T
>
339 polygon_90_data
</font>where T is the coordinate type.
</p>
340 <p>This data type is used internally when a Manhattan polygon is
341 needed and is available to the library user who finds it convenient to
342 use a library polygon data type instead of providing their own.
343 The data type is implemented to be convenient to use with the library
346 <table id=
"table2" border=
"1" width=
"100%">
349 <td width=
"586"><b><font face=
"Courier New">geometry_type
</font></b></td>
350 <td><font face=
"Times New Roman">polygon_90_concept
</font></td>
353 <td width=
"586"><b><font face=
"Courier New">coordinate_type
</font></b></td>
354 <td><font face=
"Times New Roman">T
</font></td>
357 <td width=
"586"><b><font face=
"Courier New">iterator_type
</font></b></td>
358 <td>Iterator over vertices point_data
<T
> vertices of
362 <td width=
"586"><b><font face=
"Courier New">compact_iterator_type
</font></b></td>
363 <td><font face=
"Times New Roman">Iterator over
364 non-redundant coordinates of the polygon, alternating x, y, x, y
365 starting with an x, where each x corresponds to a vertical edge and
366 each y corresponds to a horizontal edge.
</font></td>
369 <td width=
"586"><font face=
"Courier New"><b>polygon_90_data
</b>()
</font></td>
370 <td><font face=
"Times New Roman">Default constructs the
</font>polygon.
</td>
373 <td width=
"586"><font face=
"Courier New"><b>polygon_90_data
</b>(const
374 polygon_90_data
& that)
</font></td>
375 <td><font face=
"Times New Roman">Copy construct
</font></td>
378 <td width=
"586"><font face=
"Courier New">polygon_90_data
&
379 <b>operator=
</b>(const polygon_90_data
& that)
</font></td>
380 <td>Assignment operator.
</td>
383 <td width=
"586"><font face=
"Courier New">template
384 <typename T2
><b> <br />
385 </b>polygon_90_data
& <b>operator=
</b>(const T2
&
386 that) const
</font></td>
387 <td>Assign from an object that is a model of polygon
90.
</td>
390 <td width=
"586"><font face=
"Courier New">iterator_type
<b>begin
</b>()
392 <td>Get the begin iterator over vertices of the polygon.
</td>
395 <td width=
"586"><font face=
"Courier New">iterator_type
<b>end
</b>()
397 <td>Get the end iterator over vertices of the polygon.
</td>
400 <td width=
"586"><font face=
"Courier New">compact_iterator_type
401 <b> begin_compact
</b>() const
</font></td>
402 <td>Get the begin compact iterator over non-redundant
403 coordinates of the polygon.
</td>
406 <td width=
"586"><font face=
"Courier New">compact_iterator_type
407 <b> end_compact
</b>() const
</font></td>
408 <td>Get the end compact iterator over non-redundant
409 coordinates of the polygon.
</td>
412 <td width=
"586"><font face=
"Courier New">std::size_t
<b>size
</b>()
414 <td>Get the number of elements in the sequence stored to
415 the polygon, usually equal to the number of edges of the polygon.
</td>
418 <td width=
"586"><font face=
"Courier New">template
419 <typename iT
><b> <br />
420 </b>void
<b>set
</b>(iT begin_points, iT end_points)
</font></td>
421 <td>Sets the polygon to the iterator range of points.
422 No check is performed to ensure the points describe a Manhattan figure,
423 every other x and y value of the points is used to initialize the
427 <td width=
"586"><font face=
"Courier New">template
428 <typename iT
><b> <br />
429 </b>void
<b>set_compact
</b>(iT begin_coords, iT end_coords)
</font></td>
430 <td>Sets the polygon to the iterator range of
431 coordinates.
These coordinates correspond to the x values of
432 vertical edges and y values of horizontal edges.
It is expected
433 that the sequence start with an x value and proceed x then y then x
441 <td style=
"background-color: rgb(238, 238, 238);" nowrap=
"1"
442 valign=
"top"> </td>
444 style=
"padding-left: 10px; padding-right: 10px; padding-bottom: 10px;"
445 valign=
"top" width=
"100%">
446 <table class=
"docinfo" id=
"table3" frame=
"void" rules=
"none">
447 <colgroup> <col class=
"docinfo-name" /><col
448 class=
"docinfo-content" /> </colgroup> <tbody valign=
"top">
450 <th class=
"docinfo-name">Copyright:
</th>
451 <td>Copyright © Intel Corporation
2008-
2010.
</td>
454 <th class=
"docinfo-name">License:
</th>
455 <td class=
"field-body">Distributed under the Boost Software
456 License, Version
1.0. (See accompanying file
<tt class=
"literal"> <span
457 class=
"pre">LICENSE_1_0.txt
</span></tt> or copy at
<a
458 class=
"reference" target=
"_top"
459 href=
"http://www.boost.org/LICENSE_1_0.txt">
460 http://www.boost.org/LICENSE_1_0.txt
</a>)
</td>