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:
76 };
77 
78 //=============================================================================
79 } // namespace octree
80 //=============================================================================
81 #endif // OCTREE_LOCATION_HH defined
82 //=============================================================================
CellHandle.hh
lvr2::Location::set_loc_y
void set_loc_y(LocCode _loc_y)
Definition: Location.hh:47
lvr2::Location::set_level
void set_level(LocCode _level)
Definition: Location.hh:49
lvr2::Location::set_loc_x
void set_loc_x(LocCode _loc_x)
Definition: Location.hh:46
lvr2::Location::level
LocCode level() const
Definition: Location.hh:43
lvr2::Location::loc_x
LocCode loc_x() const
Definition: Location.hh:40
lvr2::Location::loc_x_
LocCode loc_x_
Definition: Location.hh:71
lvr2::Location::set_loc_z
void set_loc_z(LocCode _loc_z)
Definition: Location.hh:48
lvr2::Location::Location
Location()
Standard constructor.
Definition: Location.hh:31
lvr2::Location::neighbor
Location neighbor(int _idx) const
Definition: Location.hh:51
lvr2::Location::level_
LocCode level_
Definition: Location.hh:74
lvr2::Location::loc_y
LocCode loc_y() const
Definition: Location.hh:41
lvr2::Location::loc_y_
LocCode loc_y_
Definition: Location.hh:72
lvr2::Location
Definition: Location.hh:24
lvr2::Location::loc_z
LocCode loc_z() const
Definition: Location.hh:42
lvr2::Location::LocCode
unsigned short LocCode
This datatype determines the maximal depth of the octree.
Definition: Location.hh:28
lvr2::Location::parent_
CellHandle parent_
Definition: Location.hh:75
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::Location::set_parent
void set_parent(CellHandle _parent)
Definition: Location.hh:45
lvr2::Location::Location
Location(LocCode _loc_x, LocCode _loc_y, LocCode _loc_z, LocCode _level, CellHandle _parent)
Definition: Location.hh:35
lvr2::CellHandle
Definition: CellHandle.hh:22
lvr2::Location::parent
CellHandle parent() const
Definition: Location.hh:39
lvr2::Location::loc_z_
LocCode loc_z_
Definition: Location.hh:73


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 Wed Mar 2 2022 00:37:24