VIPRA Documentation
Loading...
Searching...
No Matches
pedestrian_groups.hpp
1#pragma once
2
3#include <vector>
4
5#include "vipra/geometry/f3d.hpp"
6
7#include "vipra/types/idx.hpp"
8#include "vipra/vipra_behaviors/definitions/pedestrian_types.hpp"
9
10namespace VIPRA::Behaviors {
11
17 DEFAULT_CONSTRUCTIBLE(GroupsContainer)
18 COPYABLE(GroupsContainer)
19 MOVEABLE(GroupsContainer)
20
21 public:
28 static constexpr auto index(typeUID type) -> VIPRA::idx
29 {
30 if ( type == 0 ) {
31 return 0;
32 }
33
34 VIPRA::idx check = 1;
35 VIPRA::idx index = 1;
36 while ( (check & type) == 0U ) {
37 check = check << 1U;
38 ++index;
39 }
40
41 return index;
42 }
43
44 void initialize(Ptype, VIPRA::size);
45 void clean_used();
46
47 [[nodiscard]] auto size() const -> VIPRA::size;
48
49 [[nodiscard]] auto at(VIPRA::idx) const -> VIPRA::idxVec const&;
50 [[nodiscard]] auto operator[](VIPRA::idx) -> VIPRA::idxVec&;
51
52 [[nodiscard]] auto get_group(typeUID) const -> const VIPRA::idxVec&;
53
54 void add_ped(VIPRA::idx, typeUID);
55 void move_ped(VIPRA::idx, typeUID, typeUID);
56 auto remove_ped(VIPRA::idx, typeUID) -> bool;
57
58 auto set_used(VIPRA::idx, typeUID) -> bool;
59 [[nodiscard]] auto get_used(typeUID) const -> std::vector<bool> const&;
60 [[nodiscard]] auto is_used(VIPRA::idx, typeUID) const -> bool;
61
62 private:
63 std::vector<VIPRA::idxVec> _groups;
64 std::vector<std::vector<bool>> _used;
65};
66} // namespace VIPRA::Behaviors
Holds the indexes for pedestrians in each type group.
Definition pedestrian_groups.hpp:16
void add_ped(VIPRA::idx, typeUID)
Adds a pedestrians index to the group with type.
Definition pedestrian_groups.cpp:61
auto set_used(VIPRA::idx, typeUID) -> bool
Sets a pedestrian as _used in a particular group, this pedestrian can then no longer be selected from...
Definition pedestrian_groups.cpp:76
void initialize(Ptype, VIPRA::size)
Initializes the _groups, starting with all pedestrians in group 0.
Definition pedestrian_groups.cpp:33
auto size() const -> VIPRA::size
Returns the number of _groups.
Definition pedestrian_groups.cpp:153
auto at(VIPRA::idx) const -> VIPRA::idxVec const &
Gets the group at index.
Definition pedestrian_groups.cpp:143
void clean_used()
Resets _used status of all pedestrians.
Definition pedestrian_groups.cpp:106
static constexpr auto index(typeUID type) -> VIPRA::idx
Gets the index into the container for a given type.
Definition pedestrian_groups.hpp:28
auto get_used(typeUID) const -> std::vector< bool > const &
Returns vector of _used pedestrians from a group.
Definition pedestrian_groups.cpp:97
auto get_group(typeUID) const -> const VIPRA::idxVec &
Returns the group with a given type.
Definition pedestrian_groups.cpp:50
auto remove_ped(VIPRA::idx, typeUID) -> bool
Removes the pedestrian from the group with type.
Definition pedestrian_groups.cpp:114
Pedestrian Type, used as a composite of typeUIDs.
Definition pedestrian_types.hpp:23