Field3D
ResizableField< Data_T > Class Template Reference

#include <Field.h>

Inheritance diagram for ResizableField< Data_T >:
WritableField< Data_T > Field< Data_T > FieldRes FieldBase RefBase DenseField< Data_T > EmptyField< Data_T > MACField< Data_T > SparseField< Data_T >

List of all members.

Public Types

typedef ResizableField< Data_T > class_type
typedef boost::intrusive_ptr
< ResizableField
Ptr

Public Member Functions

void copyFrom (typename Field< Data_T >::Ptr other)
 Copies the data from another Field, also resizes.
template<class Data_T2 >
void copyFrom (typename Field< Data_T2 >::Ptr other)
 Copies the data from another Field of another template class, also resizes.
void matchDefinition (FieldRes::Ptr fieldToMatch)
 Sets up this field so that resolution and mapping matches the other.
void setSize (const Box3i &extents)
 Resizes the object.
void setSize (const V3i &size, int padding)
 Resizes the object with padding.
void setSize (const Box3i &extents, const Box3i &dataWindow)
 Resizes the object.
void setSize (const V3i &size)
 Resizes the object.

Static Public Member Functions

static const char * classType ()
static const char * staticClassName ()

Public Attributes

 DEFINE_FIELD_RTTI_ABSTRACT_CLASS

Protected Types

typedef WritableField< Data_T > base
 Convenience typedef for referring to base class.

Protected Member Functions

virtual void sizeChanged ()
 Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes.

Static Protected Attributes

static TemplatedFieldType
< ResizableField< Data_T > > 
ms_classType

Detailed Description

template<class Data_T>
class ResizableField< Data_T >

This class adds the ability to resize the data storage object. Most Field subclasses will derive from this class. Only classes that cannot implement sizeChanged() in a reasonable manner should derive from Field or WritableField.

Definition at line 798 of file Field.h.


Member Typedef Documentation

template<class Data_T >
typedef boost::intrusive_ptr<ResizableField> ResizableField< Data_T >::Ptr

Reimplemented from WritableField< Data_T >.

Reimplemented in DenseField< Data_T >, EmptyField< Data_T >, MACField< Data_T >, and SparseField< Data_T >.

Definition at line 805 of file Field.h.

template<class Data_T >
typedef ResizableField<Data_T> ResizableField< Data_T >::class_type

Reimplemented from WritableField< Data_T >.

Reimplemented in DenseField< Data_T >, EmptyField< Data_T >, MACField< Data_T >, and SparseField< Data_T >.

Definition at line 809 of file Field.h.

template<class Data_T >
typedef WritableField<Data_T> ResizableField< Data_T >::base [protected]

Convenience typedef for referring to base class.

Reimplemented from WritableField< Data_T >.

Reimplemented in DenseField< Data_T >, EmptyField< Data_T >, MACField< Data_T >, and SparseField< Data_T >.

Definition at line 859 of file Field.h.


Member Function Documentation

template<class Data_T >
static const char* ResizableField< Data_T >::staticClassName ( ) [inline, static]

Reimplemented from WritableField< Data_T >.

Reimplemented in DenseField< Data_T >, MACField< Data_T >, and SparseField< Data_T >.

Definition at line 812 of file Field.h.

  {
    return "ResizableField";
  }
template<class Data_T >
static const char* ResizableField< Data_T >::classType ( ) [inline, static]
template<class Data_T >
void ResizableField< Data_T >::setSize ( const V3i size)

Resizes the object.

Warning:
Never call this from a constructor. It calls the virtual function sizeChanged().

Definition at line 878 of file Field.h.

Referenced by convertCellCenteredToMAC(), SparseFieldIO::read(), MACFieldIO::read(), DenseFieldIO::readData(), and Field3DInputFile::readProxyLayer().

{
  Field<Data_T>::m_extents.min = V3i(0);
  Field<Data_T>::m_extents.max = size - V3i(1);
  Field<Data_T>::m_dataWindow = Field<Data_T>::m_extents;

  // Tell subclasses that the size changed so they can update themselves.
  sizeChanged();
}
template<class Data_T >
void ResizableField< Data_T >::setSize ( const Box3i extents)

Resizes the object.

Warning:
Never call this from a constructor. It calls the virtual function sizeChanged().

Definition at line 891 of file Field.h.

{ 
  Field<Data_T>::m_extents = extents;
  Field<Data_T>::m_dataWindow = extents;
  // Tell subclasses that the size changed so they can update themselves.
  sizeChanged();
}
template<class Data_T >
void ResizableField< Data_T >::setSize ( const Box3i extents,
const Box3i dataWindow 
)

Resizes the object.

Warning:
Never call this from a constructor. It calls the virtual function sizeChanged().

Definition at line 902 of file Field.h.

{ 
    
  Field<Data_T>::m_extents = extents;
  Field<Data_T>::m_dataWindow = dataWindow;
  // Tell subclasses that the size changed so they can update themselves.
  sizeChanged();
}
template<class Data_T >
void ResizableField< Data_T >::setSize ( const V3i size,
int  padding 
)

Resizes the object with padding.

Warning:
Never call this from a constructor. It calls the virtual function sizeChanged().

Definition at line 915 of file Field.h.

{ 
  setSize(Box3i(V3i(0), size - V3i(1)),
          Box3i(V3i(-padding), 
                size + V3i(padding - 1))); 
}
template<class Data_T >
void ResizableField< Data_T >::copyFrom ( typename Field< Data_T >::Ptr  other)

Copies the data from another Field, also resizes.

Definition at line 925 of file Field.h.

References Field< Data_T >::cbegin(), FieldRes::dataWindow(), FieldRes::extents(), FieldRes::mapping(), and FieldRes::setMapping().

{
  // Set mapping
  FieldRes::setMapping(other->mapping());
  // Set size to match
  setSize(other->extents(), other->dataWindow());

  // Copy over the data
  typename base::iterator i = base::begin();
  typename base::iterator end = base::end();
  typename Field<Data_T>::const_iterator c = other->cbegin();
  for (; i != end; ++i, ++c)
    *i = *c;
}
template<class Data_T >
template<class Data_T2 >
void ResizableField< Data_T >::copyFrom ( typename Field< Data_T2 >::Ptr  other)

Copies the data from another Field of another template class, also resizes.

Definition at line 944 of file Field.h.

References Field< Data_T >::cbegin(), FieldRes::dataWindow(), FieldRes::extents(), and FieldRes::mapping().

{
  // Set mapping
  setMapping(other->mapping());
  // Set size to match
  setSize(other->extents(), other->dataWindow());
  // Copy over the data
  typename base::iterator i = base::begin();
  typename base::iterator end = base::end();
  typename Field<Data_T2>::const_iterator c = other->cbegin();
  for (; i != end; ++i, ++c)
    *i = *c;
}
template<class Data_T >
void ResizableField< Data_T >::matchDefinition ( FieldRes::Ptr  fieldToMatch)

Sets up this field so that resolution and mapping matches the other.

Definition at line 961 of file Field.h.

References FieldRes::setMapping().

Referenced by MACField< Data_T >::copyMAC().

{
  setSize(fieldToMatch->extents(), fieldToMatch->dataWindow());
  FieldRes::setMapping(fieldToMatch->mapping());
}
template<class Data_T >
virtual void ResizableField< Data_T >::sizeChanged ( ) [inline, protected, virtual]

Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes.

Note:
Make sure to call the base class version in subclasses!

Reimplemented in DenseField< Data_T >, MACField< Data_T >, and SparseField< Data_T >.

Definition at line 866 of file Field.h.

References FieldRes::m_extents, and FieldRes::m_mapping.

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

  { base::m_mapping->setExtents(base::m_extents); }

Member Data Documentation

template<class Data_T >
ResizableField< Data_T >::DEFINE_FIELD_RTTI_ABSTRACT_CLASS

Reimplemented from WritableField< Data_T >.

Definition at line 810 of file Field.h.

template<class Data_T >
TemplatedFieldType<ResizableField<Data_T> > ResizableField< Data_T >::ms_classType [static, protected]

Reimplemented from WritableField< Data_T >.

Reimplemented in DenseField< Data_T >, MACField< Data_T >, and SparseField< Data_T >.

Definition at line 855 of file Field.h.


The documentation for this class was generated from the following file: