44#include "MACFieldIO.h"
66const int MACFieldIO::k_versionNumber(1);
67const std::string MACFieldIO::k_versionAttrName(
"version");
68const std::string MACFieldIO::k_extentsStr(
"extents");
69const std::string MACFieldIO::k_dataWindowStr(
"data_window");
70const std::string MACFieldIO::k_componentsStr(
"components");
71const std::string MACFieldIO::k_bitsPerComponentStr(
"bits_per_component");
72const std::string MACFieldIO::k_uDataStr(
"u_data");
73const std::string MACFieldIO::k_vDataStr(
"v_data");
74const std::string MACFieldIO::k_wDataStr(
"w_data");
79MACFieldIO::read(hid_t layerGroup,
const std::string & ,
89 throw BadHdf5IdException(
"Bad layer group in MACFieldIO::read");
92 if (!
readAttribute(layerGroup, k_versionAttrName, 1, version))
93 throw MissingAttributeException(
"Couldn't find attribute " +
96 if (version != k_versionNumber)
97 throw UnsupportedVersionException(
"MACField version not supported: " +
98 lexical_cast<std::string>(version));
100 if (!
readAttribute(layerGroup, k_extentsStr, 6, extents.min.x))
101 throw MissingAttributeException(
"Couldn't find attribute " +
104 if (!
readAttribute(layerGroup, k_dataWindowStr, 6, dataW.min.x))
105 throw MissingAttributeException(
"Couldn't find attribute " +
108 if (!
readAttribute(layerGroup, k_componentsStr, 1, components))
109 throw MissingAttributeException(
"Couldn't find attribute " +
113 if (!
readAttribute(layerGroup, k_bitsPerComponentStr, 1, bits))
114 throw MissingAttributeException(
"Couldn't find attribute: " +
115 k_bitsPerComponentStr);
124 field->setSize(extents, dataW);
125 readData<V3h>(layerGroup, field);
134 field->setSize(extents, dataW);
135 readData<V3d>(layerGroup, field);
145 field->setSize(extents, dataW);
146 readData<V3f>(layerGroup, field);
158MACFieldIO::read(
const OgIGroup & ,
159 const std::string & ,
160 const std::string & ,
171 if (layerGroup == -1) {
172 throw BadHdf5IdException(
"Bad layer group in MACFieldIO::write");
177 1, k_versionNumber)) {
178 throw WriteAttributeException(
"Couldn't write attribute " +
191 success = writeInternal<V3f>(layerGroup, vecFloatField);
192 }
else if (vecHalfField) {
193 success = writeInternal<V3h>(layerGroup, vecHalfField);
194 }
else if (vecDoubleField) {
195 success = writeInternal<V3d>(layerGroup, vecDoubleField);
197 throw WriteLayerException(
"MACFieldIO does not support the given "
198 "MACField template parameter");
OgDataType
Enumerates the various uses for Ogawa-level groups.
boost::intrusive_ptr< FieldBase > Ptr
This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book...
boost::intrusive_ptr< MACField > Ptr
Field_T::Ptr field_dynamic_cast(RefBase::Ptr field)
Dynamic cast that uses string-comparison in order to be safe even after an object crosses a shared li...
FIELD3D_API bool readAttribute(hid_t location, const std::string &attrName, std::string &value)
Reads a string attribute.
FIELD3D_API bool writeAttribute(hid_t location, const std::string &attrName, const std::string &value)
Writes a string attribute.
Namespace for Exception objects.
Contains utility functions and classes for Hdf5 files.
#define FIELD3D_NAMESPACE_SOURCE_CLOSE