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);
71 template<
typename IterT>
73 statistics(
const IterT& iter,
bool threaded =
true);
105 template<
typename IterT,
typename ValueOp>
107 statistics(
const IterT& iter,
const ValueOp& op,
bool threaded);
172 template<
typename OperatorT,
typename IterT>
174 opStatistics(
const IterT& iter,
const OperatorT& op = OperatorT(),
bool threaded =
true);
180 namespace stats_internal {
185 template<
typename IterT,
typename AuxT =
void>
190 template<
typename TreeT,
typename ValueIterT>
191 struct IterTraits<tree::TreeValueIteratorBase<TreeT, ValueIterT> > {
202 static inline double get(
const T& val) {
return double(val); }
207 static inline double get(
const T& val) {
return val.length(); }
214 template<
typename IterT,
typename StatsT>
220 inline void operator()(
const IterT& iter, StatsT& stats)
const {
221 if (iter.isVoxelValue()) stats.add(ImplT::get(*iter));
222 else stats.add(ImplT::get(*iter), iter.getVoxelCount());
229 template<
typename IterT,
typename ValueOp>
235 inline void operator()(
const IterT& iter) { getValue(iter, stats); }
247 template<
typename IterT,
typename ValueOp>
250 HistOp(
const ValueOp& op,
double vmin,
double vmax,
size_t bins):
251 hist(vmin, vmax, bins), getValue(op)
255 inline void operator()(
const IterT& iter) { getValue(iter, hist); }
268 template<
typename IterT,
typename OpT>
271 typedef typename IterT::TreeT
TreeT;
272 typedef typename TreeT::ValueType
ValueT;
280 template<
typename TreeT>
286 MathOp(
const IterT& iter,
const OpT& op):
287 mAcc(*THROW_IF_NULL(iter.getTree())), mOp(op)
293 if (it.isVoxelValue()) {
295 mStats.add(mOp.result(
mAcc, it.getCoord()));
302 CoordBBox bbox = it.getBoundingBox();
304 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
305 for (x = bbox.min().x(); x <= bbox.max().x(); ++x) {
306 for (y = bbox.min().y(); y <= bbox.max().y(); ++y) {
307 for (z = bbox.min().z(); z <= bbox.max().z(); ++z) {
308 mStats.add(mOp.result(
mAcc, it.getCoord()));
322 template<
typename IterT>
324 histogram(
const IterT& iter,
double vmin,
double vmax,
size_t numBins,
bool threaded)
334 template<
typename IterT>
343 template<
typename IterT,
typename ValueOp>
345 statistics(
const IterT& iter,
const ValueOp& valOp,
bool threaded)
353 template<
typename OperatorT,
typename IterT>
366 #endif // OPENVDB_TOOLS_STATISTICS_HAS_BEEN_INCLUDED
This class computes a histogram, with a fixed interval width, of a population of floating-point value...
Definition: Stats.h:165
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
Definition: Exceptions.h:88
This class computes statistics (minimum value, maximum value, mean, variance and standard deviation) ...
Definition: Stats.h:59
AccessorT mAcc
Definition: GridOperators.h:383
#define OPENVDB_VERSION_NAME
Definition: version.h:45
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:663