File indexing completed on 2025-01-18 09:36:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP
0021 #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP
0022
0023
0024
0025 #include <boost/geometry/core/access.hpp>
0026 #include <boost/geometry/core/coordinate_type.hpp>
0027 #include <boost/geometry/core/coordinate_dimension.hpp>
0028 #include <boost/geometry/strategy/area.hpp>
0029 #include <boost/geometry/util/select_most_precise.hpp>
0030
0031
0032 namespace boost { namespace geometry
0033 {
0034
0035 namespace strategy { namespace area
0036 {
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 template
0051 <
0052 typename CalculationType = void
0053 >
0054 class cartesian
0055 {
0056 public :
0057 template <typename Geometry>
0058 struct result_type
0059 : strategy::area::detail::result_type
0060 <
0061 Geometry,
0062 CalculationType
0063 >
0064 {};
0065
0066 template <typename Geometry>
0067 class state
0068 {
0069 friend class cartesian;
0070
0071 typedef typename result_type<Geometry>::type return_type;
0072
0073 public:
0074 inline state()
0075 : sum(0)
0076 {
0077
0078 assert_dimension<Geometry, 2>();
0079 }
0080
0081 private:
0082 inline return_type area() const
0083 {
0084 return_type const two = 2;
0085 return sum / two;
0086 }
0087
0088 return_type sum;
0089 };
0090
0091 template <typename PointOfSegment, typename Geometry>
0092 static inline void apply(PointOfSegment const& p1,
0093 PointOfSegment const& p2,
0094 state<Geometry>& st)
0095 {
0096 typedef typename state<Geometry>::return_type return_type;
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 st.sum += (return_type(get<0>(p1)) + return_type(get<0>(p2)))
0111 * (return_type(get<1>(p1)) - return_type(get<1>(p2)));
0112 }
0113
0114 template <typename Geometry>
0115 static inline auto result(state<Geometry>& st)
0116 {
0117 return st.area();
0118 }
0119
0120 };
0121
0122 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0123
0124 namespace services
0125 {
0126 template <>
0127 struct default_strategy<cartesian_tag>
0128 {
0129 typedef strategy::area::cartesian<> type;
0130 };
0131
0132 }
0133
0134 #endif
0135
0136
0137 }}
0138
0139
0140
0141 }}
0142
0143
0144 #endif