octomap 1.5.0
include/octomap/OcTreeDataNode.h
Go to the documentation of this file.
00001 #ifndef OCTOMAP_OCTREE_DATA_NODE_H
00002 #define OCTOMAP_OCTREE_DATA_NODE_H
00003 
00004 // $Id: OcTreeDataNode.h 401 2012-08-03 15:16:39Z ahornung $
00005 
00014 /*
00015  * Copyright (c) 2009, K. M. Wurm, A. Hornung, University of Freiburg
00016  * All rights reserved.
00017  *
00018  * Redistribution and use in source and binary forms, with or without
00019  * modification, are permitted provided that the following conditions are met:
00020  *
00021  *     * Redistributions of source code must retain the above copyright
00022  *       notice, this list of conditions and the following disclaimer.
00023  *     * Redistributions in binary form must reproduce the above copyright
00024  *       notice, this list of conditions and the following disclaimer in the
00025  *       documentation and/or other materials provided with the distribution.
00026  *     * Neither the name of the University of Freiburg nor the names of its
00027  *       contributors may be used to endorse or promote products derived from
00028  *       this software without specific prior written permission.
00029  *
00030  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00031  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00032  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00033  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00034  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00035  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00036  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00037  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00038  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00039  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00040  * POSSIBILITY OF SUCH DAMAGE.
00041  */
00042 
00043 #include "octomap_types.h"
00044 #include "assert.h"
00045 #include <bitset>
00046 
00047 namespace octomap {
00048 
00049   class AbstractOcTreeNode {
00050 
00051 
00052   };
00053 
00061   template<typename T> class OcTreeDataNode: public AbstractOcTreeNode {
00062 
00063   public:
00064 
00065     OcTreeDataNode();
00066     OcTreeDataNode(T initVal);
00068     OcTreeDataNode(const OcTreeDataNode& rhs);
00069 
00070     ~OcTreeDataNode();
00071 
00073     bool operator==(const OcTreeDataNode& rhs) const;
00074 
00075 
00076     // -- children  ----------------------------------
00077 
00078 
00080     bool createChild(unsigned int i);
00081 
00083     bool childExists(unsigned int i) const;
00084 
00086     OcTreeDataNode<T>* getChild(unsigned int i);
00087 
00089     const OcTreeDataNode<T>* getChild(unsigned int i) const;
00090 
00092     bool hasChildren() const;
00093 
00096     bool collapsible() const;
00097 
00099     void deleteChild(unsigned int i);
00100 
00101     // -- pruning of children  -----------------------
00102 
00103 
00108     bool pruneNode();
00109 
00118     void expandNode();
00119 
00121     T getValue() const{return value;};
00123     void setValue(T v) {value = v;};
00124 
00125     // file IO:
00126 
00134     std::istream& readValue(std::istream &s);
00135 
00144     std::ostream& writeValue(std::ostream &s) const;
00145 
00146 
00148     typedef T DataType;
00149 
00150 
00151   protected:
00152     void allocChildren();
00153 
00155     OcTreeDataNode<T>** children;
00157     T value;
00158 
00159   };
00160 
00161 
00162 } // end namespace
00163 
00164 #include "octomap/OcTreeDataNode.hxx"
00165 
00166 #endif