Field.h File Reference
Fields

Contains Field, WritableField and ResizableField classes. More...

`#include <cmath>`
`#include <vector>`
`#include <map>`
`#include <boost/intrusive_ptr.hpp>`
`#include <boost/thread/mutex.hpp>`
`#include "Traits.h"`
`#include "Exception.h"`
`#include "FieldMapping.h"`
`#include "FieldMetadata.h"`
`#include "Log.h"`
`#include "RefCount.h"`
`#include "Types.h"`
`#include "ns.h"`

Go to the source code of this file.

## Classes

class | Field< Data_T >
class | Field< Data_T >::const_iterator
class | FieldBase
class | FieldRes
class | ResizableField< Data_T >
class | WritableField< Data_T >
class | WritableField< Data_T >::iterator

## Namespaces

namespace | Exc
| Namespace for Exception objects.

## Macros

#define | FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
#define | FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(field)

## Functions

template<class Iter_T>
void | advance (Iter_T &iter, int num)
template<class Iter_T>
void | advance (Iter_T &iter, int num, const Iter_T &end)
Box3i | clipBounds (const Box3i &bbox, const Box3i &bounds)
Box3d | continuousBounds (const Box3i &bbox)
V2i | contToDisc (const V2d &contCoord)
| Goes from continuous coords to discrete for a 2-vector.
V3i | contToDisc (const V3d &contCoord)
| Goes from continuous coords to discrete for a 3-vector.
int | contToDisc (double contCoord)
| Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel.
Box3i | discreteBounds (const Box3d &bbox)
| Converts a floating point bounding box to an integer bounding box.
V2d | discToCont (const V2i &discCoord)
| Goes from discrete coords to continuous for a 2-vector.
V3d | discToCont (const V3i &discCoord)
| Goes from discrete coords to continuous for a 3-vector.
double | discToCont (int discCoord)
| Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (Field)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (ResizableField)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (WritableField)
V3i | indexToCoord (const size_t idx, const V3i &res)
template<class Data_T>
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.
template<class Data_T, class Data_T2>
bool | sameDefinition (typename Field< Data_T >::Ptr a, typename Field< Data_T2 >::Ptr b, double tolerance=0.0)
| Checks whether the mapping and resolution in two different fields are identical.

## Detailed Description

Contains Field, WritableField and ResizableField classes.

Definition in file Field.h.

## Macro Definition Documentation

## FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION

#define FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION

Value:
virtual std::string className() const \
{ return staticClassName(); } \
virtual std::string classType() const \
{ return staticClassType(); } \

Definition at line 473 of file Field.h.

#define FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION \
virtual std::string className() const \
{ return staticClassName(); } \
virtual std::string classType() const \
{ return staticClassType(); } \

Referenced by ProceduralField< half >::lsSample(), and EmptyField< float >::lvalue().

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION

#define FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( |  | field | ) |

Value:
template <typename Data_T> \
TemplatedFieldType<field<Data_T> > field<Data_T>::ms_classType = \
TemplatedFieldType<field<Data_T> >(); \
TemplatedFieldType
Used to return a string for the name of a templated field.
Definition Traits.h:283

Definition at line 479 of file Field.h.

#define FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(field) \
template <typename Data_T> \
TemplatedFieldType<field<Data_T> > field<Data_T>::ms_classType = \
TemplatedFieldType<field<Data_T> >(); \

## Function Documentation

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [1/3]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | Field |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [2/3]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | WritableField |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [3/3]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | ResizableField |  | ) |

## sameDefinition()

template<class Data_T, class Data_T2>

bool sameDefinition | ( | typename Field< Data_T >::Ptr | a,
|  | typename Field< Data_T2 >::Ptr | b,
|  | double | tolerance = 0.0 )

Checks whether the mapping and resolution in two different fields are identical.

Definition at line 1016 of file Field.h.

{
if (a->extents() != b->extents()) {
return false;
}
if (a->dataWindow() != b->dataWindow()) {
return false;
}
if (!a->mapping()->isIdentical(b->mapping(), tolerance)) {
return false;
}
return true;
}

References FieldRes::dataWindow(), FieldRes::extents(), and FieldRes::mapping().

Referenced by isIdentical().

## isIdentical()

template<class Data_T>

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.

Todo
  This should also check the mapping

Definition at line 1037 of file Field.h.

{
if (!sameDefinition<Data_T, Data_T>(a, b)) {
return false;
}
// If data window is the same, we can safely assume that the range of
// both fields' iterators are the same.
typename Field<Data_T>::const_iterator is1 = a->cbegin();
typename Field<Data_T>::const_iterator is2 = b->cbegin();
typename Field<Data_T>::const_iterator ie1 = a->cend();
bool same = true;
for (; is1 != ie1; ++is1, ++is2) {
if (*is1 != *is2) {
same = false;
break;
}
}
return same;
}
sameDefinition
bool sameDefinition(typename Field< Data_T >::Ptr a, typename Field< Data_T2 >::Ptr b, double tolerance=0.0)
Checks whether the mapping and resolution in two different fields are identical.
Definition Field.h:1016
Field::const_iterator
Definition Field.h:492

References Field< Data_T >::cbegin(), Field< Data_T >::cend(), and sameDefinition().

## contToDisc() [1/3]

int contToDisc | ( | double | contCoord | ) |

inline

Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel.

Definition at line 1061 of file Field.h.

{
return static_cast<int>(std::floor(contCoord));
}

Referenced by contToDisc(), and contToDisc().

## discToCont() [1/3]

double discToCont | ( | int | discCoord | ) |

inline

Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.

Definition at line 1070 of file Field.h.

{
return static_cast<double>(discCoord) + 0.5;
}

Referenced by FrustumFieldMapping::computeVoxelSize(), discToCont(), discToCont(), detail::MIPSeparableThreadOp< Field_T, FilterOp_T, IsAnalytic_T >::operator()(), and detail::separable().

## contToDisc() [2/3]

V2i contToDisc | ( | const V2d & | contCoord | ) |

inline

Goes from continuous coords to discrete for a 2-vector.

Definition at line 1078 of file Field.h.

{
return V2i(contToDisc(contCoord.x), contToDisc(contCoord.y));
}
contToDisc
int contToDisc(double contCoord)
Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel.
Definition Field.h:1061
V2i
Imath::V2i V2i
Definition SpiMathLib.h:65

References contToDisc().

## discToCont() [2/3]

V2d discToCont | ( | const V2i & | discCoord | ) |

inline

Goes from discrete coords to continuous for a 2-vector.

Definition at line 1086 of file Field.h.

{
return V2d(discToCont(discCoord.x), discToCont(discCoord.y));
}
discToCont
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.
Definition Field.h:1070
V2d
Imath::V2d V2d
Definition SpiMathLib.h:67

References discToCont().

## contToDisc() [3/3]

V3i contToDisc | ( | const V3d & | contCoord | ) |

inline

Goes from continuous coords to discrete for a 3-vector.

Definition at line 1094 of file Field.h.

{
return V3i(contToDisc(contCoord.x), contToDisc(contCoord.y),
contToDisc(contCoord.z));
}
V3i
Imath::V3i V3i
Definition SpiMathLib.h:71

References contToDisc().

## discToCont() [3/3]

V3d discToCont | ( | const V3i & | discCoord | ) |

inline

Goes from discrete coords to continuous for a 3-vector.

Definition at line 1103 of file Field.h.

{
return V3d(discToCont(discCoord.x), discToCont(discCoord.y),
discToCont(discCoord.z));
}
V3d
Imath::V3d V3d
Definition SpiMathLib.h:74

References discToCont().

## continuousBounds()

Box3d continuousBounds | ( | const Box3i & | bbox | ) |

inline

Definition at line 1111 of file Field.h.

{
Box3d result;
result.min.x = static_cast<float>(bbox.min.x);
result.min.y = static_cast<float>(bbox.min.y);
result.min.z = static_cast<float>(bbox.min.z);
result.max.x = static_cast<float>(bbox.max.x + 1);
result.max.y = static_cast<float>(bbox.max.y + 1);
result.max.z = static_cast<float>(bbox.max.z + 1);
return result;
}
Box3d
Imath::Box3d Box3d
Definition SpiMathLib.h:79

Referenced by blockCoords(), Vec<>::FieldWrapper(), and Vec<>::MIPFieldWrapper().

## discreteBounds()

Box3i discreteBounds | ( | const Box3d & | bbox | ) |

inline

Converts a floating point bounding box to an integer bounding box.

Note
  If the float-to-int conversion overflows, the result is set to be std::numeric_limits<int>::max()

Definition at line 1128 of file Field.h.

{
using std::floor;
using std::ceil;
Box3i result;
result.min.x = static_cast<int>(floor(clampForType<double, int>(bbox.min.x)));
result.min.y = static_cast<int>(floor(clampForType<double, int>(bbox.min.y)));
result.min.z = static_cast<int>(floor(clampForType<double, int>(bbox.min.z)));
result.max.x = static_cast<int>(ceil(clampForType<double, int>(bbox.max.x)));
result.max.y = static_cast<int>(ceil(clampForType<double, int>(bbox.max.y)));
result.max.z = static_cast<int>(ceil(clampForType<double, int>(bbox.max.z)));
return result;
}
Box3i
Imath::Box3i Box3i
Definition SpiMathLib.h:77
clampForType
To_T clampForType(const From_T v)
Definition Types.h:94
detail::ceil
FIELD3D_VEC3_T< T > ceil(const FIELD3D_VEC3_T< T > &v)
Ceil function for Vec3.
Definition CoordSys.h:114
detail::floor
FIELD3D_VEC3_T< T > floor(const FIELD3D_VEC3_T< T > &v)
Floor function for Vec3.
Definition CoordSys.h:104

References clampForType().

Referenced by FieldSampler< WrapperVec_T, Dims_T >::getMinMax(), FieldSampler< WrapperVec_T, Dims_T >::getMinMaxMIP(), and FieldSampler< WrapperVec_T, Dims_T >::getMinMaxPrefilt().

## clipBounds()

Box3i clipBounds | ( | const Box3i & | bbox,
|  | const Box3i & | bounds )

inline

Definition at line 1145 of file Field.h.

{
Box3i result;
result.min.x = std::max(bbox.min.x, bounds.min.x);
result.min.y = std::max(bbox.min.y, bounds.min.y);
result.min.z = std::max(bbox.min.z, bounds.min.z);
result.max.x = std::min(bbox.max.x, bounds.max.x);
result.max.y = std::min(bbox.max.y, bounds.max.y);
result.max.z = std::min(bbox.max.z, bounds.max.z);
return result;
}

Referenced by detail::checkInputEmpty(), SparseField< Data_T >::getGrainBounds(), FieldSampler< WrapperVec_T, Dims_T >::getMinMax(), FieldSampler< WrapperVec_T, Dims_T >::getMinMaxMIP(), and FieldSampler< WrapperVec_T, Dims_T >::getMinMaxPrefilt().

## indexToCoord()

V3i indexToCoord | ( | const size_t | idx,
|  | const V3i & | res )

inline

Definition at line 1187 of file Field.h.

{
const int i = idx % res.x;
const int j = (idx / res.x) % res.y;
const int k = idx / (res.x * res.y);
return V3i(i, j, k);
}

Referenced by SparseField< Data_T >::getGrainBounds().