intersection_result.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2015, 2016.
  4. // Modifications copyright (c) 2015-2016 Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  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_STRATEGIES_INTERSECTION_RESULT_HPP
  10. #define BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP
  11. #include <cstddef>
  12. #include <boost/geometry/policies/robustness/segment_ratio.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. template <typename SegmentRatio>
  16. struct fraction_type
  17. {
  18. SegmentRatio robust_ra; // TODO this can be renamed now to "ra"
  19. SegmentRatio robust_rb;
  20. bool initialized;
  21. inline fraction_type()
  22. : initialized(false)
  23. {}
  24. template <typename Info>
  25. inline void assign(Info const& info)
  26. {
  27. initialized = true;
  28. robust_ra = info.robust_ra;
  29. robust_rb = info.robust_rb;
  30. }
  31. inline void assign(SegmentRatio const& a, SegmentRatio const& b)
  32. {
  33. initialized = true;
  34. robust_ra = a;
  35. robust_rb = b;
  36. }
  37. };
  38. //
  39. /*!
  40. \brief return-type for segment-intersection
  41. \note Set in intersection_points.hpp, from segment_intersection_info
  42. */
  43. template
  44. <
  45. typename Point,
  46. typename SegmentRatio = segment_ratio<typename coordinate_type<Point>::type>
  47. >
  48. struct segment_intersection_points
  49. {
  50. std::size_t count; // The number of intersection points
  51. // TODO: combine intersections and fractions in one struct
  52. Point intersections[2];
  53. fraction_type<SegmentRatio> fractions[2];
  54. typedef Point point_type;
  55. segment_intersection_points()
  56. : count(0)
  57. {}
  58. };
  59. }} // namespace boost::geometry
  60. #endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP