Field3D
FieldSampler< WrapperVec_T, 1 > Struct Template Reference

Scalar specialization. More...

#include <FieldSampler.h>

Static Public Member Functions

static void getMinMax (const WrapperVec_T &f, const Box3d &wsBounds, float *min, float *max)
 
static void getMinMaxMIP (const WrapperVec_T &f, const Box3d &wsBounds, float *min, float *max)
 
static void sample (const WrapperVec_T &f, const V3d &p, float *value, bool isVs)
 
static void sampleMIP (const WrapperVec_T &f, const V3d &p, const float wsSpotSize, float *value, bool isVs)
 

Detailed Description

template<typename WrapperVec_T>
struct FieldSampler< WrapperVec_T, 1 >

Scalar specialization.

Definition at line 39 of file FieldSampler.h.

Member Function Documentation

template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 1 >::sample ( const WrapperVec_T &  f,
const V3d p,
float *  value,
bool  isVs 
)
inlinestatic

Definition at line 42 of file FieldSampler.h.

44  {
45  if (isVs) {
46  for (size_t i = 0, end = f.size(); i < end; ++i) {
47  if (f[i].vsBounds.intersects(p)) {
48  *value += f[i].interp.sample(*f[i].field, p);
49  }
50  }
51  } else {
52  V3d vsP;
53  for (size_t i = 0, end = f.size(); i < end; ++i) {
54  f[i].mapping->worldToVoxel(p, vsP);
55  if (f[i].vsBounds.intersects(vsP)) {
56  *value += f[i].interp.sample(*f[i].field, vsP);
57  }
58  }
59  }
60  }
Imath::V3d V3d
Definition: SpiMathLib.h:74
template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 1 >::sampleMIP ( const WrapperVec_T &  f,
const V3d p,
const float  wsSpotSize,
float *  value,
bool  isVs 
)
inlinestatic

Definition at line 62 of file FieldSampler.h.

64  {
65  if (isVs) {
66  for (size_t i = 0, end = f.size(); i < end; ++i) {
67  if (f[i].vsBounds.intersects(p)) {
68  *value += f[i].interp->sample(p, wsSpotSize);
69  }
70  }
71  } else {
72  V3d vsP;
73  for (size_t i = 0, end = f.size(); i < end; ++i) {
74  f[i].mapping->worldToVoxel(p, vsP);
75  if (f[i].vsBounds.intersects(vsP)) {
76  *value += f[i].interp->sample(vsP, wsSpotSize);
77  }
78  }
79  }
80  }
Imath::V3d V3d
Definition: SpiMathLib.h:74
template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 1 >::getMinMax ( const WrapperVec_T &  f,
const Box3d wsBounds,
float *  min,
float *  max 
)
inlinestatic

Definition at line 82 of file FieldSampler.h.

References clipBounds(), discreteBounds(), and worldToVoxel().

84  {
85  for (size_t field = 0, end = f.size(); field < end; ++field) {
86  // Data window
87  const Box3i dw = f[field].field->dataWindow();
88  // Transform corners to voxel space and compute bounds
89  Box3d vsBounds;
90  worldToVoxel(f[field].mapping, wsBounds, vsBounds);
91  Box3i dvsBounds = clipBounds(discreteBounds(vsBounds), dw);
92  // Early termination if no intersection
93  if (!dw.intersects(dvsBounds)) {
94  return;
95  }
96  for (int k = dvsBounds.min.z; k <= dvsBounds.max.z; ++k) {
97  for (int j = dvsBounds.min.y; j <= dvsBounds.max.y; ++j) {
98  for (int i = dvsBounds.min.x; i <= dvsBounds.max.x; ++i) {
99  float val = f[field].field->fastValue(i, j, k);
100  min[0] = std::min(val, min[0]);
101  max[0] = std::max(val, max[0]);
102  }
103  }
104  }
105  }
106  }
Box3i clipBounds(const Box3i &bbox, const Box3i &bounds)
Definition: Field.h:1144
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
void worldToVoxel(const Field3D::FieldMapping *mapping, const Box3d &wsBounds, Box3d &vsBounds)
Computes a voxel space bounds given a bounding box in world space. This is done by transforming each ...
Imath::Box3d Box3d
Definition: SpiMathLib.h:79
Box3i discreteBounds(const Box3d &bbox)
Definition: Field.h:1130
template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 1 >::getMinMaxMIP ( const WrapperVec_T &  f,
const Box3d wsBounds,
float *  min,
float *  max 
)
inlinestatic

Definition at line 108 of file FieldSampler.h.

References clipBounds(), discreteBounds(), and worldToVoxel().

110  {
111  for (size_t field = 0, end = f.size(); field < end; ++field) {
112  // Data window
113  const Box3i dw = f[field].field->dataWindow();
114  // Transform corners to voxel space and compute bounds
115  Box3d vsBounds;
116  worldToVoxel(f[field].mapping, wsBounds, vsBounds);
117  Box3i dvsBounds = clipBounds(discreteBounds(vsBounds), dw);
118  // Early termination if no intersection
119  if (!dw.intersects(dvsBounds)) {
120  return;
121  }
122  for (int k = dvsBounds.min.z; k <= dvsBounds.max.z; ++k) {
123  for (int j = dvsBounds.min.y; j <= dvsBounds.max.y; ++j) {
124  for (int i = dvsBounds.min.x; i <= dvsBounds.max.x; ++i) {
125  float val = f[field].field->fastMipValue(0, i, j, k);
126  min[0] = std::min(val, min[0]);
127  max[0] = std::max(val, max[0]);
128  }
129  }
130  }
131  }
132  }
Box3i clipBounds(const Box3i &bbox, const Box3i &bounds)
Definition: Field.h:1144
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
void worldToVoxel(const Field3D::FieldMapping *mapping, const Box3d &wsBounds, Box3d &vsBounds)
Computes a voxel space bounds given a bounding box in world space. This is done by transforming each ...
Imath::Box3d Box3d
Definition: SpiMathLib.h:79
Box3i discreteBounds(const Box3d &bbox)
Definition: Field.h:1130

The documentation for this struct was generated from the following file: