Field3D
|
Provides writing of .f3d (internally, hdf5 or Ogawa) files. More...
#include <Field3DFile.h>
Public Types | |
enum | CreateMode { OverwriteMode, FailOnExisting } |
![]() | |
typedef std::map< std::string, std::string > | GroupMembershipMap |
Public Member Functions | |
bool | create (const std::string &filename, CreateMode cm=OverwriteMode) |
Creates a .f3d file on disk. More... | |
Constructors & destructor | |
Field3DOutputFile () | |
virtual | ~Field3DOutputFile () |
Writing layer to disk | |
template<class Data_T > | |
bool | writeLayer (const std::string &layerName, typename Field< Data_T >::Ptr layer) |
Writes a scalar layer to the "Default" partition. More... | |
template<class Data_T > | |
bool | writeLayer (const std::string &partitionName, const std::string &layerName, typename Field< Data_T >::Ptr layer) |
Writes a layer to a specific partition. The partition will be created if not specified. More... | |
template<class Data_T > | |
bool | writeLayer (typename Field< Data_T >::Ptr layer) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively. More... | |
Backward compatibility | |
template<class Data_T > | |
bool | writeScalarLayer (const std::string &layerName, typename Field< Data_T >::Ptr layer) |
Writes a scalar layer to the "Default" partition. More... | |
template<class Data_T > | |
bool | writeScalarLayer (const std::string &partitionName, const std::string &layerName, typename Field< Data_T >::Ptr layer) |
Writes a layer to a specific partition. The partition will be created if not specified. More... | |
template<class Data_T > | |
bool | writeScalarLayer (typename Field< Data_T >::Ptr layer) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively. More... | |
template<class Data_T > | |
bool | writeVectorLayer (const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer) |
Writes a scalar layer to the "Default" partition. More... | |
template<class Data_T > | |
bool | writeVectorLayer (const std::string &partitionName, const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer) |
Writes a layer to a specific partition. The partition will be created if not specified. More... | |
template<class Data_T > | |
bool | writeVectorLayer (typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively. More... | |
bool | writeGlobalMetadata () |
This routine is call if you want to write out global metadata to disk. More... | |
bool | writeGroupMembership () |
This routine is called just before closing to write out any group membership to disk. More... | |
![]() | |
void | clear () |
Clear the data structures and close the file. More... | |
bool | close () |
Closes the file. No need to call this unless you specifically want to close the file early. It will close once the File object goes out of scope. More... | |
FieldMetadata & | metadata () |
accessor to the m_metadata class More... | |
const FieldMetadata & | 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... | |
Field3DFileBase () | |
virtual | ~Field3DFileBase ()=0 |
Pure virtual destructor to ensure we never instantiate this class. More... | |
void | getPartitionNames (std::vector< std::string > &names) const |
Gets the names of all the partitions in the file. More... | |
void | getScalarLayerNames (std::vector< std::string > &names, const std::string &partitionName) const |
Gets the names of all the scalar layers in a given partition. More... | |
void | getVectorLayerNames (std::vector< std::string > &names, const std::string &partitionName) const |
Gets the names of all the vector layers in a given partition. More... | |
void | addGroupMembership (const GroupMembershipMap &groupMembers) |
Add to the group membership. More... | |
void | printHierarchy () const |
Static Public Member Functions | |
static void | useOgawa (const bool enabled) |
Whether to output ogawa files. More... | |
Private Member Functions | |
void | cleanup () |
virtual void | closeInternal () |
Closes the file if open. More... | |
File::Partition::Ptr | createNewPartition (const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field) |
Create newPartition given the input config. More... | |
std::string | incrementPartitionName (std::string &pname) |
Increment the partition or make it zero if there's not an integer suffix. More... | |
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 as plain attributes under a group. More... | |
bool | writeMetadata (OgOGroup &metadataGroup) |
Writes metadata for this file. More... | |
bool | writeMetadata (OgOGroup &metadataGroup, FieldBase::Ptr layer) |
Writes metadata for this layer. More... | |
Private Attributes | |
boost::shared_ptr< Alembic::Ogawa::OArchive > | m_archive |
Pointer to the Ogawa archive. More... | |
boost::shared_ptr< Field3DOutputFileHDF5 > | m_hdf5 |
HDF5 fallback. More... | |
boost::shared_ptr< OgOGroup > | m_root |
Pointer to root group. More... | |
Static Private Attributes | |
static bool | ms_doOgawa = true |
Whether to output ogawa files. More... | |
Additional Inherited Members | |
![]() | |
typedef std::map< std::string, int > | PartitionCountMap |
typedef std::vector< File::Partition::Ptr > | PartitionList |
![]() | |
File::Partition::Ptr | getPartition (const std::string &partitionName) const |
Returns a pointer to the given partition. More... | |
File::Partition::Ptr | partition (const std::string &partitionName) |
Returns a pointer to the given partition. More... | |
File::Partition::Ptr | partition (const std::string &partitionName) const |
Returns a pointer to the given partition. More... | |
void | getIntPartitionNames (std::vector< std::string > &names) const |
Gets the names of all the -internal- partitions in the file. More... | |
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 -internal- partition name. More... | |
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 -internal- partition name. More... | |
int | numIntPartitions (const std::string &partitionName) const |
Returns the number of internal partitions for a given partition name. More... | |
std::string | makeIntPartitionName (const std::string &partitionsName, int i) const |
Makes an internal partition name given the external partition name. Effectively just tacks on .X to the name, where X is the number. More... | |
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 mappings get the same name but each subsequent differing mapping gets a new, separate name. More... | |
std::string | removeUniqueId (const std::string &partitionName) const |
Strips any unique identifiers from the partition name and returns the original name. More... | |
![]() | |
GroupMembershipMap | m_groupMembership |
Keeps track of group membership for each layer of partition name. The key is the "group" and the value is a space separated list of "partitionName.0:Layer1 partitionName.1:Layer0 ..." More... | |
boost::shared_ptr< Field3DFileHDF5Base > | m_hdf5Base |
HDF5 fallback. More... | |
std::vector< LayerInfo > | m_layerInfo |
This stores layer info. More... | |
FieldMetadata | m_metadata |
metadata More... | |
PartitionCountMap | m_partitionCount |
Contains a counter for each partition name. This is used to keep multiple fields with the same name unique in the file. More... | |
std::vector< std::string > | m_partitionNames |
This stores partition names. More... | |
PartitionList | m_partitions |
Vector of partitions. More... | |
Provides writing of .f3d (internally, hdf5 or Ogawa) files.
Refer to using_files for examples of how to use this in your code.
Definition at line 636 of file Field3DFile.h.
Enumerator | |
---|---|
OverwriteMode | |
FailOnExisting |
Definition at line 642 of file Field3DFile.h.
Field3DOutputFile::Field3DOutputFile | ( | ) |
Definition at line 963 of file Field3DFile.cpp.
|
virtual |
bool Field3DOutputFile::create | ( | const std::string & | filename, |
CreateMode | cm = OverwriteMode |
||
) |
Creates a .f3d file on disk.
Definition at line 977 of file Field3DFile.cpp.
References closeInternal(), FailOnExisting, fileExists(), m_archive, m_hdf5, Field3DFileBase::m_hdf5Base, m_root, and ms_doOgawa.
|
inlinestatic |
|
inline |
Writes a scalar layer to the "Default" partition.
Definition at line 687 of file Field3DFile.h.
bool Field3DOutputFile::writeLayer | ( | const std::string & | partitionName, |
const std::string & | layerName, | ||
typename Field< Data_T >::Ptr | layer | ||
) |
Writes a layer to a specific partition. The partition will be created if not specified.
Definition at line 1409 of file Field3DFile.cpp.
References createNewPartition(), incrementPartitionName(), Field3DFileBase::intPartitionName(), m_archive, FieldRes::mapping(), File::Layer::name, File::Layer::parent, Field3DFileBase::partition(), Msg::print(), Msg::SevWarning, writeField(), and writeMetadata().
|
inline |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively.
Definition at line 703 of file Field3DFile.h.
References FieldBase::attribute, and FieldBase::name.
|
inline |
Writes a scalar layer to the "Default" partition.
Definition at line 715 of file Field3DFile.h.
|
inline |
Writes a layer to a specific partition. The partition will be created if not specified.
Definition at line 727 of file Field3DFile.h.
|
inline |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively.
Definition at line 740 of file Field3DFile.h.
|
inline |
Writes a scalar layer to the "Default" partition.
Definition at line 750 of file Field3DFile.h.
|
inline |
Writes a layer to a specific partition. The partition will be created if not specified.
Definition at line 762 of file Field3DFile.h.
|
inline |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively.
Definition at line 775 of file Field3DFile.h.
bool Field3DOutputFile::writeGlobalMetadata | ( | ) |
This routine is call if you want to write out global metadata to disk.
Definition at line 1234 of file Field3DFile.cpp.
References m_hdf5, m_root, Msg::print(), Msg::SevWarning, and writeMetadata().
bool Field3DOutputFile::writeGroupMembership | ( | ) |
This routine is called just before closing to write out any group membership to disk.
Definition at line 1252 of file Field3DFile.cpp.
References Field3DFileBase::m_groupMembership, m_hdf5, Msg::print(), Msg::SevWarning, and Hdf5Util::writeAttribute().
|
inlineprivatevirtual |
Closes the file if open.
Implements Field3DFileBase.
Definition at line 796 of file Field3DFile.h.
Referenced by create().
|
inlineprivate |
|
private |
Increment the partition or make it zero if there's not an integer suffix.
Definition at line 1302 of file Field3DFile.cpp.
References Field3DFileBase::m_partitionCount, Field3DFileBase::makeIntPartitionName(), and Field3DFileBase::removeUniqueId().
Referenced by writeLayer().
|
private |
Create newPartition given the input config.
Definition at line 1355 of file Field3DFile.cpp.
References Field3DFileBase::m_partitions, m_root, Field3DFileBase::partition(), Msg::print(), Msg::SevWarning, and writeMapping().
Referenced by writeLayer().
|
private |
Writes the mapping to the given Og node. Mappings are assumed to be light-weight enough to be stored as plain attributes under a group.
Definition at line 1013 of file Field3DFile.cpp.
References ClassFactory::createFieldMappingIO(), Msg::print(), Msg::SevWarning, and ClassFactory::singleton().
Referenced by createNewPartition().
|
private |
Writes metadata for this layer.
Definition at line 1045 of file Field3DFile.cpp.
References Msg::print(), and Msg::SevWarning.
Referenced by writeGlobalMetadata(), and writeLayer().
|
private |
Writes metadata for this file.
Definition at line 1140 of file Field3DFile.cpp.
References FieldMetadata::floatMetadata(), FieldMetadata::intMetadata(), Field3DFileBase::metadata(), Msg::print(), Msg::SevWarning, FieldMetadata::strMetadata(), FieldMetadata::vecFloatMetadata(), and FieldMetadata::vecIntMetadata().
|
staticprivate |
Whether to output ogawa files.
Definition at line 841 of file Field3DFile.h.
Referenced by create().
|
private |
Pointer to the Ogawa archive.
Definition at line 844 of file Field3DFile.h.
Referenced by create(), and writeLayer().
|
private |
Pointer to root group.
Definition at line 846 of file Field3DFile.h.
Referenced by create(), createNewPartition(), Field3DInputFile::readLayer(), Field3DInputFile::readProxyLayer(), and writeGlobalMetadata().
|
private |
HDF5 fallback.
Definition at line 849 of file Field3DFile.h.
Referenced by create(), Field3DInputFile::readProxyLayer(), writeGlobalMetadata(), and writeGroupMembership().