Field3D
Field3DFileHDF5.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------//
2
3/*
4 * Copyright (c) 2009 Sony Pictures Imageworks Inc
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the
17 * distribution. Neither the name of Sony Pictures Imageworks nor the
18 * names of its contributors may be used to endorse or promote
19 * products derived from this software without specific prior written
20 * permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33 * OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36//----------------------------------------------------------------------------//
37
45//----------------------------------------------------------------------------//
46
47#ifndef _INCLUDED_Field3D_Field3DFileHDF5_H_
48#define _INCLUDED_Field3D_Field3DFileHDF5_H_
49
50//----------------------------------------------------------------------------//
51
52#include <list>
53#include <string>
54#include <vector>
55
56#include <hdf5.h>
57
58#include <boost/intrusive_ptr.hpp>
59
60#include "EmptyField.h"
61#include "Field.h"
62#include "FieldCache.h"
63#include "FieldMetadata.h"
64#include "ClassFactory.h"
65#include "Hdf5Util.h"
66
67//----------------------------------------------------------------------------//
68
69#include "ns.h"
70
72
73
74
75//----------------------------------------------------------------------------//
76// Function Declarations
77//----------------------------------------------------------------------------//
78
80// \{
81
84template <class Data_T>
85typename Field<Data_T>::Ptr
86readField(const std::string &className, hid_t layerGroup,
87 const std::string &filename, const std::string &layerPath);
88
92
96
101 FieldMapping::Ptr mapping);
102
104
105//----------------------------------------------------------------------------//
106// Layer
107//----------------------------------------------------------------------------//
108
111namespace FileHDF5 {
112
120class Layer
121{
122public:
124 std::string name;
127 std::string parent;
128};
129
130} // namespace FileHDF5
131
132//----------------------------------------------------------------------------//
133// Partition
134//----------------------------------------------------------------------------//
135
136namespace FileHDF5 {
137
146{
147public:
148
149 typedef std::vector<Layer> ScalarLayerList;
150 typedef std::vector<Layer> VectorLayerList;
151
152 typedef boost::intrusive_ptr<Partition> Ptr;
153 typedef boost::intrusive_ptr<const Partition> CPtr;
154
155 // RTTI replacement ----------------------------------------------------------
156
159
160 static const char *staticClassType()
161 {
162 return "Partition";
163 }
164
165 // Ctors, dtor ---------------------------------------------------------------
166
169 : RefBase()
170 { }
171
172 // From RefBase --------------------------------------------------------------
173
176
177 virtual std::string className() const;
178
180
181 // Main methods --------------------------------------------------------------
182
184 void addScalarLayer(const FileHDF5::Layer &layer);
186 void addVectorLayer(const FileHDF5::Layer &layer);
187
189 const FileHDF5::Layer* scalarLayer(const std::string &name) const;
191 const FileHDF5::Layer* vectorLayer(const std::string &name) const;
192
194 void getScalarLayerNames(std::vector<std::string> &names) const;
196 void getVectorLayerNames(std::vector<std::string> &names) const;
197
198 // Public data members -------------------------------------------------------
199
201 std::string name;
204
205private:
206
207 // Private data members ------------------------------------------------------
208
213
214 // Typedefs ------------------------------------------------------------------
215
217 typedef RefBase base;
218
219};
220
221} // namespace FileHDF5
222
223//----------------------------------------------------------------------------//
224// Field3DFileHDF5Base
225//----------------------------------------------------------------------------//
226
234//----------------------------------------------------------------------------//
235
237{
238public:
239
240 friend class Field3DInputFile;
241 friend class Field3DOutputFile;
242
243 // Structs -------------------------------------------------------------------
244
245 struct LayerInfo
246 {
247 std::string name;
248 std::string parentName;
250 LayerInfo(std::string par, std::string nm, int cpt)
251 : name(nm), parentName(par), components(cpt)
252 { /* Empty */ }
253 };
254
255 // Typedefs ------------------------------------------------------------------
256
257 typedef std::map<std::string, std::string> GroupMembershipMap;
258
259 // Ctor, dtor ----------------------------------------------------------------
260
263
266 virtual ~Field3DFileHDF5Base() = 0;
267
269
270 // Main methods --------------------------------------------------------------
271
273 void clear();
274
278 bool close();
279
282
284 void getPartitionNames(std::vector<std::string> &names) const;
286 void getScalarLayerNames(std::vector<std::string> &names,
287 const std::string &partitionName) const;
289 void getVectorLayerNames(std::vector<std::string> &names,
290 const std::string &partitionName) const;
291
294 FileHDF5::Partition::Ptr getPartition(const std::string &partitionName) const
295 { return partition(partitionName); }
296
298
301
305 std::string intPartitionName(const std::string &partitionName,
306 const std::string &layerName,
307 FieldRes::Ptr field);
308
311 std::string removeUniqueId(const std::string &partitionName) const;
312
314 void addGroupMembership(const GroupMembershipMap &groupMembers);
315
317
318 // Access to metadata --------------------------------------------------------
319
322 { return m_metadata; }
323
325 const FieldMetadata& metadata() const
326 { return m_metadata; }
327
330 virtual void metadataHasChanged(const std::string &/* name */)
331 { /* Empty */ }
332
333 // Debug ---------------------------------------------------------------------
334
337
338 void printHierarchy() const;
339
341
342protected:
343
344 // Internal typedefs ---------------------------------------------------------
345
346 typedef std::vector<FileHDF5::Partition::Ptr> PartitionList;
347 typedef std::map<std::string, int> PartitionCountMap;
348
349 // Convenience methods -------------------------------------------------------
350
353
355 void closeInternal();
358 FileHDF5::Partition::Ptr partition(const std::string &partitionName);
361 FileHDF5::Partition::Ptr partition(const std::string &partitionName) const;
362
364 void getIntPartitionNames(std::vector<std::string> &names) const;
367 void getIntScalarLayerNames(std::vector<std::string> &names,
368 const std::string &intPartitionName) const;
371 void getIntVectorLayerNames(std::vector<std::string> &names,
372 const std::string &intPartitionName) const;
373
375 int numIntPartitions(const std::string &partitionName) const;
376
379 std::string makeIntPartitionName(const std::string &partitionsName,
380 int i) const;
381
383
384 // Data members --------------------------------------------------------------
385
387 std::vector<LayerInfo> m_layerInfo;
388
394 std::vector<std::string> m_partitionNames;
395
399
404
407
408private:
409
410 // Private member functions --------------------------------------------------
411
414
415
416};
417
418//----------------------------------------------------------------------------//
419// Field3DInputFileHDF5
420//----------------------------------------------------------------------------//
421
435//----------------------------------------------------------------------------//
436
438{
439public:
440
441 friend class Field3DInputFile;
442 friend class Field3DOutputFile;
443
444 // Ctors, dtor ---------------------------------------------------------------
445
448
450 virtual ~Field3DInputFileHDF5();
451
453
454 // Main interface ------------------------------------------------------------
455
458
463 template <class Data_T>
464 typename Field<Data_T>::Vec
465 readScalarLayers(const std::string &layerName = std::string("")) const;
466
468 template <class Data_T>
469 typename Field<Data_T>::Vec
470 readScalarLayers(const std::string &partitionName,
471 const std::string &layerName) const;
472
477 template <class Data_T>
478 typename Field<FIELD3D_VEC3_T<Data_T> >::Vec
479 readVectorLayers(const std::string &layerName = std::string("")) const;
480
482 template <class Data_T>
483 typename Field<FIELD3D_VEC3_T<Data_T> >::Vec
484 readVectorLayers(const std::string &partitionName,
485 const std::string &layerName) const;
486
489 template <template <typename T> class Field_T, class Data_T>
490 typename Field_T<Data_T>::Vec
491 readScalarLayersAs(const std::string &layerName = std::string("")) const
492 {
493 typedef typename Field<Data_T>::Vec FieldList;
494 typedef typename Field_T<Data_T>::Vec TypedFieldList;
495
496 // First, read the layers as-is
499
500 // Loop over fields, converting if needed
502 typename FieldList::iterator i = originals.begin();
503 for (; i != originals.end(); ++i) {
504 typename Field_T<Data_T>::Ptr targetField;
506 if (targetField) {
507 output.push_back(targetField);
508 } else {
509 typename Field_T<Data_T>::Ptr newTarget(new Field_T<Data_T>);
510 newTarget->name = (*i)->name;
511 newTarget->attribute = (*i)->attribute;
512 newTarget->copyMetadata(**i);
513 newTarget->copyFrom(*i);
514 output.push_back(newTarget);
515 }
516 }
517
518 return output;
519 }
520
523 template <template <typename T> class Field_T, class Data_T>
524 typename Field_T<Data_T>::Vec
525 readScalarLayersAs(const std::string &partitionName,
526 const std::string &layerName) const
527 {
528 typedef typename Field<Data_T>::Vec FieldList;
529 typedef typename Field_T<Data_T>::Vec TypedFieldList;
530
531 // First, read the layers as-is
534
535 // Loop over fields, converting if needed
537 typename FieldList::iterator i = originals.begin();
538 for (; i != originals.end(); ++i) {
539 typename Field_T<Data_T>::Ptr targetField;
541 if (targetField) {
542 output.push_back(targetField);
543 } else {
544 typename Field_T<Data_T>::Ptr newTarget(new Field_T<Data_T>);
545 newTarget->name = (*i)->name;
546 newTarget->attribute = (*i)->attribute;
547 newTarget->copyMetadata(**i);
548 newTarget->copyFrom(*i);
549 output.push_back(newTarget);
550 }
551 }
552
553 return output;
554 }
555
558 template <template <typename T> class Field_T, class Data_T>
559 typename Field_T<FIELD3D_VEC3_T<Data_T> >::Vec
560 readVectorLayersAs(const std::string &layerName = std::string("")) const
561 {
563 typedef typename Field<FIELD3D_VEC3_T<Data_T> >::Vec FieldList;
564 typedef typename Field_T<FIELD3D_VEC3_T<Data_T> >::Vec TypedFieldList;
565
566 // First, read the layers as-is
569
570 // Loop over fields, converting if needed
572 typename FieldList::iterator i = originals.begin();
573 for (; i != originals.end(); ++i) {
574 typename TypedVField::Ptr targetField;
576 if (targetField) {
577 output.push_back(targetField);
578 } else {
579 typename TypedVField::Ptr newTarget(new TypedVField);
580 newTarget->name = (*i)->name;
581 newTarget->attribute = (*i)->attribute;
582 newTarget->copyMetadata(**i);
583 newTarget->copyFrom(*i);
584 output.push_back(newTarget);
585 }
586 }
587
588 return output;
589 }
590
593 template <template <typename T> class Field_T, class Data_T>
594 typename Field_T<FIELD3D_VEC3_T<Data_T> >::Vec
595 readVectorLayersAs(const std::string &partitionName,
596 const std::string &layerName) const
597 {
599 typedef typename Field<FIELD3D_VEC3_T<Data_T> >::Vec FieldList;
600 typedef typename Field_T<FIELD3D_VEC3_T<Data_T> >::Vec TypedFieldList;
601
602 // First, read the layers as-is
605
606 // Loop over fields, converting if needed
608 typename FieldList::iterator i = originals.begin();
609 for (; i != originals.end(); ++i) {
610 typename TypedVField::Ptr targetField;
612 if (targetField) {
613 output.push_back(targetField);
614 } else {
615 typename TypedVField::Ptr newTarget(new TypedVField);
616 newTarget->name = (*i)->name;
617 newTarget->attribute = (*i)->attribute;
618 newTarget->copyMetadata(**i);
619 newTarget->copyFrom(*i);
620 output.push_back(newTarget);
621 }
622 }
623
624 return output;
625 }
626
628
631
637 template <class Data_T>
639 readProxyLayer(const std::string &partitionName,
640 const std::string &layerName,
641 bool isVectorLayer) const;
642
647 template <class Data_T>
649 readProxyLayer(hid_t location, const std::string &name,
650 const std::string &attribute,
651 FieldMapping::Ptr mapping) const;
652
658 template <class Data_T>
660 readProxyScalarLayers(const std::string &name = std::string("")) const;
661
667 template <class Data_T>
669 readProxyVectorLayers(const std::string &name = std::string("")) const;
670
672
673 // File IO ---
674
677 bool open(const std::string &filename);
678
679 // Callback convenience methods ----------------------------------------------
680
683
685 herr_t parsePartition(hid_t loc_id, const std::string partitionName);
686
688 herr_t parseLayer(hid_t loc_id, const std::string &partitionName,
689 const std::string &layerName);
690
692
693 // Convenience methods -------------------------------------------------------
694
696 bool readGroupMembership(GroupMembershipMap &gpMembershipMap);
697
698private:
699
700 // Convenience methods -------------------------------------------------------
701
704 template <class Data_T>
705 typename Field<Data_T>::Ptr
706 readScalarLayer(const std::string &intPartitionName,
707 const std::string &layerName) const;
708
711 template <class Data_T>
712 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr
713 readVectorLayer(const std::string &intPartitionName,
714 const std::string &layerName) const;
715
718 template <class Data_T>
719 typename Field<Data_T>::Ptr
720 readLayer(const std::string &intPartitionName,
721 const std::string &layerName,
722 bool isVectorLayer) const;
723
725 bool readPartitionAndLayerInfo();
726
728 bool readMetadata(hid_t metadata_id, FieldBase::Ptr field) const;
729
731 bool readMetadata(hid_t metadata_id);
732
733 // Data members --------------------------------------------------------------
734
736 std::string m_filename;
737
738};
739
740//----------------------------------------------------------------------------//
741// Utility functions
742//----------------------------------------------------------------------------//
743
744
745//----------------------------------------------------------------------------//
746// Field3DOutputFileHDF5
747//----------------------------------------------------------------------------//
748
762//----------------------------------------------------------------------------//
763
765{
766public:
767
768 friend class Field3DInputFile;
769 friend class Field3DOutputFile;
770
771 // Enums ---------------------------------------------------------------------
772
775 FailOnExisting
776 };
777
778 // Ctors, dtor ---------------------------------------------------------------
779
782
784 virtual ~Field3DOutputFileHDF5();
785
787
788 // Main interface ------------------------------------------------------------
789
792
794 template <class Data_T>
795 bool writeScalarLayer(const std::string &layerName,
796 typename Field<Data_T>::Ptr layer)
797 { return writeScalarLayer<Data_T>(layerName, std::string("default"), layer); }
798
800 template <class Data_T>
801 bool writeVectorLayer(const std::string &layerName,
802 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer)
803 { return writeVectorLayer<Data_T>(layerName, std::string("default"), layer); }
804
807 template <class Data_T>
808 bool writeScalarLayer(const std::string &partitionName,
809 const std::string &layerName,
810 typename Field<Data_T>::Ptr layer);
811
814 template <class Data_T>
815 bool writeScalarLayer(typename Field<Data_T>::Ptr layer);
816
819 template <class Data_T>
820 bool writeVectorLayer(const std::string &partitionName,
821 const std::string &layerName,
822 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer);
823
826 template <class Data_T>
827 bool writeVectorLayer(typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer);
828
830
832 bool create(const std::string &filename, CreateMode cm = OverwriteMode);
833
835 bool writeGlobalMetadata();
836
839 bool writeGroupMembership();
840
842 std::string incrementPartitionName(std::string &pname);
843
845 template <class Data_T>
847 createNewPartition(const std::string &partitionName,
848 const std::string &layerName,
849 typename Field<Data_T>::Ptr field);
850 private:
851
852 // Convenience methods -------------------------------------------------------
853
857 bool writeMapping(hid_t partitionLocation, FieldMapping::Ptr mapping);
858
860 template <class Data_T>
861 bool writeLayer(const std::string &partitionName,
862 const std::string &layerName,
863 bool isVectorLayer,
864 typename Field<Data_T>::Ptr layer);
865
867 bool writeMetadata(hid_t metadataGroup, FieldBase::Ptr layer);
868
870 bool writeMetadata(hid_t metadataGroup);
871
872};
873
874//----------------------------------------------------------------------------//
875// Field3DInputFileHDF5-related callback functions
876//----------------------------------------------------------------------------//
877
879namespace InputFileHDF5 {
880
889
893FIELD3D_API herr_t parsePartitions(hid_t loc_id, const char *partitionName,
894 const H5L_info_t *linfo, void *opdata);
895
899FIELD3D_API herr_t parseLayers(hid_t loc_id, const char *partitionName,
900 const H5L_info_t *linfo, void *opdata);
901
902} // namespace InputFileHDF5
903
904//----------------------------------------------------------------------------//
905// Field3DInputFileHDF5
906//----------------------------------------------------------------------------//
907
908template <class Data_T>
909typename Field<Data_T>::Vec
910Field3DInputFileHDF5::readScalarLayers(const std::string &name) const
911{
912 using namespace std;
913
914 typedef typename Field<Data_T>::Ptr FieldPtr;
915 typedef typename Field<Data_T>::Vec FieldList;
916
918 std::vector<std::string> parts;
920
921 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
922 std::vector<std::string> layers;
924 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
925 // Only read if it matches the name
926 if ((name.length() == 0) || (*l == name)) {
927 FieldPtr mf = readScalarLayer<Data_T>(*p, *l);
928 if (mf) {
929 ret.push_back(mf);
930 }
931 }
932 }
933 }
934
935 return ret;
936}
937
938//----------------------------------------------------------------------------//
939
940template <class Data_T>
941typename Field<Data_T>::Vec
942Field3DInputFileHDF5::readScalarLayers(const std::string &partitionName,
943 const std::string &layerName) const
944{
945 using namespace std;
946
947 typedef typename Field<Data_T>::Ptr FieldPtr;
948 typedef typename Field<Data_T>::Vec FieldList;
949
951
952 if ((layerName.length() == 0) || (partitionName.length() == 0))
953 return ret;
954
955 std::vector<std::string> parts;
957
958 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
959 std::vector<std::string> layers;
961 if (removeUniqueId(*p) == partitionName) {
962 for (vector<string>::iterator l = layers.begin();
963 l != layers.end(); ++l) {
964 // Only read if it matches the name
965 if (*l == layerName) {
966 FieldPtr mf = readScalarLayer<Data_T>(*p, *l);
967 if (mf)
968 ret.push_back(mf);
969 }
970 }
971 }
972 }
973
974 return ret;
975}
976
977//----------------------------------------------------------------------------//
978
979template <class Data_T>
980typename Field<FIELD3D_VEC3_T<Data_T> >::Vec
981Field3DInputFileHDF5::readVectorLayers(const std::string &name) const
982{
983 using namespace std;
984
985 typedef typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr FieldPtr;
986 typedef typename Field<FIELD3D_VEC3_T<Data_T> >::Vec FieldList;
987
989
990 std::vector<std::string> parts;
992
993 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
994 std::vector<std::string> layers;
996 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
997 // Only read if it matches the name
998 if ((name.length() == 0) || (*l == name)) {
999 FieldPtr mf = readVectorLayer<Data_T>(*p, *l);
1000 if (mf)
1001 ret.push_back(mf);
1002 }
1003 }
1004 }
1005
1006 return ret;
1007}
1008
1009//----------------------------------------------------------------------------//
1010
1011template <class Data_T>
1012typename Field<FIELD3D_VEC3_T<Data_T> >::Vec
1013Field3DInputFileHDF5::readVectorLayers(const std::string &partitionName,
1014 const std::string &layerName) const
1015{
1016 using namespace std;
1017
1018 typedef typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr FieldPtr;
1019 typedef typename Field<FIELD3D_VEC3_T<Data_T> >::Vec FieldList;
1020
1021 FieldList ret;
1022
1023 if ((layerName.length() == 0) || (partitionName.length() == 0))
1024 return ret;
1025
1026 std::vector<std::string> parts;
1028
1029 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1030 std::vector<std::string> layers;
1032 if (removeUniqueId(*p) == partitionName) {
1033 for (vector<string>::iterator l = layers.begin();
1034 l != layers.end(); ++l) {
1035 // Only read if it matches the name
1036 if (*l == layerName) {
1037 FieldPtr mf = readVectorLayer<Data_T>(*p, *l);
1038 if (mf)
1039 ret.push_back(mf);
1040 }
1041 }
1042 }
1043 }
1044
1045 return ret;
1046}
1047
1048//----------------------------------------------------------------------------//
1049
1050template <class Data_T>
1051typename Field<Data_T>::Ptr
1052Field3DInputFileHDF5::readLayer(const std::string &intPartitionName,
1053 const std::string &layerName,
1054 bool isVectorLayer) const
1055{
1056 using namespace boost;
1057 using namespace std;
1058 using namespace Hdf5Util;
1059
1060 typedef typename Field<Data_T>::Ptr FieldPtr;
1061
1062 // Instantiate a null pointer for easier code reading
1063 FieldPtr nullPtr;
1064
1065 GlobalLock lock(g_hdf5Mutex);
1066
1067 // Find the partition
1069 if (!part) {
1070 Msg::print(Msg::SevWarning, "Couldn't find partition: " + intPartitionName);
1071 return nullPtr;
1072 }
1073
1074 // Find the layer in the partition
1075 const FileHDF5::Layer *l;
1076 if (isVectorLayer)
1077 l = part->vectorLayer(layerName);
1078 else
1079 l = part->scalarLayer(layerName);
1080 if (!l) {
1081 Msg::print(Msg::SevWarning, "Couldn't find layer: " + layerName );
1082 return nullPtr;
1083 }
1084
1085 // Open the layer group
1086 string layerPath = l->parent + "/" + l->name;
1087 H5ScopedGopen layerGroup(m_file, layerPath.c_str());
1088
1089 if (layerGroup.id() < 0) {
1090 Msg::print(Msg::SevWarning, "Couldn't find layer group " + layerName
1091 + " in .f3d file ");
1092 return nullPtr;
1093 }
1094
1095 // Get the class name
1096 string className;
1097 if (!readAttribute(layerGroup.id(), "class_name", className)) {
1098 Msg::print(Msg::SevWarning, "Couldn't find class_name attrib in layer " +
1099 layerName);
1100 return nullPtr;
1101 }
1102
1103 // Check the cache
1104
1106 FieldPtr cachedField = cache.getCachedField(m_filename, layerPath);
1107
1108 if (cachedField) {
1109 return cachedField;
1110 }
1111
1112 // Construct the field and load the data
1113
1114 // Unlock the g_hdf5Mutex while calling readField() so that other threads
1115 // have a chance to pre-empt loading in between (prevents deadlocks with
1116 // sparse reader)
1117 lock.unlock();
1118
1119 typename Field<Data_T>::Ptr field;
1120 field = readField<Data_T>(className, layerGroup.id(), m_filename, layerPath);
1121
1122 if (!field) {
1123#if 0 // This isn't really an error
1124 Msg::print(Msg::SevWarning, "Couldn't read the layer data of layer: "
1125 + layerName);
1126#endif
1127 return nullPtr;
1128 }
1129
1130 // Now we need to use Hdf5 again, so re-aquire the lock.
1131 lock.lock();
1132
1133 // read the metadata
1134 string metadataPath = layerPath + "/metadata";
1136 if (metadataGroup.id() > 0) {
1137 readMetadata(metadataGroup.id(), field);
1138 }
1139
1140 // Set the name of the field so it's possible to re-create the file
1142 field->attribute = layerName;
1143 field->setMapping(part->mapping);
1144
1145 // Cache the field for future use
1146 if (field) {
1147 cache.cacheField(field, m_filename, layerPath);
1148 }
1149
1150 return field;
1151}
1152
1153//----------------------------------------------------------------------------//
1154
1155template <class Data_T>
1157Field3DInputFileHDF5::readProxyLayer(const std::string &partitionName,
1158 const std::string &layerName,
1159 bool isVectorLayer) const
1160{
1161 using namespace boost;
1162 using namespace std;
1163 using namespace Hdf5Util;
1164
1165 GlobalLock lock(g_hdf5Mutex);
1166
1167 // Instantiate a null pointer for easier code reading
1169
1170 if ((layerName.length() == 0) || (partitionName.length() == 0))
1171 return emptyList;
1172
1173 std::vector<std::string> parts, layers;
1175
1176 bool foundPartition = false;
1177
1178 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1179 if (removeUniqueId(*p) == partitionName) {
1180 foundPartition = true;
1181 if (isVectorLayer) {
1183 } else {
1185 }
1186 for (vector<string>::iterator l = layers.begin();
1187 l != layers.end(); ++l) {
1188 if (*l == layerName) {
1189 // Find the partition
1191 if (!part) {
1192 Msg::print(Msg::SevWarning, "Couldn't find partition: " + *p);
1193 return emptyList;
1194 }
1195 // Find the layer
1196 const FileHDF5::Layer *layer;
1197 if (isVectorLayer)
1198 layer = part->vectorLayer(layerName);
1199 else
1200 layer = part->scalarLayer(layerName);
1201 if (!layer) {
1202 Msg::print(Msg::SevWarning, "Couldn't find layer: " + layerName);
1203 return emptyList;
1204 }
1205 // Open the layer group
1206 string layerPath = layer->parent + "/" + layer->name;
1207 H5ScopedGopen layerGroup(m_file, layerPath.c_str());
1208 if (layerGroup.id() < 0) {
1209 Msg::print(Msg::SevWarning, "Couldn't find layer group "
1210 + layerName + " in .f3d file ");
1211 return emptyList;
1212 }
1213
1214 // Make the proxy representation
1215 typename EmptyField<Data_T>::Ptr field =
1217 part->mapping);
1218
1219 // Read MIPField's number of mip levels
1220 int numLevels = 0;
1221 H5ScopedGopen mipGroup(layerGroup, "mip_levels");
1222 if (mipGroup.id() >= 0)
1223 readAttribute(mipGroup, "levels", 1, numLevels);
1224 field->metadata().setIntMetadata("mip_levels", numLevels);
1225
1226 // Add field to output
1227 output.push_back(field);
1228 }
1229 }
1230 }
1231 }
1232
1233 if (!foundPartition) {
1234 Msg::print(Msg::SevWarning, "Couldn't find partition: " + partitionName);
1235 return emptyList;
1236 }
1237
1238 return output;
1239}
1240
1241//----------------------------------------------------------------------------//
1242
1243template <class Data_T>
1246 const std::string &name,
1247 const std::string &attribute,
1248 FieldMapping::Ptr mapping) const
1249{
1250 using namespace boost;
1251 using namespace std;
1252 using namespace Hdf5Util;
1253
1255
1256 GlobalLock lock(g_hdf5Mutex);
1257
1258 // Read the extents and data window
1259 Box3i extents, dataW;
1260 if (!readAttribute(location, "extents", 6, extents.min.x)) {
1261 return null;
1262 }
1263 if (!readAttribute(location, "data_window", 6, dataW.min.x)) {
1264 return null;
1265 }
1266
1267 // Construct the field and load the data
1268 typename EmptyField<Data_T>::Ptr field(new EmptyField<Data_T>);
1269 field->setSize(extents, dataW);
1270
1271 // Read the metadata
1272 H5ScopedGopen metadataGroup(location, "metadata");
1273 if (metadataGroup.id() > 0) {
1274 readMetadata(metadataGroup.id(), field);
1275 }
1276
1277 // Set field properties
1278 field->name = name;
1279 field->attribute = attribute;
1280 field->setMapping(mapping);
1281
1282 return field;
1283}
1284
1285//----------------------------------------------------------------------------//
1286
1287template <class Data_T>
1290{
1291 using namespace std;
1292
1293 typedef typename EmptyField<Data_T>::Ptr FieldPtr;
1294 typedef std::vector<FieldPtr> FieldList;
1295
1296 FieldList ret;
1297
1298 std::vector<std::string> parts;
1300
1301 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1302 std::vector<std::string> layers;
1304 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
1305 // Only read if it matches the name
1306 if ((name.length() == 0) || (*l == name)) {
1307 FieldList f = readProxyLayer<Data_T>(*p, *l, false);
1308 for (typename FieldList::iterator i = f.begin(); i != f.end(); ++i) {
1309 if (*i) {
1310 ret.push_back(*i);
1311 }
1312 }
1313 }
1314 }
1315 }
1316
1317 return ret;
1318}
1319
1320//----------------------------------------------------------------------------//
1321
1322template <class Data_T>
1325{
1326 using namespace std;
1327
1328 typedef typename EmptyField<Data_T>::Ptr FieldPtr;
1329 typedef std::vector<FieldPtr> FieldList;
1330
1331 FieldList ret;
1332
1333 std::vector<std::string> parts;
1335
1336 for (vector<string>::iterator p = parts.begin(); p != parts.end(); ++p) {
1337 std::vector<std::string> layers;
1339 for (vector<string>::iterator l = layers.begin(); l != layers.end(); ++l) {
1340 // Only read if it matches the name
1341 if ((name.length() == 0) || (*l == name)) {
1342 FieldList f = readProxyLayer<Data_T>(*p, *l, true);
1343 for (typename FieldList::iterator i = f.begin(); i != f.end(); ++i) {
1344 if (*i) {
1345 ret.push_back(*i);
1346 }
1347 }
1348 }
1349 }
1350 }
1351
1352 return ret;
1353}
1354
1355//----------------------------------------------------------------------------//
1356
1357template <class Data_T>
1358typename Field<Data_T>::Ptr
1359Field3DInputFileHDF5::readScalarLayer(const std::string &intPartitionName,
1360 const std::string &layerName) const
1361{
1363}
1364
1365//----------------------------------------------------------------------------//
1366
1367template <class Data_T>
1368typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr
1369Field3DInputFileHDF5::readVectorLayer(const std::string &intPartitionName,
1370 const std::string &layerName) const
1371{
1373}
1374
1375//----------------------------------------------------------------------------//
1376// Field3DOutputFileHDF5
1377//----------------------------------------------------------------------------//
1378
1379template <class Data_T>
1381Field3DOutputFileHDF5::createNewPartition(const std::string &partitionName,
1382 const std::string & /* layerName */,
1383 typename Field<Data_T>::Ptr field)
1384{
1385 using namespace Hdf5Util;
1386 using namespace Exc;
1387
1388 GlobalLock lock(g_hdf5Mutex);
1389
1391
1392 newPart->name = partitionName;
1393
1394 H5ScopedGcreate partGroup(m_file, newPart->name.c_str());
1395 if (partGroup.id() < 0) {
1397 "Error creating partition: " + newPart->name);
1398 return FileHDF5::Partition::Ptr();
1399 }
1400
1401 m_partitions.push_back(newPart);
1402
1403 // Pick up new pointer
1404 FileHDF5::Partition::Ptr part = partition(partitionName);
1405
1406 // Add mapping group to the partition
1409 try {
1410 if (!writeMapping(partGroup.id(), field->mapping())) {
1412 "writeMapping returned false for an unknown reason ");
1413 return FileHDF5::Partition::Ptr();
1414 }
1415 }
1416 catch (WriteMappingException &e) {
1417 Msg::print(Msg::SevWarning, "Couldn't write mapping for partition: "
1418 + partitionName);
1419 return FileHDF5::Partition::Ptr();
1420 }
1421 catch (...) {
1423 "Unknown error when writing mapping for partition: "
1424 + partitionName);
1425 return FileHDF5::Partition::Ptr();
1426 }
1427
1428 // Set the mapping of the partition. Since all layers share their
1429 // partition's mapping, we can just pick this first one. All subsequent
1430 // additions to the same partition are checked to have the same mapping
1431 part->mapping = field->mapping();
1432
1433 // Tag node as partition
1434 // Create a version attribute on the root node
1435 if (!writeAttribute(partGroup.id(), "is_field3d_partition", "1")) {
1436 Msg::print(Msg::SevWarning, "Adding partition string.");
1437 return FileHDF5::Partition::Ptr();
1438 }
1439
1440 return part;
1441}
1442
1443//----------------------------------------------------------------------------//
1444
1445template <class Data_T>
1446bool
1448 const std::string &layerName,
1449 bool isVectorLayer,
1450 typename Field<Data_T>::Ptr field)
1451{
1452 using namespace std;
1453 using namespace Exc;
1454 using namespace Hdf5Util;
1455
1456 GlobalLock lock(g_hdf5Mutex);
1457
1458 if (!field) {
1460 "Called writeLayer with null pointer. Ignoring...");
1461 return false;
1462 }
1463
1464 if (m_file < 0) {
1466 "Attempting to write layer without opening file first. ");
1467 return false;
1468 }
1469
1470 string partitionName = intPartitionName(userPartitionName, layerName, field);
1471
1472 // See if the partition already exists or if we need to make it ---
1473
1474 FileHDF5::Partition::Ptr part = partition(partitionName);
1475
1476 if (!part) {
1477 part = createNewPartition<Data_T>(partitionName,layerName,field);
1478 if (!part)
1479 return false;
1480 } else {
1481
1482 if (!field->mapping()) {
1484 "Couldn't add layer \"" + layerName + "\" to partition \""
1485 + partitionName + "\" because the layer's mapping is null.");
1486 return false;
1487 }
1488
1489 // If the partition already existed, we need to make sure that the layer
1490 // doesn't also exist
1491 if (!isVectorLayer) {
1492 if (part->scalarLayer(layerName)) {
1493 //need to create a new partition and then add the layer to that
1494 std::string newPartitionName = incrementPartitionName(partitionName);
1496 if (!part)
1497 return false;
1498 }
1499 } else {
1500 if (part->vectorLayer(layerName)) {
1501 //need to create a new partition and then add the layer to that
1502 std::string newPartitionName = incrementPartitionName(partitionName);
1504 if (!part)
1505 return false;
1506 }
1507 }
1508 }
1509
1510 if (!part->mapping) {
1511 Msg::print(Msg::SevWarning, "Severe error - partition mapping is null: "
1512 + partitionName);
1513 return false;
1514 }
1515
1516 // Check that the mapping matches what's already in the Partition
1517 if (!field->mapping()->isIdentical(part->mapping)) {
1518 Msg::print(Msg::SevWarning, "Couldn't add layer \"" + layerName
1519 + "\" to partition \"" + partitionName
1520 + "\" because mapping doesn't match");
1521 return false;
1522 }
1523
1524 // Open the partition
1526
1527 // Build a Layer object ---
1528
1529 FileHDF5::Layer layer;
1530 layer.name = layerName;
1531 layer.parent = partitionName;
1532
1533 // Add Layer to file ---
1534
1537
1538 if (layerGroup.id() < 0) {
1539 Msg::print(Msg::SevWarning, "Error creating layer: " + layerName);
1540 return false;
1541 }
1542
1543 // Tag as layer
1544 if (!writeAttribute(layerGroup.id(), "class_type", "field3d_layer")) {
1545 Msg::print(Msg::SevWarning, "Error adding layer string.");
1546 return false;
1547 }
1548
1549 // Add metadata group and write it out
1550 H5ScopedGcreate metadataGroup(layerGroup.id(), "metadata");
1551 if (metadataGroup.id() < 0) {
1552 Msg::print(Msg::SevWarning, "Error creating group: metadata");
1553 return false;
1554 }
1555 if (!writeMetadata(metadataGroup.id(), field)) {
1556 Msg::print(Msg::SevWarning, "Error writing metadata.");
1557 return false;
1558 }
1559
1560 if (!writeField(layerGroup.id(), field)) {
1561 Msg::print(Msg::SevWarning, "Error writing layer: " + layer.name);
1562 return false;
1563 }
1564
1565 // Add layer to partition ---
1566
1567 if (isVectorLayer)
1568 part->addVectorLayer(layer);
1569 else
1570 part->addScalarLayer(layer);
1571
1572 return true;
1573}
1574
1575//----------------------------------------------------------------------------//
1576
1577template <class Data_T>
1578bool
1579Field3DOutputFileHDF5::writeScalarLayer(const std::string &partitionName,
1580 const std::string &layerName,
1581 typename Field<Data_T>::Ptr field)
1582{
1583 return writeLayer<Data_T>(partitionName, layerName, false, field);
1584}
1585
1586//----------------------------------------------------------------------------//
1587
1588template <class Data_T>
1589bool
1591{
1592 if (layer->name.size() == 0) {
1593 Msg::print(Msg::SevWarning, "Field3DOutputFileHDF5::writeScalarLayer: "
1594 "Tried to write a scalar layer with no name");
1595 return false;
1596 }
1597 if (layer->attribute.size() == 0) {
1598 Msg::print(Msg::SevWarning, "Field3DOutputFileHDF5::writeScalarLayer: "
1599 "Tried to write a scalar layer with no attribute name");
1600 return false;
1601 }
1602 return writeScalarLayer<Data_T>(layer->name, layer->attribute, layer);
1603}
1604
1605//----------------------------------------------------------------------------//
1606
1607template <class Data_T>
1608bool
1610writeVectorLayer(const std::string &partitionName,
1611 const std::string &layerName,
1612 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr field)
1613{
1614 return writeLayer<FIELD3D_VEC3_T<Data_T> >(partitionName, layerName,
1615 true, field);
1616}
1617
1618//----------------------------------------------------------------------------//
1619
1620template <class Data_T>
1621bool
1623 (typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer)
1624{
1625 if (layer->name.size() == 0) {
1626 Msg::print(Msg::SevWarning, "Field3DOutputFileHDF5::writeVectorLayer: "
1627 "Tried to write a vector layer with no name");
1628 return false;
1629 }
1630 if (layer->attribute.size() == 0) {
1631 Msg::print(Msg::SevWarning, "Field3DOutputFileHDF5::writeVectorLayer: "
1632 "Tried to write a vector layer with no attribute name");
1633 return false;
1634 }
1635 return writeVectorLayer<Data_T>(layer->name, layer->attribute, layer);
1636}
1637
1638//----------------------------------------------------------------------------//
1639// Template Function Implementations
1640//----------------------------------------------------------------------------//
1641
1642template <class Data_T>
1643typename Field<Data_T>::Ptr
1644readField(const std::string &className, hid_t layerGroup,
1645 const std::string &filename, const std::string &layerPath)
1646{
1647
1649
1650 typedef typename Field<Data_T>::Ptr FieldPtr;
1651
1652 FieldIO::Ptr io = factory.createFieldIO(className);
1653 if (!io) {
1654 Msg::print(Msg::SevWarning, "Unable to find class type: " +
1655 className);
1656 return FieldPtr();
1657 }
1658
1660 FieldBase::Ptr field = io->read(layerGroup, filename, layerPath, typeEnum);
1661
1662 if (!field) {
1663 // We don't need to print a message, because it could just be that
1664 // a layer of the specified data type and name couldn't be found
1665 return FieldPtr();
1666 }
1667
1668 FieldPtr result = field_dynamic_cast<Field<Data_T> >(field);
1669
1670 if (result)
1671 return result;
1672
1673 return FieldPtr();
1674}
1675
1676//----------------------------------------------------------------------------//
1677
1679
1680//----------------------------------------------------------------------------//
1681
1682#endif
Contains the ClassFactory class for registering Field3D classes.
Contains the EmptyField class.
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 bool writeFieldMapping(hid_t mappingGroup, FieldMapping::Ptr mapping)
This function creates a FieldMappingIO instance based on mapping->className() which then writes Field...
FIELD3D_API FieldMapping::Ptr readFieldMapping(hid_t mappingGroup)
This function creates a FieldMappingIO instance based on className read from mappingGroup location wh...
Contains the FieldCache class.
Basic container for metedata.
Contains Field, WritableField and ResizableField classes.
Contains various utility functions for Hdf5.
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
Definition Hdf5Util.cpp:67
boost::recursive_mutex::scoped_lock GlobalLock
Definition Hdf5Util.h:78
Imath::Box3i Box3i
Definition SpiMathLib.h:77
#define FIELD3D_MTX_T
Definition StdMathLib.h:99
DataTypeEnum
Definition Traits.h:108
static ClassFactory & singleton()
}
This subclass of Field does not store any data.
Definition EmptyField.h:88
boost::intrusive_ptr< EmptyField > Ptr
Definition EmptyField.h:93
std::vector< Ptr > Vec
Definition EmptyField.h:94
std::map< std::string, int > PartitionCountMap
std::vector< std::string > m_partitionNames
This stores partition names.
PartitionList m_partitions
Vector of partitions.
void getVectorLayerNames(std::vector< std::string > &names, const std::string &partitionName) const
Gets the names of all the vector layers in a given partition.
virtual void metadataHasChanged(const std::string &)
This function should implemented by concrete classes to get the callback when metadata changes.
Field3DFileHDF5Base(const Field3DFileHDF5Base &)
void getPartitionNames(std::vector< std::string > &names) const
Gets the names of all the partitions in the file.
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 ...
GroupMembershipMap m_groupMembership
Keeps track of group membership for each layer of partition name. The key is the "group" and the valu...
hid_t m_file
The hdf5 id of the current file. Will be -1 if no file is 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 ...
std::vector< FileHDF5::Partition::Ptr > PartitionList
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 ...
FileHDF5::Partition::Ptr partition(const std::string &partitionName) const
Returns a pointer to the given partition.
FieldMetadata & metadata()
accessor to the m_metadata class
void getScalarLayerNames(std::vector< std::string > &names, const std::string &partitionName) const
Gets the names of all the scalar layers in a given partition.
std::vector< LayerInfo > m_layerInfo
This stores layer info.
const FieldMetadata & metadata() const
Read only access to the m_metadata class.
std::string removeUniqueId(const std::string &partitionName) const
Strips any unique identifiers from the partition name and returns the original name.
FileHDF5::Partition::Ptr partition(const std::string &partitionName)
Returns a pointer to the given partition.
PartitionCountMap m_partitionCount
Contains a counter for each partition name. This is used to keep multiple fields with the same name u...
void getIntPartitionNames(std::vector< std::string > &names) const
Gets the names of all the -internal- partitions in the file.
FieldMetadata m_metadata
metadata
FileHDF5::Partition::Ptr getPartition(const std::string &partitionName) const
Returns a pointer to the given partition.
std::map< std::string, std::string > GroupMembershipMap
Provides reading of .f3d (internally, hdf5) files.
std::string m_filename
Filename, only to be set by open().
Field_T< FIELD3D_VEC3_T< Data_T > >::Vec readVectorLayersAs(const std::string &layerName=std::string("")) const
Retrieves a layers for all partitions. Converts it to the given template type if needed.
bool readMetadata(hid_t metadata_id, FieldBase::Ptr field) const
Read metadata for this layer.
Field_T< Data_T >::Vec readScalarLayersAs(const std::string &partitionName, const std::string &layerName) const
Retrieves a layers given their and its parent partition's name. Converts it to the given template typ...
EmptyField< Data_T >::Vec readProxyLayer(const std::string &partitionName, const std::string &layerName, bool isVectorLayer) const
Retrieves a proxy version (EmptyField) of each layer .
EmptyField< Data_T >::Vec readProxyVectorLayers(const std::string &name=std::string("")) const
Retrieves a proxy version (EmptyField) of each vector layer.
Field< Data_T >::Ptr readScalarLayer(const std::string &intPartitionName, const std::string &layerName) const
Retrieves a single layer given its and its parent partition's name. Maintains the on-disk data types.
Field< Data_T >::Vec readScalarLayers(const std::string &layerName=std::string("")) const
Retrieves all the layers of scalar type and maintains their on-disk data types.
Field_T< Data_T >::Vec readScalarLayersAs(const std::string &layerName=std::string("")) const
Retrieves all layers for all partitions. Converts it to the given template type if needed.
Field< FIELD3D_VEC3_T< Data_T > >::Vec readVectorLayers(const std::string &layerName=std::string("")) const
Retrieves all the layers of vector type and maintains their on-disk data types.
Field< FIELD3D_VEC3_T< Data_T > >::Ptr readVectorLayer(const std::string &intPartitionName, const std::string &layerName) const
Retrieves a single layer given its and its parent partition's name. Maintains the on-disk data types.
EmptyField< Data_T >::Vec readProxyScalarLayers(const std::string &name=std::string("")) const
Retrieves a proxy version (EmptyField) of each scalar layer.
Field_T< FIELD3D_VEC3_T< Data_T > >::Vec readVectorLayersAs(const std::string &partitionName, const std::string &layerName) const
Retrieves a layers given their and its parent partition's name. Converts it to the given template typ...
Field< Data_T >::Ptr readLayer(const std::string &intPartitionName, const std::string &layerName, bool isVectorLayer) const
This call does the actual reading of a layer. Notice that it expects a unique -internal- partition na...
Provides reading of .f3d (internally, hdf5 or Ogawa) files.
Provides writing of .f3d (internally, hdf5) files.
FileHDF5::Partition::Ptr createNewPartition(const std::string &partitionName, const std::string &layerName, typename Field< Data_T >::Ptr field)
create newPartition given the input config
bool writeVectorLayer(const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer)
Writes a vector layer to the "Default" partition.
bool writeMapping(hid_t partitionLocation, FieldMapping::Ptr mapping)
Writes the mapping to the given hdf5 node. Mappings are assumed to be light-weight enough to be store...
bool writeMetadata(hid_t metadataGroup, FieldBase::Ptr layer)
Writes metadata for this layer.
bool writeLayer(const std::string &partitionName, const std::string &layerName, bool isVectorLayer, typename Field< Data_T >::Ptr layer)
Performs the actual writing of the layer to disk.
bool writeScalarLayer(const std::string &layerName, typename Field< Data_T >::Ptr layer)
Writes a scalar layer to the "Default" partition.
std::string incrementPartitionName(std::string &pname)
increment the partition or make it zero if there's not an integer suffix
Provides writing of .f3d (internally, hdf5 or Ogawa) files.
boost::intrusive_ptr< FieldBase > Ptr
Definition Field.h:97
FieldMetadata & metadata()
accessor to the m_metadata class
Definition Field.h:155
std::string attribute
Optional name of the attribute the field represents.
Definition Field.h:173
std::string name
Optional name of the field.
Definition Field.h:171
static FieldCache & singleton()
Returns a reference to the FieldCache singleton.
Definition FieldCache.h:135
boost::intrusive_ptr< FieldIO > Ptr
Definition FieldIO.h:91
boost::intrusive_ptr< FieldMapping > Ptr
void setIntMetadata(const std::string &name, const int val)
Set the a int value for the given metadata name.
void setMapping(FieldMapping::Ptr mapping)
Sets the field's mapping.
Definition Field.h:347
boost::intrusive_ptr< FieldRes > Ptr
Definition Field.h:213
FieldMapping::Ptr mapping()
Returns a pointer to the mapping.
Definition Field.h:263
Definition Field.h:390
std::vector< Ptr > Vec
This is a convenience typedef for the list that Field3DInputFile::readScalarLayers() and Field3DInput...
Definition Field.h:403
boost::intrusive_ptr< Field > Ptr
Definition Field.h:395
std::string parent
The name of the parent partition. We need this in order to open its group.
std::string name
The name of the layer (always available)
boost::intrusive_ptr< Partition > Ptr
boost::intrusive_ptr< const Partition > CPtr
std::vector< Layer > VectorLayerList
std::string name
Name of the partition.
RefBase base
Convenience typedef for referring to base class.
VectorLayerList m_vectorLayers
The vector-valued layers belonging to this partition.
static const char * staticClassType()
FieldMapping::Ptr mapping
Pointer to the mapping object.
std::vector< Layer > ScalarLayerList
ScalarLayerList m_scalarLayers
The scalar-valued layers belonging to this partition.
Scoped object - creates a group on creation and closes it on destruction.
Definition Hdf5Util.h:166
Scoped object - opens a group on creation and closes it on destruction.
Definition Hdf5Util.h:195
RefBase & operator=(const RefBase &)
Assignment operator.
Definition RefCount.h:134
void setSize(const V3i &size)
Resizes the object.
Definition Field.h:913
Namespace for Exception objects.
Definition Exception.h:57
Namespace for file I/O specifics.
Contains utility functions and classes for Hdf5 files.
Definition Hdf5Util.h:86
Namespace for file input specifics.
FIELD3D_API herr_t parsePartitions(hid_t loc_id, const char *partitionName, const H5L_info_t *linfo, void *opdata)
Gets called from readPartitionAndLayerInfo to check each group found under the root of the file....
FIELD3D_API herr_t parseLayers(hid_t loc_id, const char *partitionName, const H5L_info_t *linfo, void *opdata)
Gets called from readPartitionAndLayerInfo to check each group found under the root of the file....
@ SevWarning
Definition Log.h:68
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity.
Definition Log.cpp:70
#define FIELD3D_API
Definition ns.h:77
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition ns.h:58
static DataTypeEnum typeEnum()
LayerInfo(std::string par, std::string nm, int cpt)
struct used to pass the class and partition info back to the parseLayers() callback
Field3DInputFileHDF5 * file