intersection_result.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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-2024.
  4. // Modifications copyright (c) 2015-2024 Oracle and/or its affiliates.
  5. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  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_INTERSECTION_RESULT_HPP
  11. #define BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP
  12. #include <cstddef>
  13. #include <boost/geometry/core/coordinate_type.hpp>
  14. #include <boost/geometry/policies/robustness/segment_ratio.hpp>
  15. namespace boost { namespace geometry
  16. {
  17. template <typename SegmentRatio>
  18. struct fraction_type
  19. {
  20. SegmentRatio ra;
  21. SegmentRatio rb;
  22. bool initialized;
  23. inline fraction_type()
  24. : initialized(false)
  25. {}
  26. template <typename Info>
  27. inline void assign(Info const& info)
  28. {
  29. initialized = true;
  30. ra = info.ra;
  31. rb = info.rb;
  32. }
  33. inline void assign(SegmentRatio const& a, SegmentRatio const& b)
  34. {
  35. initialized = true;
  36. ra = a;
  37. rb = b;
  38. }
  39. };
  40. //
  41. /*!
  42. \brief return-type for segment-intersection
  43. \note Set in intersection_points.hpp, from segment_intersection_info
  44. */
  45. template
  46. <
  47. typename Point,
  48. typename SegmentRatio = segment_ratio<coordinate_type_t<Point>>
  49. >
  50. struct segment_intersection_points
  51. {
  52. std::size_t count; // The number of intersection points
  53. // TODO: combine intersections and fractions in one struct
  54. Point intersections[2];
  55. fraction_type<SegmentRatio> fractions[2];
  56. typedef Point point_type;
  57. segment_intersection_points()
  58. : count(0)
  59. {}
  60. };
  61. }} // namespace boost::geometry
  62. #endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP