Location.hh
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // CLASS Location
4 //
5 // This class encodes the location of an octree cell, i.e. the
6 // position of its lower left back corner, its size and its parent
7 // cell.
8 //
9 //=============================================================================
10 
11 #ifndef OCTREE_LOCATION_HH
12 #define OCTREE_LOCATION_HH
13 
14 //== INCLUDES =================================================================
15 
16 #include "CellHandle.hh"
17 
18 //== NAMESPACES ===============================================================
19 
20 namespace lvr2 {
21 
22 //== CLASS DEFINITION =========================================================
23 
24 class Location
25 {
26 public:
28  typedef unsigned short LocCode; // formerly short
29 
32  : loc_x_( 0 ), loc_y_( 0 ), loc_z_( 0 ), level_( 0 ), parent_( CellHandle() )
33  {}
34 
35  Location( LocCode _loc_x, LocCode _loc_y, LocCode _loc_z, LocCode _level, CellHandle _parent )
36  : loc_x_( _loc_x ), loc_y_( _loc_y ), loc_z_( _loc_z ), level_( _level ), parent_( _parent )
37  {}
38 
39  CellHandle parent() const { return parent_; }
40  LocCode loc_x() const { return loc_x_; }
41  LocCode loc_y() const { return loc_y_; }
42  LocCode loc_z() const { return loc_z_; }
43  LocCode level() const { return level_; }
44 
45  void set_parent( CellHandle _parent ) { parent_ = _parent; }
46  void set_loc_x ( LocCode _loc_x ) { loc_x_ = _loc_x; }
47  void set_loc_y ( LocCode _loc_y ) { loc_y_ = _loc_y; }
48  void set_loc_z ( LocCode _loc_z ) { loc_z_ = _loc_z; }
49  void set_level ( LocCode _level ) { level_ = _level; }
50 
51  Location neighbor( int _idx ) const {
52  LocCode binary_cell_size = 1 << level();
53  switch( _idx ) {
54  case 0 :
55  return Location( loc_x() + binary_cell_size, loc_y(), loc_z(), level(), CellHandle() );
56  case 1 :
57  return Location( loc_x(), loc_y() + binary_cell_size, loc_z(), level(), CellHandle() );
58  case 2 :
59  return Location( loc_x(), loc_y(), loc_z() + binary_cell_size, level(), CellHandle() );
60  case 3 :
61  return Location( loc_x(), loc_y(), loc_z() - binary_cell_size, level(), CellHandle() );
62  case 4 :
63  return Location( loc_x(), loc_y() - binary_cell_size, loc_z(), level(), CellHandle() );
64  case 5 :
65  return Location( loc_x() - binary_cell_size, loc_y(), loc_z(), level(), CellHandle() );
66  }
67  return (*this);
68  }
69 
70 private:
71  LocCode loc_x_;
72  LocCode loc_y_;
73  LocCode loc_z_;
74  LocCode level_;
76 };
77 
78 //=============================================================================
79 } // namespace octree
80 //=============================================================================
81 #endif // OCTREE_LOCATION_HH defined
82 //=============================================================================
Location neighbor(int _idx) const
Definition: Location.hh:51
LocCode loc_z_
Definition: Location.hh:73
Location(LocCode _loc_x, LocCode _loc_y, LocCode _loc_z, LocCode _level, CellHandle _parent)
Definition: Location.hh:35
void set_parent(CellHandle _parent)
Definition: Location.hh:45
LocCode loc_x() const
Definition: Location.hh:40
LocCode loc_y() const
Definition: Location.hh:41
Location()
Standard constructor.
Definition: Location.hh:31
void set_loc_y(LocCode _loc_y)
Definition: Location.hh:47
LocCode loc_x_
Definition: Location.hh:71
unsigned short LocCode
This datatype determines the maximal depth of the octree.
Definition: Location.hh:28
CellHandle parent() const
Definition: Location.hh:39
LocCode loc_z() const
Definition: Location.hh:42
LocCode level_
Definition: Location.hh:74
void set_loc_z(LocCode _loc_z)
Definition: Location.hh:48
void set_loc_x(LocCode _loc_x)
Definition: Location.hh:46
void set_level(LocCode _level)
Definition: Location.hh:49
LocCode loc_y_
Definition: Location.hh:72
CellHandle parent_
Definition: Location.hh:75
LocCode level() const
Definition: Location.hh:43


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08