Field3D
MatrixFieldMapping Class Reference

Represents the mapping of a field by a matrix transform. More...

#include <FieldMapping.h>

Inheritance diagram for MatrixFieldMapping:
FieldMapping RefBase

Public Types

typedef MatrixFieldMapping class_type
 
typedef Curve< Imath::M44dMatrixCurve
 Time-varying matrix. More...
 
typedef boost::intrusive_ptr< MatrixFieldMappingPtr
 Convenience typedef. More...
 
- Public Types inherited from FieldMapping
typedef FieldMapping class_type
 
typedef boost::intrusive_ptr< FieldMappingPtr
 
- Public Types inherited from RefBase
typedef boost::intrusive_ptr< RefBasePtr
 
typedef boost::weak_ptr< RefBaseWeakPtr
 

Public Member Functions

const M44dlocalToWorld () const
 Returns a reference to the local to world transform. More...
 
const MatrixCurve::SampleVeclocalToWorldSamples () const
 Returns a vector of all motion samples for local to world transform. More...
 
void makeIdentity ()
 Sets the transform to identity. This makes it functionally equivalent to a NullFieldMapping. More...
 
void setLocalToWorld (const M44d &lsToWs)
 Sets the local to world transform. All other matrices will be updated based on this. More...
 
void setLocalToWorld (float t, const M44d &lsToWs)
 Sets the local to world transform at a given time. More...
 
const M44dvoxelToWorld () const
 Returns a reference to the voxel to world space transform. More...
 
const M44dworldToVoxel () const
 Returns a reference to the world to voxel space transform. More...
 
Constructors & destructor
 MatrixFieldMapping ()
 
 MatrixFieldMapping (const Box3i &extents)
 
From FieldMapping
virtual void worldToVoxel (const V3d &wsP, V3d &vsP) const
 Transform from world space position into voxel space. More...
 
virtual void worldToVoxel (const V3d &wsP, V3d &vsP, float time) const
 
virtual void voxelToWorld (const V3d &vsP, V3d &wsP) const
 Transform from voxel space position into world space. More...
 
virtual void voxelToWorld (const V3d &vsP, V3d &wsP, float time) const
 
virtual void worldToLocal (const V3d &wsP, V3d &lsP) const
 Transform from world space position into local space. More...
 
virtual void worldToLocal (const V3d &wsP, V3d &lsP, float time) const
 
virtual void localToWorld (const V3d &lsP, V3d &wsP) const
 Transform from local space position into world space. More...
 
virtual void localToWorld (const V3d &lsP, V3d &wsP, float time) const
 
void worldToVoxelDir (const V3d &wsV, V3d &vsV) const
 
void voxelToWorldDir (const V3d &vsV, V3d &wsV) const
 
void worldToLocalDir (const V3d &wsV, V3d &lsV) const
 
void localToWorldDir (const V3d &lsV, V3d &wsV) const
 
virtual void extentsChanged ()
 Implement this if the subclass needs to update itself when the resolution changes. More...
 
virtual std::string className () const
 Returns the FieldMapping type name. Used when writing/reading from disk. More...
 
virtual bool isIdentical (FieldMapping::Ptr other, double tolerance=0.0) const
 Whether the mapping is identical to another mapping. More...
 
virtual V3d wsVoxelSize (int, int, int) const
 Returns world-space size of a voxel at the specified coordinate. More...
 
virtual FieldMapping::Ptr clone () const
 Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it. More...
 
- Public Member Functions inherited from FieldMapping
const V3dorigin () const
 Returns the origin. More...
 
const V3dresolution () const
 Returns the resolution. More...
 
void setExtents (const Box3i &extents)
 This sets the field extents information to use for defining the local coordinate space. More...
 
 FieldMapping ()
 Constructor. More...
 
 FieldMapping (const Box3i &extents)
 Construct with known extents. More...
 
virtual ~FieldMapping ()
 Destructor. More...
 
void localToVoxel (const V3d &lsP, V3d &vsP) const
 Transform from local space to voxel space. This is just a multiplication by the resolution of the Field that we're mapping. More...
 
void voxelToLocal (const V3d &vsP, V3d &lsP) const
 Inverse of localToVoxel. More...
 
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer. More...
 
size_t refcnt ()
 Used by boost::intrusive_pointer. More...
 
void unref () const
 Used by boost::intrusive_pointer. More...
 
WeakPtr weakPtr () const
 
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor. More...
 
RefBaseoperator= (const RefBase &)
 Assignment operator. More...
 
virtual ~RefBase ()
 Destructor. More...
 
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();. More...
 
bool matchRTTI (const char *typenameStr)
 Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones. More...
 

Static Public Member Functions

static const char * staticClassType ()
 
- Static Public Member Functions inherited from FieldMapping
static const char * staticClassType ()
 
- Static Public Member Functions inherited from RefBase
static const char * staticClassType ()
 

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS
 
- Public Attributes inherited from FieldMapping
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 

Private Types

typedef FieldMapping base
 Convenience typedef for referring to base class. More...
 

Private Member Functions

void getLocalToVoxelMatrix (M44d &result)
 
void updateTransform ()
 Updates the local to world transformation matrix. More...
 

Private Attributes

bool m_isTimeVarying
 Stores whether the curve has more than one time sample. More...
 
M44d m_lsToWs
 Local space to world space. More...
 
MatrixCurve m_lsToWsCurve
 Time-varying local to world space transform. More...
 
M44d m_vsToWs
 Voxel space to world space. More...
 
MatrixCurve m_vsToWsCurve
 Time-varying voxel to world space transform. More...
 
M44d m_wsToLs
 World space to local space. More...
 
M44d m_wsToVs
 World space to voxel space. More...
 
V3d m_wsVoxelSize
 Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency. More...
 

Additional Inherited Members

- Protected Attributes inherited from FieldMapping
V3d m_origin
 The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min. More...
 
V3d m_res
 The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1. More...
 

Detailed Description

Represents the mapping of a field by a matrix transform.

Refer to using_mappings for examples of how to use this in your code.

Note
Regarding time-varying matrices. If setLocalToWorld(M44d) is called, an underlying Curve object is created with just one sample at time=0.0.
Todo:
Add calls for easily specifying the transform given grid size, offset, rotation, etc.

Definition at line 327 of file FieldMapping.h.

Member Typedef Documentation

typedef boost::intrusive_ptr<MatrixFieldMapping> MatrixFieldMapping::Ptr

Convenience typedef.

Definition at line 334 of file FieldMapping.h.

Time-varying matrix.

Definition at line 336 of file FieldMapping.h.

Convenience typedef for referring to base class.

Definition at line 513 of file FieldMapping.h.

Constructor & Destructor Documentation

MatrixFieldMapping::MatrixFieldMapping ( )

Definition at line 229 of file FieldMapping.cpp.

References makeIdentity().

Referenced by clone().

230  : FieldMapping()
231 {
232  makeIdentity();
233 }
FieldMapping()
Constructor.
void makeIdentity()
Sets the transform to identity. This makes it functionally equivalent to a NullFieldMapping.
MatrixFieldMapping::MatrixFieldMapping ( const Box3i extents)

Definition at line 237 of file FieldMapping.cpp.

References makeIdentity().

238  : FieldMapping(extents)
239 {
240  makeIdentity();
241 }
FieldMapping()
Constructor.
void makeIdentity()
Sets the transform to identity. This makes it functionally equivalent to a NullFieldMapping.

Member Function Documentation

static const char* MatrixFieldMapping::staticClassType ( )
inlinestatic

Definition at line 343 of file FieldMapping.h.

Referenced by className().

344  {
345  return "MatrixFieldMapping";
346  }
void MatrixFieldMapping::setLocalToWorld ( const M44d lsToWs)

Sets the local to world transform. All other matrices will be updated based on this.

Note
This resets the Curve to contain just one sample at time=0.0

Definition at line 245 of file FieldMapping.cpp.

References m_lsToWsCurve, makeIdentity(), and Curve< T >::numSamples().

246 {
247  if (m_lsToWsCurve.numSamples() > 0) {
248  makeIdentity();
249  }
250  setLocalToWorld(0.0f, lsToWs);
251 }
size_t numSamples() const
Returns the number of samples in the curve.
Definition: Curve.h:99
void setLocalToWorld(const M44d &lsToWs)
Sets the local to world transform. All other matrices will be updated based on this.
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
void makeIdentity()
Sets the transform to identity. This makes it functionally equivalent to a NullFieldMapping.
void MatrixFieldMapping::setLocalToWorld ( float  t,
const M44d lsToWs 
)

Sets the local to world transform at a given time.

Definition at line 255 of file FieldMapping.cpp.

References Curve< T >::addSample(), m_lsToWsCurve, and updateTransform().

256 {
257  m_lsToWsCurve.addSample(t, lsToWs);
258  updateTransform();
259 }
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
void addSample(const float t, const T &value)
Adds a sample point to the curve.
Definition: Curve.h:172
void updateTransform()
Updates the local to world transformation matrix.
const M44d& MatrixFieldMapping::localToWorld ( ) const
inline

Returns a reference to the local to world transform.

Note
This assumes the query to be at time=0.0

Definition at line 369 of file FieldMapping.h.

370  { return m_lsToWs; }
M44d m_lsToWs
Local space to world space.
Definition: FieldMapping.h:486
const M44d& MatrixFieldMapping::worldToVoxel ( ) const
inline

Returns a reference to the world to voxel space transform.

Note
This assumes the query to be at time=0.0

Definition at line 374 of file FieldMapping.h.

375  { return m_wsToVs; }
M44d m_wsToVs
World space to voxel space.
Definition: FieldMapping.h:495
const M44d& MatrixFieldMapping::voxelToWorld ( ) const
inline

Returns a reference to the voxel to world space transform.

Note
This assumes the query to be at time=0.0

Definition at line 379 of file FieldMapping.h.

380  { return m_vsToWs; }
M44d m_vsToWs
Voxel space to world space.
Definition: FieldMapping.h:492
const MatrixCurve::SampleVec& MatrixFieldMapping::localToWorldSamples ( ) const
inline

Returns a vector of all motion samples for local to world transform.

Definition at line 383 of file FieldMapping.h.

384  { return m_lsToWsCurve.samples(); }
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
const SampleVec & samples() const
Returns a const reference to the samples in the curve.
Definition: Curve.h:103
void MatrixFieldMapping::makeIdentity ( )

Sets the transform to identity. This makes it functionally equivalent to a NullFieldMapping.

Definition at line 263 of file FieldMapping.cpp.

References Curve< T >::clear(), m_lsToWsCurve, and updateTransform().

Referenced by MatrixFieldMapping(), and setLocalToWorld().

264 {
266  updateTransform();
267 }
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
void updateTransform()
Updates the local to world transformation matrix.
void clear()
Clears all samples in curve.
Definition: Curve.h:107
virtual void MatrixFieldMapping::worldToVoxel ( const V3d wsP,
V3d vsP 
) const
inlinevirtual

Transform from world space position into voxel space.

Implements FieldMapping.

Definition at line 395 of file FieldMapping.h.

396  { m_wsToVs.multVecMatrix(wsP, vsP); }
M44d m_wsToVs
World space to voxel space.
Definition: FieldMapping.h:495
virtual void MatrixFieldMapping::worldToVoxel ( const V3d wsP,
V3d vsP,
float  time 
) const
inlinevirtual

Implements FieldMapping.

Definition at line 397 of file FieldMapping.h.

398  {
399  if (!m_isTimeVarying) {
400  m_wsToVs.multVecMatrix(wsP, vsP);
401  } else {
402  M44d wsToVs = m_vsToWsCurve.linear(time).inverse();
403  wsToVs.multVecMatrix(wsP, vsP);
404  }
405  }
Imath::M44d M44d
Definition: SpiMathLib.h:82
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
Definition: FieldMapping.h:500
T linear(const float t) const
Linearly interpolates a value from the curve.
Definition: Curve.h:199
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
Definition: FieldMapping.h:504
M44d m_wsToVs
World space to voxel space.
Definition: FieldMapping.h:495
virtual void MatrixFieldMapping::voxelToWorld ( const V3d vsP,
V3d wsP 
) const
inlinevirtual

Transform from voxel space position into world space.

Implements FieldMapping.

Definition at line 407 of file FieldMapping.h.

408  { m_vsToWs.multVecMatrix(vsP, wsP); }
M44d m_vsToWs
Voxel space to world space.
Definition: FieldMapping.h:492
virtual void MatrixFieldMapping::voxelToWorld ( const V3d vsP,
V3d wsP,
float  time 
) const
inlinevirtual

Implements FieldMapping.

Definition at line 409 of file FieldMapping.h.

410  {
411  if (!m_isTimeVarying) {
412  m_vsToWs.multVecMatrix(vsP, wsP);
413  } else {
414  M44d vsToWs = m_vsToWsCurve.linear(time);
415  vsToWs.multVecMatrix(vsP, wsP);
416  }
417  }
Imath::M44d M44d
Definition: SpiMathLib.h:82
M44d m_vsToWs
Voxel space to world space.
Definition: FieldMapping.h:492
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
Definition: FieldMapping.h:500
T linear(const float t) const
Linearly interpolates a value from the curve.
Definition: Curve.h:199
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
Definition: FieldMapping.h:504
virtual void MatrixFieldMapping::worldToLocal ( const V3d wsP,
V3d lsP 
) const
inlinevirtual

Transform from world space position into local space.

Implements FieldMapping.

Definition at line 419 of file FieldMapping.h.

Referenced by FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectMatrixMapping().

420  { m_wsToLs.multVecMatrix(wsP, lsP); }
M44d m_wsToLs
World space to local space.
Definition: FieldMapping.h:489
virtual void MatrixFieldMapping::worldToLocal ( const V3d wsP,
V3d lsP,
float  time 
) const
inlinevirtual

Implements FieldMapping.

Definition at line 421 of file FieldMapping.h.

423  {
424  if (!m_isTimeVarying) {
425  m_wsToLs.multVecMatrix(wsP, lsP);
426  } else {
427  M44d wsToLs = m_lsToWsCurve.linear(time).inverse();
428  wsToLs.multVecMatrix(wsP, lsP);
429  }
430  }
Imath::M44d M44d
Definition: SpiMathLib.h:82
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
T linear(const float t) const
Linearly interpolates a value from the curve.
Definition: Curve.h:199
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
Definition: FieldMapping.h:504
M44d m_wsToLs
World space to local space.
Definition: FieldMapping.h:489
virtual void MatrixFieldMapping::localToWorld ( const V3d lsP,
V3d wsP 
) const
inlinevirtual

Transform from local space position into world space.

Implements FieldMapping.

Definition at line 432 of file FieldMapping.h.

433  { m_lsToWs.multVecMatrix(lsP, wsP); }
M44d m_lsToWs
Local space to world space.
Definition: FieldMapping.h:486
virtual void MatrixFieldMapping::localToWorld ( const V3d lsP,
V3d wsP,
float  time 
) const
inlinevirtual

Implements FieldMapping.

Definition at line 434 of file FieldMapping.h.

435  {
436  if (!m_isTimeVarying) {
437  m_lsToWs.multVecMatrix(lsP, wsP);
438  } else {
439  M44d lsToWs = m_lsToWsCurve.linear(time);
440  lsToWs.multVecMatrix(lsP, wsP);
441  }
442  }
Imath::M44d M44d
Definition: SpiMathLib.h:82
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
M44d m_lsToWs
Local space to world space.
Definition: FieldMapping.h:486
T linear(const float t) const
Linearly interpolates a value from the curve.
Definition: Curve.h:199
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
Definition: FieldMapping.h:504
void MatrixFieldMapping::worldToVoxelDir ( const V3d wsV,
V3d vsV 
) const
inline
Todo:
Generalize and make time-dependent.

Definition at line 445 of file FieldMapping.h.

446  { m_wsToVs.multDirMatrix(wsV, vsV); }
M44d m_wsToVs
World space to voxel space.
Definition: FieldMapping.h:495
void MatrixFieldMapping::voxelToWorldDir ( const V3d vsV,
V3d wsV 
) const
inline
Todo:
Generalize and make time-dependent.

Definition at line 449 of file FieldMapping.h.

450  { m_vsToWs.multDirMatrix(vsV, wsV); }
M44d m_vsToWs
Voxel space to world space.
Definition: FieldMapping.h:492
void MatrixFieldMapping::worldToLocalDir ( const V3d wsV,
V3d lsV 
) const
inline
Todo:
Generalize and make time-dependent.

Definition at line 453 of file FieldMapping.h.

Referenced by FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectMatrixMapping().

454  { m_wsToLs.multDirMatrix(wsV, lsV); }
M44d m_wsToLs
World space to local space.
Definition: FieldMapping.h:489
void MatrixFieldMapping::localToWorldDir ( const V3d lsV,
V3d wsV 
) const
inline
Todo:
Generalize and make time-dependent.

Definition at line 457 of file FieldMapping.h.

References FieldMapping::className(), FieldMapping::extentsChanged(), and FieldMapping::isIdentical().

458  { m_lsToWs.multDirMatrix(lsV, wsV); }
M44d m_lsToWs
Local space to world space.
Definition: FieldMapping.h:486
void MatrixFieldMapping::extentsChanged ( )
virtual

Implement this if the subclass needs to update itself when the resolution changes.

Reimplemented from FieldMapping.

Definition at line 271 of file FieldMapping.cpp.

References updateTransform().

272 {
273  updateTransform();
274 }
void updateTransform()
Updates the local to world transformation matrix.
std::string MatrixFieldMapping::className ( ) const
virtual

Returns the FieldMapping type name. Used when writing/reading from disk.

Implements FieldMapping.

Definition at line 278 of file FieldMapping.cpp.

References staticClassType().

279 {
280  return std::string(staticClassType());
281 }
static const char * staticClassType()
Definition: FieldMapping.h:343
bool MatrixFieldMapping::isIdentical ( FieldMapping::Ptr  other,
double  tolerance = 0.0 
) const
virtual

Whether the mapping is identical to another mapping.

Implements FieldMapping.

Definition at line 285 of file FieldMapping.cpp.

References FIELD3D_NAMESPACE_OPEN::checkMatricesIdentical(), FIELD3D_NAMESPACE_OPEN::k_matrixMappingName(), m_lsToWsCurve, m_vsToWsCurve, and Curve< T >::samples().

287 {
289 
290  if (other->className() != k_matrixMappingName) {
291  return false;
292  } else {
293 
295  FIELD_DYNAMIC_CAST<MatrixFieldMapping>(other);
296 
297  if (mm) {
298 
299  const SampleVec lsToWs1 = m_lsToWsCurve.samples();
300  const SampleVec lsToWs2 = mm->m_lsToWsCurve.samples();
301  const SampleVec vsToWs1 = m_vsToWsCurve.samples();
302  const SampleVec vsToWs2 = mm->m_vsToWsCurve.samples();
303 
304  size_t numSamples = lsToWs1.size();
305 
306  // First check if time sample counts differ
307  // lsToWs and vsToWs are guaranteed to have same sample count.
308  if (lsToWs1.size() != lsToWs2.size()) {
309  return false;
310  }
311 
312  // Then check if all time samples match, then check localToWorld
313  // and voxelToWorld matrices
314  for (size_t i = 0; i < numSamples; ++i) {
315  if (lsToWs1[i].first != lsToWs2[i].first) {
316  return false;
317  }
318  if (!checkMatricesIdentical(lsToWs1[i].second, lsToWs2[i].second,
319  tolerance)) {
320  return false;
321  }
322  if (!checkMatricesIdentical(vsToWs1[i].second, vsToWs2[i].second,
323  tolerance)) {
324  return false;
325  }
326  }
327 
328  return true;
329 
330  } else {
331  return false;
332  }
333  }
334  return false;
335 }
const string k_matrixMappingName("MatrixFieldMapping")
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
Definition: FieldMapping.h:500
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
const SampleVec & samples() const
Returns a const reference to the samples in the curve.
Definition: Curve.h:103
std::vector< Sample > SampleVec
Definition: Curve.h:85
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
Definition: FieldMapping.h:334
bool checkMatricesIdentical(const Matrix_T &m1, const Matrix_T &m2, double tolerance)
virtual V3d MatrixFieldMapping::wsVoxelSize ( int  i,
int  j,
int  k 
) const
inlinevirtual

Returns world-space size of a voxel at the specified coordinate.

Implements FieldMapping.

Definition at line 467 of file FieldMapping.h.

References FieldMapping::clone().

Referenced by FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectMatrixMapping().

468  { return m_wsVoxelSize; }
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency...
Definition: FieldMapping.h:508
FieldMapping::Ptr MatrixFieldMapping::clone ( ) const
virtual

Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it.

Implements FieldMapping.

Definition at line 390 of file FieldMapping.cpp.

References MatrixFieldMapping().

391 {
392  return Ptr(new MatrixFieldMapping(*this));
393 }
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
Definition: FieldMapping.h:334
void MatrixFieldMapping::updateTransform ( )
private

Updates the local to world transformation matrix.

Definition at line 339 of file FieldMapping.cpp.

References Curve< T >::addSample(), Curve< T >::clear(), getLocalToVoxelMatrix(), Curve< T >::linear(), m_isTimeVarying, m_lsToWs, m_lsToWsCurve, m_vsToWs, m_vsToWsCurve, m_wsToLs, m_wsToVs, m_wsVoxelSize, Curve< T >::numSamples(), and Curve< T >::samples().

Referenced by extentsChanged(), makeIdentity(), and setLocalToWorld().

340 {
341  typedef MatrixCurve::SampleVec::const_iterator SampleIter;
342 
343  // Build the voxel to world space transforms ---
344  M44d lsToVs;
345  getLocalToVoxelMatrix(lsToVs);
346  M44d vsToLs = lsToVs.inverse();
347  // Loop over all samples in lsToWs, append vsToLs and create new curve
348  // Also handle the special case where lsToWs has no samples. In that
349  // case m_vsToWsCurve still has to have one sample.
350  const MatrixCurve::SampleVec &lsToWs = m_lsToWsCurve.samples();
352  for (SampleIter i = lsToWs.begin(), end = lsToWs.end(); i != end; i++) {
353  m_vsToWsCurve.addSample(i->first, vsToLs * i->second);
354  }
355 
356  // See if the curve has more than just a single sample
358 
359  // Sample the time-varying transforms at time=0.0
361  m_wsToLs = m_lsToWs.inverse();
362  m_vsToWs = vsToLs * m_lsToWs;
363  m_wsToVs = m_vsToWs.inverse();
364 
365  // Precompute the voxel size
366  V3d voxelOrigin, nextVoxel;
367  m_vsToWs.multVecMatrix(V3d(0, 0, 0), voxelOrigin);
368  m_vsToWs.multVecMatrix(V3d(1, 0, 0), nextVoxel);
369  m_wsVoxelSize.x = (nextVoxel - voxelOrigin).length();
370  m_vsToWs.multVecMatrix(V3d(0, 1, 0), nextVoxel);
371  m_wsVoxelSize.y = (nextVoxel - voxelOrigin).length();
372  m_vsToWs.multVecMatrix(V3d(0, 0, 1), nextVoxel);
373  m_wsVoxelSize.z = (nextVoxel - voxelOrigin).length();
374 }
Imath::M44d M44d
Definition: SpiMathLib.h:82
size_t numSamples() const
Returns the number of samples in the curve.
Definition: Curve.h:99
M44d m_vsToWs
Voxel space to world space.
Definition: FieldMapping.h:492
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
Definition: FieldMapping.h:500
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:498
M44d m_lsToWs
Local space to world space.
Definition: FieldMapping.h:486
void addSample(const float t, const T &value)
Adds a sample point to the curve.
Definition: Curve.h:172
Imath::V3d V3d
Definition: SpiMathLib.h:74
const SampleVec & samples() const
Returns a const reference to the samples in the curve.
Definition: Curve.h:103
T linear(const float t) const
Linearly interpolates a value from the curve.
Definition: Curve.h:199
void getLocalToVoxelMatrix(M44d &result)
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
Definition: FieldMapping.h:504
std::vector< Sample > SampleVec
Definition: Curve.h:85
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency...
Definition: FieldMapping.h:508
void clear()
Clears all samples in curve.
Definition: Curve.h:107
M44d m_wsToLs
World space to local space.
Definition: FieldMapping.h:489
M44d m_wsToVs
World space to voxel space.
Definition: FieldMapping.h:495
void MatrixFieldMapping::getLocalToVoxelMatrix ( M44d result)
private
Todo:
Unit test this

Definition at line 378 of file FieldMapping.cpp.

References FieldMapping::m_origin, and FieldMapping::m_res.

Referenced by updateTransform().

379 {
380  // Local to voxel is a scale by the resolution of the field, offset
381  // to the origin of the extents
382  M44d scaling, translation;
383  scaling.setScale(m_res);
384  translation.setTranslation(m_origin);
385  result = scaling * translation;
386 }
Imath::M44d M44d
Definition: SpiMathLib.h:82
V3d m_origin
The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min.
Definition: FieldMapping.h:190
V3d m_res
The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1.
Definition: FieldMapping.h:193

Member Data Documentation

MatrixFieldMapping::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 341 of file FieldMapping.h.

M44d MatrixFieldMapping::m_lsToWs
private

Local space to world space.

Note
This is used only when m_lsToWsCurve has zero or one samples.

Definition at line 486 of file FieldMapping.h.

Referenced by updateTransform().

M44d MatrixFieldMapping::m_wsToLs
private

World space to local space.

Note
This is used only when m_lsToWsCurve has zero or one samples.

Definition at line 489 of file FieldMapping.h.

Referenced by updateTransform().

M44d MatrixFieldMapping::m_vsToWs
private

Voxel space to world space.

Note
This is used only when m_lsToWsCurve has zero or one samples.

Definition at line 492 of file FieldMapping.h.

Referenced by updateTransform().

M44d MatrixFieldMapping::m_wsToVs
private

World space to voxel space.

Note
This is used only when m_lsToWsCurve has zero or one samples.

Definition at line 495 of file FieldMapping.h.

Referenced by updateTransform().

MatrixCurve MatrixFieldMapping::m_lsToWsCurve
private

Time-varying local to world space transform.

Definition at line 498 of file FieldMapping.h.

Referenced by isIdentical(), makeIdentity(), setLocalToWorld(), and updateTransform().

MatrixCurve MatrixFieldMapping::m_vsToWsCurve
private

Time-varying voxel to world space transform.

Definition at line 500 of file FieldMapping.h.

Referenced by isIdentical(), and updateTransform().

bool MatrixFieldMapping::m_isTimeVarying
private

Stores whether the curve has more than one time sample.

Note
This is set by updateTransform().

Definition at line 504 of file FieldMapping.h.

Referenced by updateTransform().

V3d MatrixFieldMapping::m_wsVoxelSize
private

Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.

Definition at line 508 of file FieldMapping.h.

Referenced by updateTransform().


The documentation for this class was generated from the following files: