Main MRPT website > C++ reference for MRPT 1.4.0
OcTreeLUT.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_OCTREE_LUT_H
10 #define OCTOMAP_OCTREE_LUT_H
11 
12 // $Id: OcTreeLUT.h 213 2011-06-16 15:06:53Z kai_wurm $
13 
14 /**
15  * OctoMap:
16  * A probabilistic, flexible, and compact 3D mapping library for robotic systems.
17  * @author Raphael Schmitt, K. M. Wurm, A. Hornung, University of Freiburg, Copyright (C) 2010.
18  * @see http://octomap.sourceforge.net/
19  * License: New BSD License
20  */
21 
22 /*
23  * Copyright (c) 2010, Raphael Schmitt, 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 "OcTreeLUTdefs.h"
53 #include "octomap_types.h"
54 #include "OcTreeKey.h"
55 
56 namespace octomap {
57 
58 
59  //! comparator for keys
60  struct equal_keys {
61  bool operator() (const unsigned short int* key1, const unsigned short int* key2) const {
62  return ((key1[0]==key2[0]) && (key1[1] == key2[1]) && (key1[2] == key2[2]));
63  }
64  };
65 
66  struct hash_key {
67  unsigned short int operator()(const unsigned short int* key) const {
68  return (((31 + key[0]) * 31 + key[1]) * 31 + key[2]);
69  }
70  };
71 
72 
73 
74  /**
75  * Implements a lookup table that allows to computer keys of neighbor cells directly,
76  * see: Samet 1989, "Implementing ray tracing with octrees and neighbor finding"
77  */
78  class OcTreeLUT {
79 
80  public:
81 
82  /**
83  * (N)orth: positive X (S)outh: negative X
84  * (W)est : positive Y (E)ast: negative Y
85  * (T)op : positive Z (B)ottom: negative Z
86  */
87 
88  typedef enum {
89  W = 0, E, N, S , T , B, // face neighbors
90  SW, NW, SE, NE, TW, BW, TE, BE, TN, TS, BN, BS, // edge neighbors
91  TNW, TSW, TNE, TSE, BNW, BSW, BNE, BSE // vertex neighbors
93 
94 
95  public:
96 
97  OcTreeLUT(unsigned int _max_depth);
98  ~OcTreeLUT();
99 
100  bool genNeighborKey(const OcTreeKey& node_key, const signed char& dir,
101  OcTreeKey& neighbor_key) const;
102 
103  protected:
104 
105  void initLUT();
106 
107  unsigned int genPos(const OcTreeKey& key, const int& i) const;
108  void changeKey(const int& val, OcTreeKey& key, const unsigned short int& i) const;
109 
110  protected:
111 
112  unsigned int max_depth;
113 
114  signed char nf_values[8][26];
115  signed char nf_rec_values[8][26];
116  signed char nf_multiple_values[26][4];
117  };
118 
119 } // namespace
120 
121 #endif
OctoMap: A probabilistic, flexible, and compact 3D mapping library for robotic systems.
bool operator()(const unsigned short int *key1, const unsigned short int *key2) const
Definition: OcTreeLUT.h:61
unsigned int max_depth
Definition: OcTreeLUT.h:112
NeighborDirection
(N)orth: positive X (S)outh: negative X (W)est : positive Y (E)ast: negative Y (T)op : positive Z (B)...
Definition: OcTreeLUT.h:88
unsigned short int operator()(const unsigned short int *key) const
Definition: OcTreeLUT.h:67
OcTreeKey is a container class for internal key addressing.
Definition: OcTreeKey.h:68
comparator for keys
Definition: OcTreeLUT.h:60
Implements a lookup table that allows to computer keys of neighbor cells directly, see: Samet 1989, "Implementing ray tracing with octrees and neighbor finding".
Definition: OcTreeLUT.h:78



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN: at Sun Aug 14 23:58:29 UTC 2016