Go to the documentation of this file.
23 const int KernelCollection::HULL_KEY = 0;
24 const int KernelCollection::KDTREE_KEY = 1;
25 const int KernelCollection::NSTREE_KEY = 2;
26 const int KernelCollection::MESH_KEY = 3;
27 const int KernelCollection::AABBTREE_KEY = 4;
28 const int KernelCollection::VIEWCACHE_KEY = 5;
30 std::istream& operator>>(std::istream &in, KernelCollection &v)
38 void KernelCollection::invalidateHelperStructures()
40 totalWeight_ = boost::none;
41 maxLocCutPoint_ = boost::none;
45 void KernelCollection::assertConsistency()
const
49 i->assertConsistency();
59 invalidateHelperStructures();
60 kernelType_ = boost::none;
67 invalidateHelperStructures();
72 kernels_.push_back(NUKLEI_RELEASE(f.
clone()));
89 kernels_.replace(idx, NUKLEI_RELEASE(k.
clone()));
90 invalidateHelperStructures();
98 NUKLEI_THROW(
"KernelCollection empty, hence undefined kernelType.");
112 invalidateHelperStructures();
126 invalidateHelperStructures();
127 return nuklei_trsl::sort_iterator(
begin(),
end(),
128 std::greater<kernel::base>(), sortSize);
134 return nuklei_trsl::sort_iterator(
begin(),
end(),
135 std::greater<kernel::base>(), sortSize);
141 NUKLEI_TRACE_BEGIN();
144 for (Container::const_iterator i = kernels_.begin(); i != kernels_.end(); i++)
146 *totalWeight_ += i->getWeight();
147 *maxLocCutPoint_ = std::max(*maxLocCutPoint_, i->polyCutPoint());
154 NUKLEI_TRACE_BEGIN();
156 NUKLEI_THROW(
"Undefined total weight. Call computeKernelStatistics() first.");
157 return *totalWeight_;
161 weight_t KernelCollection::maxLocCutPoint()
const
163 NUKLEI_TRACE_BEGIN();
164 if (!maxLocCutPoint_)
165 NUKLEI_THROW(
"Undefined max cut point. Call computeKernelStatistics() first.");
166 return *maxLocCutPoint_;
172 NUKLEI_TRACE_BEGIN();
183 for (Container::iterator i = kernels_.begin(); i != kernels_.end(); ++i)
185 i->setWeight( i->getWeight() / *totalWeight_ );
196 for (Container::iterator i = kernels_.begin(); i != kernels_.end(); ++i)
203 NUKLEI_TRACE_BEGIN();
211 coord_t f = i->getWeight() / (w + i->getWeight());
223 NUKLEI_TRACE_BEGIN();
231 coord_t f = i->getWeight() / (w + i->getWeight());
232 dev->polyUpdateWidth(*i, f);
242 NUKLEI_TRACE_BEGIN();
251 NUKLEI_TRACE_BEGIN();
252 invalidateHelperStructures();
254 i->polyMakeTransformWith(t);
259 const Quaternion &rotation)
261 NUKLEI_TRACE_BEGIN();
263 transfo.
loc_ = translation;
264 la::copyRotation(transfo.
ori_, rotation);
271 std::vector<Vector3> proj;
273 proj.push_back(i->getLoc());
279 NUKLEI_TRACE_BEGIN();
286 k->setWeight( 1.0/sampleSize );
296 NUKLEI_TRACE_BEGIN();
297 *
this =
sample(sampleSize);
303 NUKLEI_TRACE_BEGIN();
311 NUKLEI_TRACE_BEGIN();
312 for (
iterator i = kernels_.begin(); i != kernels_.end(); i++)
315 maxLocCutPoint_ = i->polyCutPoint();
322 NUKLEI_TRACE_BEGIN();
323 for (
iterator i = kernels_.begin(); i != kernels_.end(); i++)
328 void KernelCollection::clearDescriptors()
330 NUKLEI_TRACE_BEGIN();
331 for (
iterator i = kernels_.begin(); i != kernels_.end(); ++i)
332 i->clearDescriptor();
336 void KernelCollection::setFlag(
const bitfield_t flag)
338 for (
iterator i = kernels_.begin(); i != kernels_.end(); ++i)
Quaternion ori_
Kernel orientation.
nuklei_trsl::ppfilter_iterator< is_picked, const_iterator > const_sample_iterator
Sample Iterator type.
Type
Explicit query of a kernel's type. See Type Queries for more info.
bool empty() const
Returns true if empty.
nuklei_trsl::reorder_iterator< const_iterator > const_sort_iterator
Sort Iterator type.
std::vector< Vector3 > get3DPointCloud() const
Returns the locations of the contained kernels in an std::vector.
void add(const kernel::base &f)
Adds a copy of f.
nuklei_trsl::ppfilter_iterator< is_picked, iterator > sample_iterator
Sample Iterator type.
Container::const_iterator const_iterator
KernelCollection iterator.
double weight_t
Type for particle weights.
kernel::base::ptr moments() const
Returns a kernel holding the mean and standard deviation in position and orientation of the data.
nuklei_trsl::is_picked_systematic< kernel::base, weight_t, kernel::base::WeightAccessor > is_picked
Used internally.
This class acts as a vector-like container for kernels. It also provides methods related to kernel de...
Vector3 loc_
Kernel location.
sort_iterator sortBegin(size_t sortSize)
Returns an iterator that iterates through the sortSize kernels of highest weight, in order of decreas...
void uniformizeWeights()
Sets all weights to , where is the total weight of the collection.
unsigned int bitfield_t
Type for bitfield.
void setKernelLocH(coord_t h)
Sets the location bandwidth of all kernels.
weight_t totalWeight() const
Returns the sum of kernel weights.
void setKernelOriH(coord_t h)
Sets the orientation bandwidth of all kernels.
#define NUKLEI_ASSERT(expression)
Throws an Error if expression is not true.
Polymorphic kernel class.
NUKLEI_UNIQUE_PTR< kernel::base > ptr
NUKLEI_UNIQUE_PTR for kernel::base.
double coord_t
Type for point coordinates.
Container::iterator end()
Returns an iterator pointing to the last kernel.
KernelCollection sample(int sampleSize) const
Returns sampleSize samples from the density modeled by *this.
const kernel::base & randomKernel() const
Returns a kernel from the collection.
kernel::base::ptr mean() const
Returns a kernel holding the mean position and orientation of the data.
void transformWith(const kernel::se3 &t)
Transforms the data with t.
Container::iterator begin()
Returns an iterator pointing to the first kernel.
void replace(const size_t idx, const kernel::base &k)
Replaces the idx'th kernel with a copy of k.
sample_iterator sampleBegin(size_t sampleSize)
Returns an iterator that iterates through sampleSize kernels selected randomly.
void normalizeWeights()
Divides all weights by the total weight.
void resetWithSampleOf(const KernelCollection &kc, int sampleSize)
Deprecated. Use sample() instead.
Container::size_type size() const
Returns the number of kernels.
virtual Type polyType() const =0
Get the "kernel type", i.e., its domain of definition.
nuklei_trsl::reorder_iterator< iterator > sort_iterator
Sort Iterator type.
void computeKernelStatistics()
Computes the sum of all kernel weights (total weight), and the maximum kernel cut point.
Container::iterator iterator
KernelCollection iterator.
void clear()
Resets the class to its initial state.
virtual base::ptr clone() const =0
Clone the kernel.
#define NUKLEI_THROW(x)
Throws an Error.