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)
 
int contToDisc (double contCoord)
 Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel. More...
 
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...
 
Box3i discreteBounds (const Box3d &bbox)
 
double discToCont (int discCoord)
 Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel. 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...
 
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (Field)
 
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (WritableField)
 
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (ResizableField)
 
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

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

Definition at line 478 of file Field.h.

Referenced by EmptyField< Data_T >::staticClassType(), and ProceduralField< Data_T >::~ProceduralField().

#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 484 of file Field.h.

Referenced by ResizableField< Data_T >::sizeChanged().

Function Documentation

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( Field  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( WritableField  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( ResizableField  )
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 1021 of file Field.h.

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

1024 {
1025  if (a->extents() != b->extents()) {
1026  return false;
1027  }
1028  if (a->dataWindow() != b->dataWindow()) {
1029  return false;
1030  }
1031  if (!a->mapping()->isIdentical(b->mapping(), tolerance)) {
1032  return false;
1033  }
1034  return true;
1035 }
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 1042 of file Field.h.

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

Referenced by FieldMapping::extentsChanged().

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

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

Definition at line 1066 of file Field.h.

References detail::floor().

Referenced by contToDisc().

1067 {
1068  return static_cast<int>(std::floor(contCoord));
1069 }
FIELD3D_VEC3_T< T > floor(const FIELD3D_VEC3_T< T > &v)
Floor function for Vec3.
Definition: CoordSys.h:95
double discToCont ( int  discCoord)
inline

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

Definition at line 1075 of file Field.h.

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

1076 {
1077  return static_cast<double>(discCoord) + 0.5;
1078 }
V2i contToDisc ( const V2d contCoord)
inline

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

Definition at line 1083 of file Field.h.

References contToDisc().

1084 {
1085  return V2i(contToDisc(contCoord.x), contToDisc(contCoord.y));
1086 }
Imath::V2i V2i
Definition: SpiMathLib.h:65
int contToDisc(double contCoord)
Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel...
Definition: Field.h:1066
V2d discToCont ( const V2i discCoord)
inline

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

Definition at line 1091 of file Field.h.

References discToCont().

1092 {
1093  return V2d(discToCont(discCoord.x), discToCont(discCoord.y));
1094 }
Imath::V2d V2d
Definition: SpiMathLib.h:67
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel...
Definition: Field.h:1075
V3i contToDisc ( const V3d contCoord)
inline

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

Definition at line 1099 of file Field.h.

References contToDisc().

1100 {
1101  return V3i(contToDisc(contCoord.x), contToDisc(contCoord.y),
1102  contToDisc(contCoord.z));
1103 }
Imath::V3i V3i
Definition: SpiMathLib.h:71
int contToDisc(double contCoord)
Goes from continuous coordinates to discrete coordinates See Graphics Gems - What is a pixel...
Definition: Field.h:1066
V3d discToCont ( const V3i discCoord)
inline

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

Definition at line 1108 of file Field.h.

References discToCont().

1109 {
1110  return V3d(discToCont(discCoord.x), discToCont(discCoord.y),
1111  discToCont(discCoord.z));
1112 }
Imath::V3d V3d
Definition: SpiMathLib.h:74
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel...
Definition: Field.h:1075
Box3d continuousBounds ( const Box3i bbox)
inline

Definition at line 1116 of file Field.h.

1117 {
1118  Box3d result;
1119  result.min.x = static_cast<float>(bbox.min.x);
1120  result.min.y = static_cast<float>(bbox.min.y);
1121  result.min.z = static_cast<float>(bbox.min.z);
1122  result.max.x = static_cast<float>(bbox.max.x + 1);
1123  result.max.y = static_cast<float>(bbox.max.y + 1);
1124  result.max.z = static_cast<float>(bbox.max.z + 1);
1125  return result;
1126 }
Imath::Box3d Box3d
Definition: SpiMathLib.h:79
Box3i discreteBounds ( const Box3d bbox)
inline

Definition at line 1130 of file Field.h.

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

Referenced by FieldSampler< WrapperVec_T, 1 >::getMinMax(), FieldSampler< WrapperVec_T, 3 >::getMinMax(), FieldSampler< WrapperVec_T, 1 >::getMinMaxMIP(), and FieldSampler< WrapperVec_T, 3 >::getMinMaxMIP().

1131 {
1132  Box3i result;
1133  result.min.x = static_cast<int>(std::floor(bbox.min.x));
1134  result.min.y = static_cast<int>(std::floor(bbox.min.y));
1135  result.min.z = static_cast<int>(std::floor(bbox.min.z));
1136  result.max.x = static_cast<int>(std::ceil(bbox.max.x));
1137  result.max.y = static_cast<int>(std::ceil(bbox.max.y));
1138  result.max.z = static_cast<int>(std::ceil(bbox.max.z));
1139  return result;
1140 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
FIELD3D_VEC3_T< T > floor(const FIELD3D_VEC3_T< T > &v)
Floor function for Vec3.
Definition: CoordSys.h:95
FIELD3D_VEC3_T< T > ceil(const FIELD3D_VEC3_T< T > &v)
Ceil function for Vec3.
Definition: CoordSys.h:105
Box3i clipBounds ( const Box3i bbox,
const Box3i bounds 
)
inline

Definition at line 1144 of file Field.h.

Referenced by detail::checkInputEmpty(), DenseField< Data_T >::getGrainBounds(), SparseField< Data_T >::getGrainBounds(), FieldSampler< WrapperVec_T, 1 >::getMinMax(), FieldSampler< WrapperVec_T, 3 >::getMinMax(), FieldSampler< WrapperVec_T, 1 >::getMinMaxMIP(), and FieldSampler< WrapperVec_T, 3 >::getMinMaxMIP().

1145 {
1146  Box3i result;
1147  result.min.x = std::max(bbox.min.x, bounds.min.x);
1148  result.min.y = std::max(bbox.min.y, bounds.min.y);
1149  result.min.z = std::max(bbox.min.z, bounds.min.z);
1150  result.max.x = std::min(bbox.max.x, bounds.max.x);
1151  result.max.y = std::min(bbox.max.y, bounds.max.y);
1152  result.max.z = std::min(bbox.max.z, bounds.max.z);
1153  return result;
1154 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
V3i indexToCoord ( const size_t  idx,
const V3i res 
)
inline

Definition at line 1186 of file Field.h.

References FIELD3D_NAMESPACE_HEADER_CLOSE.

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

1187 {
1188  const int i = idx % res.x;
1189  const int j = (idx / res.x) % res.y;
1190  const int k = idx / (res.x * res.y);
1191  return V3i(i, j, k);
1192 }
Imath::V3i V3i
Definition: SpiMathLib.h:71