Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_GEOMETRIES_BOX_HPP Chris@16: #define BOOST_GEOMETRY_GEOMETRIES_BOX_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: namespace model Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Class box: defines a box made of two describing points Chris@16: \ingroup geometries Chris@16: \details Box is always described by a min_corner() and a max_corner() point. If another Chris@16: rectangle is used, use linear_ring or polygon. Chris@16: \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms Chris@16: are implemented for box. Boxes are also used in Spatial Indexes. Chris@16: \tparam Point point type. The box takes a point type as template parameter. Chris@16: The point type can be any point type. Chris@16: It can be 2D but can also be 3D or more dimensional. Chris@16: The box can also take a latlong point type as template parameter. Chris@16: */ Chris@16: Chris@16: template Chris@16: class box Chris@16: { Chris@16: BOOST_CONCEPT_ASSERT( (concept::Point) ); Chris@16: Chris@16: public: Chris@16: Chris@16: inline box() {} Chris@16: Chris@16: /*! Chris@16: \brief Constructor taking the minimum corner point and the maximum corner point Chris@16: */ Chris@16: inline box(Point const& min_corner, Point const& max_corner) Chris@16: { Chris@16: geometry::convert(min_corner, m_min_corner); Chris@16: geometry::convert(max_corner, m_max_corner); Chris@16: } Chris@16: Chris@16: inline Point const& min_corner() const { return m_min_corner; } Chris@16: inline Point const& max_corner() const { return m_max_corner; } Chris@16: Chris@16: inline Point& min_corner() { return m_min_corner; } Chris@16: inline Point& max_corner() { return m_max_corner; } Chris@16: Chris@16: private: Chris@16: Chris@16: Point m_min_corner; Chris@16: Point m_max_corner; Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace model Chris@16: Chris@16: Chris@16: // Traits specializations for box above Chris@16: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: namespace traits Chris@16: { Chris@16: Chris@16: template Chris@16: struct tag > Chris@16: { Chris@16: typedef box_tag type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct point_type > Chris@16: { Chris@16: typedef Point type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct indexed_access, min_corner, Dimension> Chris@16: { Chris@16: typedef typename geometry::coordinate_type::type coordinate_type; Chris@16: Chris@16: static inline coordinate_type get(model::box const& b) Chris@16: { Chris@16: return geometry::get(b.min_corner()); Chris@16: } Chris@16: Chris@16: static inline void set(model::box& b, coordinate_type const& value) Chris@16: { Chris@16: geometry::set(b.min_corner(), value); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct indexed_access, max_corner, Dimension> Chris@16: { Chris@16: typedef typename geometry::coordinate_type::type coordinate_type; Chris@16: Chris@16: static inline coordinate_type get(model::box const& b) Chris@16: { Chris@16: return geometry::get(b.max_corner()); Chris@16: } Chris@16: Chris@16: static inline void set(model::box& b, coordinate_type const& value) Chris@16: { Chris@16: geometry::set(b.max_corner(), value); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace traits Chris@16: #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: #endif // BOOST_GEOMETRY_GEOMETRIES_BOX_HPP