Program Listing for File FastGA.hpp¶
↰ Return to documentation for file (include\FastGA\FastGA.hpp
)
#ifndef FASTGA_GA_HPP
#define FASTGA_GA_HPP
#include <string>
#include "FastGA/Ico.hpp"
#include "FastGA/Helper.hpp"
#include "FastGA/FastBinarySearch.hpp"
#include "FastGA/NanoFlannAdaptors.hpp"
#include <memory>
#define FASTGA_LEVEL 1
#define FASTGA_MAX_PHI 180.0
#define FASTGA_MAX_LEAF_SIZE 10
#define FASTGA_KDTREE_EPS 0.0
#define FASTGA_EXHAUSTIVE 0
#define FASTGA_TRI_NBRS 12
namespace FastGA {
// TODO This should be like an Abstract class
template <class T>
class GaussianAccumulator
{
public:
Ico::IcoMesh mesh;
std::vector<Bucket<T>> buckets;
std::vector<uint8_t> mask;
Helper::BBOX projected_bbox;
size_t num_buckets;
GaussianAccumulator();
GaussianAccumulator(const int level = FASTGA_LEVEL, const double max_phi = FASTGA_MAX_PHI);
MatX3d GetBucketNormals(const bool mesh_order = false);
std::vector<double> GetNormalizedBucketCounts(const bool mesh_order = false);
std::vector<double> GetNormalizedBucketCountsByVertex(const bool mesh_order = false);
std::vector<T> GetBucketSFCValues();
MatX2d GetBucketProjection();
Ico::IcoMesh CopyIcoMesh(const bool mesh_order = false);
void ClearCount();
protected:
std::vector<size_t> sort_idx;
void SortBucketsByIndices();
};
class GaussianAccumulatorKD : public GaussianAccumulator<uint32_t>
{
public:
GaussianAccumulatorKD(const int level = FASTGA_LEVEL, const double max_phi = FASTGA_MAX_PHI,
const size_t max_leaf_size = FASTGA_MAX_LEAF_SIZE);
std::vector<size_t> Integrate(const MatX3d& normals, const float eps = FASTGA_KDTREE_EPS);
protected:
const NFA::BUCKET2KD bucket2kd;
const nanoflann::KDTreeSingleIndexAdaptorParams index_params;
std::unique_ptr<NFA::nano_kd_tree_t> kd_tree_ptr;
};
class GaussianAccumulatorOpt : public GaussianAccumulator<uint32_t>
{
public:
std::vector<uint32_t> bucket_hv;
MatX12I bucket_neighbors;
Regression regression;
GaussianAccumulatorOpt(const int level = FASTGA_LEVEL, const double max_phi = FASTGA_MAX_PHI);
std::vector<size_t> Integrate(const MatX3d& normals, const int num_nbr = FASTGA_TRI_NBRS);
// std::vector<size_t> Integrate2(const MatX3d &normals, const int num_nbr = FASTGA_TRI_NBRS);
protected:
};
class GaussianAccumulatorS2 : public GaussianAccumulator<uint64_t>
{
public:
std::vector<uint64_t> bucket_hv;
MatX12I bucket_neighbors;
GaussianAccumulatorS2(const int level = FASTGA_LEVEL, const double max_phi = FASTGA_MAX_PHI);
std::vector<size_t> Integrate(const MatX3d& normals, const int num_nbr = FASTGA_TRI_NBRS);
protected:
Regression regression;
};
class GaussianAccumulatorS2Beta
{
public:
Ico::IcoMesh mesh;
std::vector<BucketS2> buckets;
size_t num_buckets;
std::vector<uint64_t> bucket_hv;
MatX12I bucket_neighbors;
Ico::IcoCharts ico_chart;
GaussianAccumulatorS2Beta(const int level = FASTGA_LEVEL);
std::vector<size_t> Integrate(const MatX3d& normals, const int num_nbr = FASTGA_TRI_NBRS);
MatX3d GetBucketNormals(const bool mesh_order = false);
MatX3d GetBucketAverageNormals(const bool mesh_order = false);
std::vector<int> GetBucketCounts(const bool mesh_order = false);
std::vector<double> GetNormalizedBucketCounts(const bool mesh_order = false);
std::vector<double> GetNormalizedBucketCountsByVertex(const bool mesh_order = false);
MatX3d GetAverageNormalsByVertex(const bool mesh_order = false);
std::vector<uint64_t> GetBucketSFCValues();
MatX2d GetBucketProjection();
Ico::IcoMesh CopyIcoMesh(const bool mesh_order = false);
void ClearCount();
void AverageBucketNormals();
MatX3d FindPeaks(uint8_t threshold_abs=25, bool exclude_border=false, double cluster_distance=0.10, double min_cluster_weight=0.15);
protected:
std::vector<size_t> sort_idx;
Regression regression;
void SortBucketsByIndices();
};
} // namespace FastGA
#endif