Field3D
FieldMapping Class Referenceabstract

Base class for mapping between world-, local- and voxel coordinates. More...

#include <FieldMapping.h>

Inheritance diagram for FieldMapping:
RefBase FrustumFieldMapping MatrixFieldMapping NullFieldMapping

Public Types

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 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...
 
Constructors & destructor
 FieldMapping ()
 Constructor. More...
 
 FieldMapping (const Box3i &extents)
 Construct with known extents. More...
 
virtual ~FieldMapping ()
 Destructor. More...
 
To be implemented by subclasses
virtual Ptr clone () const =0
 Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it. More...
 
virtual void worldToVoxel (const V3d &wsP, V3d &vsP) const =0
 Transform from world space position into voxel space. More...
 
virtual void worldToVoxel (const V3d &wsP, V3d &vsP, float time) const =0
 
virtual void voxelToWorld (const V3d &vsP, V3d &wsP) const =0
 Transform from voxel space position into world space. More...
 
virtual void voxelToWorld (const V3d &vsP, V3d &wsP, float time) const =0
 
virtual void worldToLocal (const V3d &wsP, V3d &lsP) const =0
 Transform from world space position into local space. More...
 
virtual void worldToLocal (const V3d &wsP, V3d &lsP, float time) const =0
 
virtual void localToWorld (const V3d &lsP, V3d &wsP) const =0
 Transform from local space position into world space. More...
 
virtual void localToWorld (const V3d &lsP, V3d &wsP, float time) const =0
 
virtual V3d wsVoxelSize (int i, int j, int k) const =0
 Returns world-space size of a voxel at the specified coordinate. More...
 
virtual void extentsChanged ()
 Implement this if the subclass needs to update itself when the resolution changes. More...
 
virtual std::string className () const =0
 Returns the FieldMapping type name. Used when writing/reading from disk. More...
 
virtual bool isIdentical (FieldMapping::Ptr other, double tolerance=0.0) const =0
 Whether the mapping is identical to another mapping. More...
 
Transforms implemented in this class
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 RefBase
static const char * staticClassType ()
 

Public Attributes

 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 

Protected Attributes

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...
 

Private Types

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

Detailed Description

Base class for mapping between world-, local- and voxel coordinates.

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

Local coordinates (ls) are defined as [0,1] over the FieldData object's -extents- (not data window). Thus, if the extents.min isn't at origin, the coordinate system stays the same as if it was.

Voxel coordinates (vs) are defined as [0,size-1] over the FieldData object's -extents- (not data window).

Note
The center of a voxel at (i,j) in integer coordinates is (i+0.5,j+0.5) in continuous coordinates.

Definition at line 86 of file FieldMapping.h.

Member Typedef Documentation

typedef boost::intrusive_ptr<FieldMapping> FieldMapping::Ptr

Definition at line 92 of file FieldMapping.h.

Definition at line 96 of file FieldMapping.h.

typedef RefBase FieldMapping::base
private

Convenience typedef for referring to base class.

Definition at line 200 of file FieldMapping.h.

Constructor & Destructor Documentation

FieldMapping::FieldMapping ( )

Constructor.

Definition at line 113 of file FieldMapping.cpp.

114  : RefBase(),
115  m_origin(V3i(0)),
116  m_res(V3i(1))
117 {
118  /* Empty */
119 }
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
Imath::V3i V3i
Definition: SpiMathLib.h:71
RefBase()
Definition: RefCount.h:120
FieldMapping::FieldMapping ( const Box3i extents)

Construct with known extents.

Definition at line 123 of file FieldMapping.cpp.

References setExtents().

124  : RefBase()
125 {
126  setExtents(extents);
127 }
RefBase()
Definition: RefCount.h:120
void setExtents(const Box3i &extents)
This sets the field extents information to use for defining the local coordinate space.
FieldMapping::~FieldMapping ( )
virtual

Destructor.

Definition at line 131 of file FieldMapping.cpp.

132 {
133  /* Empty */
134 }

Member Function Documentation

static const char* FieldMapping::staticClassType ( )
inlinestatic

Definition at line 99 of file FieldMapping.h.

Referenced by className(), and NullFieldMapping::className().

100  {
101  return "FieldMapping";
102  }
void FieldMapping::setExtents ( const Box3i extents)

This sets the field extents information to use for defining the local coordinate space.

Note
You need to call this again if you change the resolution of the field after creation. We grab the extents information in this call because it would be too slow to do so in every transformation.

Definition at line 146 of file FieldMapping.cpp.

References extentsChanged(), m_origin, and m_res.

Referenced by FieldMapping().

147 {
148  m_origin = extents.min;
149  m_res = extents.max - extents.min + V3i(1);
150  extentsChanged();
151 }
V3d m_origin
The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min.
Definition: FieldMapping.h:190
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
Definition: FieldMapping.h:161
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
Imath::V3i V3i
Definition: SpiMathLib.h:71
const V3d& FieldMapping::origin ( ) const
inline

Returns the origin.

Definition at line 128 of file FieldMapping.h.

129  { return m_origin; }
V3d m_origin
The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min.
Definition: FieldMapping.h:190
const V3d& FieldMapping::resolution ( ) const
inline

Returns the resolution.

Definition at line 131 of file FieldMapping.h.

References worldToVoxel().

132  { return m_res; }
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
virtual Ptr FieldMapping::clone ( ) const
pure virtual

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

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane(), NullFieldMapping::wsVoxelSize(), and MatrixFieldMapping::wsVoxelSize().

virtual void FieldMapping::worldToVoxel ( const V3d wsP,
V3d vsP 
) const
pure virtual

Transform from world space position into voxel space.

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane().

virtual void FieldMapping::worldToVoxel ( const V3d wsP,
V3d vsP,
float  time 
) const
pure virtual
virtual void FieldMapping::voxelToWorld ( const V3d vsP,
V3d wsP 
) const
pure virtual

Transform from voxel space position into world space.

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane().

virtual void FieldMapping::voxelToWorld ( const V3d vsP,
V3d wsP,
float  time 
) const
pure virtual
virtual void FieldMapping::worldToLocal ( const V3d wsP,
V3d lsP 
) const
pure virtual

Transform from world space position into local space.

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane().

virtual void FieldMapping::worldToLocal ( const V3d wsP,
V3d lsP,
float  time 
) const
pure virtual
virtual void FieldMapping::localToWorld ( const V3d lsP,
V3d wsP 
) const
pure virtual

Transform from local space position into world space.

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane().

virtual void FieldMapping::localToWorld ( const V3d lsP,
V3d wsP,
float  time 
) const
pure virtual
virtual V3d FieldMapping::wsVoxelSize ( int  i,
int  j,
int  k 
) const
pure virtual

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

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane().

virtual void FieldMapping::extentsChanged ( )
inlinevirtual

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

Reimplemented in FrustumFieldMapping, and MatrixFieldMapping.

Definition at line 161 of file FieldMapping.h.

References isIdentical().

Referenced by FrustumFieldMapping::farPlane(), MatrixFieldMapping::localToWorldDir(), and setExtents().

162  { /* Empty */ }
std::string FieldMapping::className ( ) const
pure virtual

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

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Definition at line 139 of file FieldMapping.cpp.

References staticClassType().

Referenced by FrustumFieldMapping::farPlane(), NullFieldMapping::localToWorld(), and MatrixFieldMapping::localToWorldDir().

140 {
141  return std::string(staticClassType());
142 }
static const char * staticClassType()
Definition: FieldMapping.h:99
virtual bool FieldMapping::isIdentical ( FieldMapping::Ptr  other,
double  tolerance = 0.0 
) const
pure virtual

Whether the mapping is identical to another mapping.

Implemented in FrustumFieldMapping, MatrixFieldMapping, and NullFieldMapping.

Referenced by FrustumFieldMapping::farPlane(), NullFieldMapping::localToWorld(), and MatrixFieldMapping::localToWorldDir().

void FieldMapping::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.

Definition at line 155 of file FieldMapping.cpp.

References m_origin, and m_res.

Referenced by NullFieldMapping::worldToVoxel(), and FrustumFieldMapping::worldToVoxel().

156 {
157  vsP = m_origin + lsP * m_res;
158 }
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
void FieldMapping::voxelToLocal ( const V3d vsP,
V3d lsP 
) const

Inverse of localToVoxel.

Definition at line 162 of file FieldMapping.cpp.

References FIELD3D_LERPFACTOR, m_origin, and m_res.

Referenced by NullFieldMapping::voxelToWorld(), and FrustumFieldMapping::voxelToWorld().

163 {
164  lsP.x = FIELD3D_LERPFACTOR(vsP.x, m_origin.x, m_origin.x + m_res.x);
165  lsP.y = FIELD3D_LERPFACTOR(vsP.y, m_origin.y, m_origin.y + m_res.y);
166  lsP.z = FIELD3D_LERPFACTOR(vsP.z, m_origin.z, m_origin.z + m_res.z);
167 }
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
#define FIELD3D_LERPFACTOR
Definition: SpiMathLib.h:92

Member Data Documentation

FieldMapping::DEFINE_FIELD_RTTI_ABSTRACT_CLASS

Definition at line 97 of file FieldMapping.h.

V3d FieldMapping::m_origin
protected

The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min.

Definition at line 190 of file FieldMapping.h.

Referenced by FrustumFieldMapping::computeVoxelSize(), MatrixFieldMapping::getLocalToVoxelMatrix(), FrustumFieldMapping::getLocalToVoxelMatrix(), localToVoxel(), setExtents(), voxelToLocal(), and FrustumFieldMapping::wsVoxelSize().

V3d FieldMapping::m_res
protected

The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1.

Definition at line 193 of file FieldMapping.h.

Referenced by FrustumFieldMapping::computeVoxelSize(), MatrixFieldMapping::getLocalToVoxelMatrix(), FrustumFieldMapping::getLocalToVoxelMatrix(), localToVoxel(), setExtents(), voxelToLocal(), and FrustumFieldMapping::wsVoxelSize().


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