Field3D
MatrixFieldMappingIO Class Reference

#include <FieldMappingIO.h>

Inheritance diagram for MatrixFieldMappingIO:
FieldMappingIO RefBase

List of all members.

Public Types

typedef MatrixFieldMappingIO class_type
typedef boost::intrusive_ptr
< MatrixFieldMappingIO
Ptr
- Public Types inherited from FieldMappingIO
- Public Types inherited from RefBase

Public Member Functions

virtual std::string className () const
 Returns the class name.
 MatrixFieldMappingIO ()
 Ctor.
virtual FieldMapping::Ptr read (hid_t mappingGroup)
 Reads the field mapping and tries to create a MatrixFieldMapping object from it.
virtual bool write (hid_t mappingGroup, FieldMapping::Ptr mapping)
 Writes the given field mapping to disk.
- Public Member Functions inherited from FieldMappingIO
 FieldMappingIO ()
 Ctor.
virtual ~FieldMappingIO ()
 Dtor.
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer.
size_t refcnt ()
 Used by boost::intrusive_pointer.
void unref () const
 Used by boost::intrusive_pointer.
 RefBase ()
 RefBase (const RefBase &)
 Copy constructor.
RefBaseoperator= (const RefBase &)
 Assignment operator.
virtual ~RefBase ()
 Destructor.
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.
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.

Static Public Member Functions

static const char * classType ()
 RTTI replacement.
static FieldMappingIO::Ptr create ()

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS
- Public Attributes inherited from FieldMappingIO
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS

Private Types

typedef FieldMappingIO base
 Convenience typedef for referring to base class.

Detailed Description

Handles IO for a MatrixFieldMapping object

Definition at line 191 of file FieldMappingIO.h.


Member Typedef Documentation

typedef boost::intrusive_ptr<MatrixFieldMappingIO> MatrixFieldMappingIO::Ptr

Reimplemented from FieldMappingIO.

Definition at line 198 of file FieldMappingIO.h.

Reimplemented from FieldMappingIO.

Definition at line 202 of file FieldMappingIO.h.

Convenience typedef for referring to base class.

Reimplemented from FieldMappingIO.

Definition at line 239 of file FieldMappingIO.h.


Constructor & Destructor Documentation

MatrixFieldMappingIO::MatrixFieldMappingIO ( )
inline

Ctor.

Definition at line 213 of file FieldMappingIO.h.

{ }

Member Function Documentation

static const char* MatrixFieldMappingIO::classType ( )
inlinestatic

RTTI replacement.

Reimplemented from FieldMappingIO.

Definition at line 205 of file FieldMappingIO.h.

{
return "MatrixFieldMappingIO";
}
static FieldMappingIO::Ptr MatrixFieldMappingIO::create ( )
inlinestatic

Definition at line 217 of file FieldMappingIO.h.

Referenced by initIO().

{ return Ptr(new MatrixFieldMappingIO); }
FieldMapping::Ptr MatrixFieldMappingIO::read ( hid_t  mappingGroup)
virtual

Reads the field mapping and tries to create a MatrixFieldMapping object from it.

Returns:
Matrix if no object was read

Implements FieldMappingIO.

Definition at line 122 of file FieldMappingIO.cpp.

References Msg::print(), Hdf5Util::readAttribute(), and Msg::SevWarning.

{
M44d mtx;
int numSamples=0;
// For backward compatibility, we first try to read the non-time-varying
// mapping.
try {
readAttribute(mappingGroup, k_matrixMappingDataName, 16, mtx.x[0][0]);
mm->setLocalToWorld(mtx);
return mm;
}
catch (...) {
// Do nothing
}
// If we didn't find the non-time-varying matrix data then we attempt
// to read time samples
try {
if (!readAttribute(mappingGroup, k_matrixMappingNumSamples, 1, numSamples)) {
Msg::print(Msg::SevWarning, "Couldn't read attribute " +
k_matrixMappingNumSamples);
}
} catch (...) {
//do nothing
}
for (int i = 0; i < numSamples; ++i) {
float time;
string timeAttr = k_matrixMappingTime + boost::lexical_cast<string>(i);
string matrixAttr = k_matrixMappingMatrix + boost::lexical_cast<string>(i);
if (!readAttribute(mappingGroup, timeAttr, 1, time)) {
Msg::print(Msg::SevWarning, "Couldn't read attribute " + timeAttr);
}
std::vector<unsigned int> attrSize;
attrSize.assign(2,4);
if (!readAttribute(mappingGroup, matrixAttr, attrSize, mtx.x[0][0])) {
Msg::print(Msg::SevWarning, "Couldn't read attribute " + matrixAttr);
}
mm->setLocalToWorld(time, mtx);
}
return mm;
}
bool MatrixFieldMappingIO::write ( hid_t  mappingGroup,
FieldMapping::Ptr  mapping 
)
virtual

Writes the given field mapping to disk.

Returns:
true if successful, otherwise false

Implements FieldMappingIO.

Definition at line 178 of file FieldMappingIO.cpp.

References Msg::print(), Msg::SevWarning, and Hdf5Util::writeAttribute().

{
FIELD_DYNAMIC_CAST<MatrixFieldMapping>(mapping);
if (!mm) {
Msg::print(Msg::SevWarning, "Couldn't get MatrixFieldMapping from pointer");
return false;
}
// First write number of time samples
const SampleVec &samples = mm->localToWorldSamples();
int numSamples = static_cast<int>(samples.size());
if (!writeAttribute(mappingGroup, k_matrixMappingNumSamples, 1, numSamples)) {
Msg::print(Msg::SevWarning, "Couldn't add attribute " +
k_matrixMappingNumSamples);
return false;
}
// Then write each sample
for (int i = 0; i < numSamples; ++i) {
string timeAttr = k_matrixMappingTime + boost::lexical_cast<string>(i);
string matrixAttr = k_matrixMappingMatrix + boost::lexical_cast<string>(i);
if (!writeAttribute(mappingGroup, timeAttr, 1, samples[i].first)) {
Msg::print(Msg::SevWarning, "Couldn't add attribute " + timeAttr);
return false;
}
std::vector<unsigned int> attrSize;
attrSize.assign(2,4);
if (!writeAttribute(mappingGroup, matrixAttr, attrSize,
samples[i].second.x[0][0])) {
Msg::print(Msg::SevWarning, "Couldn't add attribute " + matrixAttr);
return false;
}
}
return true;
}
std::string MatrixFieldMappingIO::className ( ) const
virtual

Returns the class name.

Implements FieldMappingIO.

Definition at line 224 of file FieldMappingIO.cpp.

References FIELD3D_NAMESPACE_OPEN::k_matrixMappingName().

{
}

Member Data Documentation

MatrixFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 203 of file FieldMappingIO.h.


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