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);
222 : name(nm), parentName(par), components(cpt)
255 void getPartitionNames(std::vector<std::string> &names)
const;
257 void getScalarLayerNames(std::vector<std::string> &names,
258 const std::string &partitionName)
const;
260 void getVectorLayerNames(std::vector<std::string> &names,
261 const std::string &partitionName)
const;
279 return m_hdf5Base->metadata();
288 return m_hdf5Base->metadata();
303 void printHierarchy()
const;
322 {
return partition(partitionName); }
334 void getIntPartitionNames(std::vector<std::string> &names)
const;
337 void getIntScalarLayerNames(std::vector<std::string> &names,
338 const std::string &intPartitionName)
const;
341 void getIntVectorLayerNames(std::vector<std::string> &names,
342 const std::string &intPartitionName)
const;
345 int numIntPartitions(
const std::string &partitionName)
const;
349 std::string makeIntPartitionName(
const std::string &partitionsName,
355 std::string intPartitionName(
const std::string &partitionName,
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);
466 return readLayers<Data_T>(layerName);
470 template <
class Data_T>
473 const std::string &layerName)
const
476 return m_hdf5->readScalarLayers<Data_T>(partitionName, layerName);
478 return readLayers<Data_T>(partitionName, layerName);
485 template <
class Data_T>
490 return m_hdf5->readVectorLayers<Data_T>(layerName);
492 return readLayers<FIELD3D_VEC3_T<Data_T> >(layerName);
496 template <
class Data_T>
499 const std::string &layerName)
const
502 return m_hdf5->readVectorLayers<Data_T>(partitionName, layerName);
504 return readLayers<FIELD3D_VEC3_T<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;
550 m_hdf5->closeInternal();
563 m_partitions.clear();
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) {
674 ms_doOgawa = enabled;
676 std::cerr <<
"WARNING: Field3D only supports Ogawa-backed files "
677 <<
"on little-endian systems." << std::endl;
686 template <
class Data_T>
690 return writeLayer<Data_T>(std::string(
"default"), layerName, layer);
695 template <
class Data_T>
696 bool writeLayer(
const std::string &partitionName,
697 const std::string &layerName,
702 template <
class Data_T>
705 return writeLayer<Data_T>(layer->
name, layer->
attribute, layer);
714 template <
class Data_T>
719 return m_hdf5->writeScalarLayer<Data_T>(layerName, layer);
721 return writeScalarLayer<Data_T>(std::string(
"default"), layerName, layer);
726 template <
class Data_T>
728 const std::string &layerName,
732 return m_hdf5->writeScalarLayer<Data_T>(partitionName, layerName, layer);
734 return writeLayer<Data_T>(partitionName, layerName, layer);
739 template <
class Data_T>
743 return m_hdf5->writeScalarLayer<Data_T>(layer);
745 return writeLayer<Data_T>(layer);
749 template <
class Data_T>
754 return m_hdf5->writeVectorLayer<Data_T>(layerName, layer);
756 return writeVectorLayer<Data_T>(std::string(
"default"), layerName, layer);
761 template <
class Data_T>
763 const std::string &layerName,
767 return m_hdf5->writeVectorLayer<Data_T>(partitionName, layerName, layer);
769 return writeLayer<FIELD3D_VEC3_T<Data_T> >(partitionName, layerName, layer);
774 template <
class Data_T>
778 return m_hdf5->writeVectorLayer<Data_T>(layer);
780 return writeLayer<FIELD3D_VEC3_T<Data_T> >(layer);
784 bool writeGlobalMetadata();
788 bool writeGroupMembership();
799 m_hdf5->closeInternal();
811 m_partitions.clear();
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...
virtual void metadataHasChanged(const std::string &)
This function should implemented by concrete classes to get the callback when metadata changes.
File::Partition::Ptr partition(const std::string &partitionName) const
Returns a pointer to the given partition.
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.
FieldMetadata m_metadata
metadata
std::vector< File::Partition::Ptr > PartitionList
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
std::vector< std::string > m_partitionNames
This stores partition names.
std::map< std::string, int > PartitionCountMap
PartitionCountMap m_partitionCount
Contains a counter for each partition name. This is used to keep multiple fields with the same name u...
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
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.
boost::intrusive_ptr< const Partition > CPtr
FieldMapping::Ptr mapping
Pointer to the mapping object.
static const char * staticClassType()
DEFINE_FIELD_RTTI_CONCRETE_CLASS
RefBase base
Convenience typedef for referring to base class.
std::vector< Layer > LayerList
boost::intrusive_ptr< Partition > Ptr
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)