Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: // Chris@101: // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. Chris@101: // Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands. Chris@101: // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. Chris@101: Chris@101: // This file was modified by Oracle on 2014. Chris@101: // Modifications copyright (c) 2014, Oracle and/or its affiliates. Chris@101: Chris@101: // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 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_POINT_CONCEPT_HPP Chris@16: #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@101: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry { namespace concept Chris@16: { Chris@16: Chris@16: /*! Chris@16: \brief Point concept. Chris@16: \ingroup concepts Chris@16: Chris@16: \par Formal definition: Chris@16: The point concept is defined as following: Chris@16: - there must be a specialization of traits::tag defining point_tag as type Chris@16: - there must be a specialization of traits::coordinate_type defining the type Chris@16: of its coordinates Chris@16: - there must be a specialization of traits::coordinate_system defining its Chris@16: coordinate system (cartesian, spherical, etc) Chris@16: - there must be a specialization of traits::dimension defining its number Chris@16: of dimensions (2, 3, ...) (derive it conveniently Chris@16: from boost::mpl::int_<X> for X-D) Chris@16: - there must be a specialization of traits::access, per dimension, Chris@16: with two functions: Chris@16: - \b get to get a coordinate value Chris@16: - \b set to set a coordinate value (this one is not checked for ConstPoint) Chris@101: - for non-Cartesian coordinate systems, the coordinate system's units Chris@101: must either be boost::geometry::degree or boost::geometry::radian Chris@101: Chris@16: Chris@16: \par Example: Chris@16: Chris@16: A legacy point, defining the necessary specializations to fulfil to the concept. Chris@16: Chris@16: Suppose that the following point is defined: Chris@16: \dontinclude doxygen_5.cpp Chris@16: \skip legacy_point1 Chris@16: \until }; Chris@16: Chris@16: It can then be adapted to the concept as following: Chris@16: \dontinclude doxygen_5.cpp Chris@16: \skip adapt legacy_point1 Chris@16: \until }} Chris@16: Chris@16: Note that it is done like above to show the system. Users will normally use the registration macro. Chris@16: Chris@16: \par Example: Chris@16: Chris@16: A read-only legacy point, using a macro to fulfil to the ConstPoint concept. Chris@16: It cannot be modified by the library but can be used in all algorithms where Chris@16: points are not modified. Chris@16: Chris@16: The point looks like the following: Chris@16: Chris@16: \dontinclude doxygen_5.cpp Chris@16: \skip legacy_point2 Chris@16: \until }; Chris@16: Chris@16: It uses the macro as following: Chris@16: \dontinclude doxygen_5.cpp Chris@16: \skip adapt legacy_point2 Chris@16: \until end adaptation Chris@16: Chris@16: */ Chris@16: Chris@16: template Chris@16: class Point Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: Chris@16: typedef typename coordinate_type::type ctype; Chris@16: typedef typename coordinate_system::type csystem; Chris@16: Chris@101: // The following enum is used to fully instantiate the coordinate Chris@101: // system class; this is needed in order to check the units passed Chris@101: // to it for non-Cartesian coordinate systems. Chris@101: enum { cs_check = sizeof(csystem) }; Chris@101: Chris@16: enum { ccount = dimension::value }; Chris@16: Chris@16: template Chris@16: struct dimension_checker Chris@16: { Chris@16: static void apply() Chris@16: { Chris@16: P* p = 0; Chris@16: geometry::set(*p, geometry::get(*p)); Chris@16: dimension_checker::apply(); Chris@16: } 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: /// BCCL macro to apply the Point concept Chris@16: BOOST_CONCEPT_USAGE(Point) Chris@16: { Chris@16: dimension_checker::apply(); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief point concept (const version). Chris@16: Chris@16: \ingroup const_concepts Chris@16: Chris@16: \details The ConstPoint concept apply the same as the Point concept, Chris@16: but does not apply write access. Chris@16: Chris@16: */ Chris@16: template Chris@16: class ConstPoint Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: Chris@16: typedef typename coordinate_type::type ctype; Chris@16: typedef typename coordinate_system::type csystem; Chris@16: Chris@101: // The following enum is used to fully instantiate the coordinate Chris@101: // system class; this is needed in order to check the units passed Chris@101: // to it for non-Cartesian coordinate systems. Chris@101: enum { cs_check = sizeof(csystem) }; Chris@101: Chris@16: enum { ccount = dimension::value }; Chris@16: Chris@16: template Chris@16: struct dimension_checker Chris@16: { Chris@16: static void apply() Chris@16: { Chris@16: const P* p = 0; Chris@16: ctype coord(geometry::get(*p)); Chris@101: boost::ignore_unused(coord); Chris@16: dimension_checker::apply(); Chris@16: } 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: /// BCCL macro to apply the ConstPoint concept Chris@16: BOOST_CONCEPT_USAGE(ConstPoint) Chris@16: { Chris@16: dimension_checker::apply(); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: }}} // namespace boost::geometry::concept Chris@16: Chris@16: #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP