centroid_concept.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include <boost/core/ignore_unused.hpp>
  14. namespace boost { namespace geometry { namespace concepts
  15. {
  16. /*!
  17. \brief Checks strategy for centroid
  18. \ingroup centroid
  19. */
  20. template <typename Strategy>
  21. class CentroidStrategy
  22. {
  23. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  24. // 1) must define state_type,
  25. typedef typename Strategy::state_type state_type;
  26. // 2) must define point_type,
  27. typedef typename Strategy::point_type point_type;
  28. // 3) must define point_type, of polygon (segments)
  29. typedef typename Strategy::segment_point_type spoint_type;
  30. struct check_methods
  31. {
  32. static void apply()
  33. {
  34. Strategy *str = 0;
  35. state_type *st = 0;
  36. // 4) must implement a static method apply,
  37. // getting two segment-points
  38. spoint_type const* sp = 0;
  39. str->apply(*sp, *sp, *st);
  40. // 5) must implement a static method result
  41. // getting the centroid
  42. point_type *c = 0;
  43. bool r = str->result(*st, *c);
  44. boost::ignore_unused(str, r);
  45. }
  46. };
  47. public :
  48. BOOST_CONCEPT_USAGE(CentroidStrategy)
  49. {
  50. check_methods::apply();
  51. }
  52. #endif
  53. };
  54. }}} // namespace boost::geometry::concepts
  55. #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP