File: XdmfDataDesc.h

package info (click to toggle)
vtk6 6.1.0+dfsg2-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 165,164 kB
  • ctags: 226,428
  • sloc: cpp: 1,354,490; ansic: 730,748; python: 227,134; tcl: 48,285; xml: 8,290; yacc: 4,832; java: 3,827; perl: 3,108; lex: 1,809; sh: 1,437; asm: 471; makefile: 229
file content (245 lines) | stat: -rw-r--r-- 9,852 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*******************************************************************/
/*                               XDMF                              */
/*                   eXtensible Data Model and Format              */
/*                                                                 */
/*  Id : Id  */
/*  Date : $Date$ */
/*  Version : $Revision$ */
/*                                                                 */
/*  Author:                                                        */
/*     Jerry A. Clarke                                             */
/*     clarke@arl.army.mil                                         */
/*     US Army Research Laboratory                                 */
/*     Aberdeen Proving Ground, MD                                 */
/*                                                                 */
/*     Copyright @ 2002 US Army Research Laboratory                */
/*     All Rights Reserved                                         */
/*     See Copyright.txt or http://www.arl.hpc.mil/ice for details */
/*                                                                 */
/*     This software is distributed WITHOUT ANY WARRANTY; without  */
/*     even the implied warranty of MERCHANTABILITY or FITNESS     */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice   */
/*     for more information.                                       */
/*                                                                 */
/*******************************************************************/
#ifndef __XdmfDataDesc_h
#define __XdmfDataDesc_h

#include "XdmfObject.h"
#include "XdmfHDFSupport.h"

#define XDMF_SELECTALL    0
#define XDMF_HYPERSLAB    1
#define XDMF_COORDINATES  2

class XdmfDsmBuffer;


//! Number Type and Shape
/*!
    XdmfDataDesc is a class to operate of the \b TYPE and \b SHAPE of data.
    The \b TYPE refers to whether the data is Integer or Floating Point
    and its precision (i.e. 64 bit floats, 32 bit ints). The \b SHAPE refers to
    the \b rank and \b dimensions of the data. The \b rank is the number of
    dimensions. The \b dimensions are the length of each extent. For example,
    if we have an array that is 10x20x30 then the rank is 3 and the dimensions
    are 10,20,30. Data is specified with its slowest changing dimension listed 
    first. So for a datset with IDim = 100, JDim = 200, and KDim = 300, the
    shape would be (300, 200, 100).

    XdmfDataDesc also specifies \b SELECTION. This is the part of the dataset
    that will be accessed. \b SELECTION can either be a HyperSlab or Coordinates.
    HyperSlab specifies start, stride, and count (length) for each dimension. Coordinates
    specifies the parametric coordinates. For a 300x200x100 dataset, the HyperSlab
    (0, 1, 300, 99, 1, 1, 0, 1, 100) would specify the 99'th J Plane of data. The
    Coordinate (0,0,0) would specify the first value, and (299, 199, 99) would
    specify the last.
*/

class XDMF_EXPORT XdmfDataDesc : public XdmfObject {


public :
  XdmfDataDesc();
  virtual ~XdmfDataDesc();

//! Print Information to stdout
  void    Print( void );

//!  Set the type of number for homogeneous DataSets : all Float, all Int etc.
  XdmfInt32  SetNumberType( XdmfInt32 NumberType, XdmfInt64 CompoundSize = 16 );
//!  Set the type of number for homogeneous DataSets : all Float, all Int etc.
  XdmfInt32  SetNumberTypeFromString( XdmfConstString NumberType, XdmfInt64 CompoundSize = 16 );
//! Returns the number type
  XdmfInt32  GetNumberType( void );
//! Returns the number type as a character string
  XdmfConstString  GetNumberTypeAsString( void );
//! Set Rank and Dimensions of Dataset
  XdmfInt32  SetShape( XdmfInt32 Rank, XdmfInt64 *Dimensions );
//! Fills Dimensions and returns Rank
  XdmfInt32  GetShape( XdmfInt64 *Dimensions );
//! Returns a SPACE separated string of the dimensions
  XdmfConstString  GetShapeAsString( void );
//! Copy the Selection from one Desc to another
  XdmfInt32  CopySelection( XdmfDataDesc *DataDesc );
//! Copy the Shape from one Desc to another
  XdmfInt32  CopyShape( XdmfDataDesc *DataDesc );
//! Copy the Number Type from one Desc to another
  XdmfInt32  CopyType( XdmfDataDesc *DataDesc ) {
        return( this->CopyType( DataDesc->GetDataType() ) );
        }
#ifndef SWIG
#ifndef DOXYGEN_SKIP
  XdmfInt32  CopyShape( hid_t DataSpace );
  XdmfInt32  CopyType( hid_t DataType );
#endif  /* DOXYGEN_SKIP */
#endif  /* SWIG */

//! Convenience function to set shape linear
/*!
    Sets the rank = 1, and Dimensions[0] = Length
*/
  XdmfInt32  SetNumberOfElements( XdmfInt64 Length ) {
        return( this->SetShape( 1, &Length ) );
        };
//! Set Rank and Dimensions of Dataset From a String
  XdmfInt32  SetShapeFromString( XdmfConstString String  );

//! Select the Entire Dataset for Transfer
  XdmfInt32  SelectAll( void );
//! Select by Start, Stride, Count mechanism
  XdmfInt32  SelectHyperSlab( XdmfInt64 *Start, XdmfInt64 *Stride, XdmfInt64 *Count );
//! Select by Start, Stride, Count mechanism via String
  XdmfInt32  SelectHyperSlabFromString( XdmfConstString Start, XdmfConstString Stride, XdmfConstString Count );
//! Fills in Start, Stride, and Count. Returns the rank
  XdmfInt32  GetHyperSlab( XdmfInt64 *Start, XdmfInt64 *Stride, XdmfInt64 *Count );
//! Returns the HyperSlab as a SPACE separated string
/*!
    Return value is
\verbatim
    Start[0] Start[1] ... Start[N]
    Stride[0] Stride[1] ... Stride[N]
    Count[0] Count[1] ... Count[N]
\endverbatim
*/
  XdmfConstString  GetHyperSlabAsString( void );
//! Select via explicit parametric coordinates
  XdmfInt32  SelectCoordinates( XdmfInt64 NumberOfElements, XdmfInt64 *Coordinates );
//! Select via explicit parametric coordinates as a string
  XdmfInt32  SelectCoordinatesFromString( XdmfConstString Coordinates );
//! Return Selection coordinates 
  XdmfInt64  *GetCoordinates( XdmfInt64 Start = 0, XdmfInt64 Nelements = 0 );
//! Return Selection coordinates as a string
  XdmfConstString  GetCoordinatesAsString( XdmfInt64 Start =0, XdmfInt64 Nelements = 0 );
//! Get the number of selected elements
  XdmfInt64  GetSelectionSize( void );
//! Get the number of total elements in a dataset
  XdmfInt64  GetNumberOfElements( void );

//! Get the Compression Value
  XdmfGetValueMacro( Compression, XdmfInt32 );
//! Set the Compression Value
  XdmfSetValueMacro( Compression, XdmfInt32 );
  XdmfInt32 SetCompression(){return(this->SetCompression(0));};

//! Get the number of dimensions
  XdmfGetValueMacro( Rank, XdmfInt32 );
//! Get the length of each dimension
  XdmfGetIndexValueMacro( Dimension, XdmfInt64 );

//! Get the Start of HyperSlab Selection
  XdmfGetIndexValueMacro( Start, XdmfInt64 );
//! Get the Stride of HyperSlab Selection
  XdmfGetIndexValueMacro( Stride, XdmfInt64 );
//! Get the count of HyperSlab Selection
  XdmfGetIndexValueMacro( Count, XdmfInt64 );

//! Get the selection type ( HyperSlab / Coordinates )
  XdmfGetValueMacro( SelectionType, XdmfInt32 );
//! Get the selection type as a string
  XdmfConstString GetSelectionTypeAsString( void );

//! Internal Method to Get Low Level DataType
  XdmfGetValueMacro( DataType, hid_t );
//! Internal Method to Get Low Level DataSpace
  XdmfGetValueMacro( DataSpace, hid_t );

//! Get the size ( in bytes ) of the base Element
  XdmfInt64  GetElementSize( void );

//! Compound Data Type Access: SetDataType( XDMF_COMPOUND_TYPE ) must be called First
#ifndef SWIG
  XdmfInt32  AddCompoundMember( XdmfConstString Name,
        XdmfInt32 NumberType = XDMF_FLOAT32_TYPE,
        XdmfInt32 Rank = 1,
        XdmfInt64 *Dimensions = NULL,
        XdmfInt64 Offset = 0);
#endif

  XdmfInt32  AddCompoundMemberFromString( XdmfConstString Name,
        XdmfConstString NumberType,
        XdmfConstString Shape,
        XdmfInt64  Offset = 0);

//! Get the total number of members in the Compound Data Set
  XdmfInt64  GetNumberOfMembers( void );
//! Get the member name
  XdmfConstString  GetMemberName( XdmfInt64 Index );
//! Get the Total Number of Element in the member
  XdmfInt64  GetMemberLength( XdmfInt64 Index );
//! Get the total size ( in bytes ) of the member
  XdmfInt64  GetMemberSize( XdmfInt64 Index );
//! Get the Shape of the member
  XdmfInt32  GetMemberShape( XdmfInt64 Index, XdmfInt64 *Dimensions );
  XdmfConstString  GetMemberShapeAsString(  XdmfInt64 Index );
//! Get the member base number type
  XdmfInt32  GetMemberType( XdmfInt64 Index );
//! Get the member base number type as a string 
  XdmfConstString  GetMemberTypeAsString( XdmfInt64 Index );
//! Get the member offset
  XdmfInt64  GetMemberOffset( XdmfInt64 Index );
//! Set the name of the Heavy Data Set when written (if applicable)
  XdmfSetStringMacro(HeavyDataSetName);
//! Get the name of the Heavy Data Set when written (if applicable)
  XdmfGetStringMacro(HeavyDataSetName);
//! Get DSM Buffer
  XdmfGetValueMacro(DsmBuffer, XdmfDsmBuffer *);
//! Set DSM Buffer
  XdmfSetValueMacro(DsmBuffer, XdmfDsmBuffer *);




//! Internal Method to Copy From Exiting Type and Space
//  XdmfInt32  Copy( hid_t DataType, hid_t DataSpace );

protected:
  // HDF5 Stuff
  hid_t           DataType;
  hid_t    DataSpace;
/*
  H5T_class_t     Class;
  H5T_order_t     Order;
  size_t          Size;
*/
  XdmfInt32  SelectionType;
  XdmfInt32  NumberType;
  XdmfInt32  Rank;
  XdmfInt32  Compression;
  XdmfInt64  NextOffset;
  XdmfInt64  Dimension[XDMF_MAX_DIMENSION];
#if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&((H5_VERS_MINOR>6)||((H5_VERS_MINOR==6)&&(H5_VERS_RELEASE>=4))))
  hsize_t  Start[XDMF_MAX_DIMENSION];
#else
  hssize_t  Start[XDMF_MAX_DIMENSION];
#endif
  hsize_t    Stride[XDMF_MAX_DIMENSION];
  hsize_t    Count[XDMF_MAX_DIMENSION];

  void SetShapeString(XdmfConstString shape);
  XdmfString ShapeString;
  XdmfString   HeavyDataSetName;
  XdmfDsmBuffer *DsmBuffer;
};

#endif // __XdmfDataDesc_h