Class AbstractOcTree

Inheritance Relationships

Derived Types

Class Documentation

class AbstractOcTree

This abstract class is an interface to all octrees and provides a factory design pattern for readin and writing all kinds of OcTrees to files (see read()).

Subclassed by octomap::OcTreeBaseImpl< CountingOcTreeNode, AbstractOcTree >, octomap::OcTreeBaseImpl< NODE, AbstractOcTree >, octomap::AbstractOccupancyOcTree

Public Functions

AbstractOcTree()
inline virtual ~AbstractOcTree()
virtual AbstractOcTree *create() const = 0

virtual constructor: creates a new object of same type

virtual std::string getTreeType() const = 0

returns actual class name as string for identification

virtual double getResolution() const = 0
virtual void setResolution(double res) = 0
virtual size_t size() const = 0
virtual size_t memoryUsage() const = 0
virtual size_t memoryUsageNode() const = 0
virtual void getMetricMin(double &x, double &y, double &z) = 0
virtual void getMetricMin(double &x, double &y, double &z) const = 0
virtual void getMetricMax(double &x, double &y, double &z) = 0
virtual void getMetricMax(double &x, double &y, double &z) const = 0
virtual void getMetricSize(double &x, double &y, double &z) = 0
virtual void prune() = 0
virtual void expand() = 0
virtual void clear() = 0
bool write(const std::string &filename) const

Write file header and complete tree to file (serialization)

bool write(std::ostream &s) const

Write file header and complete tree to stream (serialization)

virtual std::istream &readData(std::istream &s) = 0

Read all nodes from the input stream (without file header), for this the tree needs to be already created. For general file IO, you should probably use AbstractOcTree::read() instead.

virtual std::ostream &writeData(std::ostream &s) const = 0

Write complete state of tree to stream (without file header) unmodified. Pruning the tree first produces smaller files (lossless compression)

Public Static Functions

static AbstractOcTree *createTree(const std::string id, double res)

Creates a certain OcTree (factory pattern)

Parameters:
Returns:

pointer to newly created OcTree (empty). NULL if the ID is unknown!

static AbstractOcTree *read(const std::string &filename)

Read the file header, create the appropriate class and deserialize. This creates a new octree which you need to delete yourself. If you expect or requre a specific kind of octree, use dynamic_cast afterwards:

AbstractOcTree* tree = AbstractOcTree::read("filename.ot");
OcTree* octree = dynamic_cast<OcTree*>(tree);

static AbstractOcTree *read(std::istream &s)

Read the file header, create the appropriate class and deserialize. This creates a new octree which you need to delete yourself.

Protected Static Functions

static bool readHeader(std::istream &s, std::string &id, unsigned &size, double &res)
static void registerTreeType(AbstractOcTree *tree)

Protected Static Attributes

static const std::string fileHeader