Field3D
Field.h File Reference

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

 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. More...
 
V3i contToDisc (const V3d &contCoord)
 Goes from continuous coords to discrete for a 3-vector. More...
 
int contToDisc (double contCoord)
 Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel. More...
 
Box3i discreteBounds (const Box3d &bbox)
 Converts a floating point bounding box to an integer bounding box. More...
 
V2d discToCont (const V2i &discCoord)
 Goes from discrete coords to continuous for a 2-vector. More...
 
V3d discToCont (const V3i &discCoord)
 Goes from discrete coords to continuous for a 3-vector. More...
 
double discToCont (int discCoord)
 Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel. More...
 
 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. More...
 
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. More...
 

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.

◆ 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> >(); \

Definition at line 479 of file Field.h.

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.

1019 {
1020  if (a->extents() != b->extents()) {
1021  return false;
1022  }
1023  if (a->dataWindow() != b->dataWindow()) {
1024  return false;
1025  }
1026  if (!a->mapping()->isIdentical(b->mapping(), tolerance)) {
1027  return false;
1028  }
1029  return true;
1030 }

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

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

1038 {
1039  if (!sameDefinition<Data_T, Data_T>(a, b)) {
1040  return false;
1041  }
1042  // If data window is the same, we can safely assume that the range of
1043  // both fields' iterators are the same.
1044  typename Field<Data_T>::const_iterator is1 = a->cbegin();
1045  typename Field<Data_T>::const_iterator is2 = b->cbegin();
1046  typename Field<Data_T>::const_iterator ie1 = a->cend();
1047  bool same = true;
1048  for (; is1 != ie1; ++is1, ++is2) {
1049  if (*is1 != *is2) {
1050  same = false;
1051  break;
1052  }
1053  }
1054  return same;
1055 }

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

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

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

References detail::floor().

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

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

Referenced by FrustumFieldMapping::computeVoxelSize(), 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.

1079 {
1080  return V2i(contToDisc(contCoord.x), contToDisc(contCoord.y));
1081 }

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.

1087 {
1088  return V2d(discToCont(discCoord.x), discToCont(discCoord.y));
1089 }

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.

1095 {
1096  return V3i(contToDisc(contCoord.x), contToDisc(contCoord.y),
1097  contToDisc(contCoord.z));
1098 }

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.

1104 {
1105  return V3d(discToCont(discCoord.x), discToCont(discCoord.y),
1106  discToCont(discCoord.z));
1107 }

References discToCont().

◆ continuousBounds()

Box3d continuousBounds ( const Box3i bbox)
inline

Definition at line 1111 of file Field.h.

1112 {
1113  Box3d result;
1114  result.min.x = static_cast<float>(bbox.min.x);
1115  result.min.y = static_cast<float>(bbox.min.y);
1116  result.min.z = static_cast<float>(bbox.min.z);
1117  result.max.x = static_cast<float>(bbox.max.x + 1);
1118  result.max.y = static_cast<float>(bbox.max.y + 1);
1119  result.max.z = static_cast<float>(bbox.max.z + 1);
1120  return result;
1121 }

Referenced by blockCoords().

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

1129 {
1130  using std::floor;
1131  using std::ceil;
1132 
1133  Box3i result;
1134  result.min.x = static_cast<int>(floor(clampForType<double, int>(bbox.min.x)));
1135  result.min.y = static_cast<int>(floor(clampForType<double, int>(bbox.min.y)));
1136  result.min.z = static_cast<int>(floor(clampForType<double, int>(bbox.min.z)));
1137  result.max.x = static_cast<int>(ceil(clampForType<double, int>(bbox.max.x)));
1138  result.max.y = static_cast<int>(ceil(clampForType<double, int>(bbox.max.y)));
1139  result.max.z = static_cast<int>(ceil(clampForType<double, int>(bbox.max.z)));
1140  return result;
1141 }

References detail::ceil(), and detail::floor().

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.

1146 {
1147  Box3i result;
1148  result.min.x = std::max(bbox.min.x, bounds.min.x);
1149  result.min.y = std::max(bbox.min.y, bounds.min.y);
1150  result.min.z = std::max(bbox.min.z, bounds.min.z);
1151  result.max.x = std::min(bbox.max.x, bounds.max.x);
1152  result.max.y = std::min(bbox.max.y, bounds.max.y);
1153  result.max.z = std::min(bbox.max.z, bounds.max.z);
1154  return result;
1155 }

References detail::max(), and detail::min().

Referenced by detail::checkInputEmpty(), DenseField< Data_T >::getGrainBounds(), 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.

1188 {
1189  const int i = idx % res.x;
1190  const int j = (idx / res.x) % res.y;
1191  const int k = idx / (res.x * res.y);
1192  return V3i(i, j, k);
1193 }

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

V3i
Imath::V3i V3i
Definition: SpiMathLib.h:71
contToDisc
int contToDisc(double contCoord)
Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel.
Definition: Field.h:1061
V3d
Imath::V3d V3d
Definition: SpiMathLib.h:74
discToCont
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.
Definition: Field.h:1070
Field::const_iterator
Definition: Field.h:491
detail::floor
FIELD3D_VEC3_T< T > floor(const FIELD3D_VEC3_T< T > &v)
Floor function for Vec3.
Definition: CoordSys.h:104
detail::max
T max(const T a, const T2 b)
Max operation on mixed types.
Definition: FieldSampler.h:32
V2i
Imath::V2i V2i
Definition: SpiMathLib.h:65
Box3d
Imath::Box3d Box3d
Definition: SpiMathLib.h:79
detail::ceil
FIELD3D_VEC3_T< T > ceil(const FIELD3D_VEC3_T< T > &v)
Ceil function for Vec3.
Definition: CoordSys.h:114
V2d
Imath::V2d V2d
Definition: SpiMathLib.h:67
Box3i
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
detail::min
T min(const T a, const T2 b)
Min operation on mixed types.
Definition: FieldSampler.h:25