1 /*******************************************************************/ 2 /* XDMF */ 3 /* eXtensible Data Model and Format */ 4 /* */ 5 /* Id : Id */ 6 /* Date : $Date$ */ 7 /* Version : $Revision$ */ 8 /* */ 9 /* Author: */ 10 /* Jerry A. Clarke */ 11 /* clarke@arl.army.mil */ 12 /* US Army Research Laboratory */ 13 /* Aberdeen Proving Ground, MD */ 14 /* */ 15 /* Copyright @ 2002 US Army Research Laboratory */ 16 /* All Rights Reserved */ 17 /* See Copyright.txt or http://www.arl.hpc.mil/ice for details */ 18 /* */ 19 /* This software is distributed WITHOUT ANY WARRANTY; without */ 20 /* even the implied warranty of MERCHANTABILITY or FITNESS */ 21 /* FOR A PARTICULAR PURPOSE. See the above copyright notice */ 22 /* for more information. */ 23 /* */ 24 /*******************************************************************/ 25 #ifndef __XdmfDataDesc_h 26 #define __XdmfDataDesc_h 27 28 #include "XdmfObject.h" 29 #include "XdmfHDFSupport.h" 30 31 #define XDMF_SELECTALL 0 32 #define XDMF_HYPERSLAB 1 33 #define XDMF_COORDINATES 2 34 35 namespace xdmf2 36 { 37 38 class XdmfDsmBuffer; 39 40 41 //! Number Type and Shape 42 /*! 43 XdmfDataDesc is a class to operate of the \b TYPE and \b SHAPE of data. 44 The \b TYPE refers to whether the data is Integer or Floating Point 45 and its precision (i.e. 64 bit floats, 32 bit ints). The \b SHAPE refers to 46 the \b rank and \b dimensions of the data. The \b rank is the number of 47 dimensions. The \b dimensions are the length of each extent. For example, 48 if we have an array that is 10x20x30 then the rank is 3 and the dimensions 49 are 10,20,30. Data is specified with its slowest changing dimension listed 50 first. So for a datset with IDim = 100, JDim = 200, and KDim = 300, the 51 shape would be (300, 200, 100). 52 53 XdmfDataDesc also specifies \b SELECTION. This is the part of the dataset 54 that will be accessed. \b SELECTION can either be a HyperSlab or Coordinates. 55 HyperSlab specifies start, stride, and count (length) for each dimension. Coordinates 56 specifies the parametric coordinates. For a 300x200x100 dataset, the HyperSlab 57 (0, 1, 300, 99, 1, 1, 0, 1, 100) would specify the 99'th J Plane of data. The 58 Coordinate (0,0,0) would specify the first value, and (299, 199, 99) would 59 specify the last. 60 */ 61 62 class XDMF_EXPORT XdmfDataDesc : public XdmfObject { 63 64 65 public : 66 XdmfDataDesc(); 67 virtual ~XdmfDataDesc(); 68 69 //! Print Information to stdout 70 void Print( void ); 71 72 //! Set the type of number for homogeneous DataSets : all Float, all Int etc. 73 XdmfInt32 SetNumberType( XdmfInt32 NumberType, XdmfInt64 CompoundSize = 16 ); 74 //! Set the type of number for homogeneous DataSets : all Float, all Int etc. 75 XdmfInt32 SetNumberTypeFromString( XdmfConstString NumberType, XdmfInt64 CompoundSize = 16 ); 76 //! Returns the number type 77 XdmfInt32 GetNumberType( void ); 78 //! Returns the number type as a character string 79 XdmfConstString GetNumberTypeAsString( void ); 80 //! Set Rank and Dimensions of Dataset 81 XdmfInt32 SetShape( XdmfInt32 Rank, XdmfInt64 *Dimensions ); 82 //! Fills Dimensions and returns Rank 83 XdmfInt32 GetShape( XdmfInt64 *Dimensions ); 84 //! Returns a SPACE separated string of the dimensions 85 XdmfConstString GetShapeAsString( void ); 86 //! Copy the Selection from one Desc to another 87 XdmfInt32 CopySelection( XdmfDataDesc *DataDesc ); 88 //! Copy the Shape from one Desc to another 89 XdmfInt32 CopyShape( XdmfDataDesc *DataDesc ); 90 //! Copy the Number Type from one Desc to another CopyType(XdmfDataDesc * DataDesc)91 XdmfInt32 CopyType( XdmfDataDesc *DataDesc ) { 92 return( this->CopyType( DataDesc->GetDataType() ) ); 93 } 94 #ifndef SWIG 95 #ifndef DOXYGEN_SKIP 96 XdmfInt32 CopyShape( hid_t DataSpace ); 97 XdmfInt32 CopyType( hid_t DataType ); 98 #endif /* DOXYGEN_SKIP */ 99 #endif /* SWIG */ 100 101 //! Convenience function to set shape linear 102 /*! 103 Sets the rank = 1, and Dimensions[0] = Length 104 */ SetNumberOfElements(XdmfInt64 Length)105 XdmfInt32 SetNumberOfElements( XdmfInt64 Length ) { 106 return( this->SetShape( 1, &Length ) ); 107 }; 108 //! Set Rank and Dimensions of Dataset From a String 109 XdmfInt32 SetShapeFromString( XdmfConstString String ); 110 111 //! Select the Entire Dataset for Transfer 112 XdmfInt32 SelectAll( void ); 113 //! Select by Start, Stride, Count mechanism 114 XdmfInt32 SelectHyperSlab( XdmfInt64 *Start, XdmfInt64 *Stride, XdmfInt64 *Count ); 115 //! Select by Start, Stride, Count mechanism via String 116 XdmfInt32 SelectHyperSlabFromString( XdmfConstString Start, XdmfConstString Stride, XdmfConstString Count ); 117 //! Fills in Start, Stride, and Count. Returns the rank 118 XdmfInt32 GetHyperSlab( XdmfInt64 *Start, XdmfInt64 *Stride, XdmfInt64 *Count ); 119 //! Returns the HyperSlab as a SPACE separated string 120 /*! 121 Return value is 122 \verbatim 123 Start[0] Start[1] ... Start[N] 124 Stride[0] Stride[1] ... Stride[N] 125 Count[0] Count[1] ... Count[N] 126 \endverbatim 127 */ 128 XdmfConstString GetHyperSlabAsString( void ); 129 //! Select via explicit parametric coordinates 130 XdmfInt32 SelectCoordinates( XdmfInt64 NumberOfElements, XdmfInt64 *Coordinates ); 131 //! Select via explicit parametric coordinates as a string 132 XdmfInt32 SelectCoordinatesFromString( XdmfConstString Coordinates ); 133 //! Return Selection coordinates 134 XdmfInt64 *GetCoordinates( XdmfInt64 Start = 0, XdmfInt64 Nelements = 0 ); 135 //! Return Selection coordinates as a string 136 XdmfConstString GetCoordinatesAsString( XdmfInt64 Start =0, XdmfInt64 Nelements = 0 ); 137 //! Get the number of selected elements 138 XdmfInt64 GetSelectionSize( void ); 139 //! Get the number of total elements in a dataset 140 XdmfInt64 GetNumberOfElements( void ); 141 142 //! Get the Compression Value 143 XdmfGetValueMacro( Compression, XdmfInt32 ); 144 //! Set the Compression Value 145 XdmfSetValueMacro( Compression, XdmfInt32 ); SetCompression()146 XdmfInt32 SetCompression(){return(this->SetCompression(0));}; 147 148 //! Get the number of dimensions 149 XdmfGetValueMacro( Rank, XdmfInt32 ); 150 //! Get the length of each dimension 151 XdmfGetIndexValueMacro( Dimension, XdmfInt64 ); 152 153 //! Get the Start of HyperSlab Selection 154 XdmfGetIndexValueMacro( Start, XdmfInt64 ); 155 //! Get the Stride of HyperSlab Selection 156 XdmfGetIndexValueMacro( Stride, XdmfInt64 ); 157 //! Get the count of HyperSlab Selection 158 XdmfGetIndexValueMacro( Count, XdmfInt64 ); 159 160 //! Get the selection type ( HyperSlab / Coordinates ) 161 XdmfGetValueMacro( SelectionType, XdmfInt32 ); 162 //! Get the selection type as a string 163 XdmfConstString GetSelectionTypeAsString( void ); 164 165 //! Internal Method to Get Low Level DataType 166 XdmfGetValueMacro( DataType, hid_t ); 167 //! Internal Method to Get Low Level DataSpace 168 XdmfGetValueMacro( DataSpace, hid_t ); 169 170 //! Get the size ( in bytes ) of the base Element 171 XdmfInt64 GetElementSize( void ); 172 173 //! Compound Data Type Access: SetDataType( XDMF_COMPOUND_TYPE ) must be called First 174 #ifndef SWIG 175 XdmfInt32 AddCompoundMember( XdmfConstString Name, 176 XdmfInt32 NumberType = XDMF_FLOAT32_TYPE, 177 XdmfInt32 Rank = 1, 178 XdmfInt64 *Dimensions = NULL, 179 XdmfInt64 Offset = 0); 180 #endif 181 182 XdmfInt32 AddCompoundMemberFromString( XdmfConstString Name, 183 XdmfConstString NumberType, 184 XdmfConstString Shape, 185 XdmfInt64 Offset = 0); 186 187 //! Get the total number of members in the Compound Data Set 188 XdmfInt64 GetNumberOfMembers( void ); 189 //! Get the member name 190 XdmfConstString GetMemberName( XdmfInt64 Index ); 191 //! Get the Total Number of Element in the member 192 XdmfInt64 GetMemberLength( XdmfInt64 Index ); 193 //! Get the total size ( in bytes ) of the member 194 XdmfInt64 GetMemberSize( XdmfInt64 Index ); 195 //! Get the Shape of the member 196 XdmfInt32 GetMemberShape( XdmfInt64 Index, XdmfInt64 *Dimensions ); 197 XdmfConstString GetMemberShapeAsString( XdmfInt64 Index ); 198 //! Get the member base number type 199 XdmfInt32 GetMemberType( XdmfInt64 Index ); 200 //! Get the member base number type as a string 201 XdmfConstString GetMemberTypeAsString( XdmfInt64 Index ); 202 //! Get the member offset 203 XdmfInt64 GetMemberOffset( XdmfInt64 Index ); 204 //! Set the name of the Heavy Data Set when written (if applicable) 205 XdmfSetStringMacro(HeavyDataSetName); 206 //! Get the name of the Heavy Data Set when written (if applicable) 207 XdmfGetStringMacro(HeavyDataSetName); 208 //! Get DSM Buffer 209 XdmfGetValueMacro(DsmBuffer, XdmfDsmBuffer *); 210 //! Set DSM Buffer 211 XdmfSetValueMacro(DsmBuffer, XdmfDsmBuffer *); 212 213 214 215 216 //! Internal Method to Copy From Exiting Type and Space 217 // XdmfInt32 Copy( hid_t DataType, hid_t DataSpace ); 218 219 protected: 220 // HDF5 Stuff 221 hid_t DataType; 222 hid_t DataSpace; 223 /* 224 H5T_class_t Class; 225 H5T_order_t Order; 226 size_t Size; 227 */ 228 XdmfInt32 SelectionType; 229 XdmfInt32 NumberType; 230 XdmfInt32 Rank; 231 XdmfInt32 Compression; 232 XdmfInt64 NextOffset; 233 XdmfInt64 Dimension[XDMF_MAX_DIMENSION]; 234 #if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&((H5_VERS_MINOR>6)||((H5_VERS_MINOR==6)&&(H5_VERS_RELEASE>=4)))) 235 hsize_t Start[XDMF_MAX_DIMENSION]; 236 #else 237 hssize_t Start[XDMF_MAX_DIMENSION]; 238 #endif 239 hsize_t Stride[XDMF_MAX_DIMENSION]; 240 hsize_t Count[XDMF_MAX_DIMENSION]; 241 242 void SetShapeString(XdmfConstString shape); 243 XdmfString ShapeString; 244 XdmfString HeavyDataSetName; 245 XdmfDsmBuffer *DsmBuffer; 246 }; 247 248 } 249 #endif // __XdmfDataDesc_h 250