DatasetHeader Class Reference
[Graphics]
Loads metadata from a dataset.
More...
#include <DatasetHeader.hpp>
List of all members.
Public Member Functions |
| DatasetHeader (string filename) |
| DatasetHeader (istream &stream) |
vector< string > | getComments () const |
int | getDepth () const |
string | getEndian () const |
string | getFilename () const |
int | getHeight () const |
int | getHigh () const |
int | getLow () const |
int | getMax () const |
int | getMin () const |
int | getOffset () const |
Vector | getPitch () const |
string | getType () const |
int | getWidth () const |
void | print () const |
void | setEndian (const string &endian) |
void | setFilename (const string &filename) |
void | setLow (int low) |
void | setHigh (int high) |
void | setMax (int max) |
void | setMin (int min) |
void | setType (const string &type) |
void | setWidth (int width) |
void | setHeight (int height) |
void | setDepth (int depth) |
Protected Member Functions |
void | check () |
void | check (istream &stream) |
void | read () |
void | read (istream &stream) |
Private Attributes |
Vector | pitch |
int | beginning |
int | offset |
int | high |
int | low |
int | max |
int | min |
int | width |
int | height |
int | depth |
string | endian |
string | filename |
string | type |
vector< string > | comments |
Detailed Description
Loads metadata from a dataset.
Perhaps most significant is the type of the data, which determines how many bytes in the data make up a single sample and what C++ type the sample corresponds with.
Also important are the height, width, and depth of the dataset, which is measured in the number of samples, as well as the offset needed to skip over the header and get to the data.
Here is the form of a valid file:
VLIB.1
# Comments
# More comments
width height depth
type
endian
pitchX pitchY pitchZ
min max
low high
- See also:
- check()
-
getWidth()
-
getHeight()
-
getDepth()
-
getOffset()
-
getType()
Constructor & Destructor Documentation
Reads a header from a dataset file.
- Parameters:
-
[in] | filename | Path to the file. |
- Exceptions:
-
Reads a dataset header directly from an input stream.
- Parameters:
-
[in] | stream | Input stream to read from. |
- Exceptions:
-
Member Function Documentation
void check |
( |
istream & |
stream |
) |
[protected] |
Checks if the stream has a good header, then finds its beginning.
Determines if the header is good by reading the first line of the stream as text. It will only be deemed appropriate if the first line is equal to VLIB.1.
To find the beginning of the actual information in the header, it continues reading the stream by skipping over any comments. Note that comments are lines in which the first character is #.
At the end of the execution of this method, beginning
will be set to the number of lines that should be skipped to get to the start of the metadata in the stream's header. In other words, the next line after that will be the first line containing metadata.
- Exceptions:
-
| const_char* | if the stream does not have an appropriate header. |
void check |
( |
|
) |
[protected] |
Checks if the file exists, then calls check(istream&).
- Exceptions:
-
| const_char* | if the file could not be opened. |
vector< string > getComments |
( |
|
) |
const [inline] |
- Returns:
- User-added description.
int getDepth |
( |
|
) |
const [inline] |
- Returns:
- Number of samples in the Z direction.
string getEndian |
( |
|
) |
const [inline] |
- Returns:
- Little or big byte ordering.
string getFilename |
( |
|
) |
const [inline] |
- Returns:
- Path to the file the header is contained in.
int getHeight |
( |
|
) |
const [inline] |
- Returns:
- Number of samples in the Y direction.
int getHigh |
( |
|
) |
const [inline] |
- Returns:
- Highest value in the dataset according to the header.
int getLow |
( |
|
) |
const [inline] |
- Returns:
- Lowest value in the dataset according to the header.
int getMax |
( |
|
) |
const [inline] |
- Returns:
- Maximum possible value according to the header.
int getMin |
( |
|
) |
const [inline] |
- Returns:
- Minimum possible value according to the header.
int getOffset |
( |
|
) |
const [inline] |
- Returns:
- Lines to skip to get past the header.
In other words, the next byte after that will be the first byte of the actual samples. Because the Vlib specification is so strict, we assume that the values read are on six consecutive lines. Therefore the offset is just beginning + 6
, where beginning
is the value computed from the check() method.
Vector getPitch |
( |
|
) |
const [inline] |
- Returns:
- Size of samples in each direction.
string getType |
( |
|
) |
const [inline] |
- Returns:
- String representing the type of the data.
Generally this will be one of:
- uint8 for
char
- int16 for
short
- float for
float
int getWidth |
( |
|
) |
const [inline] |
- Returns:
- Number of samples in the X direction.
void read |
( |
istream & |
stream |
) |
[protected] |
Reads the details in the header and sets offset
.
- See also:
- getOffset()
void read |
( |
|
) |
[protected] |
The documentation for this class was generated from the following files:
- DatasetHeader.hpp
- DatasetHeader.cpp