Main MRPT website > C++ reference for MRPT 1.4.0
CountingOcTree.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef OCTOMAP_COUNTING_OCTREE_HH
10 #define OCTOMAP_COUNTING_OCTREE_HH
11 
12 // $Id: CountingOcTree.h 391 2012-06-21 10:07:53Z ahornung $
13 
14 /**
15 * OctoMap:
16 * A probabilistic, flexible, and compact 3D mapping library for robotic systems.
17 * @author K. M. Wurm, A. Hornung, University of Freiburg, Copyright (C) 2009.
18 * @see http://octomap.sourceforge.net/
19 * License: New BSD License
20 */
21 
22 /*
23  * Copyright (c) 2009-2011, K. M. Wurm, A. Hornung, University of Freiburg
24  * All rights reserved.
25  *
26  * Redistribution and use in source and binary forms, with or without
27  * modification, are permitted provided that the following conditions are met:
28  *
29  * * Redistributions of source code must retain the above copyright
30  * notice, this list of conditions and the following disclaimer.
31  * * Redistributions in binary form must reproduce the above copyright
32  * notice, this list of conditions and the following disclaimer in the
33  * documentation and/or other materials provided with the distribution.
34  * * Neither the name of the University of Freiburg nor the names of its
35  * contributors may be used to endorse or promote products derived from
36  * this software without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
42  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
43  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49  */
50 
51 
52 #include <stdio.h>
53 #include "OcTreeBase.h"
54 #include "OcTreeDataNode.h"
55 #include <mrpt/maps/link_pragmas.h> // For DLL export within mrpt-maps via the MAPS_IMPEXP macro
56 
57 namespace octomap {
58 
59  /**
60  * An Octree-node which stores an internal counter per node / volume.
61  *
62  * Count is recursive, parent nodes have the summed count of their
63  * children.
64  *
65  * \note In our mapping system this data structure is used in
66  * CountingOcTree in the sensor model only
67  */
68  class /*MAPS_IMPEXP*/ CountingOcTreeNode : public OcTreeDataNode<unsigned int> {
69 
70  public:
71 
74  bool createChild(unsigned int i);
75 
76  inline CountingOcTreeNode* getChild(unsigned int i) {
78  }
79 
80  inline const CountingOcTreeNode* getChild(unsigned int i) const {
81  return static_cast<const CountingOcTreeNode*> (OcTreeDataNode<unsigned int>::getChild(i));
82  }
83 
84  inline unsigned int getCount() const { return getValue(); }
85  inline void increaseCount() { value++; }
86  inline void setCount(unsigned c) {this->setValue(c); }
87 
88  // overloaded:
89  void expandNode();
90  };
91 
92 
93 
94  /**
95  * An AbstractOcTree which stores an internal counter per node / volume.
96  *
97  * Count is recursive, parent nodes have the summed count of their
98  * children.
99  *
100  * \note In our mapping system this data structure is used in
101  * the sensor model only. Do not use, e.g., insertScan.
102  */
103  class /*MAPS_IMPEXP*/ CountingOcTree : public OcTreeBase <CountingOcTreeNode> {
104 
105  public:
106  /// Default constructor, sets resolution of leafs
107  CountingOcTree(double resolution) : OcTreeBase<CountingOcTreeNode>(resolution) {};
108  virtual CountingOcTreeNode* updateNode(const point3d& value);
109  CountingOcTreeNode* updateNode(const OcTreeKey& k);
110  void getCentersMinHits(point3d_list& node_centers, unsigned int min_hits) const;
111 
112  protected:
113 
114  void getCentersMinHitsRecurs( point3d_list& node_centers,
115  unsigned int& min_hits,
116  unsigned int max_depth,
117  CountingOcTreeNode* node, unsigned int depth,
118  const OcTreeKey& parent_key) const;
119 
120  /**
121  * Static member object which ensures that this OcTree's prototype
122  * ends up in the classIDMapping only once
123  */
125  public:
127  CountingOcTree* tree = new CountingOcTree(0.1);
129  }
130  };
131  /// static member to ensure static initialization (only once)
133  };
134 
135 
136 }
137 
138 
139 #endif
OctoMap: A probabilistic, flexible, and compact 3D mapping library for robotic systems.
CountingOcTree(double resolution)
Default constructor, sets resolution of leafs.
An Octree-node which stores an internal counter per node / volume.
An AbstractOcTree which stores an internal counter per node / volume.
CountingOcTreeNode * getChild(unsigned int i)
unsigned int getCount() const
void setValue(unsigned intv)
sets value to be stored in the node
std::list< octomath::Vector3 > point3d_list
Definition: octomap_types.h:68
unsigned int value
stored data (payload)
static void registerTreeType(AbstractOcTree *tree)
static StaticMemberInitializer countingOcTreeMemberInit
static member to ensure static initialization (only once)
OcTreeKey is a container class for internal key addressing.
Definition: OcTreeKey.h:68
Static member object which ensures that this OcTree&#39;s prototype ends up in the classIDMapping only on...
bool createChild(unsigned int i)
Basic node in the OcTree that can hold arbitrary data of type T in value.
const CountingOcTreeNode * getChild(unsigned int i) const
OcTreeDataNode< T > * getChild(unsigned int i)
This class represents a three-dimensional vector.
Definition: Vector3.h:65



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN:Unversioned directory at Mon May 30 18:20:32 UTC 2016