Voxomap
A C++11 voxel container.
example_smart_area.cpp
Go to the documentation of this file.
1 
6 #include <iostream>
8 #include "voxel_octree/SmartArea.hpp"
9 
10 // First, we begin by define a user data structure (voxel data)
11 struct UserData
12 {
13  // Constructor
14  UserData(int value = 0) : value(value)
15  {
16  }
17 
18  // Attribute of the voxel
19  int64_t value = 0;
20 };
21 
22 void main()
23 {
24  // Create the voxel container
25  // Use SmartArea as voxel leaf structure
27 
28  // Add a voxel at position 0, 0, 0 with value 42
29  voxel_octree.addVoxel(0, 0, 0, 42);
30 
31  // Update value of voxel at position 0, 0, 0 with value 43
32  voxel_octree.updateVoxel(0, 0, 0, 43);
33 
34  // Declare iterator
36 
37  // Get iterator on voxel at position 0, 0, 0
38  it = voxel_octree.findVoxel(0, 0, 0);
39 
40  if (it)
41  {
42  // Get the node where the voxel is
44  node = it.node;
45 
46  // Get the voxel area where the voxel is
47  voxomap::SmartArea<UserData>* area = it.getArea();
48 
49  // Write the internal position of the voxel is inside the node and its value
50  std::cout << "x: " << int(it.x) << " y: " << int(it.y) << " z: " << int(it.z) << " value: " << it.voxel->value << std::endl;
51  }
52 
53  // Remove voxel at position 0, 0, 0
54  voxel_octree.removeVoxel(0, 0, 0);
55 }
56 
voxomap::VoxelOctree::findVoxel
iterator findVoxel(T x, T y, T z)
Returns a voxel iterator.
VoxelOctree.hpp
voxomap::VoxelOctree::removeVoxel
bool removeVoxel(T x, T y, T z, Args &&... args)
Removes a voxel.
voxomap::VoxelOctree::addVoxel
std::pair< iterator, bool > addVoxel(T x, T y, T z, Args &&... args)
Add the voxel if not exist.
voxomap::VoxelNode
Node optimized for voxel.
Definition: VoxelNode.hpp:14
voxomap::VoxelOctree
Octree optimized for voxel.
Definition: VoxelOctree.hpp:17
voxomap::VoxelOctree::updateVoxel
iterator updateVoxel(T x, T y, T z, Args &&... args)
Update the voxel if already exist.