1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>box_view</title> 5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Chapter 1. Geometry"> 8<link rel="up" href="../views.html" title="Views"> 9<link rel="prev" href="../views.html" title="Views"> 10<link rel="next" href="segment_view.html" title="segment_view"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../views.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../views.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="segment_view.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="geometry.reference.views.box_view"></a><a class="link" href="box_view.html" title="box_view">box_view</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635666874288"></a> 31Makes a box behave like a ring or a range. 32 </p> 33<h6> 34<a name="geometry.reference.views.box_view.h0"></a> 35 <span class="phrase"><a name="geometry.reference.views.box_view.description"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.description">Description</a> 36 </h6> 37<p> 38 Adapts a box to the Boost.Range concept, enabling the user to iterating 39 box corners. The box_view is registered as a Ring Concept 40 </p> 41<h6> 42<a name="geometry.reference.views.box_view.h1"></a> 43 <span class="phrase"><a name="geometry.reference.views.box_view.model_of"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.model_of">Model 44 of</a> 45 </h6> 46<p> 47 <a class="link" href="../concepts/concept_ring.html" title="Ring Concept">Ring Concept</a> 48 </p> 49<h6> 50<a name="geometry.reference.views.box_view.h2"></a> 51 <span class="phrase"><a name="geometry.reference.views.box_view.synopsis"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.synopsis">Synopsis</a> 52 </h6> 53<p> 54</p> 55<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Box</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">Clockwise</span><span class="special">></span> 56<span class="keyword">struct</span> <span class="identifier">box_view</span> 57 <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">points_view</span><span class="special"><</span> <span class="identifier">geometry</span><span class="special">::</span><span class="identifier">point_type</span><span class="special"><</span> <span class="identifier">Box</span> <span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="number">5</span> <span class="special">></span> 58<span class="special">{</span> 59 <span class="comment">// ...</span> 60<span class="special">};</span> 61</pre> 62<p> 63 </p> 64<h6> 65<a name="geometry.reference.views.box_view.h3"></a> 66 <span class="phrase"><a name="geometry.reference.views.box_view.template_parameter_s_"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.template_parameter_s_">Template 67 parameter(s)</a> 68 </h6> 69<div class="informaltable"><table class="table"> 70<colgroup> 71<col> 72<col> 73<col> 74</colgroup> 75<thead><tr> 76<th> 77 <p> 78 Parameter 79 </p> 80 </th> 81<th> 82 <p> 83 Default 84 </p> 85 </th> 86<th> 87 <p> 88 Description 89 </p> 90 </th> 91</tr></thead> 92<tbody> 93<tr> 94<td> 95 <p> 96 typename Box 97 </p> 98 </td> 99<td> 100 </td> 101<td> 102 <p> 103 A type fulfilling the Box Concept 104 </p> 105 </td> 106</tr> 107<tr> 108<td> 109 <p> 110 bool Clockwise 111 </p> 112 </td> 113<td> 114 <p> 115 true 116 </p> 117 </td> 118<td> 119 <p> 120 If true, walks in clockwise direction, otherwise it walks in 121 counterclockwise direction 122 </p> 123 </td> 124</tr> 125</tbody> 126</table></div> 127<h6> 128<a name="geometry.reference.views.box_view.h4"></a> 129 <span class="phrase"><a name="geometry.reference.views.box_view.constructor_s_"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.constructor_s_">Constructor(s)</a> 130 </h6> 131<div class="informaltable"><table class="table"> 132<colgroup> 133<col> 134<col> 135<col> 136</colgroup> 137<thead><tr> 138<th> 139 <p> 140 Function 141 </p> 142 </th> 143<th> 144 <p> 145 Description 146 </p> 147 </th> 148<th> 149 <p> 150 Parameters 151 </p> 152 </th> 153</tr></thead> 154<tbody><tr> 155<td> 156 <p> 157</p> 158<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">box_view</span><span class="special">(</span><span class="identifier">Box</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">box</span><span class="special">)</span></pre> 159<p> 160 </p> 161 </td> 162<td> 163 <p> 164 Constructor accepting the box to adapt. 165 </p> 166 </td> 167<td> 168 <p> 169 <span class="bold"><strong>Box const &</strong></span>: <span class="emphasis"><em>box</em></span>: 170 </p> 171 </td> 172</tr></tbody> 173</table></div> 174<h6> 175<a name="geometry.reference.views.box_view.h5"></a> 176 <span class="phrase"><a name="geometry.reference.views.box_view.header"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.header">Header</a> 177 </h6> 178<p> 179 Either 180 </p> 181<p> 182 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 183 </p> 184<p> 185 Or 186 </p> 187<p> 188 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">views</span><span class="special">/</span><span class="identifier">box_view</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 189 </p> 190<h6> 191<a name="geometry.reference.views.box_view.h6"></a> 192 <span class="phrase"><a name="geometry.reference.views.box_view.complexity"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.complexity">Complexity</a> 193 </h6> 194<p> 195 Compile time 196 </p> 197<h6> 198<a name="geometry.reference.views.box_view.h7"></a> 199 <span class="phrase"><a name="geometry.reference.views.box_view.example"></a></span><a class="link" href="box_view.html#geometry.reference.views.box_view.example">Example</a> 200 </h6> 201<p> 202 Shows usage of the Boost.Range compatible view on a box 203 </p> 204<p> 205</p> 206<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 207 208<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 209 210 211<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 212<span class="special">{</span> 213 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">box</span> 214 <span class="special"><</span> 215 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">></span> 216 <span class="special">></span> <span class="identifier">box_type</span><span class="special">;</span> 217 218 <span class="comment">// Define the Boost.Range compatible type:</span> 219 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">box_view</span><span class="special"><</span><span class="identifier">box_type</span><span class="special">></span> <span class="identifier">box_view</span><span class="special">;</span> 220 221 <span class="identifier">box_type</span> <span class="identifier">box</span><span class="special">;</span> 222 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">assign_values</span><span class="special">(</span><span class="identifier">box</span><span class="special">,</span> <span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">4</span><span class="special">);</span> 223 224 <span class="identifier">box_view</span> <span class="identifier">view</span><span class="special">(</span><span class="identifier">box</span><span class="special">);</span> 225 226 <span class="comment">// Iterating in clockwise direction over the points of this box</span> 227 <span class="keyword">for</span> <span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_iterator</span><span class="special"><</span><span class="identifier">box_view</span> <span class="keyword">const</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">view</span><span class="special">);</span> 228 <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">view</span><span class="special">);</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> 229 <span class="special">{</span> 230 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> 231 <span class="special">}</span> 232 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 233 234 <span class="comment">// Note that a box_view is tagged as a ring, so supports area etc.</span> 235 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Area: "</span> <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">area</span><span class="special">(</span><span class="identifier">view</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 236 237 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 238<span class="special">}</span> 239</pre> 240<p> 241 </p> 242<p> 243 Output: 244 </p> 245<pre class="programlisting">(0, 0) (0, 4) (4, 4) (4, 0) (0, 0) 246Area: 16 247</pre> 248</div> 249<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 250<td align="left"></td> 251<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 252 Wulkiewicz, Oracle and/or its affiliates<p> 253 Distributed under the Boost Software License, Version 1.0. (See accompanying 254 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 255 </p> 256</div></td> 257</tr></table> 258<hr> 259<div class="spirit-nav"> 260<a accesskey="p" href="../views.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../views.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="segment_view.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 261</div> 262</body> 263</html> 264