48#ifndef _INCLUDED_Field3D_Field3DFile_H_
49#define _INCLUDED_Field3D_Field3DFile_H_
57#include <boost/shared_ptr.hpp>
127 typedef boost::intrusive_ptr<Partition>
Ptr;
128 typedef boost::intrusive_ptr<const Partition>
CPtr;
152 virtual std::string className()
const;
162 const File::Layer* layer(
const std::string &name)
const;
165 void getLayerNames(std::vector<std::string> &names)
const;
168 OgOGroup& group()
const;
170 void setGroup(boost::shared_ptr<OgOGroup> ptr);
258 const std::string &partitionName)
const;
261 const std::string &partitionName)
const;
303 void printHierarchy()
const;
356 const std::string &layerName,
361 std::string
removeUniqueId(
const std::string &partitionName)
const;
431 bool open(
const std::string &filename);
436 const static std::string encodings[2] = {
"Ogawa",
"HDF5" };
437 return encodings[
m_hdf5 ? 1 : 0];
443 template <
class Data_T>
445 readLayers(
const std::string &layerName = std::string(
""))
const;
447 template <
class Data_T>
449 readLayers(
const std::string &partitionName,
450 const std::string &layerName)
const;
459 template <
class Data_T>
464 return m_hdf5->readScalarLayers<Data_T>(layerName);
470 template <
class Data_T>
473 const std::string &layerName)
const
476 return m_hdf5->readScalarLayers<Data_T>(partitionName, layerName);
485 template <
class Data_T>
490 return m_hdf5->readVectorLayers<Data_T>(layerName);
496 template <
class Data_T>
499 const std::string &layerName)
const
502 return m_hdf5->readVectorLayers<Data_T>(partitionName, layerName);
517 template <
class Data_T>
519 readProxyLayer(
const std::string &partitionName,
520 const std::string &layerName,
521 bool isVectorLayer)
const;
528 template <
class Data_T>
530 readProxyScalarLayers(
const std::string &name = std::string(
""))
const;
537 template <
class Data_T>
539 readProxyVectorLayers(
const std::string &name = std::string(
""))
const;
574 template <
class Data_T>
576 readLayer(
const std::string &intPartitionName,
577 const std::string &layerName)
const;
582 template <
class Data_T>
584 readProxyLayer(OgIGroup &location,
const std::string &name,
585 const std::string &attribute,
589 bool readPartitionAndLayerInfo();
592 bool readMetadata(
const OgIGroup &metadataGroup,
FieldBase::Ptr field)
const;
595 bool readMetadata(
const OgIGroup &metadataGroup);
607 boost::shared_ptr<Field3DInputFileHDF5>
m_hdf5;
660 bool create(
const std::string &filename, CreateMode cm = OverwriteMode);
673 if (u.c[0] == 0x67) {
676 std::cerr <<
"WARNING: Field3D only supports Ogawa-backed files "
677 <<
"on little-endian systems." << std::endl;
686 template <
class Data_T>
695 template <
class Data_T>
696 bool writeLayer(
const std::string &partitionName,
697 const std::string &layerName,
702 template <
class Data_T>
714 template <
class Data_T>
719 return m_hdf5->writeScalarLayer<Data_T>(layerName, layer);
726 template <
class Data_T>
728 const std::string &layerName,
732 return m_hdf5->writeScalarLayer<Data_T>(partitionName, layerName, layer);
739 template <
class Data_T>
743 return m_hdf5->writeScalarLayer<Data_T>(layer);
749 template <
class Data_T>
754 return m_hdf5->writeVectorLayer<Data_T>(layerName, layer);
761 template <
class Data_T>
763 const std::string &layerName,
767 return m_hdf5->writeVectorLayer<Data_T>(partitionName, layerName, layer);
774 template <
class Data_T>
778 return m_hdf5->writeVectorLayer<Data_T>(layer);
784 bool writeGlobalMetadata();
788 bool writeGroupMembership();
821 std::string incrementPartitionName(std::string &pname);
825 createNewPartition(
const std::string &partitionName,
833 bool writeMetadata(OgOGroup &metadataGroup,
FieldBase::Ptr layer);
836 bool writeMetadata(OgOGroup &metadataGroup);
849 boost::shared_ptr<Field3DOutputFileHDF5>
m_hdf5;
Contains the ClassFactory class for registering Field3D classes.
Contains the EmptyField class.
Contains the Field3DFileHDF5 classes.
bool fileExists(const std::string &filename)
checks to see if a file/directory exists or not
Contains Field, WritableField and ResizableField classes.
Contains forward declarations for Ogawa classes.
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.
virtual void metadataHasChanged(const std::string &)
This function should implemented by concrete classes to get the callback when metadata changes.
void getScalarLayerNames(std::vector< std::string > &names, const std::string &partitionName) const
Gets the names of all the scalar layers in a given partition.
File::Partition::Ptr partition(const std::string &partitionName) const
Returns a pointer to the given partition.
std::string makeIntPartitionName(const std::string &partitionsName, int i) const
Makes an internal partition name given the external partition name. Effectively just tacks on ....
std::vector< File::Partition::Ptr > PartitionList
Field3DFileBase(const Field3DFileBase &)
FieldMetadata & metadata()
accessor to the m_metadata class
virtual void closeInternal()=0
Closes the file if open.
File::Partition::Ptr getPartition(const std::string &partitionName) const
Returns a pointer to the given partition.
std::map< std::string, int > PartitionCountMap
FieldMetadata m_metadata
metadata
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.
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.
std::vector< std::string > m_partitionNames
This stores partition names.
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 ...
PartitionCountMap m_partitionCount
Contains a counter for each partition name. This is used to keep multiple fields with the same name u...
std::map< std::string, std::string > GroupMembershipMap
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....
const FieldMetadata & metadata() const
Read only access to the m_metadata class.
std::vector< LayerInfo > m_layerInfo
This stores layer info.
Provides writing of .f3d (internally, hdf5) files.
Provides writing of .f3d (internally, hdf5 or Ogawa) 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.
static void useOgawa(const bool enabled)
Whether to output ogawa files.
boost::shared_ptr< OgOGroup > m_root
Pointer to root group.
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.
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 ...
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.
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 ...
boost::shared_ptr< Alembic::Ogawa::OArchive > m_archive
Pointer to the Ogawa archive.
bool writeScalarLayer(const std::string &layerName, typename Field< Data_T >::Ptr layer)
Writes a scalar layer to the "Default" partition.
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 ...
bool writeVectorLayer(const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer)
Writes a scalar layer to the "Default" partition.
boost::intrusive_ptr< FieldBase > Ptr
std::string attribute
Optional name of the attribute the field represents.
std::string name
Optional name of the field.
boost::intrusive_ptr< FieldMapping > Ptr
boost::intrusive_ptr< FieldRes > Ptr
std::vector< Ptr > Vec
This is a convenience typedef for the list that Field3DInputFile::readScalarLayers() and Field3DInput...
boost::intrusive_ptr< Field > Ptr
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.
std::vector< Layer > LayerList
RefBase base
Convenience typedef for referring to base class.
FieldMapping::Ptr mapping
Pointer to the mapping object.
static const char * staticClassType()
boost::intrusive_ptr< Partition > Ptr
DEFINE_FIELD_RTTI_CONCRETE_CLASS
boost::intrusive_ptr< const Partition > CPtr
RefBase & operator=(const RefBase &)
Assignment operator.
Namespace for file I/O specifics.
#define FIELD3D_NAMESPACE_HEADER_CLOSE
LayerInfo(std::string par, std::string nm, int cpt)