 |
Voxomap
A C++11 voxel container.
|
Go to the documentation of this file. 1 #ifndef _VOXOMAP_VOXELNODE_HPP_
2 #define _VOXOMAP_VOXELNODE_HPP_
8 #include "../octree/Node.hpp"
9 #include "../utils/BoundingBox.hpp"
14 template <
class T_Container>
class VoxelOctree;
20 template <
class T_Container>
21 class VoxelNode :
public Node<VoxelNode<T_Container>>
26 using iterator =
typename T_Container::iterator;
39 std::map<Vector3I, VoxelNode<T_Container>*>
nodes;
131 template <
typename... Args>
139 template <
typename... Args>
146 template <
typename... Args>
154 template <
typename... Args>
167 void exploreVoxelContainer(std::function<
void(
typename T_Container::VoxelContainer
const&)>
const& predicate)
const;
186 std::function<
void(
VoxelNode&)>
const& in_predicate,
187 std::function<
void(
VoxelNode&)>
const& out_predicate);
243 #include "VoxelNode.ipp"
245 #endif // _VOXOMAP_VOXELNODE_HPP_
VoxelNode(int x, int y, int z, int size)
Constructs VoxelNode with its properties.
iterator findRelativeVoxel(int x, int y, int z) const
Search voxel with position relative to the node position.
std::pair< VoxelNode< T_Container > *, bool > neighbor_nodes[3][3][3]
Cache of neighbor nodes.
std::map< Vector3I, VoxelNode< T_Container > * > nodes
Cache of nodes.
void setVoxelContainer(std::shared_ptr< T_Container > container)
Sets the voxel container.
void exploreVoxelNode(std::function< void(VoxelNode const &)> const &predicate) const
Browse all voxel nodes and call predicate on each.
virtual ~VoxelNode()=default
Default destructor.
size_t unserialize(char const *str, size_t strsize)
Unserialize str.
bool findVoxel(iterator &it)
Search voxel.
bool hasVoxel() const
Returns true if node has voxel.
T_Container const * getVoxelContainer() const
Returns the voxel container.
bool updateVoxel(iterator &it, Args &&... args)
Update the voxel if already exist.
void serialize(std::string &str) const
Serialize the structure.
void exploreVoxelContainer(std::function< void(typename T_Container::VoxelContainer const &)> const &predicate) const
Browse all voxel containers and call predicate on each.
typename T_Container::iterator iterator
uint32_t serializeNode(std::string &str) const
Serialize node in str.
static int findVoxelPosition(int src)
Method to find voxel index inside its container.
Node optimized for voxel.
iterator begin()
Returns an iterator to the first voxel of the node.
T_Container * getVoxelContainer()
Returns the voxel container.
Use by the method findRelativeVoxel to improve performance.
void merge(VoxelNode &node)
Merge this with node Add existing voxel in node inside this but don't update voxel that already exist...
void exploreVoxel(std::function< void(iterator const &)> const &predicate) const
Browse all voxels and call predicate on each.
void exploreBoundingBox(BoundingBox< int > const &bounding_box, std::function< void(VoxelNode &)> const &in_predicate, std::function< void(VoxelNode &)> const &out_predicate)
Browse all voxel containers.
std::shared_ptr< T_Container > getSharedVoxelContainer()
Returns a shared pointer to the voxel container.
void copyOnWrite()
Copy the voxel container if a modification occured (add/remove/update voxel) and the container is sha...
std::shared_ptr< T_Container > _container
Voxel container.
NeighborAreaCache()
Default constructor.
void exploreVoxelNode(std::function< void(VoxelNode &)> const &predicate)
Browse all voxel containers and call predicate on each.
unsigned int getNbVoxel() const
Returns the number of voxels.
bool empty() const
Returns true if there is no voxel.
iterator findRelativeVoxel(NeighborAreaCache &neighbor_cache, int x, int y, int z) const
Search voxel with position relative to the node position. Use cache structure for improve performance...
void putVoxel(iterator &it, Args &&... args)
Add or update the voxel.
bool removeVoxel(iterator const &it, Args &&... args)
Remove an existing voxel.
VoxelNode(VoxelNode const &other)
Copy constructor.
bool addVoxel(iterator &it, Args &&... args)
Add the voxel if not exist.
iterator findVoxel(int x, int y, int z)
Search voxel.
typename T_Container::VoxelData VoxelData
iterator end()
Returns an iterator to the voxel folowing the last voxel of the node.
static int findContainerPosition(int src, int container_id)
Method to find voxel container index inside its container.