This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/grid/GridNode.h
FrankE 99ee95ce7b worked on signal-strength-estimation
add this information to grid nodes
evaluate this information
new test-cases
2016-07-15 15:29:07 +02:00

85 lines
1.8 KiB
C++
Executable File

#ifndef GRIDNODE_H
#define GRIDNODE_H
#include "GridNodeBBox.h"
#include "GridPoint.h"
/** forward decl. */
template<typename> class Grid;
/**
* INTERNAL DATASTRUCTURE
* this data-structure is internally used by the Grid
* to store additional information for each node besides
* the user's requested data-structure
*/
struct GridNode {
private:
/** grant full access to the grid */
template<typename> friend class Grid;
/** INTERNAL: node's index array-index */
int _idx;
/** INTERNAL: store neighbors (via index) */
int _neighbors[10];
/** INTERNAL: number of neighbors */
uint8_t _numNeighbors;
/** semantic annotation for this node */
uint8_t _type;
public:
static const uint8_t TYPE_FLOOR = 0;
static const uint8_t TYPE_STAIR = 1;
static const uint8_t TYPE_ELEVATOR = 2;
static const uint8_t TYPE_DOOR = 3;
public:
/** ctor */
GridNode() : _idx(-1), _neighbors(), _numNeighbors(0), _type(0) {;}
/** get the node's index within its grid */
int getIdx() const {return _idx;}
/** get the number of neighbors for this node */
int getNumNeighbors() const {return _numNeighbors;}
/** reached neighbor limit? */
bool fullyConnected() const {return _numNeighbors >= 10;}
/** is this node connected to the given index? */
bool hasNeighbor(const int idx) const {
for (int i = 0; i < _numNeighbors; ++i) {
if (_neighbors[i] == idx) {return true;}
}
return false;
}
/** get the node's semantic type */
uint8_t getType() const {return _type;}
/** set the node's semantic type */
void setType(const uint8_t type) {this->_type = type;}
// /** get the n-th neighbor for this node */
// template <int gridSize_cm, typename T> inline T& getNeighbor(const int nth, const Grid<gridSize_cm, T>& grid) const {
// return grid.getNeighbor(_idx, nth);
// }
};
#endif // GRIDNODE_H