RaycastResults.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <ROS2Sensors/Lidar/RaycastResults.h>
  9. namespace ROS2Sensors
  10. {
  11. RaycastResults::RaycastResults(RaycastResultFlags flags, size_t count)
  12. : m_count{ count }
  13. {
  14. EnsureFlagSatisfied<RaycastResultFlags::Point>(flags, count);
  15. EnsureFlagSatisfied<RaycastResultFlags::Range>(flags, count);
  16. EnsureFlagSatisfied<RaycastResultFlags::Intensity>(flags, count);
  17. EnsureFlagSatisfied<RaycastResultFlags::SegmentationData>(flags, count);
  18. }
  19. RaycastResults::RaycastResults(RaycastResults&& other)
  20. : m_count{ other.m_count }
  21. , m_points{ AZStd::move(other.m_points) }
  22. , m_ranges{ AZStd::move(other.m_ranges) }
  23. , m_intensities{ AZStd::move(other.m_intensities) }
  24. , m_segmentationData{ AZStd::move(other.m_segmentationData) }
  25. {
  26. other.m_count = 0U;
  27. }
  28. void RaycastResults::Clear()
  29. {
  30. m_count = 0U;
  31. ClearFieldIfPresent<RaycastResultFlags::Point>();
  32. ClearFieldIfPresent<RaycastResultFlags::Range>();
  33. ClearFieldIfPresent<RaycastResultFlags::Intensity>();
  34. ClearFieldIfPresent<RaycastResultFlags::SegmentationData>();
  35. }
  36. void RaycastResults::Resize(size_t count)
  37. {
  38. m_count = count;
  39. ResizeFieldIfPresent<RaycastResultFlags::Point>(count);
  40. ResizeFieldIfPresent<RaycastResultFlags::Range>(count);
  41. ResizeFieldIfPresent<RaycastResultFlags::Intensity>(count);
  42. ResizeFieldIfPresent<RaycastResultFlags::SegmentationData>(count);
  43. }
  44. RaycastResults& RaycastResults::operator=(RaycastResults&& other)
  45. {
  46. if (this == &other)
  47. {
  48. return *this;
  49. }
  50. m_count = other.m_count;
  51. other.m_count = 0U;
  52. m_points = AZStd::move(other.m_points);
  53. m_ranges = AZStd::move(other.m_ranges);
  54. m_intensities = AZStd::move(other.m_intensities);
  55. m_segmentationData = AZStd::move(other.m_segmentationData);
  56. return *this;
  57. }
  58. bool RaycastResults::IsEmpty() const
  59. {
  60. return GetCount() == 0U;
  61. }
  62. size_t RaycastResults::GetCount() const
  63. {
  64. return m_count;
  65. }
  66. } // namespace ROS2Sensors