AbstractOcTree.h
Go to the documentation of this file.
1 /*
2  * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3  * http://octomap.github.com/
4  *
5  * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6  * All rights reserved.
7  * License: New BSD
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  * * Neither the name of the University of Freiburg nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef OCTOMAP_ABSTRACT_OCTREE_H
35 #define OCTOMAP_ABSTRACT_OCTREE_H
36 
37 #include <cstddef>
38 #include <fstream>
39 #include <string>
40 #include <iostream>
41 #include <map>
42 
43 namespace octomap {
44 
51  friend class StaticMapInit;
52  public:
54  virtual ~AbstractOcTree() {};
55 
57  virtual AbstractOcTree* create() const = 0;
58 
60  virtual std::string getTreeType() const = 0;
61 
62 
63 
64  virtual double getResolution() const = 0;
65  virtual void setResolution(double res) = 0;
66  virtual size_t size() const = 0;
67  virtual size_t memoryUsage() const = 0;
68  virtual size_t memoryUsageNode() const = 0;
69  virtual void getMetricMin(double& x, double& y, double& z) = 0;
70  virtual void getMetricMin(double& x, double& y, double& z) const = 0;
71  virtual void getMetricMax(double& x, double& y, double& z) = 0;
72  virtual void getMetricMax(double& x, double& y, double& z) const = 0;
73  virtual void getMetricSize(double& x, double& y, double& z) = 0;
74 
75  virtual void prune() = 0;
76  virtual void expand() = 0;
77  virtual void clear() = 0;
78 
79  //-- Iterator tree access
80 
81  // default iterator is leaf_iterator
82 // class leaf_iterator;
83 // class tree_iterator;
84 // class leaf_bbx_iterator;
85 // typedef leaf_iterator iterator;
86  class iterator_base;
87 // /// @return beginning of the tree as leaf iterator
88  //virtual iterator_base begin(unsigned char maxDepth=0) const = 0;
89 // /// @return end of the tree as leaf iterator
90 // virtual const iterator end() const = 0;
91 // /// @return beginning of the tree as leaf iterator
92 // virtual leaf_iterator begin_leafs(unsigned char maxDepth=0) const = 0;
93 // /// @return end of the tree as leaf iterator
94 // virtual const leaf_iterator end_leafs() const = 0;
95 // /// @return beginning of the tree as leaf iterator in a bounding box
96 // virtual leaf_bbx_iterator begin_leafs_bbx(const OcTreeKey& min, const OcTreeKey& max, unsigned char maxDepth=0) const = 0;
97 // /// @return beginning of the tree as leaf iterator in a bounding box
98 // virtual leaf_bbx_iterator begin_leafs_bbx(const point3d& min, const point3d& max, unsigned char maxDepth=0) const = 0;
99 // /// @return end of the tree as leaf iterator in a bounding box
100 // virtual const leaf_bbx_iterator end_leafs_bbx() const = 0;
101 // /// @return beginning of the tree as iterator to all nodes (incl. inner)
102 // virtual tree_iterator begin_tree(unsigned char maxDepth=0) const = 0;
103 // /// @return end of the tree as iterator to all nodes (incl. inner)
104 // const tree_iterator end_tree() const = 0;
105 
107  bool write(const std::string& filename) const;
109  bool write(std::ostream& s) const;
110 
118  static AbstractOcTree* createTree(const std::string id, double res);
119 
130  static AbstractOcTree* read(const std::string& filename);
131 
134  static AbstractOcTree* read(std::istream &s);
135 
142  virtual std::istream& readData(std::istream &s) = 0;
143 
146  virtual std::ostream& writeData(std::ostream &s) const = 0;
147  private:
149  static std::map<std::string, AbstractOcTree*>& classIDMapping();
150 
151  protected:
152  static bool readHeader(std::istream &s, std::string& id, unsigned& size, double& res);
153  static void registerTreeType(AbstractOcTree* tree);
154 
155  static const std::string fileHeader;
156  };
157 
158 
159 
160 
161 } // end namespace
162 
163 
164 #endif
virtual void getMetricSize(double &x, double &y, double &z)=0
virtual size_t memoryUsage() const =0
static void registerTreeType(AbstractOcTree *tree)
virtual std::string getTreeType() const =0
returns actual class name as string for identification
static AbstractOcTree * read(const std::string &filename)
virtual std::istream & readData(std::istream &s)=0
friend class StaticMapInit
static bool readHeader(std::istream &s, std::string &id, unsigned &size, double &res)
virtual size_t size() const =0
virtual size_t memoryUsageNode() const =0
virtual std::ostream & writeData(std::ostream &s) const =0
virtual double getResolution() const =0
static AbstractOcTree * createTree(const std::string id, double res)
virtual void prune()=0
virtual void getMetricMin(double &x, double &y, double &z)=0
virtual void clear()=0
virtual void expand()=0
static std::map< std::string, AbstractOcTree * > & classIDMapping()
create private store, Construct on first use
virtual void setResolution(double res)=0
bool write(const std::string &filename) const
Write file header and complete tree to file (serialization)
virtual AbstractOcTree * create() const =0
virtual constructor: creates a new object of same type
virtual void getMetricMax(double &x, double &y, double &z)=0
static const std::string fileHeader


octomap
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Feb 28 2022 22:58:06