intersection_result.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.
  4. // Modifications copyright (c) 2015 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. #if defined(HAVE_MATRIX_AS_STRING)
  12. #include <string>
  13. #endif
  14. #include <cstddef>
  15. namespace boost { namespace geometry
  16. {
  17. template <typename SegmentRatio>
  18. struct fraction_type
  19. {
  20. SegmentRatio robust_ra; // TODO this can be renamed now to "ra"
  21. SegmentRatio robust_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. robust_ra = info.robust_ra;
  31. robust_rb = info.robust_rb;
  32. }
  33. inline void assign(SegmentRatio const& a, SegmentRatio const& b)
  34. {
  35. initialized = true;
  36. robust_ra = a;
  37. robust_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 <typename Point, typename SegmentRatio>
  46. struct segment_intersection_points
  47. {
  48. std::size_t count; // The number of intersection points
  49. // TODO: combine intersections and fractions in one struct
  50. Point intersections[2];
  51. fraction_type<SegmentRatio> fractions[2];
  52. typedef Point point_type;
  53. segment_intersection_points()
  54. : count(0)
  55. {}
  56. };
  57. // All assigned in cart_intersect, passed to intersection_points
  58. template <typename CoordinateType, typename PromotedType, typename SegmentRatio>
  59. struct segment_intersection_info
  60. {
  61. typedef PromotedType promoted_type;
  62. CoordinateType dx_a, dy_a;
  63. CoordinateType dx_b, dy_b;
  64. SegmentRatio robust_ra;
  65. SegmentRatio robust_rb;
  66. };
  67. }} // namespace boost::geometry
  68. #endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP