...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Makes a box behave like a ring or a range.
Adapts a box to the Boost.Range concept, enabling the user to iterating box corners. The box_view is registered as a Ring Concept
template<typename Box, bool Clockwise> struct box_view : public detail::points_view< geometry::point_type< Box >::type, 5 > { // ... };
Parameter |
Default |
Description |
---|---|---|
typename Box |
A type fulfilling the Box Concept |
|
bool Clockwise |
true |
If true, walks in clockwise direction, otherwise it walks in counterclockwise direction |
Function |
Description |
Parameters |
---|---|---|
box_view(Box const & box)
|
Constructor accepting the box to adapt. |
Box const &: box: |
Either
#include <boost/geometry.hpp>
Or
#include <boost/geometry/views/box_view.hpp>
Compile time
Shows usage of the Boost.Range compatible view on a box
#include <iostream> #include <boost/geometry.hpp> int main() { typedef boost::geometry::model::box < boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> > box_type; // Define the Boost.Range compatible type: typedef boost::geometry::box_view<box_type> box_view; box_type box; boost::geometry::assign_values(box, 0, 0, 4, 4); box_view view(box); // Iterating in clockwise direction over the points of this box for (boost::range_iterator<box_view const>::type it = boost::begin(view); it != boost::end(view); ++it) { std::cout << " " << boost::geometry::dsv(*it); } std::cout << std::endl; // Note that a box_view is tagged as a ring, so supports area etc. std::cout << "Area: " << boost::geometry::area(view) << std::endl; return 0; }
Output:
(0, 0) (0, 4) (4, 4) (4, 0) (0, 0) Area: 16