Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. 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_CONCEPTS_SEGMENT_CONCEPT_HPP Chris@16: #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP Chris@16: Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry { namespace concept Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Segment concept. Chris@16: \ingroup concepts Chris@16: \details Formal definition: Chris@16: The segment concept is defined as following: Chris@16: - there must be a specialization of traits::tag defining segment_tag as type Chris@16: - there must be a specialization of traits::point_type to define the Chris@16: underlying point type (even if it does not consist of points, it should define Chris@16: this type, to indicate the points it can work with) Chris@16: - there must be a specialization of traits::indexed_access, per index Chris@16: and per dimension, with two functions: Chris@16: - get to get a coordinate value Chris@16: - set to set a coordinate value (this one is not checked for ConstSegment) Chris@16: Chris@16: \note The segment concept is similar to the box concept, defining another tag. Chris@16: However, the box concept assumes the index as min_corner, max_corner, while Chris@16: for the segment concept there is no assumption. Chris@16: */ Chris@16: template Chris@16: class Segment Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: typedef typename point_type::type point_type; Chris@16: Chris@16: BOOST_CONCEPT_ASSERT( (concept::Point) ); Chris@16: Chris@16: Chris@16: template Chris@16: struct dimension_checker Chris@16: { Chris@16: static void apply() Chris@16: { Chris@16: Geometry* s = 0; Chris@16: geometry::set(*s, geometry::get(*s)); Chris@16: dimension_checker::apply(); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct dimension_checker Chris@16: { Chris@16: static void apply() {} Chris@16: }; Chris@16: Chris@16: public : Chris@16: Chris@16: BOOST_CONCEPT_USAGE(Segment) Chris@16: { Chris@16: static const size_t n = dimension::type::value; Chris@16: dimension_checker<0, 0, n>::apply(); Chris@16: dimension_checker<1, 0, n>::apply(); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Segment concept (const version). Chris@16: \ingroup const_concepts Chris@16: \details The ConstSegment concept verifies the same as the Segment concept, Chris@16: but does not verify write access. Chris@16: */ Chris@16: template Chris@16: class ConstSegment Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: typedef typename point_type::type point_type; Chris@16: typedef typename coordinate_type::type coordinate_type; Chris@16: Chris@16: BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); Chris@16: Chris@16: Chris@16: template Chris@16: struct dimension_checker Chris@16: { Chris@16: static void apply() Chris@16: { Chris@16: const Geometry* s = 0; Chris@16: coordinate_type coord(geometry::get(*s)); Chris@16: boost::ignore_unused_variable_warning(coord); Chris@16: dimension_checker::apply(); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct dimension_checker Chris@16: { Chris@16: static void apply() {} Chris@16: }; Chris@16: Chris@16: public : Chris@16: Chris@16: BOOST_CONCEPT_USAGE(ConstSegment) Chris@16: { Chris@16: static const size_t n = dimension::type::value; Chris@16: dimension_checker<0, 0, n>::apply(); Chris@16: dimension_checker<1, 0, n>::apply(); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: Chris@16: }}} // namespace boost::geometry::concept Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP