FieldGroup.h
Go to the documentation of this file.
//----------------------------------------------------------------------------//
#ifndef __F3DUTIL_FIELDGROUP_H__
#define __F3DUTIL_FIELDGROUP_H__
//------------------------------------------------------------------------------
// Boost includes
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/include/for_each.hpp>
#include <boost/fusion/include/as_vector.hpp>
// Field3D includes
#include "DenseField.h"
#include "Field3DFile.h"
#include "FieldInterp.h"
#include "InitIO.h"
#include "MIPField.h"
#include "MIPUtil.h"
#include "SparseField.h"
#include "MinMaxUtil.h"
// Project includes
#include "FieldWrapper.h"
//----------------------------------------------------------------------------//
#include "ns.h"
FIELD3D_NAMESPACE_OPEN
//------------------------------------------------------------------------------
// MPL stuff
//------------------------------------------------------------------------------
namespace mpl = boost::mpl;
namespace ph = mpl::placeholders;
namespace fusion = boost::fusion;
namespace fusion_ro = boost::fusion::result_of;
typedef mpl::vector<Field3D::half, float, double> ScalarTypes;
typedef mpl::vector<Field3D::V3h, Field3D::V3f, Field3D::V3d> VectorTypes;
//------------------------------------------------------------------------------
// Detail namespace
//------------------------------------------------------------------------------
namespace detail {
//------------------------------------------------------------------------------
static const char* k_minSuffix = "_min";
static const char* k_maxSuffix = "_max";
//------------------------------------------------------------------------------
template <typename T>
struct MakeDense
{
typedef typename FieldWrapper<Field3D::DenseField<T> >::Vec type;
};
//------------------------------------------------------------------------------
template <typename T>
struct MakeSparse
{
typedef typename FieldWrapper<Field3D::SparseField<T> >::Vec type;
};
//------------------------------------------------------------------------------
template <typename T>
struct MakeMIPDense
{
// typedef typename MIPFieldWrapper<Field3D::MIPDenseField<T> >::Vec type;
typedef typename
MIPFieldWrapper<Field3D::MIPField<Field3D::DenseField<T> > >::Vec type;
};
//------------------------------------------------------------------------------
template <typename T>
struct MakeMIPSparse
{
// typedef typename MIPFieldWrapper<Field3D::MIPSparseField<T> >::Vec type;
typedef typename
MIPFieldWrapper<Field3D::MIPField<Field3D::SparseField<T> > >::Vec type;
};
//------------------------------------------------------------------------------
template <int Dims_T>
struct LoadFields;
struct LoadFieldsParams
{
LoadFieldsParams(Field3D::Field3DInputFile &a_in,
const std::string &a_name,
const std::string &a_attribute,
Field3D::FieldRes::Vec &a_results,
Field3D::FieldRes::Vec &a_minResults,
Field3D::FieldRes::Vec &a_maxResults)
: in(a_in),
name(a_name),
attribute(a_attribute),
results(a_results),
minResults(a_minResults),
maxResults(a_maxResults)
{ }
Field3D::Field3DInputFile &in;
const std::string &name;
const std::string &attribute;
Field3D::FieldRes::Vec &results;
Field3D::FieldRes::Vec &minResults;
Field3D::FieldRes::Vec &maxResults;
};
template <>
struct LoadFields<1>
{
// Ctor
LoadFields(LoadFieldsParams &params)
: m_p(params)
{ }
// Functor
template <typename T>
void operator()(T)
{
// Load all fields of type T
typename Field3D::Field<T>::Vec fields =
m_p.in.readScalarLayers<T>(m_p.name, m_p.attribute);
// Add the fields to the result
BOOST_FOREACH (const typename Field3D::Field<T>::Ptr &ptr, fields) {
m_p.results.push_back(ptr);
}
// Load 'min' fields
typename Field3D::Field<T>::Vec minFields =
m_p.in.readScalarLayers<T>(m_p.name, m_p.attribute + k_minSuffix);
// Add the fields to the result
BOOST_FOREACH (const typename Field3D::Field<T>::Ptr &ptr, minFields) {
m_p.minResults.push_back(ptr);
}
// Load 'max' fields
typename Field3D::Field<T>::Vec maxFields =
m_p.in.readScalarLayers<T>(m_p.name, m_p.attribute + k_maxSuffix);
// Add the fields to the result
BOOST_FOREACH (const typename Field3D::Field<T>::Ptr &ptr, maxFields) {
m_p.maxResults.push_back(ptr);
}
}
// Data members
LoadFieldsParams &m_p;
};
template <>
struct LoadFields<3>
{
// Ctor
LoadFields(LoadFieldsParams &params)
: m_p(params)
{ }
// Functor
template <typename Vec_T>
void operator()(Vec_T)
{
typedef typename Vec_T::BaseType T;
// Load all fields of type T
typename Field3D::Field<Vec_T>::Vec fields =
m_p.in.readVectorLayers<T>(m_p.name, m_p.attribute);
// Add the fields to the result
BOOST_FOREACH (const typename Field3D::Field<Vec_T>::Ptr &ptr, fields) {
m_p.results.push_back(ptr);
}
// Load 'min' fields
typename Field3D::Field<Vec_T>::Vec minFields =
m_p.in.readVectorLayers<T>(m_p.name, m_p.attribute + k_minSuffix);
// Add the fields to the result
BOOST_FOREACH (const typename Field3D::Field<Vec_T>::Ptr &ptr, minFields) {
m_p.minResults.push_back(ptr);
}
// Load 'max' fields
typename Field3D::Field<Vec_T>::Vec maxFields =
m_p.in.readVectorLayers<T>(m_p.name, m_p.attribute + k_maxSuffix);
// Add the fields to the result
BOOST_FOREACH (const typename Field3D::Field<Vec_T>::Ptr &ptr, maxFields) {
m_p.maxResults.push_back(ptr);
}
}
// Data members
LoadFieldsParams &m_p;
};
//----------------------------------------------------------------------------//
inline std::vector<V3d>
cornerPoints(const Box3d &box)
{
std::vector<V3d> result;
result.push_back(V3d(box.min.x, box.min.y, box.min.z));
result.push_back(V3d(box.max.x, box.min.y, box.min.z));
result.push_back(V3d(box.min.x, box.max.y, box.min.z));
result.push_back(V3d(box.max.x, box.max.y, box.min.z));
result.push_back(V3d(box.min.x, box.min.y, box.max.z));
result.push_back(V3d(box.max.x, box.min.y, box.max.z));
result.push_back(V3d(box.min.x, box.max.y, box.max.z));
result.push_back(V3d(box.max.x, box.max.y, box.max.z));
return result;
}
//----------------------------------------------------------------------------//
inline std::vector<V3d>
unitCornerPoints()
{
std::vector<V3d> result;
result.push_back(V3d(0.0, 0.0, 0.0));
result.push_back(V3d(1.0, 0.0, 0.0));
result.push_back(V3d(0.0, 1.0, 0.0));
result.push_back(V3d(1.0, 1.0, 0.0));
result.push_back(V3d(0.0, 0.0, 1.0));
result.push_back(V3d(1.0, 0.0, 1.0));
result.push_back(V3d(0.0, 1.0, 1.0));
result.push_back(V3d(1.0, 1.0, 1.0));
return result;
}
//------------------------------------------------------------------------------
inline bool
intersect(const Ray3d &ray, const Box3d &box, double &outT0, double &outT1)
{
double tNear = -std::numeric_limits<double>::max();
double tFar = std::numeric_limits<double>::max();
const double epsilon = std::numeric_limits<double>::epsilon() * 10.0;
for (size_t dim = 0; dim < 3; ++dim) {
double t0, t1;
if (std::abs(ray.dir[dim]) < epsilon) {
// Ray is parallel, check if inside slab
if (ray.pos[dim] < box.min[dim] || ray.pos[dim] > box.max[dim]) {
return false;
}
}
t0 = (box.min[dim] - ray.pos[dim]) / ray.dir[dim];
t1 = (box.max[dim] - ray.pos[dim]) / ray.dir[dim];
if (t0 > t1) {
std::swap(t0, t1);
}
tNear = std::max(tNear, t0);
tFar = std::min(tFar, t1);
if (tNear > tFar) {
return false;
}
if (tFar < 0.0) {
return false;
}
}
outT0 = tNear;
outT1 = tFar;
return true;
}
//------------------------------------------------------------------------------
} // namespace detail
//------------------------------------------------------------------------------
// FieldGroup
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup
{
// MPL Typedefs --------------------------------------------------------------
// The list of basic types to support.
typedef BaseTypeList_T MPLBaseTypes;
// Instantiate FieldWrapper<Field_T> for each family with each basic type
typedef typename mpl::transform<
MPLBaseTypes,
detail::MakeDense<ph::_1> >::type MPLDenseTypes;
typedef typename mpl::transform<
MPLBaseTypes,
detail::MakeSparse<ph::_1> >::type MPLSparseTypes;
typedef typename mpl::transform<
MPLBaseTypes,
detail::MakeMIPDense<ph::_1> >::type MPLMIPDenseTypes;
typedef typename mpl::transform<
MPLBaseTypes,
detail::MakeMIPSparse<ph::_1> >::type MPLMIPSparseTypes;
// Map MPL types to boost fusion types
typedef typename fusion_ro::as_vector<MPLDenseTypes>::type DenseTypes;
typedef typename fusion_ro::as_vector<MPLSparseTypes>::type SparseTypes;
typedef typename fusion_ro::as_vector<MPLMIPDenseTypes>::type MIPDenseTypes;
typedef typename fusion_ro::as_vector<MPLMIPSparseTypes>::type MIPSparseTypes;
// Enums ---------------------------------------------------------------------
enum CompositeOp
{
Add = 0,
Avg
};
// Constants -----------------------------------------------------------------
static const int k_missingFile = -1;
// Ctors ---------------------------------------------------------------------
FieldGroup();
FieldGroup(const Field3D::FieldRes::Vec &fields);
// Main methods --------------------------------------------------------------
void setOsToWs(const Imath::M44d &osToWs);
virtual void setWsBoundsOptimization(const bool doWsBoundsOptimization);
void setValueRemapOp(ValueRemapOp::Ptr op);
virtual void setup(const Field3D::FieldRes::Ptr field);
virtual void setup(const Field3D::FieldRes::Vec &fields);
virtual void setup(const Field3D::FieldRes::Vec &fields,
const Field3D::FieldRes::Vec &minFields,
const Field3D::FieldRes::Vec &maxFields);
int load(const std::string &filename, const std::string &attribute);
void makeMinMax(const float resMult);
virtual size_t size() const;
size_t sizeMIP() const;
void sample(const V3d &wsP, const float wsSpotSize, const float time,
float *result, const CompositeOp compOp = Add);
void sample(const V3d &vsP, float *result, bool isVs) const;
void sampleMIP(const V3d &vsP, const float wsSpotSize,
float *result, bool isVs) const;
void sampleMultiple(const size_t n, const float *wsP, float *result) const;
void sampleMIPMultiple(const size_t n, const float *wsP, const float *wsSpotSize,
float *result) const;
Box3d wsBounds() const;
bool intersects(const V3d &wsP) const;
bool getIntersections(const Ray3d &ray, IntervalVec &intervals) const;
void getMinMax(const Box3d &wsBounds, float *min, float *max) const;
bool hasPrefiltMinMax() const
{ return m_hasPrefiltMinMax; }
long long int memSize() const;
const FieldRes::Vec& fields() const
{ return m_allFields; }
protected:
// Utility methods -----------------------------------------------------------
void setupMinMax(const FieldRes::Vec &minFields,
const FieldRes::Vec &maxFields);
// Data members --------------------------------------------------------------
DenseTypes m_dense;
SparseTypes m_sparse;
MIPDenseTypes m_mipDense, m_mipDenseMin, m_mipDenseMax;
MIPSparseTypes m_mipSparse, m_mipSparseMin, m_mipSparseMax;
bool m_hasPrefiltMinMax;
M44d m_osToWs;
bool m_doWsBoundsOptimization;
ValueRemapOp::Ptr m_valueRemapOp;
FieldRes::Vec m_allFields;
FieldRes::Vec m_auxFields;
// Functors ------------------------------------------------------------------
struct GrabFields;
struct DoWsBoundsOptimization;
struct CountFields;
struct MakeMinMax;
struct MakeMinMaxMIP;
struct Sample;
struct SampleMIP;
struct SampleMultiple;
struct SampleMIPMultiple;
struct GetWsBounds;
struct GetIntersections;
struct GetMinMax;
struct GetMinMaxMIP;
struct GetMinMaxPrefilt;
struct PointIsect;
struct MemSize;
};
//------------------------------------------------------------------------------
typedef FieldGroup<ScalarTypes, 1> ScalarFieldGroup;
typedef FieldGroup<VectorTypes, 3> VectorFieldGroup;
//------------------------------------------------------------------------------
// Template implementations
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
FieldGroup<BaseTypeList_T, Dims_T>::FieldGroup()
: m_hasPrefiltMinMax(false), m_doWsBoundsOptimization(false)
{ }
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
FieldGroup<BaseTypeList_T, Dims_T>::FieldGroup
(const Field3D::FieldRes::Vec &fields)
: m_hasPrefiltMinMax(false), m_doWsBoundsOptimization(false)
{
// Perform setup
setup(fields);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setOsToWs(const Imath::M44d &osToWs)
{
m_osToWs = osToWs;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setWsBoundsOptimization(const bool doWsBoundsOptimization)
{
m_doWsBoundsOptimization = doWsBoundsOptimization;
if (doWsBoundsOptimization) {
DoWsBoundsOptimization op(m_doWsBoundsOptimization);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
}
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setValueRemapOp(ValueRemapOp::Ptr op)
{
m_valueRemapOp = op;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setup(const Field3D::FieldRes::Ptr field)
{
FieldRes::Vec fields, minFields, maxFields;
fields.push_back(field);
// Perform setup
setup(fields, minFields, maxFields);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setup(const Field3D::FieldRes::Vec &fields)
{
FieldRes::Vec minFields, maxFields;
// Perform setup
setup(fields, minFields, maxFields);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setup
(const Field3D::FieldRes::Vec &fields,
const Field3D::FieldRes::Vec &minFields,
const Field3D::FieldRes::Vec &maxFields)
{
// Record fields in m_allFields
m_allFields = fields;
// Pick out primary fields
for (size_t i = 0, end = fields.size(); i < end; ++i) {
GrabFields op(fields[i], m_osToWs, m_valueRemapOp, m_doWsBoundsOptimization);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
}
// Pick out min/max fields
setupMinMax(minFields, maxFields);
}
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::setupMinMax
(const Field3D::FieldRes::Vec &minFields,
const Field3D::FieldRes::Vec &maxFields)
{
// Record minFields and maxFields as auxiliary fields
m_auxFields.insert(m_auxFields.end(), minFields.begin(), minFields.end());
m_auxFields.insert(m_auxFields.end(), maxFields.begin(), maxFields.end());
// Pick out min fields
for (size_t i = 0, end = minFields.size(); i < end; ++i) {
GrabFields op(minFields[i], m_osToWs, m_valueRemapOp, m_doWsBoundsOptimization);
fusion::for_each(m_mipDenseMin, op);
fusion::for_each(m_mipSparseMin, op);
}
// Pick out max fields
for (size_t i = 0, end = maxFields.size(); i < end; ++i) {
GrabFields op(maxFields[i], m_osToWs, m_valueRemapOp, m_doWsBoundsOptimization);
fusion::for_each(m_mipDenseMax, op);
fusion::for_each(m_mipSparseMax, op);
}
// Check if we have pre-filtered fields
CountFields countMinOp, countMaxOp;
fusion::for_each(m_mipDenseMin, countMinOp);
fusion::for_each(m_mipDenseMax, countMaxOp);
fusion::for_each(m_mipSparseMin, countMinOp);
fusion::for_each(m_mipSparseMax, countMaxOp);
if (countMinOp.count > 0 && countMaxOp.count > 0) {
m_hasPrefiltMinMax = true;
}
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
int
FieldGroup<BaseTypeList_T, Dims_T>::load
(const std::string &filename, const std::string &attribute)
{
using namespace Field3D;
// Storage for the primary fields
FieldRes::Vec results;
// Storage for the auxiliary fields
FieldRes::Vec minResults, maxResults;
// Track number of fields in group before loading.
const size_t sizeBeforeLoading = size();
// Open each file ---
std::vector<std::string> filenames;
filenames.push_back(filename);
BOOST_FOREACH (const std::string fn, filenames) {
Field3DInputFile in;
if (!in.open(fn)) {
return k_missingFile;
}
// Use partition names to determine if fields should be loaded
std::vector<std::string> names;
in.getPartitionNames(names);
BOOST_FOREACH (const std::string &name, names) {
detail::LoadFieldsParams params(in, name, attribute, results,
minResults, maxResults);
detail::LoadFields<Dims_T> op(params);
mpl::for_each<BaseTypeList_T>(op);
}
}
// Set up from fields
setup(results, minResults, maxResults);
// Done. Return the number of fields that were loaded.
return size() - sizeBeforeLoading;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::makeMinMax
(const float resMult)
{
// Storage for the auxiliary fields
FieldRes::Vec minFields, maxFields;
MakeMinMax op(minFields, maxFields, resMult);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
MakeMinMaxMIP opMIP(minFields, maxFields, resMult);
fusion::for_each(m_mipDense, opMIP);
fusion::for_each(m_mipSparse, opMIP);
setupMinMax(minFields, maxFields);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
size_t
FieldGroup<BaseTypeList_T, Dims_T>::size() const
{
CountFields op;
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
return op.count;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
size_t
FieldGroup<BaseTypeList_T, Dims_T>::sizeMIP() const
{
CountFields op;
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
return op.count;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::sample(const V3d &wsP,
const float wsSpotSize,
const float /* time */,
float *result,
const CompositeOp compOp)
{
size_t numHits = 0;
// Handle ordinary fields
Sample op(wsP, result, numHits);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
// Handle MIP fields
SampleMIP mipOp(wsP, wsSpotSize, result, numHits);
fusion::for_each(m_mipDense, mipOp);
fusion::for_each(m_mipSparse, mipOp);
// Check composite op
if (compOp == Add) {
// Nothing
} else {
if (numHits > 1) {
for (size_t i = 0; i < Dims_T; ++i) {
result[i] /= static_cast<float>(numHits);
}
}
}
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::sample(const V3d &vsP,
float *result,
bool /* isVs */) const
{
size_t numHits = 0;
Sample op(vsP, result, numHits);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::sampleMultiple(const size_t n,
const float *wsP,
float *result) const
{
size_t numHits = 0;
SampleMultiple op(n, wsP, result, numHits);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::sampleMIP(const V3d &vsP,
const float wsSpotSize,
float *result,
bool /* isVs */) const
{
size_t numHits = 0;
SampleMIP op(vsP, wsSpotSize, result, numHits);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::sampleMIPMultiple(const size_t n,
const float *wsP,
const float *wsSpotSize,
float *result) const
{
size_t numHits = 0;
SampleMIPMultiple op(n, wsP, wsSpotSize, result, numHits);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
Box3d
FieldGroup<BaseTypeList_T, Dims_T>::wsBounds() const
{
Box3d wsBounds;
GetWsBounds op(wsBounds);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
return wsBounds;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
bool
FieldGroup<BaseTypeList_T, Dims_T>::intersects(const V3d &wsP) const
{
PointIsect op(wsP);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
return op.result();
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
bool
FieldGroup<BaseTypeList_T, Dims_T>::getIntersections
(const Ray3d &ray, IntervalVec &intervals) const
{
GetIntersections op(ray, intervals);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
return intervals.size() > 0;
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
void
FieldGroup<BaseTypeList_T, Dims_T>::getMinMax(const Box3d &wsBounds,
float *min,
float *max) const
{
if (m_hasPrefiltMinMax) {
// Pre-filtered types
GetMinMaxPrefilt opMin(wsBounds, min, GetMinMaxPrefilt::Min);
GetMinMaxPrefilt opMax(wsBounds, max, GetMinMaxPrefilt::Max);
fusion::for_each(m_mipDenseMin, opMin);
fusion::for_each(m_mipSparseMin, opMin);
fusion::for_each(m_mipDenseMax, opMax);
fusion::for_each(m_mipSparseMax, opMax);
} else {
// Non-prefiltered types
GetMinMax op(wsBounds, min, max);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
// Non-prefiltered MIP types
GetMinMaxMIP opMIP(wsBounds, min, max);
fusion::for_each(m_mipDense, opMIP);
fusion::for_each(m_mipSparse, opMIP);
}
}
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
long long int
FieldGroup<BaseTypeList_T, Dims_T>::memSize() const
{
long long int result = 0;
MemSize op(result);
fusion::for_each(m_dense, op);
fusion::for_each(m_sparse, op);
fusion::for_each(m_mipDense, op);
fusion::for_each(m_mipSparse, op);
return result;
}
//------------------------------------------------------------------------------
// Functor implementations
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::GrabFields
{
GrabFields(Field3D::FieldRes::Ptr f,
const M44d &osToWs,
ValueRemapOp::Ptr op,
const bool doWsBoundsOptimization)
: m_field(f), m_osToWs(osToWs), m_op(op),
m_doWsBoundsOptimization(doWsBoundsOptimization)
{ }
template <typename WrapperVec_T>
void operator()(WrapperVec_T &vec) const
{
// Typedefs
typedef typename WrapperVec_T::value_type Wrapper_T;
typedef typename Wrapper_T::field_type Field_T;
typedef typename Field_T::Ptr FieldPtr;
// Grab field if type matches
if (FieldPtr f =
Field3D::field_dynamic_cast<Field_T>(m_field)) {
// Add to FieldWrapper vector
vec.push_back(f);
// Grab just-inserted entry
Wrapper_T &entry = vec.back();
// Set up transform
M44d id;
if (m_osToWs != id) {
entry.setOsToWs(m_osToWs);
}
// Set toggle to use world axis aligned bounding boxes in
// lookups
if (m_doWsBoundsOptimization) {
entry.setWsBoundsOptimization(m_doWsBoundsOptimization);
}
// Set up value remap op
if (m_op) {
entry.setValueRemapOp(m_op);
}
}
}
private:
Field3D::FieldRes::Ptr m_field;
M44d m_osToWs;
ValueRemapOp::Ptr m_op;
bool m_doWsBoundsOptimization;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::DoWsBoundsOptimization
{
DoWsBoundsOptimization(const bool doWsBoundsOptimization)
: m_doWsBoundsOptimization(doWsBoundsOptimization)
{ }
template <typename WrapperVec_T>
void operator()(WrapperVec_T &vec) const
{
for (size_t i = 0, end = vec.size(); i < end; ++i) {
vec[i].setWsBoundsOptimization(m_doWsBoundsOptimization);
}
}
bool m_doWsBoundsOptimization;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::CountFields
{
CountFields()
: count(0)
{ }
template <typename T>
void operator()(const T &vec) const
{ count += vec.size(); }
// Data members
mutable int count;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::MakeMinMax
{
MakeMinMax(Field3D::FieldRes::Vec &minFields,
Field3D::FieldRes::Vec &maxFields,
const float resMult)
: m_minFields(minFields),
m_maxFields(maxFields),
m_resMult(resMult),
m_numThreads(Field3D::numIOThreads())
{ }
template <typename WrapperVec_T>
void operator()(const WrapperVec_T &vec)
{
// Typedefs
typedef typename WrapperVec_T::value_type Wrapper_T;
typedef typename Wrapper_T::field_type Field_T;
typedef typename Field3D::MIPField<Field_T> MIPField_T;
typedef typename Field_T::value_type Value_T;
typedef typename Field3D::Field<Value_T>::Ptr FieldPtr;
std::pair<FieldPtr, FieldPtr> result;
for (size_t i = 0, end = vec.size(); i < end; ++i) {
const Field_T &f = *(vec[i].field);
result = Field3D::makeMinMax<MIPField_T>(f, m_resMult, m_numThreads);
m_minFields.push_back(result.first);
m_maxFields.push_back(result.second);
}
}
// Data members
Field3D::FieldRes::Vec &m_minFields;
Field3D::FieldRes::Vec &m_maxFields;
const float m_resMult;
const size_t m_numThreads;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::MakeMinMaxMIP
{
MakeMinMaxMIP(Field3D::FieldRes::Vec &minFields,
Field3D::FieldRes::Vec &maxFields,
const float resMult)
: m_minFields(minFields),
m_maxFields(maxFields),
m_resMult(resMult),
m_numThreads(Field3D::numIOThreads())
{ }
template <typename WrapperVec_T>
void operator()(const WrapperVec_T &vec)
{
// Typedefs
typedef typename WrapperVec_T::value_type Wrapper_T;
typedef typename Wrapper_T::field_type MIPField_T;
typedef typename MIPField_T::NestedType Field_T;
typedef typename Field_T::value_type Value_T;
typedef typename Field3D::Field<Value_T>::Ptr FieldPtr;
std::pair<FieldPtr, FieldPtr> result;
for (size_t i = 0, end = vec.size(); i < end; ++i) {
const Field_T &f = *(vec[i].field->concreteMipLevel(0));
result = Field3D::makeMinMax<MIPField_T>(f, m_resMult, m_numThreads);
m_minFields.push_back(result.first);
m_maxFields.push_back(result.second);
}
}
// Data members
Field3D::FieldRes::Vec &m_minFields;
Field3D::FieldRes::Vec &m_maxFields;
const float m_resMult;
const size_t m_numThreads;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::Sample
{
Sample(const V3d &p, float *result, size_t &numHits)
: m_p(p), m_result(result), m_numHits(numHits)
{ }
template <typename T>
void operator()(const T &vec) const
{
FieldSampler<T, Dims_T>::sample(vec, m_p, m_result, m_numHits);
}
// Data members
const V3d &m_p;
float *m_result;
size_t &m_numHits;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::SampleMIP
{
SampleMIP(const V3d &p, const float wsSpotSize, float *result,
size_t &numHits)
: m_p(p), m_wsSpotSize(wsSpotSize), m_result(result), m_numHits(numHits)
{ }
template <typename T>
void operator()(const T &vec) const
{
FieldSampler<T, Dims_T>::sampleMIP(vec, m_p, m_wsSpotSize, m_result,
m_numHits);
}
// Data members
const V3d &m_p;
const float m_wsSpotSize;
float *m_result;
size_t &m_numHits;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::SampleMultiple
{
SampleMultiple(const size_t n, const float *p, float *result,
size_t *numHits)
: m_n(n), m_p(p), m_result(result), m_numHits(numHits)
{ }
template <typename T>
void operator()(const T &vec) const
{
FieldSampler<T, Dims_T>::sampleMultiple(vec, m_n, m_p, m_result, m_numHits);
}
// Data members
const int m_n;
const float *m_p;
float *m_result;
size_t *m_numHits;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::SampleMIPMultiple
{
SampleMIPMultiple(const size_t n, const float *p, const float *wsSpotSize,
float *result, size_t *numHits)
: m_n(n), m_p(p), m_wsSpotSize(wsSpotSize), m_result(result),
m_numHits(numHits)
{ }
template <typename T>
void operator()(const T &vec) const
{
FieldSampler<T, Dims_T>::sampleMIPMultiple(vec, m_n, m_p, m_wsSpotSize,
m_result, m_numHits);
}
// Data members
const int m_n;
const float *m_p;
const float *m_wsSpotSize;
float *m_result;
size_t *m_numHits;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::GetWsBounds
{
GetWsBounds(Box3d &wsBounds)
: m_wsBounds(wsBounds)
{ }
template <typename T>
void operator()(const T &vec) const
{
for (size_t field = 0, end = vec.size(); field < end; ++field) {
// Pointer to mapping
const FieldMapping* mapping = vec[field].mapping;
if (mapping) {
// Corner vertices in local space
std::vector<V3d> lsP = detail::unitCornerPoints();
// Transform to world space and pad resulting bounds
for (size_t i = 0; i < 8; ++i) {
V3d wsP;
if (vec[field].doOsToWs) {
V3d osP;
mapping->localToWorld(lsP[i], osP);
vec[field].osToWs.multVecMatrix(osP, wsP);
} else {
mapping->localToWorld(lsP[i], wsP);
}
m_wsBounds.extendBy(wsP);
}
}
}
}
// Data members
Box3d &m_wsBounds;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::GetIntersections
{
GetIntersections(const Ray3d &wsRay, IntervalVec &intervals)
: m_wsRay(wsRay), m_intervals(intervals)
{
}
void intersectMatrixMapping(const Ray3d &wsRay,
const MatrixFieldMapping *mtx,
const float worldScale) const
{
using std::min;
const float time = 0.0f;
// Transform ray to local space for intersection test
Ray3d lsRay;
mtx->worldToLocal(wsRay.pos, lsRay.pos, time);
mtx->worldToLocalDir(wsRay.dir, lsRay.dir);
// Use unit bounding box to intersect against
Box3d lsBBox(V3d(0.0), V3d(1.0));
// Calculate intersection points
double t0, t1;
// Add the interval if the ray intersects the box
if (detail::intersect(lsRay, lsBBox, t0, t1)) {
const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
wsVoxelSize.z);
m_intervals.push_back(Interval(t0, t1, minLen * worldScale));
}
}
void intersectFrustumMapping(const Ray3d &wsRay,
const FrustumFieldMapping *mtx,
const float worldScale) const
{
using std::min;
typedef std::vector<V3d> PointVec;
const float time = 0.0f;
// Get the eight corners of the local space bounding box
Box3d lsBounds(V3d(0.0), V3d(1.0));
PointVec lsCorners = detail::cornerPoints(lsBounds);
// Get the world space positions of the eight corners of the frustum
PointVec wsCorners(lsCorners.size());
for (PointVec::iterator lsP = lsCorners.begin(), wsP = wsCorners.begin(),
end = lsCorners.end(); lsP != end; ++lsP, ++wsP) {
mtx->localToWorld(*lsP, *wsP, time);
}
// Construct plane for each face of frustum
Plane3d planes[6];
planes[0] = Plane3d(wsCorners[4], wsCorners[0], wsCorners[6]);
planes[1] = Plane3d(wsCorners[1], wsCorners[5], wsCorners[3]);
planes[2] = Plane3d(wsCorners[4], wsCorners[5], wsCorners[0]);
planes[3] = Plane3d(wsCorners[2], wsCorners[3], wsCorners[6]);
planes[4] = Plane3d(wsCorners[0], wsCorners[1], wsCorners[2]);
planes[5] = Plane3d(wsCorners[5], wsCorners[4], wsCorners[7]);
// Intersect ray against planes
double t0 = -std::numeric_limits<double>::max();
double t1 = std::numeric_limits<double>::max();
for (int i = 0; i < 6; ++i) {
double t;
const Plane3d &p = planes[i];
if (p.intersectT(wsRay, t)) {
if (wsRay.dir.dot(p.normal) > 0.0) {
// Non-opposing plane
t1 = std::min(t1, t);
} else {
// Opposing plane
t0 = std::max(t0, t);
}
}
}
if (t0 < t1) {
t0 = std::max(t0, 0.0);
const V3d wsVoxelSize = mtx->wsVoxelSize(0, 0, 0);
const double minLen = min(min(wsVoxelSize.x, wsVoxelSize.y),
wsVoxelSize.z);
m_intervals.push_back(Interval(t0, t1, minLen * worldScale));
}
}
template <typename T>
void operator()(const T &vec) const
{
// Intersect the ray against all the fields
for (size_t field = 0, end = vec.size(); field < end; ++field) {
// Check object space transform
Ray3d wsRay = m_wsRay;
if (vec[field].doOsToWs) {
vec[field].wsToOs.multVecMatrix(m_wsRay.pos, wsRay.pos);
vec[field].wsToOs.multDirMatrix(m_wsRay.dir, wsRay.dir);
}
// Pointer to mapping
const FieldMapping* m = vec[field].mapping;
// Check matrix mapping
if (const MatrixFieldMapping *mtx =
dynamic_cast<const MatrixFieldMapping*>(m)) {
intersectMatrixMapping(wsRay, mtx, vec[field].worldScale);
}
// Check frustum mapping
if (const FrustumFieldMapping *f =
dynamic_cast<const FrustumFieldMapping*>(m)) {
intersectFrustumMapping(wsRay, f, vec[field].worldScale);
}
}
}
// Data members
const Ray3d &m_wsRay;
IntervalVec &m_intervals;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::GetMinMax
{
GetMinMax(const Box3d &wsBounds, float *min, float *max)
: m_wsBounds(wsBounds), m_min(min), m_max(max)
{ }
template <typename T>
void operator()(const T &vec) const
{
FieldSampler<T, Dims_T>::getMinMax(vec, m_wsBounds, m_min, m_max);
}
// Data members
const Box3d &m_wsBounds;
float *m_min;
float *m_max;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::GetMinMaxMIP
{
GetMinMaxMIP(const Box3d &wsBounds, float *min, float *max)
: m_wsBounds(wsBounds), m_min(min), m_max(max)
{ }
template <typename T>
void operator()(const T &vec) const
{
FieldSampler<T, Dims_T>::getMinMaxMIP(vec, m_wsBounds, m_min, m_max);
}
// Data members
const Box3d &m_wsBounds;
float *m_min;
float *m_max;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::GetMinMaxPrefilt
{
enum MinMaxMode {
Min,
Max
};
GetMinMaxPrefilt(const Box3d &wsBounds, float *result, MinMaxMode mode)
: m_wsBounds(wsBounds), m_result(result), m_mode(mode)
{ }
template <typename T>
void operator()(const T &vec) const
{
if (m_mode == Min) {
FieldSampler<T, Dims_T>::getMinMaxPrefilt(vec, m_wsBounds, m_result,
FieldSampler<T, Dims_T>::Min);
} else {
FieldSampler<T, Dims_T>::getMinMaxPrefilt(vec, m_wsBounds, m_result,
FieldSampler<T, Dims_T>::Max);
}
}
// Data members
const Box3d &m_wsBounds;
float *m_result;
MinMaxMode m_mode;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::MemSize
{
MemSize(long long int &memSize)
: m_memSize(&memSize)
{ }
template <typename T>
void operator()(const T &vec) const
{
for (size_t field = 0, end = vec.size(); field < end; ++field) {
*m_memSize += vec[field].field->memSize();
}
}
long long int result() const
{ return m_memSize; }
// Data members
long long int *m_memSize;
};
//------------------------------------------------------------------------------
template <typename BaseTypeList_T, int Dims_T>
struct FieldGroup<BaseTypeList_T, Dims_T>::PointIsect
{
PointIsect(const V3d &wsP)
: m_wsP(wsP), m_doesIntersect(false)
{ }
template <typename T>
void operator()(const T &vec) const
{
for (size_t field = 0, end = vec.size(); field < end; ++field) {
// Loop over fields in vector
for (size_t i = 0, end = vec.size(); i < end; ++i) {
V3d vsP;
// Apply world to object transform
if (vec[i].doOsToWs) {
V3d osP;
vec[i].wsToOs.multVecMatrix(m_wsP, osP);
vec[i].mapping->worldToVoxel(osP, vsP);
} else {
vec[i].mapping->worldToVoxel(m_wsP, vsP);
}
// Sample
if (vec[i].vsBounds.intersects(vsP)) {
m_doesIntersect = true;
}
}
}
}
bool result() const
{ return m_doesIntersect; }
private:
// Data members
V3d m_wsP;
bool m_doesIntersect;
};
//----------------------------------------------------------------------------//
FIELD3D_NAMESPACE_HEADER_CLOSE
//------------------------------------------------------------------------------
#endif // include guard
//------------------------------------------------------------------------------
DenseField.h
Contains the DenseField class.
Field3DFile.h
Contains the Field3DFile classes.
MinMaxMode
MinMaxMode
Definition FieldGroup.h:1371
ScalarTypes
FIELD3D_NAMESPACE_OPEN typedef mpl::vector< Field3D::half, float, double > ScalarTypes
Definition FieldGroup.h:50
ScalarFieldGroup
FieldGroup< ScalarTypes, 1 > ScalarFieldGroup
Definition FieldGroup.h:475
VectorFieldGroup
FieldGroup< VectorTypes, 3 > VectorFieldGroup
Definition FieldGroup.h:476
VectorTypes
mpl::vector< Field3D::V3h, Field3D::V3f, Field3D::V3d > VectorTypes
Definition FieldGroup.h:51
FieldInterp.h
Contains the FieldInterp base class and some standard interpolation classes.
FieldWrapper.h
InitIO.h
Contains the initIO function.
numIOThreads
FIELD3D_API size_t numIOThreads()
Returns the number of I/O threads to use.
Definition InitIO.cpp:92
MIPField.h
Contains the MIPField class.
MIPUtil.h
Contains MIP-related utility functions.
MinMaxUtil.h
Contains MIP-related utility functions.
SparseField.h
Contains the SparseField class.
Box3d
Imath::Box3d Box3d
Definition SpiMathLib.h:79
V3d
Imath::V3d V3d
Definition SpiMathLib.h:74
Plane3d
Imath::Plane3d Plane3d
Definition SpiMathLib.h:83
M44d
Imath::M44d M44d
Definition SpiMathLib.h:82
Ray3d
Imath::Line3d Ray3d
Definition StdMathLib.h:94
IntervalVec
std::vector< Interval > IntervalVec
Definition Types.h:87
Field3DFileBase::getPartitionNames
void getPartitionNames(std::vector< std::string > &names) const
Gets the names of all the partitions in the file.
Definition Field3DFile.cpp:492
Field3DInputFile
Provides reading of .f3d (internally, hdf5 or Ogawa) files.
Definition Field3DFile.h:414
Field3DInputFile::open
bool open(const std::string &filename)
Opens the given file.
Definition Field3DFile.cpp:714
FieldMapping
Base class for mapping between world-, local- and voxel coordinates.
Definition FieldMapping.h:87
FieldMapping::localToWorld
virtual void localToWorld(const V3d &lsP, V3d &wsP) const =0
Transform from local space position into world space.
FieldRes::Vec
std::vector< Ptr > Vec
Definition Field.h:214
FrustumFieldMapping
Represents the mapping of a field by a perspective transform.
Definition FieldMapping.h:565
FrustumFieldMapping::localToWorld
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
Definition FieldMapping.cpp:618
FrustumFieldMapping::wsVoxelSize
virtual V3d wsVoxelSize(int i, int j, int k) const
Returns world-space size of a voxel at the specified coordinate.
Definition FieldMapping.cpp:728
MatrixFieldMapping
Represents the mapping of a field by a matrix transform.
Definition FieldMapping.h:335
MatrixFieldMapping::wsVoxelSize
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
Definition FieldMapping.h:484
MatrixFieldMapping::worldToLocal
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
Definition FieldMapping.h:436
MatrixFieldMapping::worldToLocalDir
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
Definition FieldMapping.h:470
ValueRemapOp::Ptr
boost::shared_ptr< ValueRemapOp > Ptr
Definition FieldWrapper.h:45
FIELD3D_NAMESPACE_OPEN
Definition FieldMapping.cpp:74
detail
Definition CoordSys.h:97
detail::k_minSuffix
static const char * k_minSuffix
Definition FieldGroup.h:61
detail::cornerPoints
std::vector< V3d > cornerPoints(const Box3d &box)
Definition FieldGroup.h:211
detail::unitCornerPoints
std::vector< V3d > unitCornerPoints()
Definition FieldGroup.h:228
detail::intersect
bool intersect(const Ray3d &ray, const Box3d &box, double &outT0, double &outT1)
Definition FieldGroup.h:245
detail::k_maxSuffix
static const char * k_maxSuffix
Definition FieldGroup.h:62
ns.h
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition ns.h:58
FieldGroup::CountFields
Definition FieldGroup.h:978
FieldGroup::CountFields::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:985
FieldGroup::CountFields::CountFields
CountFields()
Ctor.
Definition FieldGroup.h:980
FieldGroup::CountFields::count
int count
Definition FieldGroup.h:988
FieldGroup::DoWsBoundsOptimization
Definition FieldGroup.h:957
FieldGroup::DoWsBoundsOptimization::operator()
void operator()(WrapperVec_T &vec) const
Functor.
Definition FieldGroup.h:964
FieldGroup::DoWsBoundsOptimization::m_doWsBoundsOptimization
bool m_doWsBoundsOptimization
Enable world space bounds optimization.
Definition FieldGroup.h:971
FieldGroup::DoWsBoundsOptimization::DoWsBoundsOptimization
DoWsBoundsOptimization(const bool doWsBoundsOptimization)
Ctor.
Definition FieldGroup.h:959
FieldGroup::GetIntersections
Definition FieldGroup.h:1207
FieldGroup::GetIntersections::intersectFrustumMapping
void intersectFrustumMapping(const Ray3d &wsRay, const FrustumFieldMapping *mtx, const float worldScale) const
Intersect frustum mapping.
Definition FieldGroup.h:1240
FieldGroup::GetIntersections::intersectMatrixMapping
void intersectMatrixMapping(const Ray3d &wsRay, const MatrixFieldMapping *mtx, const float worldScale) const
Intersect matrix mapping.
Definition FieldGroup.h:1215
FieldGroup::GetIntersections::GetIntersections
GetIntersections(const Ray3d &wsRay, IntervalVec &intervals)
Ctor.
Definition FieldGroup.h:1209
FieldGroup::GetIntersections::m_intervals
IntervalVec & m_intervals
Definition FieldGroup.h:1321
FieldGroup::GetIntersections::m_wsRay
const Ray3d & m_wsRay
Definition FieldGroup.h:1320
FieldGroup::GetIntersections::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1295
FieldGroup::GetMinMaxMIP
Definition FieldGroup.h:1349
FieldGroup::GetMinMaxMIP::m_max
float * m_max
Definition FieldGroup.h:1363
FieldGroup::GetMinMaxMIP::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1356
FieldGroup::GetMinMaxMIP::m_min
float * m_min
Definition FieldGroup.h:1362
FieldGroup::GetMinMaxMIP::GetMinMaxMIP
GetMinMaxMIP(const Box3d &wsBounds, float *min, float *max)
Ctor.
Definition FieldGroup.h:1351
FieldGroup::GetMinMaxMIP::m_wsBounds
const Box3d & m_wsBounds
Definition FieldGroup.h:1361
FieldGroup::GetMinMaxPrefilt
Definition FieldGroup.h:1370
FieldGroup::GetMinMaxPrefilt::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1381
FieldGroup::GetMinMaxPrefilt::Max
@ Max
Definition FieldGroup.h:1373
FieldGroup::GetMinMaxPrefilt::GetMinMaxPrefilt
GetMinMaxPrefilt(const Box3d &wsBounds, float *result, MinMaxMode mode)
Ctor.
Definition FieldGroup.h:1376
FieldGroup::GetMinMaxPrefilt::m_result
float * m_result
Definition FieldGroup.h:1393
FieldGroup::GetMinMaxPrefilt::m_wsBounds
const Box3d & m_wsBounds
Definition FieldGroup.h:1392
FieldGroup::GetMinMaxPrefilt::m_mode
MinMaxMode m_mode
Definition FieldGroup.h:1394
FieldGroup::GetMinMaxPrefilt::Min
@ Min
Definition FieldGroup.h:1372
FieldGroup::GetMinMax
Definition FieldGroup.h:1328
FieldGroup::GetMinMax::m_max
float * m_max
Definition FieldGroup.h:1342
FieldGroup::GetMinMax::m_wsBounds
const Box3d & m_wsBounds
Definition FieldGroup.h:1340
FieldGroup::GetMinMax::GetMinMax
GetMinMax(const Box3d &wsBounds, float *min, float *max)
Ctor.
Definition FieldGroup.h:1330
FieldGroup::GetMinMax::m_min
float * m_min
Definition FieldGroup.h:1341
FieldGroup::GetMinMax::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1335
FieldGroup::GetWsBounds
Definition FieldGroup.h:1169
FieldGroup::GetWsBounds::m_wsBounds
Box3d & m_wsBounds
Definition FieldGroup.h:1200
FieldGroup::GetWsBounds::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1176
FieldGroup::GetWsBounds::GetWsBounds
GetWsBounds(Box3d &wsBounds)
Ctor.
Definition FieldGroup.h:1171
FieldGroup::GrabFields
Definition FieldGroup.h:900
FieldGroup::GrabFields::GrabFields
GrabFields(Field3D::FieldRes::Ptr f, const M44d &osToWs, ValueRemapOp::Ptr op, const bool doWsBoundsOptimization)
Ctor.
Definition FieldGroup.h:902
FieldGroup::GrabFields::m_osToWs
M44d m_osToWs
Object to world transform.
Definition FieldGroup.h:946
FieldGroup::GrabFields::operator()
void operator()(WrapperVec_T &vec) const
Functor.
Definition FieldGroup.h:911
FieldGroup::GrabFields::m_doWsBoundsOptimization
bool m_doWsBoundsOptimization
Enable world space bounds optimization.
Definition FieldGroup.h:950
FieldGroup::GrabFields::m_op
ValueRemapOp::Ptr m_op
Value remap operator.
Definition FieldGroup.h:948
FieldGroup::GrabFields::m_field
Field3D::FieldRes::Ptr m_field
The field to work on. Will be matched against the type of operator().
Definition FieldGroup.h:944
FieldGroup::MakeMinMaxMIP
Definition FieldGroup.h:1035
FieldGroup::MakeMinMaxMIP::MakeMinMaxMIP
MakeMinMaxMIP(Field3D::FieldRes::Vec &minFields, Field3D::FieldRes::Vec &maxFields, const float resMult)
Ctor.
Definition FieldGroup.h:1037
FieldGroup::MakeMinMaxMIP::m_numThreads
const size_t m_numThreads
Definition FieldGroup.h:1068
FieldGroup::MakeMinMaxMIP::operator()
void operator()(const WrapperVec_T &vec)
Functor.
Definition FieldGroup.h:1047
FieldGroup::MakeMinMaxMIP::m_maxFields
Field3D::FieldRes::Vec & m_maxFields
Definition FieldGroup.h:1066
FieldGroup::MakeMinMaxMIP::m_minFields
Field3D::FieldRes::Vec & m_minFields
Definition FieldGroup.h:1065
FieldGroup::MakeMinMaxMIP::m_resMult
const float m_resMult
Definition FieldGroup.h:1067
FieldGroup::MakeMinMax
Definition FieldGroup.h:995
FieldGroup::MakeMinMax::m_minFields
Field3D::FieldRes::Vec & m_minFields
Definition FieldGroup.h:1025
FieldGroup::MakeMinMax::m_resMult
const float m_resMult
Definition FieldGroup.h:1027
FieldGroup::MakeMinMax::operator()
void operator()(const WrapperVec_T &vec)
Functor.
Definition FieldGroup.h:1007
FieldGroup::MakeMinMax::m_numThreads
const size_t m_numThreads
Definition FieldGroup.h:1028
FieldGroup::MakeMinMax::MakeMinMax
MakeMinMax(Field3D::FieldRes::Vec &minFields, Field3D::FieldRes::Vec &maxFields, const float resMult)
Ctor.
Definition FieldGroup.h:997
FieldGroup::MakeMinMax::m_maxFields
Field3D::FieldRes::Vec & m_maxFields
Definition FieldGroup.h:1026
FieldGroup::MemSize
Definition FieldGroup.h:1401
FieldGroup::MemSize::m_memSize
long long int * m_memSize
Definition FieldGroup.h:1418
FieldGroup::MemSize::MemSize
MemSize(long long int &memSize)
Ctor.
Definition FieldGroup.h:1403
FieldGroup::MemSize::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1408
FieldGroup::MemSize::result
long long int result() const
Result.
Definition FieldGroup.h:1415
FieldGroup::PointIsect
Definition FieldGroup.h:1425
FieldGroup::PointIsect::PointIsect
PointIsect(const V3d &wsP)
Ctor.
Definition FieldGroup.h:1427
FieldGroup::PointIsect::result
bool result() const
Result.
Definition FieldGroup.h:1454
FieldGroup::PointIsect::m_doesIntersect
bool m_doesIntersect
Definition FieldGroup.h:1459
FieldGroup::PointIsect::m_wsP
V3d m_wsP
Definition FieldGroup.h:1458
FieldGroup::PointIsect::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1432
FieldGroup::SampleMIPMultiple
Definition FieldGroup.h:1143
FieldGroup::SampleMIPMultiple::m_n
const int m_n
Definition FieldGroup.h:1158
FieldGroup::SampleMIPMultiple::SampleMIPMultiple
SampleMIPMultiple(const size_t n, const float *p, const float *wsSpotSize, float *result, size_t *numHits)
Ctor.
Definition FieldGroup.h:1145
FieldGroup::SampleMIPMultiple::m_wsSpotSize
const float * m_wsSpotSize
Definition FieldGroup.h:1160
FieldGroup::SampleMIPMultiple::m_p
const float * m_p
Definition FieldGroup.h:1159
FieldGroup::SampleMIPMultiple::m_numHits
size_t * m_numHits
Definition FieldGroup.h:1162
FieldGroup::SampleMIPMultiple::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1152
FieldGroup::SampleMIPMultiple::m_result
float * m_result
Definition FieldGroup.h:1161
FieldGroup::SampleMIP
Definition FieldGroup.h:1096
FieldGroup::SampleMIP::SampleMIP
SampleMIP(const V3d &p, const float wsSpotSize, float *result, size_t &numHits)
Ctor.
Definition FieldGroup.h:1098
FieldGroup::SampleMIP::m_result
float * m_result
Definition FieldGroup.h:1112
FieldGroup::SampleMIP::m_numHits
size_t & m_numHits
Definition FieldGroup.h:1113
FieldGroup::SampleMIP::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1104
FieldGroup::SampleMIP::m_wsSpotSize
const float m_wsSpotSize
Definition FieldGroup.h:1111
FieldGroup::SampleMIP::m_p
const V3d & m_p
Definition FieldGroup.h:1110
FieldGroup::SampleMultiple
Definition FieldGroup.h:1120
FieldGroup::SampleMultiple::m_result
float * m_result
Definition FieldGroup.h:1135
FieldGroup::SampleMultiple::m_n
const int m_n
Definition FieldGroup.h:1133
FieldGroup::SampleMultiple::m_numHits
size_t * m_numHits
Definition FieldGroup.h:1136
FieldGroup::SampleMultiple::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1128
FieldGroup::SampleMultiple::SampleMultiple
SampleMultiple(const size_t n, const float *p, float *result, size_t *numHits)
Ctor.
Definition FieldGroup.h:1122
FieldGroup::SampleMultiple::m_p
const float * m_p
Definition FieldGroup.h:1134
FieldGroup::Sample
Definition FieldGroup.h:1075
FieldGroup::Sample::Sample
Sample(const V3d &p, float *result, size_t &numHits)
Ctor.
Definition FieldGroup.h:1077
FieldGroup::Sample::m_p
const V3d & m_p
Definition FieldGroup.h:1087
FieldGroup::Sample::m_numHits
size_t & m_numHits
Definition FieldGroup.h:1089
FieldGroup::Sample::m_result
float * m_result
Definition FieldGroup.h:1088
FieldGroup::Sample::operator()
void operator()(const T &vec) const
Functor.
Definition FieldGroup.h:1082
FieldGroup
Definition FieldGroup.h:304
FieldGroup::hasPrefiltMinMax
bool hasPrefiltMinMax() const
Whether the FieldGroup has a pre-filtered min/max representation.
Definition FieldGroup.h:412
FieldGroup::sampleMIPMultiple
void sampleMIPMultiple(const size_t n, const float *wsP, const float *wsSpotSize, float *result) const
Samples all the MIP fields in the group.
Definition FieldGroup.h:795
FieldGroup::MPLMIPSparseTypes
mpl::transform< MPLBaseTypes, detail::MakeMIPSparse< ph::_1 > >::type MPLMIPSparseTypes
Definition FieldGroup.h:322
FieldGroup< ScalarTypes, 1 >::m_valueRemapOp
ValueRemapOp::Ptr m_valueRemapOp
Definition FieldGroup.h:445
FieldGroup::load
int load(const std::string &filename, const std::string &attribute)
Loads all fields from a given file and optional attribute pattern.
Definition FieldGroup.h:620
FieldGroup::MPLBaseTypes
BaseTypeList_T MPLBaseTypes
Definition FieldGroup.h:308
FieldGroup::sampleMIP
void sampleMIP(const V3d &vsP, const float wsSpotSize, float *result, bool isVs) const
Samples all the MIP fields in the group.
Definition FieldGroup.h:779
FieldGroup::makeMinMax
void makeMinMax(const float resMult)
Make min/max representations of the fields in the group.
Definition FieldGroup.h:669
FieldGroup< ScalarTypes, 1 >::m_doWsBoundsOptimization
bool m_doWsBoundsOptimization
Definition FieldGroup.h:442
FieldGroup::size
virtual size_t size() const
The number of fields in the group.
Definition FieldGroup.h:689
FieldGroup::setWsBoundsOptimization
virtual void setWsBoundsOptimization(const bool doWsBoundsOptimization)
Enable world axis aligned bounding box in lookups. This will be used for subsequent setup() and load(...
Definition FieldGroup.h:511
FieldGroup< ScalarTypes, 1 >::m_mipSparse
MIPSparseTypes m_mipSparse
Definition FieldGroup.h:433
FieldGroup::setOsToWs
void setOsToWs(const Imath::M44d &osToWs)
Sets the current object to world transform. This will be used for subsequent setup() and load() calls...
Definition FieldGroup.h:502
FieldGroup::CompositeOp
CompositeOp
Definition FieldGroup.h:333
FieldGroup< ScalarTypes, 1 >::Add
@ Add
Definition FieldGroup.h:334
FieldGroup< ScalarTypes, 1 >::Avg
@ Avg
Definition FieldGroup.h:335
FieldGroup::setupMinMax
void setupMinMax(const FieldRes::Vec &minFields, const FieldRes::Vec &maxFields)
Set up the min/max MIP representations.
Definition FieldGroup.h:585
FieldGroup< ScalarTypes, 1 >::m_mipDenseMin
MIPDenseTypes m_mipDenseMin
Definition FieldGroup.h:432
FieldGroup< ScalarTypes, 1 >::m_dense
DenseTypes m_dense
Definition FieldGroup.h:430
FieldGroup< ScalarTypes, 1 >::fields
const FieldRes::Vec & fields() const
Definition FieldGroup.h:417
FieldGroup::getIntersections
bool getIntersections(const Ray3d &ray, IntervalVec &intervals) const
Gets the intersection intervals between the ray and the fields.
Definition FieldGroup.h:841
FieldGroup::MIPDenseTypes
fusion_ro::as_vector< MPLMIPDenseTypes >::type MIPDenseTypes
Definition FieldGroup.h:327
FieldGroup::sampleMultiple
void sampleMultiple(const size_t n, const float *wsP, float *result) const
Samples the fields in the group.
Definition FieldGroup.h:764
FieldGroup::setup
virtual void setup(const Field3D::FieldRes::Ptr field)
Adds a single field to the group.
Definition FieldGroup.h:538
FieldGroup< ScalarTypes, 1 >::m_mipSparseMax
MIPSparseTypes m_mipSparseMax
Definition FieldGroup.h:433
FieldGroup< ScalarTypes, 1 >::m_allFields
FieldRes::Vec m_allFields
Definition FieldGroup.h:448
FieldGroup< ScalarTypes, 1 >::m_auxFields
FieldRes::Vec m_auxFields
Definition FieldGroup.h:450
FieldGroup::MIPSparseTypes
fusion_ro::as_vector< MPLMIPSparseTypes >::type MIPSparseTypes
Definition FieldGroup.h:328
FieldGroup::FieldGroup
FieldGroup()
Default constructor, does nothing.
Definition FieldGroup.h:483
FieldGroup< ScalarTypes, 1 >::m_osToWs
M44d m_osToWs
Definition FieldGroup.h:439
FieldGroup::sizeMIP
size_t sizeMIP() const
The number of MIP fields in the group.
Definition FieldGroup.h:703
FieldGroup< ScalarTypes, 1 >::m_hasPrefiltMinMax
bool m_hasPrefiltMinMax
Definition FieldGroup.h:436
FieldGroup< ScalarTypes, 1 >::m_sparse
SparseTypes m_sparse
Definition FieldGroup.h:431
FieldGroup::intersects
bool intersects(const V3d &wsP) const
Whether the given point intersects any of the fields in the FieldGroup.
Definition FieldGroup.h:826
FieldGroup::MPLMIPDenseTypes
mpl::transform< MPLBaseTypes, detail::MakeMIPDense< ph::_1 > >::type MPLMIPDenseTypes
Definition FieldGroup.h:319
FieldGroup::DenseTypes
fusion_ro::as_vector< MPLDenseTypes >::type DenseTypes
Definition FieldGroup.h:325
FieldGroup::FieldGroup
FieldGroup(const Field3D::FieldRes::Vec &fields)
Construct from a set of fields.
Definition FieldGroup.h:491
FieldGroup::MPLDenseTypes
mpl::transform< MPLBaseTypes, detail::MakeDense< ph::_1 > >::type MPLDenseTypes
Definition FieldGroup.h:313
FieldGroup< ScalarTypes, 1 >::m_mipDense
MIPDenseTypes m_mipDense
Definition FieldGroup.h:432
FieldGroup::setup
virtual void setup(const Field3D::FieldRes::Vec &fields, const Field3D::FieldRes::Vec &minFields, const Field3D::FieldRes::Vec &maxFields)
Initializes the FieldGroup from a set of fields with pre-computed min/max representations.
Definition FieldGroup.h:562
FieldGroup::getMinMax
void getMinMax(const Box3d &wsBounds, float *min, float *max) const
Returns the min/max range within a given bounding box.
Definition FieldGroup.h:855
FieldGroup::SparseTypes
fusion_ro::as_vector< MPLSparseTypes >::type SparseTypes
Definition FieldGroup.h:326
FieldGroup< ScalarTypes, 1 >::m_mipSparseMin
MIPSparseTypes m_mipSparseMin
Definition FieldGroup.h:433
FieldGroup::MPLSparseTypes
mpl::transform< MPLBaseTypes, detail::MakeSparse< ph::_1 > >::type MPLSparseTypes
Definition FieldGroup.h:316
FieldGroup::wsBounds
Box3d wsBounds() const
Returns the bounds of the group.
Definition FieldGroup.h:811
FieldGroup< ScalarTypes, 1 >::k_missingFile
static const int k_missingFile
Definition FieldGroup.h:341
FieldGroup::memSize
long long int memSize() const
Returns the memory use in bytes for the fields in the group.
Definition FieldGroup.h:883
FieldGroup::setup
virtual void setup(const Field3D::FieldRes::Vec &fields)
Initializes the FieldGroup from a set of fields.
Definition FieldGroup.h:550
FieldGroup< ScalarTypes, 1 >::m_mipDenseMax
MIPDenseTypes m_mipDenseMax
Definition FieldGroup.h:432
FieldGroup::setValueRemapOp
void setValueRemapOp(ValueRemapOp::Ptr op)
Sets the current ValueRemap operator. This will be used for subsequent setup() and load() calls....
Definition FieldGroup.h:529
FieldGroup::sample
void sample(const V3d &vsP, float *result, bool isVs) const
Samples the group of fields at the given point. This call will not include MIP fields,...
Definition FieldGroup.h:749
FieldGroup::sample
void sample(const V3d &wsP, const float wsSpotSize, const float time, float *result, const CompositeOp compOp=Add)
Unified sampling of the group's fields. Will handle both MIP and non-MIP data with optional compositi...
Definition FieldGroup.h:715
FieldSampler::Max
@ Max
Definition FieldSampler.h:85
FieldSampler::Min
@ Min
Definition FieldSampler.h:84
FieldSampler::sampleMIP
static void sampleMIP(const WrapperVec_T &f, const V3d &wsP, const float wsSpotSize, float *value, size_t &numHits)
Definition FieldSampler.h:188
FieldSampler::sample
static void sample(const WrapperVec_T &f, const V3d &wsP, float *value, size_t &numHits)
Definition FieldSampler.h:93
FieldSampler::sampleMultiple
static void sampleMultiple(const WrapperVec_T &f, const size_t neval, const float *wsPs, float *value, size_t *numHits)
Definition FieldSampler.h:125
FieldSampler::getMinMaxMIP
static void getMinMaxMIP(const WrapperVec_T &f, const Box3d &wsBounds, float *min, float *max)
Definition FieldSampler.h:360
FieldSampler::getMinMax
static void getMinMax(const WrapperVec_T &f, const Box3d &wsBounds, float *min, float *max)
Definition FieldSampler.h:318
FieldSampler::sampleMIPMultiple
static void sampleMIPMultiple(const WrapperVec_T &f, const size_t neval, const float *wsPs, const float *wsSpotSizes, float *value, size_t *numHits)
Definition FieldSampler.h:222
FieldSampler::getMinMaxPrefilt
static void getMinMaxPrefilt(const WrapperVec_T &f, const Box3d &wsBounds, float *result, const Mode mode)
Definition FieldSampler.h:402
FieldWrapper
This class wraps up a single field to make its interpolator and its mapping easily accessible....
Definition FieldWrapper.h:64
Interval
Represents a single integration interval. The interval is assumed to be inclusive,...
Definition Types.h:66
MIPFieldWrapper
This class wraps up a single MIP field to make its interpolator and its mapping easily accessible....
Definition FieldWrapper.h:158
detail::LoadFieldsParams
Definition FieldGroup.h:110
detail::LoadFieldsParams::in
Field3D::Field3DInputFile & in
Definition FieldGroup.h:124
detail::LoadFieldsParams::LoadFieldsParams
LoadFieldsParams(Field3D::Field3DInputFile &a_in, const std::string &a_name, const std::string &a_attribute, Field3D::FieldRes::Vec &a_results, Field3D::FieldRes::Vec &a_minResults, Field3D::FieldRes::Vec &a_maxResults)
Definition FieldGroup.h:111
detail::LoadFieldsParams::minResults
Field3D::FieldRes::Vec & minResults
Definition FieldGroup.h:128
detail::LoadFieldsParams::maxResults
Field3D::FieldRes::Vec & maxResults
Definition FieldGroup.h:129
detail::LoadFieldsParams::results
Field3D::FieldRes::Vec & results
Definition FieldGroup.h:127
detail::LoadFieldsParams::attribute
const std::string & attribute
Definition FieldGroup.h:126
detail::LoadFieldsParams::name
const std::string & name
Definition FieldGroup.h:125
detail::LoadFields< 1 >::operator()
void operator()(T)
Definition FieldGroup.h:141
detail::LoadFields< 1 >::m_p
LoadFieldsParams & m_p
Definition FieldGroup.h:166
detail::LoadFields< 1 >::LoadFields
LoadFields(LoadFieldsParams &params)
Definition FieldGroup.h:136
detail::LoadFields< 3 >::LoadFields
LoadFields(LoadFieldsParams &params)
Definition FieldGroup.h:173
detail::LoadFields< 3 >::operator()
void operator()(Vec_T)
Definition FieldGroup.h:178
detail::LoadFields< 3 >::m_p
LoadFieldsParams & m_p
Definition FieldGroup.h:205
detail::LoadFields
Definition FieldGroup.h:107
detail::MakeDense
MPL utility.
Definition FieldGroup.h:69
detail::MakeDense::type
FieldWrapper< Field3D::DenseField< T > >::Vec type
Definition FieldGroup.h:70
detail::MakeMIPDense
MPL utility.
Definition FieldGroup.h:87
detail::MakeMIPDense::type
MIPFieldWrapper< Field3D::MIPField< Field3D::DenseField< T > > >::Vec type
Definition FieldGroup.h:90
detail::MakeMIPSparse
MPL utility.
Definition FieldGroup.h:98
detail::MakeMIPSparse::type
MIPFieldWrapper< Field3D::MIPField< Field3D::SparseField< T > > >::Vec type
Definition FieldGroup.h:101
detail::MakeSparse
MPL utility.
Definition FieldGroup.h:78
detail::MakeSparse::type
FieldWrapper< Field3D::SparseField< T > >::Vec type
Definition FieldGroup.h:79