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;
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;
269 void addGroupMembership(
const GroupMembershipMap &groupMembers);
279 return m_hdf5Base->metadata();
288 return m_hdf5Base->metadata();
303 void printHierarchy()
const;
322 {
return partition(partitionName); }
325 virtual void closeInternal() = 0;
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);
664 { ms_doOgawa = enabled; }
670 template <
class Data_T>
674 return writeLayer<Data_T>(std::string(
"default"), layerName, layer);
679 template <
class Data_T>
680 bool writeLayer(
const std::string &partitionName,
681 const std::string &layerName,
686 template <
class Data_T>
689 return writeLayer<Data_T>(layer->
name, layer->
attribute, layer);
698 template <
class Data_T>
703 return m_hdf5->writeScalarLayer<Data_T>(layerName, layer);
705 return writeScalarLayer<Data_T>(std::string(
"default"), layerName, layer);
710 template <
class Data_T>
712 const std::string &layerName,
716 return m_hdf5->writeScalarLayer<Data_T>(partitionName, layerName, layer);
718 return writeLayer<Data_T>(partitionName, layerName, layer);
723 template <
class Data_T>
727 return m_hdf5->writeScalarLayer<Data_T>(layer);
729 return writeLayer<Data_T>(layer);
733 template <
class Data_T>
735 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer)
738 return m_hdf5->writeVectorLayer<Data_T>(layerName, layer);
740 return writeVectorLayer<Data_T>(std::string(
"default"), layerName, layer);
745 template <
class Data_T>
747 const std::string &layerName,
748 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer)
751 return m_hdf5->writeVectorLayer<Data_T>(partitionName, layerName, layer);
753 return writeLayer<FIELD3D_VEC3_T<Data_T> >(partitionName, layerName, layer);
758 template <
class Data_T>
762 return m_hdf5->writeVectorLayer<Data_T>(layer);
764 return writeLayer<FIELD3D_VEC3_T<Data_T> >(layer);
768 bool writeGlobalMetadata();
772 bool writeGroupMembership();
783 m_hdf5->closeInternal();
795 m_partitions.clear();
805 std::string incrementPartitionName(std::string &pname);
809 createNewPartition(
const std::string &partitionName,
817 bool writeMetadata(OgOGroup &metadataGroup,
FieldBase::Ptr layer);
820 bool writeMetadata(OgOGroup &metadataGroup);
833 boost::shared_ptr<Field3DOutputFileHDF5>
m_hdf5;
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Namespace for file I/O specifics.
boost::shared_ptr< OgOGroup > m_root
Pointer to root group.
boost::intrusive_ptr< Partition > Ptr
std::map< std::string, int > PartitionCountMap
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Contains forward declarations for Ogawa classes.
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 ...
std::map< std::string, std::string > GroupMembershipMap
boost::shared_ptr< Field3DOutputFileHDF5 > m_hdf5
HDF5 fallback.
Provides writing of .f3d (internally, hdf5 or Ogawa) files.
std::string name
Name of the partition.
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 ...
boost::intrusive_ptr< FieldBase > Ptr
RefBase base
Convenience typedef for referring to base class.
Contains the EmptyField class.
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::intrusive_ptr< FieldRes > Ptr
bool writeScalarLayer(const std::string &layerName, typename Field< Data_T >::Ptr layer)
Writes a scalar layer to the "Default" partition.
PartitionCountMap m_partitionCount
Contains a counter for each partition name. This is used to keep multiple fields with the same name u...
boost::shared_ptr< Field3DFileHDF5Base > m_hdf5Base
HDF5 fallback.
bool fileExists(const std::string &filename)
checks to see if a file/directory exists or not
std::vector< Layer > LayerList
std::vector< std::string > m_partitionNames
This stores partition names.
boost::intrusive_ptr< FieldMapping > Ptr
FieldMetadata m_metadata
metadata
std::string name
The name of the layer (always available)
PartitionList m_partitions
Vector of partitions.
Contains the Field3DFileHDF5 classesOSS sanitized.
Provides writing of .f3d (internally, hdf5) files.
static void useOgawa(const bool enabled)
Whether to output ogawa files.
std::vector< Ptr > Vec
This is a convenience typedef for the list that Field3DInputFile::readScalarLayers() and Field3DInput...
const FieldMetadata & metadata() const
Read only access to the m_metadata class.
static const char * staticClassType()
boost::intrusive_ptr< EmptyField > Ptr
static bool ms_doOgawa
Whether to output ogawa files.
boost::intrusive_ptr< const Partition > CPtr
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 writeLayer(const std::string &layerName, typename Field< Data_T >::Ptr layer)
Writes a scalar layer to the "Default" partition.
LayerInfo(std::string par, std::string nm, int cpt)
boost::shared_ptr< Alembic::Ogawa::OArchive > m_archive
Pointer to the Ogawa archive.
std::vector< LayerInfo > m_layerInfo
This stores layer info.
std::string attribute
Optional name of the attribute the field represents.
Contains Field, WritableField and ResizableField classes.
FieldMetadata & metadata()
accessor to the m_metadata class
Contains the ClassFactory class for registering Field3D classes.
boost::shared_ptr< OgOGroup > m_group
Group representing the partition.
File::Partition::Ptr getPartition(const std::string &partitionName) const
Returns a pointer to the given partition.
FieldMapping::Ptr mapping
Pointer to the mapping object.
LayerList m_layers
The layers belonging to this partition.
GroupMembershipMap m_groupMembership
Keeps track of group membership for each layer of partition name. The key is the "group" and the valu...
std::vector< File::Partition::Ptr > PartitionList
virtual void closeInternal()
Closes the file if open.
virtual void metadataHasChanged(const std::string &)
This function should implemented by concrete classes to get the callback when metadata changes...
std::string parent
The name of the parent partition. We need this in order to open its group.
boost::intrusive_ptr< Field > Ptr
bool writeVectorLayer(const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer)
Writes a scalar layer to the "Default" partition.
std::string name
Optional name of the field.
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.