123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP
- #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP
- #include <boost/geometry/core/access.hpp>
- #include <boost/geometry/core/coordinate_type.hpp>
- #include <boost/geometry/core/coordinate_dimension.hpp>
- #include <boost/geometry/strategy/area.hpp>
- #include <boost/geometry/util/select_most_precise.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace area
- {
- template
- <
- typename CalculationType = void
- >
- class cartesian
- {
- public :
- template <typename Geometry>
- struct result_type
- : strategy::area::detail::result_type
- <
- Geometry,
- CalculationType
- >
- {};
- template <typename Geometry>
- class state
- {
- friend class cartesian;
- typedef typename result_type<Geometry>::type return_type;
- public:
- inline state()
- : sum(0)
- {
-
- assert_dimension<Geometry, 2>();
- }
- private:
- inline return_type area() const
- {
- return_type const two = 2;
- return sum / two;
- }
- return_type sum;
- };
- template <typename PointOfSegment, typename Geometry>
- static inline void apply(PointOfSegment const& p1,
- PointOfSegment const& p2,
- state<Geometry>& st)
- {
- typedef typename state<Geometry>::return_type return_type;
-
-
-
-
-
-
-
-
-
- st.sum += (return_type(get<0>(p1)) + return_type(get<0>(p2)))
- * (return_type(get<1>(p1)) - return_type(get<1>(p2)));
- }
- template <typename Geometry>
- static inline auto result(state<Geometry>& st)
- {
- return st.area();
- }
- };
- #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
- namespace services
- {
- template <>
- struct default_strategy<cartesian_tag>
- {
- typedef strategy::area::cartesian<> type;
- };
- }
- #endif
- }}
- }}
- #endif
|