Field3D
FieldSampler< WrapperVec_T, 3 > Struct Template Reference

Vector 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, 3 >

Vector specialization.

Definition at line 139 of file FieldSampler.h.

Member Function Documentation

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

Definition at line 142 of file FieldSampler.h.

144  {
145  V3f v(value[0], value[1], value[2]);
146  if (isVs) {
147  for (size_t i = 0, end = f.size(); i < end; ++i) {
148  if (f[i].vsBounds.intersects(p)) {
149  v += f[i].interp.sample(*f[i].field, p);
150  }
151  }
152  } else {
153  V3d vsP;
154  for (size_t i = 0, end = f.size(); i < end; ++i) {
155  f[i].mapping->worldToVoxel(p, vsP);
156  if (f[i].vsBounds.intersects(vsP)) {
157  v += f[i].interp.sample(*f[i].field, vsP);
158  }
159  }
160  }
161  memcpy(value, &v[0], sizeof(V3f));
162  }
Imath::V3d V3d
Definition: SpiMathLib.h:74
Imath::V3f V3f
Definition: SpiMathLib.h:73
template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 3 >::sampleMIP ( const WrapperVec_T &  f,
const V3d p,
const float  wsSpotSize,
float *  value,
bool  isVs 
)
inlinestatic

Definition at line 165 of file FieldSampler.h.

167  {
168  V3f v(value[0], value[1], value[2]);
169  if (isVs) {
170  for (size_t i = 0, end = f.size(); i < end; ++i) {
171  if (f[i].vsBounds.intersects(p)) {
172  v += f[i].interp->sample(p, wsSpotSize);
173  }
174  }
175  } else {
176  V3d vsP;
177  for (size_t i = 0, end = f.size(); i < end; ++i) {
178  f[i].mapping->worldToVoxel(p, vsP);
179  if (f[i].vsBounds.intersects(vsP)) {
180  v += f[i].interp->sample(vsP, wsSpotSize);
181  }
182  }
183  }
184  memcpy(value, &v[0], sizeof(V3f));
185  }
Imath::V3d V3d
Definition: SpiMathLib.h:74
Imath::V3f V3f
Definition: SpiMathLib.h:73
template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 3 >::getMinMax ( const WrapperVec_T &  f,
const Box3d wsBounds,
float *  min,
float *  max 
)
inlinestatic

Definition at line 187 of file FieldSampler.h.

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

189  {
190  for (size_t field = 0, end = f.size(); field < end; ++field) {
191  // Data window
192  const Box3i dw = f[field].field->dataWindow();
193  // Transform corners to voxel space and compute bounds
194  Box3d vsBounds;
195  worldToVoxel(f[field].mapping, wsBounds, vsBounds);
196  Box3i dvsBounds = clipBounds(discreteBounds(vsBounds), dw);
197  // Early termination if no intersection
198  if (!dw.intersects(dvsBounds)) {
199  return;
200  }
201  for (int k = dvsBounds.min.z; k <= dvsBounds.max.z; ++k) {
202  for (int j = dvsBounds.min.y; j <= dvsBounds.max.y; ++j) {
203  for (int i = dvsBounds.min.x; i <= dvsBounds.max.x; ++i) {
204  V3f val = f[field].field->fastValue(i, j, k);
205  min[0] = std::min(val.x, min[0]);
206  min[1] = std::min(val.y, min[1]);
207  min[2] = std::min(val.z, min[2]);
208  max[0] = std::max(val.x, max[0]);
209  max[1] = std::max(val.y, max[1]);
210  max[2] = std::max(val.z, max[2]);
211  }
212  }
213  }
214  }
215  }
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
Imath::V3f V3f
Definition: SpiMathLib.h:73
template<typename WrapperVec_T >
static void FieldSampler< WrapperVec_T, 3 >::getMinMaxMIP ( const WrapperVec_T &  f,
const Box3d wsBounds,
float *  min,
float *  max 
)
inlinestatic

Definition at line 217 of file FieldSampler.h.

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

219  {
220  for (size_t field = 0, end = f.size(); field < end; ++field) {
221  // Data window
222  const Box3i dw = f[field].field->dataWindow();
223  // Transform corners to voxel space and compute bounds
224  Box3d vsBounds;
225  worldToVoxel(f[field].mapping, wsBounds, vsBounds);
226  Box3i dvsBounds = clipBounds(discreteBounds(vsBounds), dw);
227  // Early termination if no intersection
228  if (!dw.intersects(dvsBounds)) {
229  return;
230  }
231  for (int k = dvsBounds.min.z; k <= dvsBounds.max.z; ++k) {
232  for (int j = dvsBounds.min.y; j <= dvsBounds.max.y; ++j) {
233  for (int i = dvsBounds.min.x; i <= dvsBounds.max.x; ++i) {
234  V3f val = f[field].field->fastMipValue(0, i, j, k);
235  min[0] = std::min(val.x, min[0]);
236  min[1] = std::min(val.y, min[1]);
237  min[2] = std::min(val.z, min[2]);
238  max[0] = std::max(val.x, max[0]);
239  max[1] = std::max(val.y, max[1]);
240  max[2] = std::max(val.z, max[2]);
241  }
242  }
243  }
244  }
245  }
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
Imath::V3f V3f
Definition: SpiMathLib.h:73

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