36 #ifndef OPENVDB_TOOLS_STATISTICS_HAS_BEEN_INCLUDED 37 #define OPENVDB_TOOLS_STATISTICS_HAS_BEEN_INCLUDED 39 #include <openvdb/Types.h> 40 #include <openvdb/Exceptions.h> 41 #include <openvdb/math/Stats.h> 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()));
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 Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
Int32 x() const
Definition: Coord.h:157
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
const Coord & min() const
Definition: Coord.h:337
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
This class computes the minimum and maximum values of a population of floating-point values...
Definition: Stats.h:119
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
Definition: Exceptions.h:92
Int32 z() const
Definition: Coord.h:159
Definition: Exceptions.h:40
This class computes statistics (minimum value, maximum value, mean, variance and standard deviation) ...
Definition: Stats.h:209
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:671
Int32 y() const
Definition: Coord.h:158
This class computes a histogram, with a fixed interval width, of a population of floating-point value...
Definition: Stats.h:306
const Coord & max() const
Definition: Coord.h:338
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188