intersection_result.hpp 2.0 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-2021.
  4. // Modifications copyright (c) 2015-2021 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/core/coordinate_type.hpp>
  13. #include <boost/geometry/policies/robustness/segment_ratio.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. template <typename SegmentRatio>
  17. struct fraction_type
  18. {
  19. SegmentRatio robust_ra; // TODO this can be renamed now to "ra"
  20. SegmentRatio robust_rb;
  21. bool initialized;
  22. inline fraction_type()
  23. : initialized(false)
  24. {}
  25. template <typename Info>
  26. inline void assign(Info const& info)
  27. {
  28. initialized = true;
  29. robust_ra = info.robust_ra;
  30. robust_rb = info.robust_rb;
  31. }
  32. inline void assign(SegmentRatio const& a, SegmentRatio const& b)
  33. {
  34. initialized = true;
  35. robust_ra = a;
  36. robust_rb = b;
  37. }
  38. };
  39. //
  40. /*!
  41. \brief return-type for segment-intersection
  42. \note Set in intersection_points.hpp, from segment_intersection_info
  43. */
  44. template
  45. <
  46. typename Point,
  47. typename SegmentRatio = segment_ratio<typename coordinate_type<Point>::type>
  48. >
  49. struct segment_intersection_points
  50. {
  51. std::size_t count; // The number of intersection points
  52. // TODO: combine intersections and fractions in one struct
  53. Point intersections[2];
  54. fraction_type<SegmentRatio> fractions[2];
  55. typedef Point point_type;
  56. segment_intersection_points()
  57. : count(0)
  58. {}
  59. };
  60. }} // namespace boost::geometry
  61. #endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP