Field3D
FieldRes Class Reference

#include <Field.h>

Inheritance diagram for FieldRes:
FieldBase RefBase Field< Data_T > Field< DenseField< Data_T >::value_type > Field< Field_T::value_type > Field< SparseField< Data_T >::value_type > MIPBase< Data_T > ProceduralField< Data_T > WritableField< Data_T > MIPBase< DenseField< Data_T >::value_type > MIPBase< Field_T::value_type > MIPBase< SparseField< Data_T >::value_type > ResizableField< Data_T > MIPField< DenseField< Data_T > > MIPField< Field_T > MIPField< SparseField< Data_T > > DenseField< Data_T > EmptyField< Data_T > MACField< Data_T > SparseField< Data_T > MIPDenseField< Data_T > MIPSparseField< Data_T >

Public Types

typedef FieldRes class_type
 
typedef boost::intrusive_ptr< FieldResPtr
 
typedef std::vector< PtrVec
 
- Public Types inherited from FieldBase
typedef FieldBase class_type
 
typedef boost::intrusive_ptr< FieldBasePtr
 
- Public Types inherited from RefBase
typedef boost::intrusive_ptr< RefBasePtr
 
typedef boost::weak_ptr< RefBaseWeakPtr
 

Public Member Functions

V3i const dataResolution () const
 
virtual std::string dataTypeString () const
 
const Box3idataWindow () const
 Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field subclass. More...
 
const Box3iextents () const
 Returns the extents of the data. This signifies the relevant area that the data exists over. However, the data window (below) may be smaller than the extents, in which case it is only safe to call value() for those coordinate inside the data window. More...
 
 FieldRes ()
 This constructor ensures that we have a valid mapping at all times. More...
 
 FieldRes (const FieldRes &src)
 Base class copy constructor. More...
 
bool isInBounds (int i, int j, int k) const
 Returns true is the indicies are in bounds of the data window. More...
 
FieldMapping::Ptr mapping ()
 Returns a pointer to the mapping. More...
 
const FieldMapping::Ptr mapping () const
 Returns a pointer to the mapping. More...
 
virtual void mappingChanged ()
 Tells the subclass that the mapping changed. More...
 
virtual long long int memSize () const
 Returns the memory usage (in bytes) More...
 
void setMapping (FieldMapping::Ptr mapping)
 Sets the field's mapping. More...
 
virtual size_t voxelCount () const
 Counts the number of voxels. For most fields, this is just the volume of the data window, but sparse data structures can override this to return a better value. More...
 
- Public Member Functions inherited from FieldBase
 FieldBase ()
 Constructor. More...
 
 FieldBase (const FieldBase &)
 Copy Constructor. More...
 
virtual ~FieldBase ()
 Destructor. More...
 
virtual std::string className () const =0
 Returns the class name of the object. Used by the class pool and when writing the data to disk. More...
 
virtual std::string classType () const =0
 Returns the full class type string. More...
 
virtual Ptr clone () const =0
 Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement it. More...
 
FieldMetadata< FieldBase > & metadata ()
 accessor to the m_metadata class More...
 
const FieldMetadata< FieldBase > & metadata () const
 Read only access to the m_metadata class. More...
 
virtual void metadataHasChanged (const std::string &)
 This function should implemented by concrete classes to get the callback when metadata changes. More...
 
void copyMetadata (const FieldBase &field)
 Copies the metadata from a second field. More...
 
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer. More...
 
size_t refcnt ()
 Used by boost::intrusive_pointer. More...
 
void unref () const
 Used by boost::intrusive_pointer. More...
 
WeakPtr weakPtr () const
 
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor. More...
 
RefBaseoperator= (const RefBase &)
 Assignment operator. More...
 
virtual ~RefBase ()
 Destructor. More...
 
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();. More...
 
bool matchRTTI (const char *typenameStr)
 Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones. More...
 

Static Public Member Functions

static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from FieldBase
static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from RefBase
static const char * staticClassType ()
 

Public Attributes

 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from FieldBase
std::string attribute
 Optional name of the attribute the field represents. More...
 
std::string name
 Optional name of the field. More...
 

Protected Types

typedef MatrixFieldMapping default_mapping
 

Protected Attributes

Box3i m_dataWindow
 Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval. More...
 
Box3i m_extents
 Defines the extents of the the storage. This may be larger or smaller than the data window, and in the case where it is larger, care must be taken not to access voxels outside the data window. This should be treated as a closed (i.e. inclusive) interval. More...
 
FieldMapping::Ptr m_mapping
 Pointer to the field's mapping. More...
 

Private Types

typedef FieldBase base
 Convenience typedef for referring to base class. More...
 

Detailed Description

This class serves to isolate the extents and data window from its templated subclasses. Thus, anything that needs to access the extents or data window don't need to know about what data type the subclass is templated on.

It also owns the field's mapping.

Why do we have both an extent and a data window? The extents are used to define which range of voxels define the [0..1] local coordinate system. The data window in turn defines the voxels that are legal to read/write from. Thus, for optimization we may have a large extents but a small data window, or a small extents and a larger data window which would let us apply large-kernel filters without having to deal with boundary conditions.

Definition at line 212 of file Field.h.

Member Typedef Documentation

typedef boost::intrusive_ptr<FieldRes> FieldRes::Ptr

Definition at line 218 of file Field.h.

typedef std::vector<Ptr> FieldRes::Vec

Definition at line 219 of file Field.h.

Definition at line 223 of file Field.h.

Definition at line 304 of file Field.h.

typedef FieldBase FieldRes::base
private

Convenience typedef for referring to base class.

Definition at line 324 of file Field.h.

Constructor & Destructor Documentation

FieldRes::FieldRes ( )
inline

This constructor ensures that we have a valid mapping at all times.

Definition at line 330 of file Field.h.

References m_dataWindow, m_extents, and m_mapping.

332 {
333  m_extents = Box3i(V3i(0), V3i(-1));
335  m_mapping->setExtents(m_extents);
336 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
FieldMapping::Ptr m_mapping
Pointer to the field&#39;s mapping.
Definition: Field.h:317
MatrixFieldMapping default_mapping
Definition: Field.h:304
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Imath::V3i V3i
Definition: SpiMathLib.h:71
Box3i m_extents
Defines the extents of the the storage. This may be larger or smaller than the data window...
Definition: Field.h:312
FieldRes::FieldRes ( const FieldRes src)
inline

Base class copy constructor.

Todo:
OSS Go over the copy constructing - is it implemented right? 8hr

Definition at line 340 of file Field.h.

References m_mapping, and mapping().

341  : FieldBase(src)
342 {
343  // Call base class first
344  // FieldBase(src);
345  // Copy self
346  *this = src;
347  m_mapping = src.mapping()->clone();
348 }
FieldMapping::Ptr m_mapping
Pointer to the field&#39;s mapping.
Definition: Field.h:317
FieldBase()
Constructor.
Definition: Field.cpp:54
FieldMapping::Ptr mapping()
Returns a pointer to the mapping.
Definition: Field.h:268

Member Function Documentation

virtual std::string FieldRes::dataTypeString ( ) const
inlinevirtual

Reimplemented in Field< Data_T >, Field< DenseField< Data_T >::value_type >, Field< SparseField< Data_T >::value_type >, and Field< Field_T::value_type >.

Definition at line 226 of file Field.h.

227  { return std::string("FieldRes"); }
static const char* FieldRes::staticClassName ( )
inlinestatic

Definition at line 229 of file Field.h.

230  {
231  return "FieldRes";
232  }
static const char* FieldRes::staticClassType ( )
inlinestatic

Definition at line 234 of file Field.h.

235  {
236  return staticClassName();
237  }
static const char * staticClassName()
Definition: Field.h:229
const Box3i& FieldRes::extents ( ) const
inline

Returns the extents of the data. This signifies the relevant area that the data exists over. However, the data window (below) may be smaller than the extents, in which case it is only safe to call value() for those coordinate inside the data window.

Definition at line 254 of file Field.h.

Referenced by convertCellCenteredToMAC(), convertMACToCellCentered(), ResizableField< Data_T >::copyFrom(), MIPField< Field_T >::loadLevelFromDisk(), MIPField< Field_T >::mappingChanged(), sameDefinition(), ResizableField< Data_T >::setSize(), ResizableField< Data_T >::staticClassType(), MACFieldIO::writeInternal(), DenseFieldIO::writeInternal(), and SparseFieldIO::writeInternal().

255  { return m_extents; }
Box3i m_extents
Defines the extents of the the storage. This may be larger or smaller than the data window...
Definition: Field.h:312
V3i const FieldRes::dataResolution ( ) const
inline
void FieldRes::setMapping ( FieldMapping::Ptr  mapping)
inline

Sets the field's mapping.

Definition at line 352 of file Field.h.

References m_extents, m_mapping, mappingChanged(), Msg::print(), and Msg::SevWarning.

Referenced by convertCellCenteredToMAC(), ResizableField< Data_T >::copyFrom(), ResizableField< Data_T >::matchDefinition(), Field3DInputFile::readLayer(), Field3DInputFile::readProxyLayer(), and MIPField< Field_T >::updateMapping().

353 {
354  if (mapping) {
355  m_mapping = mapping->clone();
356  m_mapping->setExtents(m_extents);
357  } else {
359  "Tried to call FieldRes::setMapping with null pointer");
360  }
361  // Tell subclasses about the mapping change
362  mappingChanged();
363 }
FieldMapping::Ptr m_mapping
Pointer to the field&#39;s mapping.
Definition: Field.h:317
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity. ...
Definition: Log.cpp:66
Box3i m_extents
Defines the extents of the the storage. This may be larger or smaller than the data window...
Definition: Field.h:312
virtual void mappingChanged()
Tells the subclass that the mapping changed.
Definition: Field.h:288
FieldMapping::Ptr mapping()
Returns a pointer to the mapping.
Definition: Field.h:268
FieldMapping::Ptr FieldRes::mapping ( )
inline
const FieldMapping::Ptr FieldRes::mapping ( ) const
inline

Returns a pointer to the mapping.

Definition at line 272 of file Field.h.

273  { return m_mapping; }
FieldMapping::Ptr m_mapping
Pointer to the field&#39;s mapping.
Definition: Field.h:317
bool FieldRes::isInBounds ( int  i,
int  j,
int  k 
) const
inline

Returns true is the indicies are in bounds of the data window.

Definition at line 367 of file Field.h.

References m_dataWindow.

368 {
369  // Check bounds
370  if (i < m_dataWindow.min.x || i > m_dataWindow.max.x ||
371  j < m_dataWindow.min.y || j > m_dataWindow.max.y ||
372  k < m_dataWindow.min.z || k > m_dataWindow.max.z) {
373  return false;
374  }
375 
376  return true;
377 }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
virtual long long int FieldRes::memSize ( ) const
inlinevirtual

Returns the memory usage (in bytes)

Note
This needs to be re-implemented for any subclass that adds data members. Those classes should also call their superclass and add the combined memory use.

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

Definition at line 284 of file Field.h.

Referenced by EmptyField< Data_T >::memSize(), DenseField< Data_T >::memSize(), and MACField< Data_T >::memSize().

285  { return sizeof(*this); }
virtual void FieldRes::mappingChanged ( )
inlinevirtual

Tells the subclass that the mapping changed.

Reimplemented in MIPField< Field_T >, MIPField< SparseField< Data_T > >, and MIPField< DenseField< Data_T > >.

Definition at line 288 of file Field.h.

Referenced by setMapping().

289  { /* Empty */ }
virtual size_t FieldRes::voxelCount ( ) const
inlinevirtual

Counts the number of voxels. For most fields, this is just the volume of the data window, but sparse data structures can override this to return a better value.

Reimplemented in SparseField< Data_T >, MIPField< Field_T >, MIPField< SparseField< Data_T > >, and MIPField< DenseField< Data_T > >.

Definition at line 294 of file Field.h.

295  {
296  V3i res = m_dataWindow.size() + V3i(1);
297  return res.x * res.y * res.z;
298  }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Imath::V3i V3i
Definition: SpiMathLib.h:71

Member Data Documentation

FieldRes::DEFINE_FIELD_RTTI_ABSTRACT_CLASS

Definition at line 224 of file Field.h.

Box3i FieldRes::m_extents
protected

Defines the extents of the the storage. This may be larger or smaller than the data window, and in the case where it is larger, care must be taken not to access voxels outside the data window. This should be treated as a closed (i.e. inclusive) interval.

Definition at line 312 of file Field.h.

Referenced by FieldRes(), setMapping(), and MIPField< Field_T >::updateMapping().

FieldMapping::Ptr FieldRes::m_mapping
protected

Pointer to the field's mapping.

Definition at line 317 of file Field.h.

Referenced by FieldRes(), and setMapping().


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