|
|
00001 // Boost.Geometry (aka GGL, Generic Geometry Library) 00002 // 00003 // Copyright Bruno Lalande 2008, 2009 00004 // Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands. 00005 // Use, modification and distribution is subject to the Boost Software License, 00006 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 00007 // http://www.boost.org/LICENSE_1_0.txt) 00008 00009 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP 00010 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP 00011 00012 #include <cstddef> 00013 00014 #include <boost/type_traits/is_arithmetic.hpp> 00015 00016 #include <boost/geometry/core/access.hpp> 00017 #include <boost/geometry/core/cs.hpp> 00018 #include <boost/geometry/core/coordinate_dimension.hpp> 00019 #include <boost/geometry/core/coordinate_type.hpp> 00020 #include <boost/geometry/core/tags.hpp> 00021 00022 namespace boost { namespace geometry 00023 { 00024 00025 00026 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS 00027 namespace traits 00028 { 00029 00030 00031 #ifndef DOXYGEN_NO_DETAIL 00032 namespace detail 00033 { 00034 00035 00036 // Create class and specialization to indicate the tag 00037 // for normal cases and the case that the type of the c-array is arithmetic 00038 template <bool> 00039 struct c_array_tag 00040 { 00041 typedef geometry_not_recognized_tag type; 00042 }; 00043 00044 00045 template <> 00046 struct c_array_tag<true> 00047 { 00048 typedef point_tag type; 00049 }; 00050 00051 00052 } // namespace detail 00053 #endif // DOXYGEN_NO_DETAIL 00054 00055 00056 // Assign the point-tag, preventing arrays of points getting a point-tag 00057 template <typename CoordinateType, std::size_t DimensionCount> 00058 struct tag<CoordinateType[DimensionCount]> 00059 : detail::c_array_tag<boost::is_arithmetic<CoordinateType>::value> {}; 00060 00061 00062 template <typename CoordinateType, std::size_t DimensionCount> 00063 struct coordinate_type<CoordinateType[DimensionCount]> 00064 { 00065 typedef CoordinateType type; 00066 }; 00067 00068 00069 template <typename CoordinateType, std::size_t DimensionCount> 00070 struct dimension<CoordinateType[DimensionCount]>: boost::mpl::int_<DimensionCount> {}; 00071 00072 00073 template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension> 00074 struct access<CoordinateType[DimensionCount], Dimension> 00075 { 00076 static inline CoordinateType get(const CoordinateType p[DimensionCount]) 00077 { 00078 return p[Dimension]; 00079 } 00080 00081 static inline void set(CoordinateType p[DimensionCount], 00082 CoordinateType const& value) 00083 { 00084 p[Dimension] = value; 00085 } 00086 }; 00087 00088 // The library user has 00089 // 1) either to specify the coordinate system 00090 // 2) or include <boost/geometry/geometries/adapted/c_array_@.hpp> where @=cartesian,geographic,... 00091 00092 } // namespace traits 00093 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS 00094 00095 00096 }} // namespace boost::geometry 00097 00098 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
|
December 1, 2009 |
Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam Copyright © 2008-2009 Bruno Lalande, Paris Copyright © 2009 Mateusz Loskot, Cadcorp, London |