voronoi_builder.htm 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html><head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Voronoi Builder</title></head><body>
  5. <table style="margin: 0pt; padding: 0pt; width: 100%;" border="0" cellpadding="0" cellspacing="0">
  6. <tbody>
  7. <tr>
  8. <td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
  9. <div style="padding: 5px;" align="center"> <img src="images/boost.png" border="0" height="86" width="277"><a title="www.boost.org home page" tabindex="2" style="border: medium none ;" href="http://www.boost.org/"> </a></div>
  10. <div style="margin: 5px;">
  11. <h3 class="navbar">Contents</h3>
  12. <ul>
  13. <li><a href="index.htm">Boost.Polygon Main Page</a></li>
  14. <li><a href="gtl_design_overview.htm">Design Overview</a></li>
  15. <li><a href="gtl_isotropy.htm">Isotropy</a></li>
  16. <li><a href="gtl_coordinate_concept.htm">Coordinate Concept</a></li>
  17. <li><a href="gtl_interval_concept.htm">Interval Concept</a></li>
  18. <li><a href="gtl_point_concept.htm">Point Concept</a></li>
  19. <li><a href="gtl_segment_concept.htm">Segment Concept</a></li>
  20. <li><a href="gtl_rectangle_concept.htm">Rectangle Concept</a></li>
  21. <li><a href="gtl_polygon_90_concept.htm">Polygon 90 Concept</a></li>
  22. <li><a href="gtl_polygon_90_with_holes_concept.htm">Polygon 90
  23. With Holes Concept</a></li>
  24. <li><a href="gtl_polygon_45_concept.htm">Polygon 45 Concept</a></li>
  25. <li><a href="gtl_polygon_45_with_holes_concept.htm">Polygon 45
  26. With Holes Concept</a></li>
  27. <li><a href="gtl_polygon_concept.htm">Polygon Concept</a></li>
  28. <li><a href="gtl_polygon_with_holes_concept.htm">Polygon With
  29. Holes Concept</a></li>
  30. <li><a href="gtl_polygon_90_set_concept.htm">Polygon 90 Set
  31. Concept</a></li>
  32. <li><a href="gtl_polygon_45_set_concept.htm">Polygon 45 Set
  33. Concept</a></li>
  34. <li><a href="gtl_polygon_set_concept.htm">Polygon Set Concept</a></li>
  35. <li><a href="gtl_connectivity_extraction_90.htm">Connectivity
  36. Extraction 90</a></li>
  37. <li><a href="gtl_connectivity_extraction_45.htm">Connectivity
  38. Extraction 45</a></li>
  39. <li><a href="gtl_connectivity_extraction.htm">Connectivity
  40. Extraction</a></li>
  41. <li><a href="gtl_property_merge_90.htm">Property Merge 90</a></li>
  42. <li><a href="gtl_property_merge_45.htm">Property Merge 45</a></li>
  43. <li><a href="gtl_property_merge.htm">Property Merge</a></li>
  44. <li><a href="voronoi_main.htm">Voronoi Main Page </a></li>
  45. <li><a href="voronoi_benchmark.htm">Voronoi Benchmark</a> </li>
  46. <li>Voronoi Builder</li>
  47. <li><a href="voronoi_diagram.htm">Voronoi Diagram</a></li>
  48. </ul>
  49. <h3 class="navbar">Other Resources</h3>
  50. <ul>
  51. <li><a href="GTL_boostcon2009.pdf">GTL Boostcon 2009 Paper</a></li>
  52. <li><a href="GTL_boostcon_draft03.pdf">GTL Boostcon 2009
  53. Presentation</a></li>
  54. <li><a href="analysis.htm">Performance Analysis</a></li>
  55. <li><a href="gtl_tutorial.htm">Layout Versus Schematic Tutorial</a></li>
  56. <li><a href="gtl_minkowski_tutorial.htm">Minkowski Sum Tutorial</a></li>
  57. <li><a href="voronoi_basic_tutorial.htm">Voronoi Basic Tutorial</a></li>
  58. <li><a href="voronoi_advanced_tutorial.htm">Voronoi Advanced
  59. Tutorial</a></li>
  60. </ul>
  61. </div>
  62. <h3 class="navbar">Polygon Sponsor</h3>
  63. <div style="padding: 5px;" align="center"> <img src="images/intlogo.gif" border="0" height="51" width="127"><a title="www.adobe.com home page" tabindex="2" style="border: medium none ;" href="http://www.adobe.com/"> </a></div>
  64. </td>
  65. <td style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" valign="top" width="100%"><!-- End Header --> <br>
  66. <h1>Voronoi Builder </h1>
  67. The Voronoi builder is the event generator structure, that implements
  68. the <a href="http://en.wikipedia.org/wiki/Sweep_line_algorithm">sweepline
  69. algorithm</a>,
  70. scanning 2D space and spawning the two types of events: <a href="http://www.ams.org/samplings/feature-column/fcarc-voronoi">site
  71. events and circle events</a>. Each event is reported to the output data
  72. structure builder.
  73. The structure shares Voronoi name, as the events generated by it
  74. provide
  75. enough information to construct the Voronoi diagram of a set of points
  76. and linear segments. The requirements for the coordinate type of
  77. the input/output geometries, configured through the coordinate type
  78. traits template argument, are the following:<br>
  79. <ul>
  80. <li>The input coordinate type (for input points and enpoints of
  81. the input segments) is not required to be integral
  82. (while it
  83. still should be an integer type)</li>
  84. <li>The output coordinate type (for
  85. Voronoi vertices) is required to be IEEE-754 floating point type</li>
  86. </ul>
  87. <h2>Important</h2>
  88. The users are encouraged to use the default static methods defined in
  89. the <a href="../../../boost/polygon/voronoi.hpp">voronoi.hpp</a>
  90. header for the Voronoi diagram construction. However it's also possible
  91. to
  92. use Voronoi builder explicitly, especially if the user wants to drop
  93. the external dependencies such as MPL (metaprogramming library). The
  94. following include set doesn't depend on any external headers
  95. (except STL and boost/cstdint.hpp), even
  96. the Boost.Polygon library:<br>
  97. <br>
  98. <span style="font-family: Courier New,Courier,monospace;">#include
  99. &lt;voronoi_builder.hpp&gt;</span><br style="font-family: Courier New,Courier,monospace;">
  100. <span style="font-family: Courier New,Courier,monospace;">#include
  101. &lt;voronoi_diagram.hpp&gt;</span><br>
  102. <h2>Declaration</h2>
  103. Header: <a href="../../../boost/polygon/voronoi_builder.hpp">boost/polygon/voronoi_builder.hpp</a><br>
  104. <br>
  105. <font face="Courier New"> <span style="font-family: 'Courier New',Courier,monospace;">template
  106. &lt;typename T,</span><br style="font-family: 'Courier New',Courier,monospace;">
  107. <span style="font-family: 'Courier New',Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  108. typename CTT = detail::voronoi_ctype_traits&lt;T&gt;,</span><br style="font-family: 'Courier New',Courier,monospace;">
  109. <span style="font-family: 'Courier New',Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  110. typename VP = detail::voronoi_predicates&lt;CTT&gt; &gt;</span><br style="font-family: 'Courier New',Courier,monospace;">
  111. <span style="font-family: 'Courier New',Courier,monospace;">class
  112. voronoi_builder;</span><br>
  113. <br>
  114. <span style="font-family: 'Courier New',Courier,monospace;">T</span></font>
  115. - specifies the coordinate type of the input geometries (points and
  116. segments).<br>
  117. <font face="Courier New"> <span style="font-family: 'Courier New',Courier,monospace;">CTT</span></font>
  118. - defines the input/output coordinate type traits used by the Voronoi
  119. predicates (VP).<br>
  120. <font face="Courier New"> <span style="font-family: 'Courier New',Courier,monospace;">VP</span></font>
  121. - the predicate kernel, that contains robust and
  122. efficient predicates and functors.<br>
  123. The Voronoi builder data structure is ready to use from the box with
  124. 32-bit signed integer input coordinate type. The user may extend the
  125. input coordinate range to the other integer types (e.g. 64-bit
  126. integer), however this will also require manual setup of the
  127. coordinate type traits. Default predicate kernel provides correct and
  128. efficient predicates as long as types
  129. defined by the coordinate type traits satisfy the requirements
  130. explained at the end of this page. In case
  131. those
  132. requirements are not satisfied,<font face="Courier New"><span style="font-family: 'Courier New',Courier,monospace;"></span></font>
  133. the proper predicate kernel
  134. implementation is required.<span style="font-family: Courier New,Courier,monospace;"></span><br>
  135. <h2>Member Functions</h2>
  136. <table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
  137. <tbody>
  138. <tr>
  139. <td style="font-family: 'Courier New',Courier,monospace;"><span style="font-weight: bold;">voronoi_builder</span>()</td>
  140. <td width="693">Default
  141. constructor.</td>
  142. </tr>
  143. <tr>
  144. <td><span style="font-family: Courier New,Courier,monospace;">size_t <span style="font-weight: bold;">insert_point</span>(const int_type&amp; x,<br>
  145. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  146. const int_type&amp; y)</span> </td>
  147. <td>Inserts a point object with
  148. the specified coordinates into the Voronoi builder.<br>
  149. Returns index of the inserted point. </td>
  150. </tr>
  151. <tr>
  152. <td><span style="font-family: Courier New,Courier,monospace;">size_t <span style="font-weight: bold;">insert_segment</span>(const int_type&amp;
  153. x1,<br>
  154. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  155. const int_type&amp; y1,<br>
  156. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  157. const int_type&amp; x2,<br>
  158. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  159. const int_type&amp; y2)</span> </td>
  160. <td>Inserts a segment object
  161. with the specified coordinates into the Voronoi builder.<br>
  162. Returns index of the inserted segment. </td>
  163. </tr>
  164. <tr>
  165. <td style="font-family: 'Courier New',Courier,monospace;">template
  166. &lt;typename OUTPUT&gt;<br>
  167. void <span style="font-weight: bold;">construct</span>(OUTPUT* output)
  168. </td>
  169. <td width="693">Runs the sweepline
  170. algorithm over the set of inserted geometries and generates site and
  171. circle events to the OUTPUT data structure. It's the responsibility of
  172. the
  173. output data structure to process them.<br>
  174. Complexity: O(N * log N), where N is the total number of input points and segments.<br>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td style="font-family: 'Courier New',Courier,monospace;">void
  179. <span style="font-weight: bold;">clear</span>() </td>
  180. <td width="693">Clears the
  181. list of the inserted geometries. Sets the input geometry index to
  182. zero. </td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. <h1>Voronoi Coordinate Type Traits</h1>
  187. <p>The library provides the default coordinate type traits
  188. specialization for the
  189. 32-bit signed integer type:</p>
  190. <font style="font-family: 'Courier New',Courier,monospace;" face="Courier New">
  191. <p>template &lt;typename T&gt;<br>
  192. struct voronoi_ctype_traits;<br>
  193. <br>
  194. template &lt;&gt;<br>
  195. struct voronoi_ctype_traits&lt;int32&gt; {<br>
  196. &nbsp;&nbsp;&nbsp; typedef int32 int_type;<br>
  197. &nbsp;&nbsp;&nbsp; typedef int64 int_x2_type;<br>
  198. &nbsp;&nbsp;&nbsp; typedef uint64 uint_x2_type;<br>
  199. &nbsp;&nbsp;&nbsp; typedef extended_int&lt;128&gt; big_int_type;<br>
  200. &nbsp;&nbsp;&nbsp; typedef fpt64 fpt_type;<br>
  201. &nbsp;&nbsp;&nbsp; typedef extended_exponent_fpt&lt;fpt_type&gt;
  202. efpt_type;<br>
  203. &nbsp;&nbsp;&nbsp; typedef ulp_comparison&lt;fpt_type&gt; ulp_cmp_type;<br>
  204. &nbsp;&nbsp;&nbsp; typedef type_converter_fpt to_fpt_converter_type;<br>
  205. &nbsp;&nbsp;&nbsp; typedef type_converter_efpt to_efpt_converter_type;<br>
  206. };</p>
  207. </font> One
  208. of the most important features of the library is that Voronoi builder
  209. output geometries are constructed within defined relative error (64
  210. machine epsilons). That means, the more mantissa bits the user provided
  211. fpt_type has, the better precision of the output geometries will be. In
  212. order for the user defined traits to be consistent with the default
  213. Voronoi builder predicate kernel user should define the following set
  214. of traits (the assumption is made that input geometries have
  215. X-bit signed integer coordinate type):<br>
  216. <br>
  217. <table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
  218. <tbody>
  219. <tr>
  220. <td style="font-family: 'Courier New',Courier,monospace; font-weight: bold;">int_type
  221. </td>
  222. <td style="vertical-align: top;">At least X-bit signed
  223. integer type. </td>
  224. </tr>
  225. <tr>
  226. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">int_x2_type
  227. </td>
  228. <td style="vertical-align: top;">At least 2X-bit signed
  229. integer type. </td>
  230. </tr>
  231. <tr>
  232. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">uint_x2_type
  233. </td>
  234. <td style="vertical-align: top;">At least 2X-bit unsigned
  235. integer type. </td>
  236. </tr>
  237. <tr>
  238. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">big_int_type
  239. </td>
  240. <td style="vertical-align: top;">At least 8X-bit signed
  241. integer type if input dataset contains only points.<br>
  242. At least 64X-bit signed integer type if input dataset contains
  243. segments. </td>
  244. </tr>
  245. <tr>
  246. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">fpt_type
  247. </td>
  248. <td style="vertical-align: top;">IEEE-754 floating point
  249. type, with mantissa at least (X+16) bits and exponent able to handle
  250. 32X-bit unsigned integer type. </td>
  251. </tr>
  252. <tr>
  253. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">efpt_type
  254. </td>
  255. <td style="vertical-align: top;">IEEE-754 floating point
  256. type, with mantissa at least (X+16) bits and exponent able to handle
  257. 64X-bit unsigned integer type. </td>
  258. </tr>
  259. <tr>
  260. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">ulp_cmp_type
  261. </td>
  262. <td style="vertical-align: top;">Ulp comparison structure,
  263. that checks if two fpt_type values are within the given ulp range
  264. (relative error range). </td>
  265. </tr>
  266. <tr>
  267. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">to_fpt_converter_type
  268. </td>
  269. <td style="vertical-align: top;">Type converter structure,
  270. that converts any of the integer types above plus efpt_type to the
  271. fpt_type using operator(). </td>
  272. </tr>
  273. <tr>
  274. <td style="vertical-align: top; font-family: 'Courier New',Courier,monospace; font-weight: bold;">to_efpt_converter_type
  275. </td>
  276. <td style="vertical-align: top;">Type converter structure,
  277. that converts any of the integer types above to the efpt_type using
  278. operator(). </td>
  279. </tr>
  280. </tbody>
  281. </table>
  282. <p>Notes:</p>
  283. <ul>
  284. <li>Four different integer types are used (instead of a single
  285. big_int_type) to slightly improve algorithm performance and memory
  286. usage.</li>
  287. <li>As the maximum required size of the big_int_type is known
  288. in advance, it's possible to use fixed, stack allocated, multiprecision
  289. integer type.</li>
  290. <li>Two separate floating-point types are defined, because for
  291. the input geometries
  292. with
  293. 32-bit signed integer coordinates, double type won't be able to handle
  294. 2048-bit (64 chunks of 32 bits each) integers, as they will
  295. overflow its exponent. On the
  296. gcc compiler it's possible to use 80-bit long doubles for both fpt
  297. types, however this is not supported by the MSVC compiler.</li>
  298. <li>efpt_type and to_efpt_converter_type are not used to
  299. construct the Voronoi diagram of a set of points (mock implementation
  300. will work).</li>
  301. <li>For an example of the user defined coordinate type traits
  302. check the <a href="voronoi_advanced_tutorial.htm">advanced Voronoi
  303. tutorial</a>.</li>
  304. </ul>
  305. </td>
  306. </tr>
  307. <tr>
  308. <td style="background-color: rgb(238, 238, 238);" nowrap="1">&nbsp;</td>
  309. <td style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" valign="top" width="100%">
  310. <table class="docinfo" id="table2" frame="void" rules="none">
  311. <colgroup> <col class="docinfo-name"><col class="docinfo-content"> </colgroup> <tbody valign="top">
  312. <tr>
  313. <th class="docinfo-name">Copyright:</th>
  314. <td>Copyright © Andrii Sydorchuk 2010-2013.</td>
  315. </tr>
  316. <tr class="field">
  317. <th class="docinfo-name">License:</th>
  318. <td class="field-body">Distributed under the Boost Software
  319. 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">
  320. http://www.boost.org/LICENSE_1_0.txt</a>)</td>
  321. </tr>
  322. </tbody>
  323. </table>
  324. </td>
  325. </tr>
  326. </tbody>
  327. </table>
  328. </body></html>