Go to the documentation of this file.
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";
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); }
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); }
693 double tolerance = 0.0)
const;
704 void computeVoxelSize();
707 void getLocalToVoxelMatrix(
M44d &result);
755 #endif // Include guard
const M44d & worldToVoxel() const
Returns a reference to the world to voxel space transform.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
#define FIELD3D_NAMESPACE_HEADER_CLOSE
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
M44d m_wsToLs
World space to local space.
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 ...
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
Contains typedefs for the commonly used types in Field3D.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float) const
void setZDistribution(ZDistribution dist)
Sets the z slice distribution.
FieldMapping base
Convenience typedef for referring to base class.
V3d m_res
The integer voxel-space resolution of the underlying Field object. Is equal to field....
boost::intrusive_ptr< NullFieldMapping > Ptr
Convenience typedef.
Curve< double > FloatCurve
Time-varying float.
static const char * staticClassType()
FloatCurve m_farCurve
Time-varying far plane. Computed from m_lpsToWsCurve.
const M44d & voxelToWorld() const
Returns a reference to the voxel to world space transform.
Trivial class, world space is equal to local space, i.e. the field is contained in the unit cube [0....
FrustumFieldMapping class_type
boost::intrusive_ptr< FieldMapping > Ptr
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
M44d m_wsToVs
World space to voxel space.
virtual bool isIdentical(FieldMapping::Ptr other, double tolerance=0.0) const =0
Whether the mapping is identical to another mapping.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
const MatrixCurve::SampleVec & screenToWorldSamples() const
Returns a vector of all motion samples for screen to world transform.
virtual V3d wsVoxelSize(int i, int j, int k) const =0
Returns world-space size of a voxel at the specified coordinate.
Contains base class for reference counting with Mutex.
void voxelToWorldDir(const V3d &vsV, V3d &wsV) const
static const char * staticClassType()
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.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
ZDistribution zDistribution() const
Returns the z slice distribution.
ZDistribution m_zDistribution
Slice distribution type.
virtual std::string className() const =0
Returns the FieldMapping type name. Used when writing/reading from disk.
void voxelToLocal(const V3d &vsP, V3d &lsP) const
Inverse of localToVoxel.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const
Base class for mapping between world-, local- and voxel coordinates.
const M44d screenToWorld() const
Returns a reference to the screen to world space transform.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const =0
Contains Exception base class.
const M44d & localToWorld() const
Returns a reference to the local to world transform.
const FloatCurve::SampleVec & farPlaneSamples() const
Returns a vector of all motion samples for far plane.
boost::intrusive_ptr< FrustumFieldMapping > Ptr
Convenience typedef.
MatrixCurve m_csToWsCurve
Time-varying camera to world space transform.
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
static const char * staticClassType()
RefBase base
Convenience typedef for referring to base class.
V3d m_origin
The integer voxel-space origin of the underlying Field object. Is equal to field.extents....
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
MatrixFieldMapping class_type
MatrixCurve m_ssToWsCurve
Time-varying local perspective to world space transform This is not used in calculations,...
M44d m_lsToWs
Local space to world space.
FieldMapping base
Convenience typedef for referring to base class.
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float) const
const MatrixCurve::SampleVec & cameraToWorldSamples() const
Returns a vector of all motion samples for camera to world transform.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
const FloatCurve::SampleVec & nearPlaneSamples() const
Returns a vector of all motion samples for near plane.
MatrixCurve m_lpsToWsCurve
Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const =0
virtual Ptr clone() const =0
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.
double farPlane() const
Returns the far plane.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const =0
M44d worldToVoxel(float time) const
Returns the world to voxel space transform at a given time.
bool m_defaultState
Boolean to tell us if the mapping is in its 'default' state. This is needed because the class has a d...
Represents the mapping of a field by a matrix transform.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float) const
const MatrixCurve::SampleVec & localToWorldSamples() const
Returns a vector of all motion samples for local to world transform.
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 time) const
void worldToVoxelDir(const V3d &wsV, V3d &vsV) const
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
ZDistribution
Enumerates the Z slice distribution. .f3d files will store values as an int, so be very careful not t...
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const =0
Transform from voxel space position into world space.
M44d m_vsToWs
Voxel space to world space.
std::vector< Sample > SampleVec
const M44d cameraToWorld() const
Returns a reference to the camera to world space transform.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const =0
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.
NullFieldMapping(const Box3i &extents)
Contains the Curve class which is used to interpolate attributes in time.
static const char * staticClassType()
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const
FloatCurve m_nearCurve
Time-varying near plane. Computed from m_lpsToWsCurve.
NullFieldMapping class_type
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
const V3d & resolution() const
Returns the resolution.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
FieldMapping base
Convenience typedef for referring to base 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 Fie...
Represents the mapping of a field by a perspective transform.
const V3d & origin() const
Returns the origin.
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 ...
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const =0
Transform from world space position into voxel space.
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
void localToWorldDir(const V3d &lsV, V3d &wsV) const
std::vector< V3d > m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.
@ PerspectiveDistribution
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float) const
double nearPlane() const
Returns the near plane.