Field3D
MIPFieldWrapper< Field_T > Struct Template Reference

This class wraps up a single MIP field to make its interpolator and its mapping easily accessible. The 'Vec' typedef gives access to a std::vector. More...

#include <FieldWrapper.h>

Public Types

typedef Field_T field_type
 
typedef Field_T::LinearInterp LinearInterp
 
typedef std::vector
< MIPFieldWrapper
Vec
 

Public Member Functions

 MIPFieldWrapper (const typename Field_T::Ptr f)
 
void setOsToWs (const M44d &i_osToWs)
 
void setValueRemapOp (ValueRemapOp::Ptr op)
 
void setWsBoundsOptimization (const bool doWsBoundsOptimization_)
 

Public Attributes

bool doOsToWs
 
bool doWsBoundsOptimization
 
const Field_T * field
 
Field_T::Ptr fieldPtr
 
LinearInterpinterp
 
boost::shared_ptr< LinearInterpinterpPtr
 
const Field3D::FieldMapping * mapping
 
M44d osToWs
 Optionally, enable doOsToWs to apply a world to object transform before lookups. More...
 
const ValueRemapOpvalueRemapOp
 
ValueRemapOp::Ptr valueRemapOpPtr
 Optionally, set a ValueRemapOp to remap values. More...
 
Box3d vsBounds
 
double worldScale
 
Imath::Box3f wsBounds
 
M44d wsToOs
 
M44d wsToVs
 Optionally, enable wsBounds optimization to use a world axis aligned bounding box in lookups. More...
 

Detailed Description

template<typename Field_T>
struct MIPFieldWrapper< Field_T >

This class wraps up a single MIP field to make its interpolator and its mapping easily accessible. The 'Vec' typedef gives access to a std::vector.

Definition at line 157 of file FieldWrapper.h.

Member Typedef Documentation

template<typename Field_T>
typedef Field_T MIPFieldWrapper< Field_T >::field_type

Definition at line 159 of file FieldWrapper.h.

template<typename Field_T>
typedef std::vector<MIPFieldWrapper> MIPFieldWrapper< Field_T >::Vec

Definition at line 160 of file FieldWrapper.h.

template<typename Field_T>
typedef Field_T::LinearInterp MIPFieldWrapper< Field_T >::LinearInterp

Definition at line 161 of file FieldWrapper.h.

Constructor & Destructor Documentation

template<typename Field_T>
MIPFieldWrapper< Field_T >::MIPFieldWrapper ( const typename Field_T::Ptr  f)
inline

Definition at line 163 of file FieldWrapper.h.

References MIPFieldWrapper< Field_T >::interp, and MIPFieldWrapper< Field_T >::interpPtr.

164  : interpPtr(new LinearInterp(*f)),
165  field(f.get()),
166  fieldPtr(f),
167  mapping(f->mapping().get()),
168  vsBounds(continuousBounds(f->dataWindow())),
169  worldScale(1.0),
170  doOsToWs(false),
171  valueRemapOp(NULL)
172  {
173  interp = interpPtr.get();
174  }
LinearInterp * interp
Definition: FieldWrapper.h:228
const Field3D::FieldMapping * mapping
Definition: FieldWrapper.h:231
boost::shared_ptr< LinearInterp > interpPtr
Definition: FieldWrapper.h:227
const ValueRemapOp * valueRemapOp
Definition: FieldWrapper.h:245
Field_T::LinearInterp LinearInterp
Definition: FieldWrapper.h:161
Field_T::Ptr fieldPtr
Definition: FieldWrapper.h:230
const Field_T * field
Definition: FieldWrapper.h:229
Box3d continuousBounds(const Box3i &bbox)
Definition: Field.h:1111

Member Function Documentation

template<typename Field_T>
void MIPFieldWrapper< Field_T >::setOsToWs ( const M44d i_osToWs)
inline

Definition at line 176 of file FieldWrapper.h.

References MIPFieldWrapper< Field_T >::doOsToWs, MIPFieldWrapper< Field_T >::doWsBoundsOptimization, detail::max(), MIPFieldWrapper< Field_T >::osToWs, Msg::print(), MIPFieldWrapper< Field_T >::setWsBoundsOptimization(), MIPFieldWrapper< Field_T >::worldScale, and MIPFieldWrapper< Field_T >::wsToOs.

177  {
178  osToWs = i_osToWs;
179  wsToOs = osToWs.inverse();
180  // Compute world scale
181  V3d ws(1.0);
182  if (!Imath::extractScaling(osToWs, ws, false)) {
183  Msg::print("WARNING: FieldGroup/FieldWrapper: "
184  "Couldn't extract world scale from object-to-world "
185  "transform. Defaulting to 1.0.");
186  }
187  worldScale = std::max(std::max(ws.x, ws.y), ws.z);
188  // Set boolean
189  doOsToWs = true;
190 
191  // Update wsBounds
194  }
195  }
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity. ...
Definition: Log.cpp:70
void setWsBoundsOptimization(const bool doWsBoundsOptimization_)
Definition: FieldWrapper.h:197
T max(const T a, const T2 b)
Max operation on mixed types.
Definition: FieldSampler.h:32
bool doWsBoundsOptimization
Definition: FieldWrapper.h:242
Imath::V3d V3d
Definition: SpiMathLib.h:74
M44d osToWs
Optionally, enable doOsToWs to apply a world to object transform before lookups.
Definition: FieldWrapper.h:235
template<typename Field_T>
void MIPFieldWrapper< Field_T >::setWsBoundsOptimization ( const bool  doWsBoundsOptimization_)
inline

Definition at line 197 of file FieldWrapper.h.

References MIPFieldWrapper< Field_T >::doOsToWs, MIPFieldWrapper< Field_T >::doWsBoundsOptimization, MIPFieldWrapper< Field_T >::mapping, MIPFieldWrapper< Field_T >::vsBounds, MatrixFieldMapping::worldToVoxel(), MIPFieldWrapper< Field_T >::wsBounds, MIPFieldWrapper< Field_T >::wsToOs, and MIPFieldWrapper< Field_T >::wsToVs.

Referenced by MIPFieldWrapper< Field_T >::setOsToWs().

198  {
199  if (!doWsBoundsOptimization_)
200  return;
201  // wsBounds can be set only if mapping is a matrix
202  const MatrixFieldMapping *mtx_mapping =
203  dynamic_cast<const MatrixFieldMapping*>(mapping);
204  if (mtx_mapping) {
205  const float time = 0;
206  M44d vsToWs;
207  if (doOsToWs) {
208  wsToVs = wsToOs * mtx_mapping->worldToVoxel(time);
209  vsToWs = wsToVs.inverse();
210  } else {
211  wsToVs = mtx_mapping->worldToVoxel(time);
212  vsToWs = wsToVs.inverse();
213  }
214  const Imath::Box3d wsBounds_d = Imath::transform(vsBounds,
215  vsToWs);
216  wsBounds = Imath::Box3f(wsBounds_d.min, wsBounds_d.max);
217  doWsBoundsOptimization = true;
218  }
219  }
Imath::M44d M44d
Definition: SpiMathLib.h:82
const Field3D::FieldMapping * mapping
Definition: FieldWrapper.h:231
Imath::Box3f wsBounds
Definition: FieldWrapper.h:241
Imath::Box3d Box3d
Definition: SpiMathLib.h:79
bool doWsBoundsOptimization
Definition: FieldWrapper.h:242
M44d wsToVs
Optionally, enable wsBounds optimization to use a world axis aligned bounding box in lookups...
Definition: FieldWrapper.h:240
const M44d & worldToVoxel() const
Returns a reference to the world to voxel space transform.
Definition: FieldMapping.h:381
Imath::Box3f Box3f
Definition: SpiMathLib.h:78
Represents the mapping of a field by a matrix transform.
Definition: FieldMapping.h:334
template<typename Field_T>
void MIPFieldWrapper< Field_T >::setValueRemapOp ( ValueRemapOp::Ptr  op)
inline

Definition at line 221 of file FieldWrapper.h.

References MIPFieldWrapper< Field_T >::valueRemapOp, and MIPFieldWrapper< Field_T >::valueRemapOpPtr.

222  {
223  valueRemapOpPtr = op;
225  }
const ValueRemapOp * valueRemapOp
Definition: FieldWrapper.h:245
ValueRemapOp::Ptr valueRemapOpPtr
Optionally, set a ValueRemapOp to remap values.
Definition: FieldWrapper.h:244

Member Data Documentation

template<typename Field_T>
boost::shared_ptr<LinearInterp> MIPFieldWrapper< Field_T >::interpPtr

Definition at line 227 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::MIPFieldWrapper().

template<typename Field_T>
LinearInterp* MIPFieldWrapper< Field_T >::interp

Definition at line 228 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::MIPFieldWrapper().

template<typename Field_T>
const Field_T* MIPFieldWrapper< Field_T >::field

Definition at line 229 of file FieldWrapper.h.

template<typename Field_T>
Field_T::Ptr MIPFieldWrapper< Field_T >::fieldPtr

Definition at line 230 of file FieldWrapper.h.

template<typename Field_T>
const Field3D::FieldMapping* MIPFieldWrapper< Field_T >::mapping

Definition at line 231 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setWsBoundsOptimization().

template<typename Field_T>
Box3d MIPFieldWrapper< Field_T >::vsBounds

Definition at line 232 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setWsBoundsOptimization().

template<typename Field_T>
M44d MIPFieldWrapper< Field_T >::osToWs

Optionally, enable doOsToWs to apply a world to object transform before lookups.

Definition at line 235 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setOsToWs().

template<typename Field_T>
M44d MIPFieldWrapper< Field_T >::wsToOs
template<typename Field_T>
double MIPFieldWrapper< Field_T >::worldScale

Definition at line 236 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setOsToWs().

template<typename Field_T>
bool MIPFieldWrapper< Field_T >::doOsToWs
template<typename Field_T>
M44d MIPFieldWrapper< Field_T >::wsToVs

Optionally, enable wsBounds optimization to use a world axis aligned bounding box in lookups.

Definition at line 240 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setWsBoundsOptimization().

template<typename Field_T>
Imath::Box3f MIPFieldWrapper< Field_T >::wsBounds

Definition at line 241 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setWsBoundsOptimization().

template<typename Field_T>
bool MIPFieldWrapper< Field_T >::doWsBoundsOptimization
template<typename Field_T>
ValueRemapOp::Ptr MIPFieldWrapper< Field_T >::valueRemapOpPtr

Optionally, set a ValueRemapOp to remap values.

Definition at line 244 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setValueRemapOp().

template<typename Field_T>
const ValueRemapOp* MIPFieldWrapper< Field_T >::valueRemapOp

Definition at line 245 of file FieldWrapper.h.

Referenced by MIPFieldWrapper< Field_T >::setValueRemapOp().


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