Program Listing for File FastBox.hpp
↰ Return to documentation for file (include/lvr2/reconstruction/FastBox.hpp)
/*
* FastBox.h
*
* Created on: 03.03.2011
* Author: Thomas Wiemann
*/
#ifndef _LVR2_RECONSTRUCTION_FASTBOX_H_
#define _LVR2_RECONSTRUCTION_FASTBOX_H_
#include "lvr2/reconstruction/MCTable.hpp"
#include "lvr2/reconstruction/FastBoxTables.hpp"
#include "lvr2/geometry/Normal.hpp"
#include "QueryPoint.hpp"
#include <vector>
#include <limits>
using std::vector;
using std::numeric_limits;
namespace lvr2
{
template<typename BoxT>
struct BoxTraits
{
const static string type;
};
template<typename BaseVecT>
class FastBox
{
public:
FastBox(BaseVecT center);
virtual ~FastBox() {};
void setVertex(int index, uint value);
void setNeighbor(int index, FastBox<BaseVecT>* cell);
uint getVertex(int index);
FastBox<BaseVecT>* getNeighbor(int index);
BaseVecT& getCenter() { return m_center; }
const BaseVecT& getCenter() const { return m_center; }
virtual void getSurface(
BaseMesh<BaseVecT>& mesh,
const std::vector<QueryPoint<BaseVecT>>& query_points,
uint& globalIndex
);
virtual void getSurface(
BaseMesh<BaseVecT>& mesh,
const std::vector<QueryPoint<BaseVecT>>& query_points,
uint& globalIndex,
BoundingBox<BaseVecT>& bb,
vector<unsigned int>& duplicates,
float comparePrecision
);
static float m_voxelsize;
static uint INVALID_INDEX;
OptionalVertexHandle m_intersections[12];
BaseVecT m_center;
FastBox<BaseVecT>* m_neighbors[27];
protected:
inline bool compareFloat(double num1, double num2) const
{
if(fabs(num1 - num2) < std::numeric_limits<double>::epsilon())
return true;
else
return false;
}
int getIndex(const std::vector<QueryPoint<BaseVecT>>& query_points) const;
bool isInvalid(const std::vector<QueryPoint<BaseVecT>>& query_points) const;
void getIntersections(const BaseVecT* corners, float* distance, BaseVecT* positions) const;
void getCorners(BaseVecT corners[], const std::vector<QueryPoint<BaseVecT>>& query_points) const;
void getDistances(float distances[], const std::vector<QueryPoint<BaseVecT>>& query_points) const;
/***
* @brief Interpolates the intersection between x1 and x1.
*
* @param x1 The first coordinate
* @param x2 The second coordinate
* @param d1 The distance value for the first coordinate
* @param d2 The distance value for the second coordinate
* @return The interpolated distance.
*/
float calcIntersection(float x1, float x2, float d1, float d2) const;
float distanceToBB(const BaseVecT& v, const BoundingBox<BaseVecT>& bb) const;
uint m_vertices[8];
template <typename T> friend class BilinearFastBox;
typedef FastBox<BaseVecT> BoxType;
};
} // namespace lvr2
#include "lvr2/reconstruction/FastBox.tcc"
#endif /* _LVR2_RECONSTRUCTION_FASTBOX_H_ */