ScoreComputer.h
Go to the documentation of this file.
1#ifndef SCORECOMPUTER_HEADER
2#define SCORECOMPUTER_HEADER
3#include <GfxTL/NullClass.h>
4#ifndef _USE_MATH_DEFINES
5#define _USE_MATH_DEFINES
6#endif
7#include <cmath>
8
9#include "PointCloud.h"
10
11inline float
12weigh(const float d, const float eps)
13{
14 return std::exp(-d * d / (2.f / 9.f * eps * eps)); // gaussian weighting eps / 3 == sigma
15 // return 1.f - (d / eps) * (d / eps); // anti-quadratic weighting
16 // return 1.f - d / eps; // linear weighting
17 //return d * d; // SSE
18}
19
20template <class BaseT>
21class LocalScoreComputer : public BaseT
22{
23public:
24 template <class ShapeT>
25 static void
26 Score(const ShapeT& shape,
27 const PointCloud& pc,
28 float epsilon,
29 float normalThresh,
32 std::pair<size_t, float>* score,
33 MiscLib::Vector<size_t>* indices = NULL)
34 {
35 Vec3f n;
36 size_t size = end - begin;
37 for (size_t iter = 0; iter < size; ++iter)
38 {
39 float d = shape.DistanceAndNormal(pc[begin[iter]].pos, &n);
40 float nd = n.dot(pc[begin[iter]].normal);
41 if (d < epsilon && abs(nd) > normalThresh)
42 {
43 ++score->first;
44 score->second += weigh(d, epsilon);
45 }
46 }
47 }
48};
49
50#endif
float weigh(const float d, const float eps)
static void Score(const ShapeT &shape, const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end, std::pair< size_t, float > *score, MiscLib::Vector< size_t > *indices=NULL)
Definition basic.h:18