AbstractOcTree.h
Go to the documentation of this file.
00001 /*
00002  * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
00003  * http://octomap.github.com/
00004  *
00005  * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
00006  * All rights reserved.
00007  * License: New BSD
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions are met:
00011  *
00012  *     * Redistributions of source code must retain the above copyright
00013  *       notice, this list of conditions and the following disclaimer.
00014  *     * Redistributions in binary form must reproduce the above copyright
00015  *       notice, this list of conditions and the following disclaimer in the
00016  *       documentation and/or other materials provided with the distribution.
00017  *     * Neither the name of the University of Freiburg nor the names of its
00018  *       contributors may be used to endorse or promote products derived from
00019  *       this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031  * POSSIBILITY OF SUCH DAMAGE.
00032  */
00033 
00034 #ifndef OCTOMAP_ABSTRACT_OCTREE_H
00035 #define OCTOMAP_ABSTRACT_OCTREE_H
00036 
00037 #include <cstddef>
00038 #include <fstream>
00039 #include <string>
00040 #include <iostream>
00041 #include <map>
00042 
00043 namespace octomap {
00044 
00050   class AbstractOcTree {
00051     friend class StaticMapInit;
00052   public:
00053     AbstractOcTree();
00054     virtual ~AbstractOcTree() {};
00055 
00057     virtual AbstractOcTree* create() const = 0;
00058 
00060     virtual std::string getTreeType() const = 0;
00061 
00062 
00063 
00064     virtual double getResolution() const = 0;
00065     virtual void setResolution(double res) = 0;
00066     virtual size_t size() const = 0;
00067     virtual size_t memoryUsage() const = 0;
00068     virtual size_t memoryUsageNode() const = 0;
00069     virtual void getMetricMin(double& x, double& y, double& z) = 0;
00070     virtual void getMetricMin(double& x, double& y, double& z) const = 0;
00071     virtual void getMetricMax(double& x, double& y, double& z) = 0;
00072     virtual void getMetricMax(double& x, double& y, double& z) const = 0;
00073     virtual void getMetricSize(double& x, double& y, double& z) = 0;
00074 
00075     virtual void prune() = 0;
00076     virtual void expand() = 0;
00077     virtual void clear() = 0;
00078 
00079     //-- Iterator tree access
00080 
00081     // default iterator is leaf_iterator
00082 //    class leaf_iterator;
00083 //    class tree_iterator;
00084 //    class leaf_bbx_iterator;
00085 //    typedef leaf_iterator iterator;
00086       class iterator_base;
00087 //    /// @return beginning of the tree as leaf iterator
00088       //virtual iterator_base begin(unsigned char maxDepth=0) const = 0;
00089 //    /// @return end of the tree as leaf iterator
00090 //    virtual const iterator end() const = 0;
00091 //    /// @return beginning of the tree as leaf iterator
00092 //    virtual leaf_iterator begin_leafs(unsigned char maxDepth=0) const = 0;
00093 //    /// @return end of the tree as leaf iterator
00094 //    virtual const leaf_iterator end_leafs() const = 0;
00095 //    /// @return beginning of the tree as leaf iterator in a bounding box
00096 //    virtual leaf_bbx_iterator begin_leafs_bbx(const OcTreeKey& min, const OcTreeKey& max, unsigned char maxDepth=0) const = 0;
00097 //    /// @return beginning of the tree as leaf iterator in a bounding box
00098 //    virtual leaf_bbx_iterator begin_leafs_bbx(const point3d& min, const point3d& max, unsigned char maxDepth=0) const = 0;
00099 //    /// @return end of the tree as leaf iterator in a bounding box
00100 //    virtual const leaf_bbx_iterator end_leafs_bbx() const = 0;
00101 //    /// @return beginning of the tree as iterator to all nodes (incl. inner)
00102 //    virtual tree_iterator begin_tree(unsigned char maxDepth=0) const = 0;
00103 //    /// @return end of the tree as iterator to all nodes (incl. inner)
00104 //    const tree_iterator end_tree() const = 0;
00105 
00107     bool write(const std::string& filename) const;
00109     bool write(std::ostream& s) const;
00110 
00118     static AbstractOcTree* createTree(const std::string id, double res);
00119 
00130     static AbstractOcTree* read(const std::string& filename);
00131 
00134     static AbstractOcTree* read(std::istream &s);
00135 
00142     virtual std::istream& readData(std::istream &s) = 0;
00143 
00146     virtual std::ostream& writeData(std::ostream &s) const = 0;
00147   private:
00149     static std::map<std::string, AbstractOcTree*>& classIDMapping();
00150 
00151   protected:
00152     static bool readHeader(std::istream &s, std::string& id, unsigned& size, double& res);
00153     static void registerTreeType(AbstractOcTree* tree);
00154 
00155     static const std::string fileHeader;
00156   };
00157 
00158 
00159 
00160 
00161 } // end namespace
00162 
00163 
00164 #endif


octomap
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Feb 11 2016 23:50:59