centroid_concept.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
  11. #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
  12. #include <boost/concept_check.hpp>
  13. namespace boost { namespace geometry { namespace concept
  14. {
  15. /*!
  16. \brief Checks strategy for centroid
  17. \ingroup centroid
  18. */
  19. template <typename Strategy>
  20. class CentroidStrategy
  21. {
  22. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  23. // 1) must define state_type,
  24. typedef typename Strategy::state_type state_type;
  25. // 2) must define point_type,
  26. typedef typename Strategy::point_type point_type;
  27. // 3) must define point_type, of polygon (segments)
  28. typedef typename Strategy::segment_point_type spoint_type;
  29. struct check_methods
  30. {
  31. static void apply()
  32. {
  33. Strategy *str = 0;
  34. state_type *st = 0;
  35. // 4) must implement a static method apply,
  36. // getting two segment-points
  37. spoint_type const* sp = 0;
  38. str->apply(*sp, *sp, *st);
  39. // 5) must implement a static method result
  40. // getting the centroid
  41. point_type *c = 0;
  42. bool r = str->result(*st, *c);
  43. boost::ignore_unused_variable_warning(str);
  44. boost::ignore_unused_variable_warning(r);
  45. }
  46. };
  47. public :
  48. BOOST_CONCEPT_USAGE(CentroidStrategy)
  49. {
  50. check_methods::apply();
  51. }
  52. #endif
  53. };
  54. }}} // namespace boost::geometry::concept
  55. #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP