48 using namespace boost;
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);
160 if (layerGroup == -1) {
161 throw BadHdf5IdException(
"Bad layer group in MACFieldIO::write");
166 1, k_versionNumber)) {
167 throw WriteAttributeException(
"Couldn't write attribute " +
180 success = writeInternal<V3f>(layerGroup, vecFloatField);
181 }
else if (vecHalfField) {
182 success = writeInternal<V3h>(layerGroup, vecHalfField);
183 }
else if (vecDoubleField) {
184 success = writeInternal<V3d>(layerGroup, vecDoubleField);
186 throw WriteLayerException(
"MACFieldIO does not support the given " 187 "MACField template parameter");
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...
Contains utility functions and classes for Hdf5 files.
static const std::string k_vDataStr
FIELD3D_API bool writeAttribute(hid_t location, const std::string &attrName, const std::string &value)
Writes a string attribute.
#define FIELD3D_NAMESPACE_SOURCE_CLOSE
Namespace for Exception objects.
This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book...
FIELD3D_API bool readAttribute(hid_t location, const std::string &attrName, std::string &value)
Reads a string attribute.
boost::intrusive_ptr< FieldBase > Ptr
static const std::string k_componentsStr
static const std::string k_uDataStr
static const int k_versionNumber
void setSize(const V3i &size)
Resizes the object.
boost::intrusive_ptr< MACField > Ptr
static const std::string k_wDataStr
Contains the MACFieldIO class.
static const std::string k_extentsStr
static const std::string k_versionAttrName
static const std::string k_dataWindowStr
static const std::string k_bitsPerComponentStr
virtual bool write(hid_t layerGroup, FieldBase::Ptr field)
Writes the given field to disk.
virtual FieldBase::Ptr read(hid_t layerGroup, const std::string &filename, const std::string &layerPath, DataTypeEnum typeEnum)
Reads the field at the given location and tries to create a MACField object from it.