36 #ifndef OPENVDB_TOOLS_STATISTICS_HAS_BEEN_INCLUDED 37 #define OPENVDB_TOOLS_STATISTICS_HAS_BEEN_INCLUDED 59 template<
typename IterT>
60 inline math::Histogram
61 histogram(
const IterT& iter,
double minVal,
double maxVal,
62 size_t numBins = 10,
bool threaded =
true);
70 template<
typename IterT>
72 extrema(
const IterT& iter,
bool threaded =
true);
80 template<
typename IterT>
82 statistics(
const IterT& iter,
bool threaded =
true);
113 template<
typename IterT,
typename ValueOp>
115 extrema(
const IterT& iter,
const ValueOp& op,
bool threaded);
146 template<
typename IterT,
typename ValueOp>
148 statistics(
const IterT& iter,
const ValueOp& op,
bool threaded);
213 template<
typename OperatorT,
typename IterT>
215 opStatistics(
const IterT& iter,
const OperatorT& op = OperatorT(),
bool threaded =
true);
218 template<
typename OperatorT,
typename IterT>
220 opExtrema(
const IterT& iter,
const OperatorT& op = OperatorT(),
bool threaded =
true);
225 namespace stats_internal {
230 template<
typename IterT,
typename AuxT =
void>
235 template<
typename TreeT,
typename ValueIterT>
236 struct IterTraits<tree::TreeValueIteratorBase<TreeT, ValueIterT> > {
247 static inline double get(
const T& val) {
return double(val); }
252 static inline double get(
const T& val) {
return val.length(); }
259 template<
typename IterT,
typename StatsT>
265 inline void operator()(
const IterT& iter, StatsT& stats)
const {
266 if (iter.isVoxelValue()) stats.add(ImplT::get(*iter));
267 else stats.add(ImplT::get(*iter), iter.getVoxelCount());
273 template<
typename IterT,
typename ValueOp,
typename StatsT>
279 inline void operator()(
const IterT& iter) { getValue(iter, stats); }
291 template<
typename IterT,
typename ValueOp>
294 HistOp(
const ValueOp& op,
double vmin,
double vmax,
size_t bins):
295 hist(vmin, vmax, bins), getValue(op)
299 inline void operator()(
const IterT& iter) { getValue(iter, hist); }
312 template<
typename IterT,
typename OpT,
typename StatsT>
315 typedef typename IterT::TreeT
TreeT;
316 typedef typename TreeT::ValueType
ValueT;
324 template<
typename TreeT>
330 MathOp(
const IterT& iter,
const OpT& op):
331 mAcc(*THROW_IF_NULL(iter.getTree())), mOp(op)
337 if (it.isVoxelValue()) {
339 mStats.add(mOp.result(mAcc, it.getCoord()));
346 CoordBBox bbox = it.getBoundingBox();
348 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
349 for (x = bbox.min().x(); x <= bbox.max().x(); ++x) {
350 for (y = bbox.min().y(); y <= bbox.max().y(); ++y) {
351 for (z = bbox.min().z(); z <= bbox.max().z(); ++z) {
352 mStats.add(mOp.result(mAcc, it.getCoord()));
366 template<
typename IterT>
368 histogram(
const IterT& iter,
double vmin,
double vmax,
size_t numBins,
bool threaded)
377 template<
typename IterT>
382 return extrema(iter, valOp, threaded);
385 template<
typename IterT>
393 template<
typename IterT,
typename ValueOp>
395 extrema(
const IterT& iter,
const ValueOp& valOp,
bool threaded)
402 template<
typename IterT,
typename ValueOp>
404 statistics(
const IterT& iter,
const ValueOp& valOp,
bool threaded)
412 template<
typename OperatorT,
typename IterT>
414 opExtrema(
const IterT& iter,
const OperatorT& op,
bool threaded)
421 template<
typename OperatorT,
typename IterT>
434 #endif // OPENVDB_TOOLS_STATISTICS_HAS_BEEN_INCLUDED
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
Classes to compute statistics and histograms.
#define OPENVDB_VERSION_NAME
Definition: version.h:43
This class computes the minimum and maximum values of a population of floating-point values...
Definition: Stats.h:105
Definition: Exceptions.h:39
This class computes statistics (minimum value, maximum value, mean, variance and standard deviation) ...
Definition: Stats.h:195
This class computes a histogram, with a fixed interval width, of a population of floating-point value...
Definition: Stats.h:292
Definition: Exceptions.h:92
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:664