From a3d2775168f28cf294800b2a873ac20e3a87ddad Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Mar 2024 11:20:43 +0100 Subject: w --- src/search-astar.hpp | 2 +- src/search-node.hpp | 10 +++++++++- src/search-result.hpp | 25 ++++++++++++++----------- 3 files changed, 24 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/search-astar.hpp b/src/search-astar.hpp index c31b348f..ea150c76 100644 --- a/src/search-astar.hpp +++ b/src/search-astar.hpp @@ -11,7 +11,7 @@ namespace floormat { class world; struct point; -struct path_search_result; +class path_search_result; class astar { diff --git a/src/search-node.hpp b/src/search-node.hpp index c2977f84..c911e735 100644 --- a/src/search-node.hpp +++ b/src/search-node.hpp @@ -1,14 +1,21 @@ #pragma once #include "compat/defs.hpp" #include "search-result.hpp" +#include "point.hpp" #include #include namespace floormat { +struct path_search_result::pair +{ + point pt; + uint32_t length = 0; +}; + struct path_search_result::node { - friend struct path_search_result; + friend class path_search_result; friend struct test_app; node() noexcept; @@ -16,6 +23,7 @@ struct path_search_result::node fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(node); std::vector vec; + std::vector vec_; private: Pointer _next; diff --git a/src/search-result.hpp b/src/search-result.hpp index 257d25a3..fc5397a0 100644 --- a/src/search-result.hpp +++ b/src/search-result.hpp @@ -8,10 +8,20 @@ namespace floormat { struct point; -struct path_search_result final +class path_search_result final { friend struct test_app; + struct pair; + struct node; + Pointer _node; + float _time = 0; + uint32_t _cost = 0, _distance = (uint32_t)-1; + bool _found : 1 = false; + + static Pointer _pool; // NOLINT(*-avoid-non-const-global-variables) + +public: const point* data() const; const point& operator[](size_t index) const; size_t size() const; @@ -23,8 +33,11 @@ struct path_search_result final void set_found(bool value); uint32_t distance() const; void set_distance(uint32_t dist); + bool is_simplified() const; + const pair& simplified(); vector_wrapper raw_path(); + vector_wrapper raw_simplified_path(); ArrayView path() const; explicit operator ArrayView() const; explicit operator bool() const; @@ -35,16 +48,6 @@ struct path_search_result final path_search_result(path_search_result&&) noexcept; path_search_result& operator=(path_search_result&&) noexcept; ~path_search_result() noexcept; - -private: - struct node; - - static Pointer _pool; // NOLINT(*-avoid-non-const-global-variables) - - Pointer _node; - float _time = 0; - uint32_t _cost = 0, _distance = (uint32_t)-1; - bool _found : 1 = false; }; } // namespace floormat -- cgit v1.2.3