Octree C++ Class Template

An octree is a tree structure for storing sparse 3-D data. What you will find here is source code for the easiest and fastest C++ octree class template around. And it's free. You can find more information on octrees in general from Wikipedia.

Code Example

#include "octree.h"

int main()
{
    Octree<double> o(4096); /* Create 4096x4096x4096 octree containing doubles. */
    o(1,2,3) = 3.1416;      /* Put pi in (1,2,3). */
    o.erase(1,2,3);         /* Erase that node. */
}

Features

  • Easy: No dependencies, just pure C++. You just create the octree and put data in it as if it were a 3-D array. All the magic is done without you needing to know. And just between us, you don't want to know.
  • Fast: My octree has a neat feature: aggregates. By default they are not used and you don't need to know about them at all if you don't want to. But if you want a nice speed boost, play a bit with the AS template parameter. A higher value will result in a faster and smaller octree for small data types like int, float, double, etc.

Download

Documentation

The documentation was generated with Doxygen.

License

It's GPL. If you would like something more permissive, contact me. We can probably work something out.

Questions?

I like to receive email. I read and reply quickly to every single one. Write to me at nomis80@nomis80.org.


See my other code snippets!

Simon Perreault