EZC3D
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ezc3d::Header Class Reference

Header of a C3D file. More...

#include <Header.h>

Public Member Functions

 Header ()
 Create a valid header with minimal informations.
 
 Header (c3d &c3d, std::fstream &file)
 Read and store the header of an opened C3D file. More...
 
void print () const
 Print the header.
 
void write (std::fstream &f, std::streampos &dataStartPosition) const
 Write the header to an opened file. More...
 
void read (c3d &c3d, std::fstream &file)
 Read and store a header from an opened C3D file. More...
 
size_t nbOfZerosBeforeHeader () const
 Get the number of zeros before the header starts in the file. More...
 
size_t parametersAddress () const
 Get the byte at which the parameters start in the file. More...
 
size_t checksum () const
 Get the checksum of the header. More...
 
size_t nb3dPoints () const
 Get the number 3D points. More...
 
void nb3dPoints (size_t numberOfPoints)
 Set the number 3D points. More...
 
size_t nbAnalogs () const
 Get the number of analogs. More...
 
void nbAnalogs (size_t nbOfAnalogs)
 Set the number of analogs. More...
 
size_t nbAnalogsMeasurement () const
 Get the number of recorded analogs. More...
 
size_t nbFrames () const
 Get the number of frames. More...
 
size_t firstFrame () const
 Get the first frame. More...
 
void firstFrame (size_t frame)
 Set the first frame. More...
 
size_t lastFrame () const
 Get the last frame. More...
 
void lastFrame (size_t frame)
 Set the last frame. More...
 
size_t nbMaxInterpGap () const
 Get the maximal gap used for interpolation. More...
 
float scaleFactor () const
 Get the scaling factor to convert the 3D point. More...
 
size_t dataStart () const
 Get the number of 256-byte blocks to get to the points and analogous data in the file. More...
 
size_t nbAnalogByFrame () const
 Get the number of analog by frame. More...
 
void nbAnalogByFrame (size_t nbOfAnalogsByFrame)
 Set the number of analog by frame. More...
 
float frameRate () const
 Get the points frame rate in Hz. More...
 
void frameRate (float pointFrameRate)
 Set the points frame rate in Hz. More...
 
int emptyBlock1 () const
 Get the empty block 1. More...
 
int emptyBlock2 () const
 Get the empty block 2. More...
 
int emptyBlock3 () const
 Get the empty block 3. More...
 
int emptyBlock4 () const
 Get the empty block 4. More...
 
size_t keyLabelPresent () const
 Get the present label flag. More...
 
size_t firstBlockKeyLabel () const
 Get the first block of key labels (if present) More...
 
size_t fourCharPresent () const
 fourCharPresent More...
 
size_t nbEvents () const
 Get the number of defined time events (0 to 18) More...
 
const std::vector< float > & eventsTime () const
 Get the event times in seconds. More...
 
float eventsTime (size_t idx) const
 Get a particular event time of index idx in seconds. More...
 
std::vector< size_t > eventsDisplay () const
 Get the display flags. More...
 
size_t eventsDisplay (size_t idx) const
 Get a particular display flag of index idx. More...
 
const std::vector< std::string > & eventsLabel () const
 Get the event labels. More...
 
const std::string & eventsLabel (size_t idx) const
 Get a particular event label of index idx. More...
 

Protected Member Functions

PROCESSOR_TYPE readProcessorType (c3d &c3d, std::fstream &file)
 Reads the processor type in the parameter section, returns the file pointer where it was at the beggining of the function. More...
 

Protected Attributes

size_t _nbOfZerosBeforeHeader
 
size_t _parametersAddress
 
size_t _checksum
 
size_t _nb3dPoints
 
size_t _nbAnalogsMeasurement
 
size_t _firstFrame
 
size_t _lastFrame
 
size_t _nbMaxInterpGap
 
float _scaleFactor
 
size_t _dataStart
 
size_t _nbAnalogByFrame
 
float _frameRate
 
int _emptyBlock1
 
int _emptyBlock2
 
int _emptyBlock3
 
int _emptyBlock4
 
size_t _keyLabelPresent
 
size_t _firstBlockKeyLabel
 
size_t _fourCharPresent
 
size_t _nbEvents
 
std::vector< float > _eventsTime
 
std::vector< size_t > _eventsDisplay
 
std::vector< std::string > _eventsLabel
 

Detailed Description

Header of a C3D file.

Definition at line 16 of file Header.h.

Constructor & Destructor Documentation

◆ Header()

ezc3d::Header::Header ( ezc3d::c3d c3d,
std::fstream &  file 
)

Read and store the header of an opened C3D file.

Parameters
c3dC3D reference to copy the data in
fileAlready opened fstream file with read access

Definition at line 40 of file Header.cpp.

Member Function Documentation

◆ checksum()

size_t ezc3d::Header::checksum ( ) const

Get the checksum of the header.

Returns

The checksum of the header should be equals to 0x50 for a valid a c3d

Definition at line 241 of file Header.cpp.

◆ dataStart()

size_t ezc3d::Header::dataStart ( ) const

Get the number of 256-byte blocks to get to the points and analogous data in the file.

Returns
The number of 256-byte blocks to get to the points and analogous data in the file

Definition at line 312 of file Header.cpp.

◆ emptyBlock1()

int ezc3d::Header::emptyBlock1 ( ) const

Get the empty block 1.

Returns
The empty block 1

Definition at line 339 of file Header.cpp.

◆ emptyBlock2()

int ezc3d::Header::emptyBlock2 ( ) const

Get the empty block 2.

Returns
The empty block 2

Definition at line 344 of file Header.cpp.

◆ emptyBlock3()

int ezc3d::Header::emptyBlock3 ( ) const

Get the empty block 3.

Returns
The empty block 3

Definition at line 349 of file Header.cpp.

◆ emptyBlock4()

int ezc3d::Header::emptyBlock4 ( ) const

Get the empty block 4.

Returns
The empty block 4

Definition at line 354 of file Header.cpp.

◆ eventsDisplay() [1/2]

std::vector< size_t > ezc3d::Header::eventsDisplay ( ) const

Get the display flags.

Returns
The display flags

If it is 0x00, then it is ON. If it is 0x01, then it is OFF.

Definition at line 396 of file Header.cpp.

◆ eventsDisplay() [2/2]

size_t ezc3d::Header::eventsDisplay ( size_t  idx) const

Get a particular display flag of index idx.

Parameters
idxThe index of the event
Returns
The display flag

If it is 0x00, then it is ON. If it is 0x01, then it is OFF.

Throw a std::out_of_range exception if idx is larger than the number of events

Definition at line 401 of file Header.cpp.

◆ eventsLabel() [1/2]

const std::vector< std::string > & ezc3d::Header::eventsLabel ( ) const

Get the event labels.

Returns
The event labels

Definition at line 412 of file Header.cpp.

◆ eventsLabel() [2/2]

const std::string & ezc3d::Header::eventsLabel ( size_t  idx) const

Get a particular event label of index idx.

Parameters
idxThe index of the event
Returns
The event label in seconds

Throw a std::out_of_range exception if idx is larger than the number of events

Definition at line 417 of file Header.cpp.

◆ eventsTime() [1/2]

const std::vector< float > & ezc3d::Header::eventsTime ( ) const

Get the event times in seconds.

Returns
The event times in seconds

Definition at line 379 of file Header.cpp.

◆ eventsTime() [2/2]

float ezc3d::Header::eventsTime ( size_t  idx) const

Get a particular event time of index idx in seconds.

Parameters
idxThe index of the event
Returns
The event time in seconds

Throw a std::out_of_range exception if idx is larger than the number of events

Definition at line 384 of file Header.cpp.

◆ firstBlockKeyLabel()

size_t ezc3d::Header::firstBlockKeyLabel ( ) const

Get the first block of key labels (if present)

Returns
The first block of key labels (if present)

Definition at line 364 of file Header.cpp.

◆ firstFrame() [1/2]

size_t ezc3d::Header::firstFrame ( ) const

Get the first frame.

Returns
The first frame

Definition at line 282 of file Header.cpp.

◆ firstFrame() [2/2]

void ezc3d::Header::firstFrame ( size_t  frame)

Set the first frame.

Parameters
frame

Definition at line 287 of file Header.cpp.

◆ fourCharPresent()

size_t ezc3d::Header::fourCharPresent ( ) const

fourCharPresent

Returns

Definition at line 369 of file Header.cpp.

◆ frameRate() [1/2]

float ezc3d::Header::frameRate ( ) const

Get the points frame rate in Hz.

Returns
The points frame rate in Hz

Definition at line 329 of file Header.cpp.

◆ frameRate() [2/2]

void ezc3d::Header::frameRate ( float  pointFrameRate)

Set the points frame rate in Hz.

Parameters
pointFrameRateThe points frame rate in Hz

Definition at line 334 of file Header.cpp.

◆ keyLabelPresent()

size_t ezc3d::Header::keyLabelPresent ( ) const

Get the present label flag.

Returns
The present label flag

The present label flag. If it is equal to 12345, then label and range are present.

Definition at line 359 of file Header.cpp.

◆ lastFrame() [1/2]

size_t ezc3d::Header::lastFrame ( ) const

Get the last frame.

Returns
The last frame

Definition at line 292 of file Header.cpp.

◆ lastFrame() [2/2]

void ezc3d::Header::lastFrame ( size_t  frame)

Set the last frame.

Parameters
frame

Definition at line 297 of file Header.cpp.

◆ nb3dPoints() [1/2]

size_t ezc3d::Header::nb3dPoints ( ) const

Get the number 3D points.

Returns
The number of stored 3D points

Definition at line 246 of file Header.cpp.

◆ nb3dPoints() [2/2]

void ezc3d::Header::nb3dPoints ( size_t  numberOfPoints)

Set the number 3D points.

Parameters
numberOfPointsThe number of points

Definition at line 251 of file Header.cpp.

◆ nbAnalogByFrame() [1/2]

size_t ezc3d::Header::nbAnalogByFrame ( ) const

Get the number of analog by frame.

Returns
The number of analog by frame

Definition at line 317 of file Header.cpp.

◆ nbAnalogByFrame() [2/2]

void ezc3d::Header::nbAnalogByFrame ( size_t  nbOfAnalogsByFrame)

Set the number of analog by frame.

Parameters
nbOfAnalogsByFrameThe number of analog by frame

Definition at line 322 of file Header.cpp.

◆ nbAnalogs() [1/2]

size_t ezc3d::Header::nbAnalogs ( ) const

Get the number of analogs.

Returns
The number of analogs

Definition at line 256 of file Header.cpp.

◆ nbAnalogs() [2/2]

void ezc3d::Header::nbAnalogs ( size_t  nbOfAnalogs)

Set the number of analogs.

Parameters
nbOfAnalogsThe number of analogs

Definition at line 264 of file Header.cpp.

◆ nbAnalogsMeasurement()

size_t ezc3d::Header::nbAnalogsMeasurement ( ) const

Get the number of recorded analogs.

Returns
The number of recorded analogs

Definition at line 269 of file Header.cpp.

◆ nbEvents()

size_t ezc3d::Header::nbEvents ( ) const

Get the number of defined time events (0 to 18)

Returns
The number of defined time events (0 to 18)

Definition at line 374 of file Header.cpp.

◆ nbFrames()

size_t ezc3d::Header::nbFrames ( ) const

Get the number of frames.

Returns
The number of frames

Definition at line 274 of file Header.cpp.

◆ nbMaxInterpGap()

size_t ezc3d::Header::nbMaxInterpGap ( ) const

Get the maximal gap used for interpolation.

Returns
The maximal gap used for interpolation

Definition at line 302 of file Header.cpp.

◆ nbOfZerosBeforeHeader()

size_t ezc3d::Header::nbOfZerosBeforeHeader ( ) const

Get the number of zeros before the header starts in the file.

Returns
The number of zeros before the header starts in the file

Definition at line 209 of file Header.cpp.

◆ parametersAddress()

size_t ezc3d::Header::parametersAddress ( ) const

Get the byte at which the parameters start in the file.

Returns
The byte at which the parameters start in the file

Definition at line 214 of file Header.cpp.

◆ read()

void ezc3d::Header::read ( ezc3d::c3d c3d,
std::fstream &  file 
)

Read and store a header from an opened C3D file.

Parameters
c3dC3D reference to copy the data in
fileThe file stream already opened with read access

Definition at line 148 of file Header.cpp.

◆ readProcessorType()

ezc3d::PROCESSOR_TYPE ezc3d::Header::readProcessorType ( c3d c3d,
std::fstream &  file 
)
protected

Reads the processor type in the parameter section, returns the file pointer where it was at the beggining of the function.

Parameters
c3dC3D reference to copy the data in
fileopened file stream to be read
Returns
The processor type as specified in the c3d file (83-Intel, 84-DEC, 85-MIPS)

Definition at line 219 of file Header.cpp.

◆ scaleFactor()

float ezc3d::Header::scaleFactor ( ) const

Get the scaling factor to convert the 3D point.

Returns
The scaling factor to convert the 3D point

If the points are floats, then the scaling factor is if negative. Otherwise it is a integer

Definition at line 307 of file Header.cpp.

◆ write()

void ezc3d::Header::write ( std::fstream &  f,
std::streampos &  dataStartPosition 
) const

Write the header to an opened file.

Parameters
fAlready opened fstream file with write access
dataStartPositionReturns the byte where to put the data start parameter

Definition at line 94 of file Header.cpp.

Member Data Documentation

◆ _checksum

size_t ezc3d::Header::_checksum
protected

Byte 1.2

The checksum should be equals to 0x50 for a valid a c3d

Definition at line 88 of file Header.h.

◆ _dataStart

size_t ezc3d::Header::_dataStart
protected

Byte 9
The number of 256-byte blocks to get to the points and analogous data in the file

Definition at line 214 of file Header.h.

◆ _emptyBlock1

int ezc3d::Header::_emptyBlock1
protected

Byte 13-147

A fixed section of 0, this is defined by the standard for future use

Definition at line 261 of file Header.h.

◆ _emptyBlock2

int ezc3d::Header::_emptyBlock2
protected

Byte 152

A fixed section of 0, this is defined by the standard for future use

Definition at line 265 of file Header.h.

◆ _emptyBlock3

int ezc3d::Header::_emptyBlock3
protected

Byte 198
A fixed section of 0, this is defined by the standard for future use

Definition at line 269 of file Header.h.

◆ _emptyBlock4

int ezc3d::Header::_emptyBlock4
protected

Byte 235-256

A fixed section of 0, this is defined by the standard for future use

Definition at line 273 of file Header.h.

◆ _eventsDisplay

std::vector<size_t> ezc3d::Header::_eventsDisplay
protected

Byte 189-197

    The display flag. If it is 0x00, then it is ON.
    If it is 0x01, then it is OFF.  

Definition at line 335 of file Header.h.

◆ _eventsLabel

std::vector<std::string> ezc3d::Header::_eventsLabel
protected

Byte 199-234

         The event labels (4 characters by label)  

Definition at line 340 of file Header.h.

◆ _eventsTime

std::vector<float> ezc3d::Header::_eventsTime
protected

Byte 153-188

   The event times in seconds  

Definition at line 331 of file Header.h.

◆ _firstBlockKeyLabel

size_t ezc3d::Header::_firstBlockKeyLabel
protected

Byte 149

The first block of key labels (if present)

Definition at line 319 of file Header.h.

◆ _firstFrame

size_t ezc3d::Header::_firstFrame
protected

Byte 4

The first frame in the file. Note, contrary to the way it is stored in the file, it is 0-based, i.e. the first frame is 0.

Definition at line 144 of file Header.h.

◆ _fourCharPresent

size_t ezc3d::Header::_fourCharPresent
protected

Byte 150

The four characters flag. If it is equal to 12345, then event labels are represented as 4 characters. Otherwise it is 2 characters.

Definition at line 322 of file Header.h.

◆ _frameRate

float ezc3d::Header::_frameRate
protected

Byte 11-12

The points frame rate in Hz

Definition at line 243 of file Header.h.

◆ _keyLabelPresent

size_t ezc3d::Header::_keyLabelPresent
protected

Byte 148

The present label flag. If it is equal to 12345, then label and range are present.

Definition at line 303 of file Header.h.

◆ _lastFrame

size_t ezc3d::Header::_lastFrame
protected

Byte 5

The last frame in the file. Note, contrary to the way it is stored in the file, it is 0-based, i.e. the first frame is 0.

Definition at line 149 of file Header.h.

◆ _nb3dPoints

size_t ezc3d::Header::_nb3dPoints
protected

Byte 2

The number of stored 3D points

Definition at line 102 of file Header.h.

◆ _nbAnalogByFrame

size_t ezc3d::Header::_nbAnalogByFrame
protected

Byte 10

The number of analog by frame

Definition at line 226 of file Header.h.

◆ _nbAnalogsMeasurement

size_t ezc3d::Header::_nbAnalogsMeasurement
protected

Byte 3

The total number of analogous data per point frame

Definition at line 120 of file Header.h.

◆ _nbEvents

size_t ezc3d::Header::_nbEvents
protected

Byte 151

The number of defined time events (0 to 18)

Definition at line 327 of file Header.h.

◆ _nbMaxInterpGap

size_t ezc3d::Header::_nbMaxInterpGap
protected

Byte 6

The maximal gap used for interpolation

Definition at line 187 of file Header.h.

◆ _nbOfZerosBeforeHeader

size_t ezc3d::Header::_nbOfZerosBeforeHeader
protected

If the header doesn't start at the begining of the file remember the zero counts

Definition at line 58 of file Header.h.

◆ _parametersAddress

size_t ezc3d::Header::_parametersAddress
protected

Byte 1.1

The byte at which the parameters start in the file

Definition at line 61 of file Header.h.

◆ _scaleFactor

float ezc3d::Header::_scaleFactor
protected

Byte 7-8

The scaling factor to convert the 3D point. If the points are floats, then the scaling factor is if negative

Definition at line 199 of file Header.h.


The documentation for this class was generated from the following files: