8 , m_hasConnectedComponent(false)
17 , m_hasConnectedComponent(false)
26 m_hasConnectedComponent =
false;
32 const PointCloud&
pc,
size_t currentSize,
float epsilon,
float normalThresh,
36 for (; i < m_indices->
size(); ++i)
37 if (newIndices[(*m_indices)[i]] < minInvalidIndex)
39 (*m_indices)[j++] = newIndices[(*m_indices)[i]];
41 if (m_subset <= mergedSubsets)
43 m_hasConnectedComponent =
false;
54 m_subset -= mergedSubsets;
55 if (m_subset >= subsetSizes.
size())
61 size_t sampledPoints = 0,
63 for (i = 0; i < endi; ++i)
65 sampledPoints += subsetSizes[i];
68 GetBounds(sampledPoints, currentSize);
73 size_t reindexSize = reindex.
size();
74 for (
size_t i = 0; i < m_indices->
size(); ++i)
75 if (m_indices->
at(i) < reindexSize)
77 m_indices->
at(i) = reindex[m_indices->
at(i)];
82 float normalThresh)
const
85 #pragma omp parallel for schedule(static) reduction(+:score)
86 for (intptr_t i = 0; i < (intptr_t)m_indices->
size(); ++i)
95 size_t oldSize = m_indices->
size();
96 size_t connectedSize = m_shape->
ConnectedComponent(
pc, bitmapEpsilon, m_indices,
true, borderRatio);
97 m_indices->
resize(connectedSize);
98 m_lowerBound = m_upperBound = (
float)m_indices->
size();
102 float epsilon,
float normalThresh)
const
104 if (m_shape->
Identifier() !=
c.m_shape->Identifier())
110 for (
size_t i = 0; i < size; ++i)
112 std::pair< float, float > dn;
114 c.m_shape->DistanceAndNormalDeviation(
117 if (dn.first < epsilon &&
abs(dn.second) > normalThresh)
122 size_t tested = size;
123 size =
std::min(
c.m_indices->size(), (
size_t)9);
124 for (
size_t i = 0; i < size; ++i)
126 std::pair< float, float > dn;
129 pc[
c.m_indices->at(idx)].
pos,
131 if (dn.first < epsilon &&
abs(dn.second) > normalThresh)
137 return correct >= 2 * tested / 3;
142 float variance = 0.0f;
145 if (m_indices->
size() > 0)
148 float expectancy = 0.0f;
149 for (
int i = 0; i < m_indices->
size(); ++i)
154 expectancy /=
static_cast<float>(m_indices->
size());
157 for (
int i = 0; i < m_indices->
size(); ++i)
160 variance += dev * dev;
163 variance /=
static_cast<float>(m_indices->
size());
173 float Candidate::GetPseudoVariance(
const PointCloud&
pc)
175 float variance = 0.0f;
178 for (
int i = 0; i < m_indices->
size(); ++i)
181 variance += dev * dev;
183 variance /=
static_cast<float>(m_indices->
size());
188 void Candidate::GetScore(
const PointCloud&
pc,
float bitmapEpsilon,
bool doFiltering)
190 GetScoreMaxCCSize(
pc, bitmapEpsilon, doFiltering);
193 void Candidate::GetScoreMaxCCSize(
const PointCloud&
pc,
float bitmapEpsilon,
bool doFiltering)
196 m_indices, doFiltering);
197 m_indices->
resize(connectedSize);
199 m_score = connectedSize;
202 void Candidate::GetScoreMaxCCMinBorder(
const PointCloud&
pc,
float bitmapEpsilon,
bool doFiltering)
206 m_indices, doFiltering, &borderRatio);
207 m_indices->
resize(connectedSize);
209 m_score = connectedSize * size_t((1.0f - borderRatio) * (1.0f - GetVariance(
pc)));