no_rescale_policy.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2013 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2013 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP
  10. #define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP
  11. #include <stddef.h>
  12. #include <boost/geometry/core/coordinate_type.hpp>
  13. #include <boost/geometry/policies/robustness/robust_point_type.hpp>
  14. #include <boost/geometry/policies/robustness/segment_ratio.hpp>
  15. #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail
  20. {
  21. // Probably this will be moved out of namespace detail
  22. struct no_rescale_policy
  23. {
  24. static bool const enabled = false;
  25. // We don't rescale but return the reference of the input
  26. template <std::size_t Dimension, typename Value>
  27. inline Value const& apply(Value const& value) const
  28. {
  29. return value;
  30. }
  31. };
  32. } // namespace detail
  33. #endif
  34. // Implement meta-functions for this policy
  35. template <typename Point>
  36. struct robust_point_type<Point, detail::no_rescale_policy>
  37. {
  38. // The point itself
  39. typedef Point type;
  40. };
  41. template <typename Point>
  42. struct segment_ratio_type<Point, detail::no_rescale_policy>
  43. {
  44. // Define a segment_ratio defined on coordinate type, e.g.
  45. // int/int or float/float
  46. typedef typename geometry::coordinate_type<Point>::type coordinate_type;
  47. typedef segment_ratio<coordinate_type> type;
  48. };
  49. }} // namespace boost::geometry
  50. #endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP