// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_HPP #define BOOST_GEOMETRY_GEOMETRIES_POINT_HPP #include #include #include #include #include #include #include #include namespace boost { namespace geometry { // Silence warning C4127: conditional expression is constant #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4127) #endif namespace model { /*! \brief Basic point class, having coordinates defined in a neutral way \details Defines a neutral point class, fulfilling the Point Concept. Library users can use this point class, or use their own point classes. This point class is used in most of the samples and tests of Boost.Geometry This point class is used occasionally within the library, where a temporary point class is necessary. \ingroup geometries \tparam CoordinateType \tparam_numeric \tparam DimensionCount number of coordinates, usually 2 or 3 \tparam CoordinateSystem coordinate system, for example cs::cartesian \qbk{[include reference/geometries/point.qbk]} \qbk{before.synopsis, [heading Model of]} \qbk{before.synopsis, [link geometry.reference.concepts.concept_point Point Concept]} */ template < typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem > class point { public: /// @brief Default constructor, no initialization inline point() {} /// @brief Constructor to set one, two or three values explicit inline point(CoordinateType const& v0, CoordinateType const& v1 = 0, CoordinateType const& v2 = 0) { if (DimensionCount >= 1) m_values[0] = v0; if (DimensionCount >= 2) m_values[1] = v1; if (DimensionCount >= 3) m_values[2] = v2; } /// @brief Get a coordinate /// @tparam K coordinate to get /// @return the coordinate template inline CoordinateType const& get() const { BOOST_STATIC_ASSERT(K < DimensionCount); return m_values[K]; } /// @brief Set a coordinate /// @tparam K coordinate to set /// @param value value to set template inline void set(CoordinateType const& value) { BOOST_STATIC_ASSERT(K < DimensionCount); m_values[K] = value; } private: CoordinateType m_values[DimensionCount]; }; } // namespace model // Adapt the point to the concept #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS namespace traits { template < typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem > struct tag > { typedef point_tag type; }; template < typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem > struct coordinate_type > { typedef CoordinateType type; }; template < typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem > struct coordinate_system > { typedef CoordinateSystem type; }; template < typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem > struct dimension > : boost::mpl::int_ {}; template < typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem, std::size_t Dimension > struct access, Dimension> { static inline CoordinateType get( model::point const& p) { return p.template get(); } static inline void set( model::point& p, CoordinateType const& value) { p.template set(value); } }; } // namespace traits #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS #if defined(_MSC_VER) #pragma warning(pop) #endif }} // namespace boost::geometry #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_HPP