46#ifndef _INCLUDED_Field3D_FieldMapping_H_
47#define _INCLUDED_Field3D_FieldMapping_H_
92 typedef boost::intrusive_ptr<FieldMapping>
Ptr;
101 return "FieldMapping";
125 void setExtents(
const Box3i &extents);
165 virtual std::string className()
const = 0;
169 double tolerance = 0.0)
const = 0;
180 void localToVoxel(
const V3d &lsP,
V3d &vsP)
const;
182 void voxelToLocal(
const V3d &vsP,
V3d &lsP)
const;
212 const Box3d &wsBounds,
219 const Box3d &fromBounds,
243 typedef boost::intrusive_ptr<NullFieldMapping>
Ptr;
252 return "NullFieldMapping";
275 { localToVoxel(wsP, vsP); }
277 { localToVoxel(wsP, vsP); }
280 { voxelToLocal(vsP, wsP); }
282 { voxelToLocal(vsP, wsP); }
294 virtual std::string className()
const;
297 double tolerance = 0.0)
const;
300 {
return V3d(1.0 / m_res.x, 1.0 / m_res.y, 1.0 / m_res.z); }
341 typedef boost::intrusive_ptr<MatrixFieldMapping>
Ptr;
352 return "MatrixFieldMapping";
370 void setLocalToWorld(
const M44d &lsToWs);
372 void setLocalToWorld(
float t,
const M44d &lsToWs);
387 if (!m_isTimeVarying) {
390 return m_vsToWsCurve.linear(time).inverse();
401 {
return m_lsToWsCurve.samples(); }
413 { m_wsToVs.multVecMatrix(wsP, vsP); }
416 if (!m_isTimeVarying) {
417 m_wsToVs.multVecMatrix(wsP, vsP);
419 M44d wsToVs = m_vsToWsCurve.linear(time).inverse();
420 wsToVs.multVecMatrix(wsP, vsP);
425 { m_vsToWs.multVecMatrix(vsP, wsP); }
428 if (!m_isTimeVarying) {
429 m_vsToWs.multVecMatrix(vsP, wsP);
431 M44d vsToWs = m_vsToWsCurve.linear(time);
432 vsToWs.multVecMatrix(vsP, wsP);
437 { m_wsToLs.multVecMatrix(wsP, lsP); }
441 if (!m_isTimeVarying) {
442 m_wsToLs.multVecMatrix(wsP, lsP);
444 M44d wsToLs = m_lsToWsCurve.linear(time).inverse();
445 wsToLs.multVecMatrix(wsP, lsP);
450 { m_lsToWs.multVecMatrix(lsP, wsP); }
453 if (!m_isTimeVarying) {
454 m_lsToWs.multVecMatrix(lsP, wsP);
456 M44d lsToWs = m_lsToWsCurve.linear(time);
457 lsToWs.multVecMatrix(lsP, wsP);
463 { m_wsToVs.multDirMatrix(wsV, vsV); }
467 { m_vsToWs.multDirMatrix(vsV, wsV); }
471 { m_wsToLs.multDirMatrix(wsV, lsV); }
475 { m_lsToWs.multDirMatrix(lsV, wsV); }
477 virtual void extentsChanged();
479 virtual std::string className()
const;
482 double tolerance = 0.0)
const;
485 {
return m_wsVoxelSize; }
494 void updateTransform();
497 void getLocalToVoxelMatrix(
M44d &result);
571 typedef boost::intrusive_ptr<FrustumFieldMapping>
Ptr;
597 return "FrustumFieldMapping";
618 void setTransforms(
const M44d &ssToWs,
const M44d &csToWs);
623 void setTransforms(
float t,
const M44d &ssToWs,
const M44d &csToWs);
627 { m_zDistribution = dist; }
630 {
return m_zDistribution; }
635 {
return m_ssToWsCurve.linear(0.0); }
640 {
return m_csToWsCurve.linear(0.0); }
644 {
return m_ssToWsCurve.samples(); }
648 {
return m_csToWsCurve.samples(); }
652 {
return m_nearCurve.samples(); }
656 {
return m_farCurve.samples(); }
660 {
return m_nearCurve.linear(0.0); }
664 {
return m_farCurve.linear(0.0); }
679 virtual void voxelToWorld(
const V3d &vsP,
V3d &wsP)
const;
680 virtual void voxelToWorld(
const V3d &vsP,
V3d &wsP,
float time)
const;
682 virtual void worldToLocal(
const V3d &wsP,
V3d &lsP)
const;
683 virtual void worldToLocal(
const V3d &wsP,
V3d &lsP,
float time)
const;
685 virtual void localToWorld(
const V3d &lsP,
V3d &wsP)
const;
686 virtual void localToWorld(
const V3d &lsP,
V3d &wsP,
float time)
const;
688 virtual void extentsChanged();
690 virtual std::string className()
const;
693 double tolerance = 0.0)
const;
695 virtual V3d wsVoxelSize(
int i,
int j,
int k)
const;
704 void computeVoxelSize();
707 void getLocalToVoxelMatrix(
M44d &result);
Contains the Curve class which is used to interpolate attributes in time.
Contains Exception base class.
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
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 ...
void transformBounds(const M44d &mtx, const Box3d &fromBounds, Box3d &toBounds)
Transforms a bounding box by a 4x4 matrix This is done by transforming each corner vertex from world ...
bool isIdentical(typename Field< Data_T >::Ptr a, typename Field< Data_T >::Ptr b)
Checks whether the span and data in two different fields are identical.
Contains base class for reference counting with Mutex.
Contains typedefs for the commonly used types in Field3D.
Implements a simple function curve where samples of type T can be added along a 1D axis....
std::vector< Sample > SampleVec
Base class for mapping between world-, local- and voxel coordinates.
V3d m_origin
The integer voxel-space origin of the underlying Field object. Is equal to field.extents....
const V3d & resolution() const
Returns the resolution.
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
virtual V3d wsVoxelSize(int i, int j, int k) const =0
Returns world-space size of a voxel at the specified coordinate.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const =0
Transform from voxel space position into world space.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const =0
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
RefBase base
Convenience typedef for referring to base class.
boost::intrusive_ptr< FieldMapping > Ptr
V3d m_res
The integer voxel-space resolution of the underlying Field object. Is equal to field....
virtual Ptr clone() const =0
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const =0
Transform from world space position into local space.
const V3d & origin() const
Returns the origin.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const =0
Transform from world space position into voxel space.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const =0
Transform from local space position into world space.
virtual bool isIdentical(FieldMapping::Ptr other, double tolerance=0.0) const =0
Whether the mapping is identical to another mapping.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const =0
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const =0
static const char * staticClassType()
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const =0
Represents the mapping of a field by a perspective transform.
ZDistribution
Enumerates the Z slice distribution. .f3d files will store values as an int, so be very careful not t...
@ PerspectiveDistribution
MatrixCurve m_lpsToWsCurve
Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.
FieldMapping base
Convenience typedef for referring to base class.
bool m_defaultState
Boolean to tell us if the mapping is in its 'default' state. This is needed because the class has a d...
const FloatCurve::SampleVec & farPlaneSamples() const
Returns a vector of all motion samples for far plane.
Curve< double > FloatCurve
Time-varying float.
const MatrixCurve::SampleVec & cameraToWorldSamples() const
Returns a vector of all motion samples for camera to world transform.
MatrixCurve m_ssToWsCurve
Time-varying local perspective to world space transform This is not used in calculations,...
FloatCurve m_farCurve
Time-varying far plane. Computed from m_lpsToWsCurve.
void setZDistribution(ZDistribution dist)
Sets the z slice distribution.
const MatrixCurve::SampleVec & screenToWorldSamples() const
Returns a vector of all motion samples for screen to world transform.
std::vector< V3d > m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
ZDistribution zDistribution() const
Returns the z slice distribution.
boost::intrusive_ptr< FrustumFieldMapping > Ptr
Convenience typedef.
FloatCurve m_nearCurve
Time-varying near plane. Computed from m_lpsToWsCurve.
const M44d screenToWorld() const
Returns a reference to the screen to world space transform.
double farPlane() const
Returns the far plane.
const M44d cameraToWorld() const
Returns a reference to the camera to world space transform.
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
FrustumFieldMapping class_type
ZDistribution m_zDistribution
Slice distribution type.
double nearPlane() const
Returns the near plane.
static const char * staticClassType()
const FloatCurve::SampleVec & nearPlaneSamples() const
Returns a vector of all motion samples for near plane.
MatrixCurve m_csToWsCurve
Time-varying camera to world space transform.
Represents the mapping of a field by a matrix transform.
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
static const char * staticClassType()
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
void voxelToWorldDir(const V3d &vsV, V3d &wsV) const
const M44d & localToWorld() const
Returns a reference to the local to world transform.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
MatrixFieldMapping class_type
M44d m_wsToVs
World space to voxel space.
M44d m_wsToLs
World space to local space.
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const
DEFINE_FIELD_RTTI_CONCRETE_CLASS
M44d m_vsToWs
Voxel space to world space.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const
const M44d & voxelToWorld() const
Returns a reference to the voxel to world space transform.
M44d worldToVoxel(float time) const
Returns the world to voxel space transform at a given time.
const MatrixCurve::SampleVec & localToWorldSamples() const
Returns a vector of all motion samples for local to world transform.
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
const M44d & worldToVoxel() const
Returns a reference to the world to voxel space transform.
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.
void localToWorldDir(const V3d &lsV, V3d &wsV) const
FieldMapping base
Convenience typedef for referring to base class.
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
void worldToVoxelDir(const V3d &wsV, V3d &vsV) const
M44d m_lsToWs
Local space to world space.
Trivial class, world space is equal to local space, i.e. the field is contained in the unit cube [0....
FieldMapping base
Convenience typedef for referring to base class.
NullFieldMapping class_type
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float) const
boost::intrusive_ptr< NullFieldMapping > Ptr
Convenience typedef.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float) const
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float) const
static const char * staticClassType()
NullFieldMapping(const Box3i &extents)
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float) const
#define FIELD3D_NAMESPACE_HEADER_CLOSE