44#ifndef _INCLUDED_Field3D_DenseField_H_
45#define _INCLUDED_Field3D_DenseField_H_
49#include <boost/lexical_cast.hpp>
63template <
class Field_T>
65template <
class Field_T>
84template <
class Data_T>
92 typedef boost::intrusive_ptr<DenseField>
Ptr;
93 typedef std::vector<Ptr>
Vec;
126 virtual Data_T
value(
int i,
int j,
int k)
const;
149 virtual Data_T&
lvalue(
int i,
int j,
int k);
165 class const_iterator;
235 inline Data_T*
ptr(
int i,
int j,
int k);
237 inline const Data_T*
ptr(
int i,
int j,
int k)
const;
256template <
class Data_T>
260#if defined(WIN32) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
261 typedef std::forward_iterator_tag iterator_category;
263 typedef ptrdiff_t difference_type;
264 typedef ptrdiff_t distance_type;
265 typedef const Data_T *pointer;
266 typedef const Data_T& reference;
276 const V3i ¤tPos)
277 :
x(currentPos.
x),
y(currentPos.
y),
z(currentPos.
z),
280 if (window.intersects(currentPos))
307 template <
class Iter_T>
308 inline bool operator == (
const Iter_T &rhs)
const
310 return m_p == &(*rhs);
313 template <
class Iter_T>
314 inline bool operator != (
const Iter_T &rhs)
const
316 return m_p != &(*rhs);
324 inline const Data_T* operator -> ()
const
351template <
class Data_T>
355#if defined(WIN32) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
356 typedef std::forward_iterator_tag iterator_category;
358 typedef ptrdiff_t difference_type;
359 typedef ptrdiff_t distance_type;
360 typedef Data_T *pointer;
361 typedef Data_T& reference;
371 const V3i ¤tPos)
372 :
x(currentPos.
x),
y(currentPos.
y),
z(currentPos.
z),
375 if (window.intersects(currentPos))
402 template <
class Iter_T>
403 inline bool operator == (
const Iter_T &rhs)
const
405 return m_p == &(*rhs);
408 template <
class Iter_T>
409 inline bool operator != (
const Iter_T &rhs)
const
411 return m_p != &(*rhs);
419 inline Data_T* operator -> ()
const
445template <
class Data_T>
455template <
class Data_T>
463template <
class Data_T>
469 return res.y * res.z;
474template <
class Data_T>
480 const int y = idx % res.y;
481 const int z = idx / res.y;
492template <
class Data_T>
500template <
class Data_T>
504 long long int vectorMemSize =
m_data.capacity() *
sizeof(Data_T);
505 return sizeof(*this) + vectorMemSize + superClassMemSize;
510template <
class Data_T>
518template <
class Data_T>
537template <
class Data_T>
556template <
class Data_T>
567template <
class Data_T>
571 if (subset.isEmpty())
578template <
class Data_T>
590template <
class Data_T>
595 V3i(subset.min.x, subset.min.y, subset.max.z + 1));
600template <
class Data_T>
610template <
class Data_T>
614 if (subset.isEmpty())
616 return iterator(*
this, subset, subset.min);
621template <
class Data_T>
633template <
class Data_T>
638 V3i(subset.min.x, subset.min.y, subset.max.z + 1));
643template <
class Data_T>
657 throw Exc::ResizeException(
"Attempt to resize ResizableField object "
658 "using negative size. Data window was: " +
659 boost::lexical_cast<std::string>(
661 boost::lexical_cast<std::string>(
666 std::vector<Data_T>().swap(
m_data);
669 catch (std::bad_alloc &) {
670 throw Exc::MemoryException(
"Couldn't allocate DenseField of size " +
671 boost::lexical_cast<std::string>(
m_memSize));
677template <
class Data_T>
690template <
class Data_T>
DenseField< V3d > DenseField3d
DenseField< float > DenseFieldf
DenseField< V3h > DenseField3h
DenseField< half > DenseFieldh
DenseField< V3f > DenseField3f
DenseField< double > DenseFieldd
FIELD3D_VEC3_T< T > operator*(S s, const FIELD3D_VEC3_T< T > vec)
Scalar times Vec3 multiplication. Makes the interpolation calls cleaner.
Contains Field, WritableField and ResizableField classes.
#define FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(field)
#define DEFINE_FIELD_RTTI_CONCRETE_CLASS
const Data_T * m_p
Pointer to current element.
const_iterator(const class_type &field, const Box3i &window, const V3i ¤tPos)
const class_type & m_field
Reference to field being iterated over.
Box3i m_window
Window to traverse.
DenseField< Data_T > class_type
Data_T * m_p
Pointer to current element.
DenseField< Data_T > class_type
class_type & m_field
Reference to field being iterated over.
iterator(class_type &field, const Box3i &window, const V3i ¤tPos)
Box3i m_window
Window to traverse.
This subclass of Field stores data in a contiguous std::vector.
virtual long long int memSize() const
Returns the memory usage (in bytes)
iterator end()
Iterator pointing one element past the last valid one.
const Data_T & fastValue(int i, int j, int k) const
Read access to voxel. Notice that this is non-virtual.
iterator begin(const Box3i &subset)
Iterator to first element of specific subset.
std::vector< half > m_data
virtual Data_T & lvalue(int i, int j, int k)
Write access to a voxel. The coordinates are global coordinates.
Data_T & fastLValue(int i, int j, int k)
Write access to voxel. Notice that this is non-virtual.
iterator end(const Box3i &subset)
Iterator pointing one element past the last valid one (for a subset)
CubicGenericFieldInterp< DenseField< Data_T > > CubicInterp
DenseField()
Constructs an empty buffer.
virtual void clear(const Data_T &value)
Clears all the voxels in the storage.
LinearGenericFieldInterp< DenseField< Data_T > > LinearInterp
FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
const_iterator cbegin() const
Const iterator to first element. "cbegin" matches the tr1 c++ standard.
const_iterator cend() const
Const iterator pointing one element past the last valid one.
const FIELD3D_VEC3_T< size_t > & internalMemSize() const
Returns the internal memory size in each dimension. This is used for example in LinearInterpolator,...
virtual FieldBase::Ptr clone() const
Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement i...
const_iterator cbegin(const Box3i &subset) const
Const iterator to first element of specific subset.
iterator begin()
Iterator to first element.
const_iterator cend(const Box3i &subset) const
Const iterator pointing one element past the last valid one (for a subset)
bool getGrainBounds(const size_t idx, Box3i &vsBounds) const
Bounding box of the given 'grain'.
virtual void sizeChanged()
Subclasses should re-implement this if they need to perform memory allocations, etc....
Data_T * ptr(int i, int j, int k)
Returns a pointer to a given element. Used by the iterators mainly.
static DEFINE_FIELD_RTTI_CONCRETE_CLASS const char * staticClassName()
static TemplatedFieldType< DenseField< Data_T > > ms_classType
DenseField< Data_T > class_type
size_t numGrains() const
Number of 'grains' to use with threaded access.
FIELD3D_VEC3_T< size_t > m_memSize
static const char * staticClassType()
ResizableField< Data_T > base
const Data_T * ptr(int i, int j, int k) const
Returns a pointer to a given element. Used by the iterators mainly.
virtual half value(int i, int j, int k) const
boost::intrusive_ptr< DenseField > Ptr
boost::intrusive_ptr< FieldBase > Ptr
V3i const dataResolution() const
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e....
virtual long long int memSize() const
Returns the memory usage (in bytes)
Data_T value_type
Allows us to reference the template class.
virtual void sizeChanged()
Subclasses should re-implement this if they need to perform memory allocations, etc....
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Used to return a string for the name of a templated field.