53#include <boost/tokenizer.hpp>
54#include <boost/utility.hpp>
61#include "OgIAttribute.h"
62#include "OgIDataset.h"
64#include "OgOAttribute.h"
65#include "OgODataset.h"
90 const std::string k_mappingStr(
"mapping");
91 const std::string k_partitionName(
"partition");
92 const std::string k_versionAttrName(
"version_number");
93 const std::string k_classNameAttrName(
"class_name");
94 const std::string k_mappingTypeAttrName(
"mapping_type");
102 int k_minFileVersion[2] = { 0, 0 };
106 std::vector<std::string> makeUnique(std::vector<std::string> vec)
108 std::vector<string> ret;
109 std::sort(vec.begin(), vec.end());
110 std::vector<std::string>::iterator newEnd =
111 std::unique(vec.begin(), vec.end());
112 ret.resize(std::distance(vec.begin(), newEnd));
113 std::copy(vec.begin(), newEnd, ret.begin());
121 class print : std::unary_function<T, void>
127 void operator()(
const T& x)
const
129 for (
int i = 0; i < indent; i++)
131 std::cout << x << std::endl;
143 void checkFile(
const std::string &filename)
147 throw NoSuchFileException(filename);
153 bool isSupportedFileVersion(
const int fileVersion[3],
154 const int minVersion[2])
156 stringstream currentVersionStr;
157 currentVersionStr << k_currentFileVersion[0] <<
"."
158 << k_currentFileVersion[1] <<
"."
159 << k_currentFileVersion[2];
160 stringstream fileVersionStr;
161 fileVersionStr << fileVersion[0] <<
"."
162 << fileVersion[1] <<
"."
164 stringstream minVersionStr;
165 minVersionStr << minVersion[0] <<
"."
168 if (fileVersion[0] > k_currentFileVersion[0] ||
169 (fileVersion[0] == k_currentFileVersion[0] &&
170 fileVersion[1] > k_currentFileVersion[1])) {
172 " is higher than the current version " +
173 currentVersionStr.str());
177 if (fileVersion[0] < minVersion[0] ||
178 (fileVersion[0] == minVersion[0] &&
179 fileVersion[1] < minVersion[1])) {
181 " is lower than the minimum supported version " +
182 minVersionStr.str());
195 mappingGroup.findAttribute<
string>(k_mappingTypeAttrName);
196 if (!mappingAttr.isValid()) {
201 const std::string className = mappingAttr.value();
238 return io->write(layerGroup, field);
247 template <
class Data_T>
249 readField(
const std::string &className,
const OgIGroup &layerGroup,
250 const std::string &filename,
const std::string &layerPath)
263 OgDataType typeEnum = OgawaTypeTraits<Data_T>::typeEnum();
264 FieldBase::Ptr field = io->read(layerGroup, filename, layerPath, typeEnum);
283 bool readMeta(
const OgIGroup &group,
FieldMetadata &metadata)
286 std::vector<std::string> attrs = group.attributeNames();
288 for (
size_t i = 0, end = attrs.size(); i < end; ++i) {
292 if (attr.isValid()) {
299 if (attr.isValid()) {
306 if (attr.isValid()) {
313 if (attr.isValid()) {
320 if (attr.isValid()) {
345 return k_partitionName;
361 for (LayerList::const_iterator i =
m_layers.begin();
363 if (i->name ==
name) {
377 for (LayerList::const_iterator i =
m_layers.begin();
379 names.push_back(i->name);
423 const std::string & ,
427 for (PartitionList::const_iterator i =
m_partitions.begin();
430 if ((**i).mapping->isIdentical(field->mapping())) {
455 if ((**i).name == partitionName)
467 for (PartitionList::const_iterator i =
m_partitions.begin();
469 if ((**i).name == partitionName)
481 size_t pos = partitionName.rfind(
".");
482 if (pos == partitionName.npos) {
483 return partitionName;
485 return partitionName.substr(0, pos);
501 vector<string> tempNames;
503 for (PartitionList::const_iterator i =
m_partitions.begin();
508 names = makeUnique(tempNames);
515 const string &partitionName)
const
518 m_hdf5Base->getScalarLayerNames(names, partitionName);
530 part->getLayerNames(names);
533 names = makeUnique(names);
540 const string &partitionName)
const
543 m_hdf5Base->getVectorLayerNames(names, partitionName);
555 part->getLayerNames(names);
558 names = makeUnique(names);
568 for (PartitionList::const_iterator i =
m_partitions.begin();
570 names.push_back((**i).name);
578 const string &intPartitionName)
const
591 part->getLayerNames(names);
598 const string &intPartitionName)
const
611 part->getLayerNames(names);
648 for (PartitionList::const_iterator i =
m_partitions.begin();
650 string name = (**i).name;
651 size_t pos = name.rfind(
".");
652 if (pos != name.npos) {
653 if (name.substr(0, pos) == partitionName) {
668 return partitionName +
"." + boost::lexical_cast<std::string>(i);
681 GroupMembershipMap::const_iterator i = groupMembers.begin();
682 GroupMembershipMap::const_iterator end = groupMembers.end();
684 for (; i != end; ++i) {
685 GroupMembershipMap::iterator foundGroupIter =
729 m_archive.reset(
new Alembic::Ogawa::IArchive(filename));
735 if (
m_hdf5->open(filename)) {
739 throw NoSuchFileException(filename);
750 if (!version.isValid()) {
751 throw OgIAttributeException(
"Missing version attribute.");
753 int fileVersion[3] = { version.value()[0],
755 version.value()[2] };
756 if (!isSupportedFileVersion(fileVersion, k_minFileVersion)) {
757 stringstream versionStr;
758 versionStr << fileVersion[0] <<
"."
759 << fileVersion[1] <<
"."
761 throw UnsupportedVersionException(versionStr.str());
764 catch (OgIAttributeException &e) {
771 const OgIGroup metadataGroup =
m_root->findGroup(
"field3d_global_metadata");
772 if (metadataGroup.isValid()) {
778 "Unknown error when reading file metadata ");
787 catch (MissingGroupException &e) {
789 throw BadFileHierarchyException(filename);
791 catch (ReadMappingException &e) {
794 throw BadFileHierarchyException(filename);
799 throw BadFileHierarchyException(filename);
803 "Unknown error when reading file hierarchy. ");
804 throw BadFileHierarchyException(filename);
807 catch (NoSuchFileException &e) {
809 +
string(e.what()) );
812 catch (MissingAttributeException &e) {
814 "In file: " + filename +
" - "
815 +
string(e.what()) );
818 catch (UnsupportedVersionException &e) {
820 "In file: " + filename +
" - File version can not be read: "
824 catch (BadFileHierarchyException &) {
826 "In file: " + filename +
" - Bad file hierarchy. ");
829 catch (runtime_error &e) {
833 if (
m_hdf5->open(filename)) {
838 "In file: " + filename +
": " +
string(e.what()));
844 "In file: " + filename +
" Unknown exception ");
860 std::vector<std::string> groups =
m_root->groupNames();
864 for (std::vector<std::string>::const_iterator i = groups.begin(),
865 end = groups.end(); i != end; ++i) {
867 const std::string &name = *i;
869 if (name ==
"field3d_global_metadata") {
883 const std::string &name = (**i).name;
885 const OgIGroup partitionGroup =
m_root->findGroup(name);
886 if (!partitionGroup.isValid()) {
890 const OgIGroup mappingGroup = partitionGroup.findGroup(k_mappingStr);
891 if (!mappingGroup.isValid()) {
899 throw ReadMappingException((**i).name);
903 (**i).mapping = mapping;
908 for (PartitionList::const_iterator i =
m_partitions.begin();
911 const std::string &partitionName = (**i).name;
913 const OgIGroup partitionGroup =
m_root->findGroup(partitionName);
914 if (!partitionGroup.isValid()) {
919 groups = partitionGroup.groupNames();
920 for (std::vector<std::string>::const_iterator l = groups.begin(),
921 lEnd = groups.end(); l != lEnd; ++l) {
923 const std::string layerName = *l;
925 if (layerName == k_mappingStr) {
931 layer.
parent = partitionName;
933 partition(partitionName)->addLayer(layer);
945 return readMeta(metadataGroup, field->metadata());
952 return readMeta(metadataGroup,
metadata());
993 m_archive.reset(
new Alembic::Ogawa::OArchive(filename));
1006 k_currentFileVersion);
1017 const std::string className = mapping->className();
1021 OgOGroup mappingGroup(partitionGroup, k_mappingStr);
1033 return io->write(mappingGroup, mapping);
1036 catch (OgOGroupException &e) {
1038 throw WriteMappingException(k_mappingStr);
1049 FieldMetadata::StrMetadata::const_iterator i =
1050 field->metadata().strMetadata().begin();
1051 FieldMetadata::StrMetadata::const_iterator end =
1052 field->metadata().strMetadata().end();
1053 for (; i != end; ++i) {
1057 catch (OgOAttributeException &e) {
1066 FieldMetadata::IntMetadata::const_iterator i =
1067 field->metadata().intMetadata().begin();
1068 FieldMetadata::IntMetadata::const_iterator end =
1069 field->metadata().intMetadata().end();
1070 for (; i != end; ++i) {
1074 catch (OgOAttributeException &e) {
1083 FieldMetadata::FloatMetadata::const_iterator i =
1084 field->metadata().floatMetadata().begin();
1085 FieldMetadata::FloatMetadata::const_iterator end =
1086 field->metadata().floatMetadata().end();
1087 for (; i != end; ++i) {
1091 catch (OgOAttributeException &e) {
1100 FieldMetadata::VecIntMetadata::const_iterator i =
1101 field->metadata().vecIntMetadata().begin();
1102 FieldMetadata::VecIntMetadata::const_iterator end =
1103 field->metadata().vecIntMetadata().end();
1104 for (; i != end; ++i) {
1108 catch (OgOAttributeException &e) {
1117 FieldMetadata::VecFloatMetadata::const_iterator i =
1118 field->metadata().vecFloatMetadata().begin();
1119 FieldMetadata::VecFloatMetadata::const_iterator end =
1120 field->metadata().vecFloatMetadata().end();
1121 for (; i != end; ++i) {
1125 catch (OgOAttributeException &e) {
1143 FieldMetadata::StrMetadata::const_iterator i =
1145 FieldMetadata::StrMetadata::const_iterator end =
1147 for (; i != end; ++i) {
1151 catch (OgOAttributeException &e) {
1160 FieldMetadata::IntMetadata::const_iterator i =
1162 FieldMetadata::IntMetadata::const_iterator end =
1164 for (; i != end; ++i) {
1168 catch (OgOAttributeException &e) {
1177 FieldMetadata::FloatMetadata::const_iterator i =
1179 FieldMetadata::FloatMetadata::const_iterator end =
1181 for (; i != end; ++i) {
1185 catch (OgOAttributeException &e) {
1194 FieldMetadata::VecIntMetadata::const_iterator i =
1196 FieldMetadata::VecIntMetadata::const_iterator end =
1198 for (; i != end; ++i) {
1202 catch (OgOAttributeException &e) {
1211 FieldMetadata::VecFloatMetadata::const_iterator i =
1213 FieldMetadata::VecFloatMetadata::const_iterator end =
1215 for (; i != end; ++i) {
1219 catch (OgOAttributeException &e) {
1237 return m_hdf5->writeGlobalMetadata();
1240 OgOGroup ogMetadata(*
m_root,
"field3d_global_metadata");
1255 return m_hdf5->writeGroupMembership();
1262 using namespace std;
1271 "Error creating field3d_group_membership group.");
1275 if (!writeAttribute(group,
"is_field3d_group_membership",
"1")) {
1277 "Failed to write field3d_group_membership attribute.");
1281 std::map<std::string, std::string>::const_iterator iter =
1283 std::map<std::string, std::string>::const_iterator iEnd =
1286 for (; iter != iEnd; ++iter) {
1287 if (!writeAttribute(group, iter->first, iter->second)) {
1289 "Failed to write groupMembership string: "+ iter->first);
1323 for (PartitionList::const_iterator i =
m_partitions.begin();
1325 cout <<
"Name: " << (**i).name << endl;
1327 cout <<
" Mapping: " << (**i).mapping->className() << endl;
1329 cout <<
" Mapping: NULL" << endl;
1330 cout <<
" Layers: " << endl;
1331 vector<string> names;
1332 (**i).getLayerNames(names);
1333 for_each(names.begin(), names.end(), print<string>(4));
1344 struct __stat64 statbuf;
1345 return (_stat64(filename.c_str(), &statbuf) != -1);
1347 struct stat statbuf;
1348 return (stat(filename.c_str(), &statbuf) != -1);
1356 const std::string & ,
1359 using namespace Exc;
1362 newPart->name = partitionName;
1364 boost::shared_ptr<OgOGroup> ogPartition(
new OgOGroup(*
m_root, newPart->name));
1365 newPart->setGroup(ogPartition);
1376 "writeMapping returned false for an unknown reason ");
1380 catch (WriteMappingException &e) {
1387 "Unknown error when writing mapping for partition: "
1395 part->mapping = field->mapping();
1408template <
class Data_T>
1410 const std::string &layerName,
1418 "Called writeLayer with null pointer. Ignoring...");
1425 "Attempting to write layer without opening file first.");
1430 string partitionName =
intPartitionName(userPartitionName, layerName, field);
1446 "Couldn't add layer \"" + layerName +
"\" to partition \""
1447 + partitionName +
"\" because the layer's mapping is null.");
1452 if (part->layer(layerName)) {
1465 if (!part->mapping) {
1472 if (!field->
mapping()->isIdentical(part->mapping)) {
1474 +
"\" to partition \"" + partitionName
1475 +
"\" because mapping doesn't match");
1481 OgOGroup &ogPartition = part->group();
1486 layer.
name = layerName;
1487 layer.
parent = partitionName;
1491 OgOGroup ogLayer(ogPartition, layerName);
1497 OgOGroup ogMetadata(ogLayer,
"metadata");
1507 part->addLayer(layer);
1514template <
class Data_T>
1517 const std::string &layerName)
const
1532 const File::Layer *layer = part->layer(layerName);
1540 if (!partitionGroup.isValid()) {
1547 const OgIGroup layerGroup = partitionGroup.findGroup(layerName);
1548 if (!layerGroup.isValid()) {
1555 string layerPath = layer->
parent +
"/" + layer->
name;
1558 className = layerGroup.findAttribute<
string>(
"class_name").value();
1560 catch (OgIAttributeException &e) {
1586 const OgIGroup metadataGroup = layerGroup.findGroup(
"metadata");
1587 if (metadataGroup.isValid()) {
1606template <
class Data_T>
1617 std::vector<std::string> parts;
1620 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1621 vector<std::string> layers;
1623 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
1625 if ((name.length() == 0) || (*l == name)) {
1639template <
class Data_T>
1642 const std::string &layerName)
const
1644 using namespace std;
1651 if ((layerName.length() == 0) || (partitionName.length() == 0))
1654 std::vector<std::string> parts;
1657 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1658 std::vector<std::string> layers;
1661 for (vector<string>::iterator l = layers.begin();
1662 l != layers.end(); ++l) {
1664 if (*l == layerName) {
1678template <
class Data_T>
1681 const std::string &name,
1682 const std::string &attribute,
1685 using namespace boost;
1686 using namespace std;
1690 const std::string extentsMinStr(
"extents_min");
1691 const std::string extentsMaxStr(
"extents_max");
1692 const std::string dataWindowMinStr(
"data_window_min");
1693 const std::string dataWindowMaxStr(
"data_window_max");
1695 Box3i extents, dataW;
1700 location.findAttribute<
veci32_t>(extentsMinStr);
1702 location.findAttribute<
veci32_t>(extentsMaxStr);
1703 if (!extMinAttr.isValid()) {
1704 throw MissingAttributeException(
"Couldn't find attribute " +
1707 if (!extMaxAttr.isValid()) {
1708 throw MissingAttributeException(
"Couldn't find attribute " +
1712 extents.min = extMinAttr.value();
1713 extents.max = extMaxAttr.value();
1718 location.findAttribute<
veci32_t>(dataWindowMinStr);
1720 location.findAttribute<
veci32_t>(dataWindowMaxStr);
1721 if (!dwMinAttr.isValid()) {
1722 throw MissingAttributeException(
"Couldn't find attribute " +
1725 if (!dwMaxAttr.isValid()) {
1726 throw MissingAttributeException(
"Couldn't find attribute " +
1730 dataW.min = dwMinAttr.value();
1731 dataW.max = dwMaxAttr.value();
1735 field->
setSize(extents, dataW);
1738 OgIGroup metadataGroup = location.findGroup(
"metadata");
1739 if (metadataGroup.isValid()) {
1753template <
class Data_T>
1756 const std::string &layerName,
1757 bool isVectorLayer)
const
1759 using namespace boost;
1760 using namespace std;
1764 return m_hdf5->readProxyLayer<Data_T>(partitionName, layerName,
1771 if ((layerName.length() == 0) || (partitionName.length() == 0))
1774 std::vector<std::string> parts, layers;
1777 bool foundPartition =
false;
1779 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1781 foundPartition =
true;
1782 if (isVectorLayer) {
1787 for (vector<string>::iterator l = layers.begin();
1788 l != layers.end(); ++l) {
1789 if (*l == layerName) {
1798 if (isVectorLayer) {
1799 layer = part->layer(layerName);
1801 layer = part->layer(layerName);
1808 string layerPath = layer->
parent +
"/" + layer->
name;
1810 if (!parent.isValid()) {
1812 + layerPath +
" in .f3d file ");
1815 OgIGroup layerGroup = parent.findGroup(layer->
name);
1816 if (!layerGroup.isValid()) {
1818 + layerPath +
" in .f3d file ");
1829 OgIGroup mipGroup = layerGroup.findGroup(
"mip_levels");
1830 if (mipGroup.isValid()) {
1832 mipGroup.findAttribute<uint32_t>(
"levels");
1833 if (levelsAttr.isValid()) {
1834 numLevels = levelsAttr.value();
1840 output.push_back(field);
1846 if (!foundPartition) {
1856template <
class Data_T>
1860 using namespace std;
1863 typedef std::vector<FieldPtr> FieldList;
1867 std::vector<std::string> parts;
1870 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1871 std::vector<std::string> layers;
1873 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
1875 if ((name.length() == 0) || (*l == name)) {
1877 for (
typename FieldList::iterator i = f.begin(); i != f.end(); ++i) {
1891template <
class Data_T>
1895 using namespace std;
1898 typedef std::vector<FieldPtr> FieldList;
1902 std::vector<std::string> parts;
1905 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1906 std::vector<std::string> layers;
1908 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
1910 if ((name.length() == 0) || (*l == name)) {
1912 for (
typename FieldList::iterator i = f.begin(); i != f.end(); ++i) {
1928#define FIELD3D_INSTANTIATION_WRITELAYER(type) \
1930 bool Field3DOutputFile::writeLayer<type> \
1931 (const std::string &, const std::string &, Field<type>::Ptr ); \
1944#define FIELD3D_INSTANTIATION_READLAYER(type) \
1947 Field3DInputFile::readLayer<type> \
1948 (const std::string &, const std::string &) const; \
1950FIELD3D_INSTANTIATION_READLAYER(
float16_t);
1951FIELD3D_INSTANTIATION_READLAYER(
float32_t);
1952FIELD3D_INSTANTIATION_READLAYER(
float64_t);
1953FIELD3D_INSTANTIATION_READLAYER(
vec16_t);
1954FIELD3D_INSTANTIATION_READLAYER(
vec32_t);
1955FIELD3D_INSTANTIATION_READLAYER(
vec64_t);
1961#define FIELD3D_INSTANTIATION_READLAYERS1(type) \
1964 Field3DInputFile::readLayers<type>(const std::string &name) const; \
1975#define FIELD3D_INSTANTIATION_READLAYERS2(type) \
1978 Field3DInputFile::readLayers<type>(const std::string &partitionName, \
1979 const std::string &layerName) const; \
1990#define FIELD3D_INSTANTIATION_READPROXYLAYER(type) \
1992 EmptyField<type>::Vec \
1993 Field3DInputFile::readProxyLayer<type>(const std::string &partitionName, \
1994 const std::string &layerName, \
1995 bool isVectorLayer) const \
2006#define FIELD3D_INSTANTIATION_READPROXYSCALARLAYER(type) \
2008 EmptyField<type>::Vec \
2009 Field3DInputFile::readProxyScalarLayers<type> \
2010 (const std::string &name) const \
2021#define FIELD3D_INSTANTIATION_READPROXYVECTORLAYER(type) \
2023 EmptyField<type>::Vec \
2024 Field3DInputFile::readProxyVectorLayers<type> \
2025 (const std::string &name) const \
Contains the ClassFactory class for registering Field3D classes.
Contains the Field3DFileHDF5 classes.
Field< Data_T >::Ptr readField(const std::string &className, hid_t layerGroup, const std::string &filename, const std::string &layerPath)
This function creates a FieldIO instance based on className which then reads the field data from laye...
FIELD3D_API bool writeField(hid_t layerGroup, FieldBase::Ptr field)
This function creates a FieldIO instance based on field->className() which then writes the field data...
FIELD3D_API FieldMapping::Ptr readFieldMapping(hid_t mappingGroup)
This function creates a FieldMappingIO instance based on className read from mappingGroup location wh...
#define FIELD3D_INSTANTIATION_READPROXYLAYER(type)
#define FIELD3D_INSTANTIATION_WRITELAYER(type)
#define FIELD3D_INSTANTIATION_READPROXYVECTORLAYER(type)
#define FIELD3D_INSTANTIATION_READLAYERS1(type)
#define FIELD3D_INSTANTIATION_READLAYERS2(type)
#define FIELD3D_INSTANTIATION_READPROXYSCALARLAYER(type)
bool fileExists(const std::string &filename)
checks to see if a file/directory exists or not
Contains the Field3DFile classes.
bool fileExists(const std::string &filename)
checks to see if a file/directory exists or not
Contains the FieldCache class.
Contains Field, WritableField and ResizableField classes.
OgDataType
Enumerates the various uses for Ogawa-level groups.
FieldIO::Ptr createFieldIO(const std::string &className) const
Instances an IO object by name.
static ClassFactory & singleton()
}
FieldMappingIO::Ptr createFieldMappingIO(const std::string &className) const
Instances an IO object by name.
This subclass of Field does not store any data.
boost::intrusive_ptr< EmptyField > Ptr
boost::shared_ptr< Field3DFileHDF5Base > m_hdf5Base
HDF5 fallback.
GroupMembershipMap m_groupMembership
Keeps track of group membership for each layer of partition name. The key is the "group" and the valu...
std::string removeUniqueId(const std::string &partitionName) const
Strips any unique identifiers from the partition name and returns the original name.
void getIntPartitionNames(std::vector< std::string > &names) const
Gets the names of all the -internal- partitions in the file.
void getScalarLayerNames(std::vector< std::string > &names, const std::string &partitionName) const
Gets the names of all the scalar layers in a given partition.
virtual ~Field3DFileBase()=0
Pure virtual destructor to ensure we never instantiate this class.
std::string makeIntPartitionName(const std::string &partitionsName, int i) const
Makes an internal partition name given the external partition name. Effectively just tacks on ....
FieldMetadata & metadata()
accessor to the m_metadata class
virtual void closeInternal()=0
Closes the file if open.
void getIntScalarLayerNames(std::vector< std::string > &names, const std::string &intPartitionName) const
Gets the names of all the scalar layers in a given partition, but assumes that partition name is the ...
void clear()
Clear the data structures and close the file.
PartitionList m_partitions
Vector of partitions.
File::Partition::Ptr partition(const std::string &partitionName)
Returns a pointer to the given partition.
std::map< std::string, std::string > GroupMembershipMap
void getPartitionNames(std::vector< std::string > &names) const
Gets the names of all the partitions in the file.
void getVectorLayerNames(std::vector< std::string > &names, const std::string &partitionName) const
Gets the names of all the vector layers in a given partition.
int numIntPartitions(const std::string &partitionName) const
Returns the number of internal partitions for a given partition name.
std::string intPartitionName(const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field)
Returns a unique partition name given the requested name. This ensures that partitions with matching ...
void printHierarchy() const
PartitionCountMap m_partitionCount
Contains a counter for each partition name. This is used to keep multiple fields with the same name u...
void addGroupMembership(const GroupMembershipMap &groupMembers)
Add to the group membership.
void getIntVectorLayerNames(std::vector< std::string > &names, const std::string &intPartitionName) const
Gets the names of all the vector layers in a given partition, but assumes that partition name is the ...
bool close()
Closes the file. No need to call this unless you specifically want to close the file early....
Provides writing of .f3d (internally, hdf5) files.
static bool ms_doOgawa
Whether to output ogawa files.
virtual void closeInternal()
Closes the file if open.
boost::shared_ptr< Field3DOutputFileHDF5 > m_hdf5
HDF5 fallback.
bool writeLayer(const std::string &layerName, typename Field< Data_T >::Ptr layer)
Writes a scalar layer to the "Default" partition.
File::Partition::Ptr createNewPartition(const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field)
Create newPartition given the input config.
virtual ~Field3DOutputFile()
bool create(const std::string &filename, CreateMode cm=OverwriteMode)
Creates a .f3d file on disk.
bool writeGlobalMetadata()
This routine is call if you want to write out global metadata to disk.
boost::shared_ptr< OgOGroup > m_root
Pointer to root group.
boost::shared_ptr< Alembic::Ogawa::OArchive > m_archive
Pointer to the Ogawa archive.
bool writeMapping(OgOGroup &partitionGroup, FieldMapping::Ptr mapping)
Writes the mapping to the given Og node. Mappings are assumed to be light-weight enough to be stored ...
bool writeGroupMembership()
This routine is called just before closing to write out any group membership to disk.
bool writeMetadata(OgOGroup &metadataGroup, FieldBase::Ptr layer)
Writes metadata for this layer.
std::string incrementPartitionName(std::string &pname)
Increment the partition or make it zero if there's not an integer suffix.
boost::intrusive_ptr< FieldBase > Ptr
FieldMetadata & metadata()
accessor to the m_metadata class
std::string attribute
Optional name of the attribute the field represents.
std::string name
Optional name of the field.
void cacheField(FieldPtr field, const std::string &filename, const std::string &layerPath)
Adds the given field to the cache.
static FieldCache & singleton()
Returns a reference to the FieldCache singleton.
FieldPtr getCachedField(const std::string &filename, const std::string &layerPath)
Checks the cache for a previously loaded field.
boost::intrusive_ptr< FieldIO > Ptr
boost::intrusive_ptr< FieldMappingIO > Ptr
boost::intrusive_ptr< FieldMapping > Ptr
boost::intrusive_ptr< FieldRes > Ptr
void setMapping(FieldMapping::Ptr mapping)
Sets the field's mapping.
FieldMapping::Ptr mapping()
Returns a pointer to the mapping.
boost::intrusive_ptr< Field > Ptr
std::vector< Ptr > Vec
This is a convenience typedef for the list that Field3DInputFile::readScalarLayers() and Field3DInput...
std::string name
The name of the layer (always available)
std::string parent
The name of the parent partition. We need this in order to open its group.
boost::shared_ptr< OgOGroup > m_group
Group representing the partition.
LayerList m_layers
The layers belonging to this partition.
std::string name
Name of the partition.
void setGroup(boost::shared_ptr< OgOGroup > ptr)
Sets the group pointer.
virtual std::string className() const
void getLayerNames(std::vector< std::string > &names) const
Gets all the layer names.
OgOGroup & group() const
Returns a reference to the OgOGroup.
const File::Layer * layer(const std::string &name) const
Finds a layer.
void addLayer(const File::Layer &layer)
Adds a layer.
boost::intrusive_ptr< Partition > Ptr
Scoped object - creates a group on creation and closes it on destruction.
void setSize(const V3i &size)
Resizes the object.
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...
Namespace for Exception objects.
Namespace for file I/O specifics.
Contains utility functions and classes for Hdf5 files.
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity.
#define FIELD3D_MAJOR_VER
#define FIELD3D_NAMESPACE_SOURCE_CLOSE
#define FIELD3D_MINOR_VER
#define FIELD3D_MICRO_VER