VAPoR  0.1
Public Member Functions | Static Public Member Functions | Friends | List of all members
VAPoR::SignificanceMap Class Reference

Implements a significance map. More...

#include <SignificanceMap.h>

Inheritance diagram for VAPoR::SignificanceMap:
VetsUtil::MyBase

Public Member Functions

 SignificanceMap ()
 
 SignificanceMap (size_t nx, size_t ny=1, size_t nz=1, size_t nt=1)
 
 SignificanceMap (std::vector< size_t > dims)
 
 SignificanceMap (const unsigned char *map, size_t nx, size_t ny=1, size_t nz=1, size_t nt=1)
 
 SignificanceMap (const unsigned char *map, std::vector< size_t > dims)
 
 SignificanceMap (const SignificanceMap &)
 
 ~SignificanceMap ()
 
int Reshape (std::vector< size_t > dims)
 
int Reshape (size_t nx, size_t ny=1, size_t nz=1, size_t nt=1)
 
void GetShape (std::vector< size_t > &dims) const
 
int Set (size_t idx)
 
int SetXYZT (size_t x, size_t y=0, size_t z=0, size_t t=0)
 
bool Test (size_t idx) const
 
bool TestXYZT (size_t x, size_t y=0, size_t z=0, size_t t=0) const
 
int Clear (size_t idx)
 
int ClearXYZT (size_t x, size_t y=0, size_t z=0, size_t t=0)
 
void Clear ()
 
size_t GetNumSignificant () const
 
int GetCoordinatesXYZT (size_t i, size_t *x, size_t *y=NULL, size_t *z=NULL, size_t *t=NULL) const
 
int GetCoordinates (size_t i, size_t *idx) const
 
void GetNextEntryRestart ()
 
int GetNextEntry (size_t *idx)
 
int GetNextEntryXYZT (size_t *x, size_t *y, size_t *z, size_t *t)
 
size_t GetMapSize (size_t num_entries) const
 
size_t GetMapSize () const
 
void GetMap (const unsigned char **map, size_t *maplen)
 
void GetMap (unsigned char *map)
 
int SetMap (const unsigned char *map)
 
int Append (const SignificanceMap &smap)
 
void Invert ()
 
void Sort ()
 
SignificanceMapoperator= (const SignificanceMap &map)
 
- Public Member Functions inherited from VetsUtil::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Member Functions

static size_t GetMapSize (vector< size_t > dims, size_t num_entries)
 
- Static Public Member Functions inherited from VetsUtil::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message. More...
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code. More...
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code. More...
 
static int GetErrCode ()
 Retrieve the current error code. More...
 
static void SetErrMsgCB (ErrMsgCB_T cb)
 
static ErrMsgCB_T GetErrMsgCB ()
 
static void SetErrMsgFilePtr (FILE *fp)
 
static const FILE * SetErrMsgFilePtr ()
 
static void SetDiagMsg (const char *format,...)
 Record a formatted diagnostic message. More...
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 

Friends

std::ostream & operator<< (std::ostream &o, const SignificanceMap &sigmap)
 

Additional Inherited Members

- Public Types inherited from VetsUtil::MyBase
typedef void(* ErrMsgCB_T )(const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T )(const char *msg)
 
- Static Public Attributes inherited from VetsUtil::MyBase
static char * ErrMsg
 
static int ErrCode
 
static int ErrMsgSize
 
static FILE * ErrMsgFilePtr
 
static ErrMsgCB_T ErrMsgCB
 
static char * DiagMsg
 
static int DiagMsgSize
 
static FILE * DiagMsgFilePtr
 
static DiagMsgCB_T DiagMsgCB
 
static bool Enabled
 
- Protected Member Functions inherited from VetsUtil::MyBase
void SetClassName (const string &name)
 

Detailed Description

Implements a significance map.

Author
John Clyne
Version
Revision
1.5
Date
Date
2012/02/28 18:15:58

This class implements a quick and dirty significance map - a mapping indicating which entries in an array are valid and which are not.

Definition at line 35 of file SignificanceMap.h.

Constructor & Destructor Documentation

VAPoR::SignificanceMap::SignificanceMap ( )
VAPoR::SignificanceMap::SignificanceMap ( size_t  nx,
size_t  ny = 1,
size_t  nz = 1,
size_t  nt = 1 
)

Significance map constructors for 1D, 2D, 3D, and 4D maps

Parameters
[in]nxDimension of X axis (fastest varying)
[in]nyDimension of Y axis (second fastest varying)
[in]nzDimension of Z axis (third fastest varying)
[in]ntDimension of Z axis (fourth fastest varying)
[in]dimsA vector specifying the number of dimensions and their lengths.
VAPoR::SignificanceMap::SignificanceMap ( std::vector< size_t >  dims)
VAPoR::SignificanceMap::SignificanceMap ( const unsigned char *  map,
size_t  nx,
size_t  ny = 1,
size_t  nz = 1,
size_t  nt = 1 
)

Significance map constructors for 1D, 2D, 3D, and 4D maps, using a previously created map. I.e. a map returned from GetMap()

Parameters
[in]mapAn encoded significance map returned by GetMap()
[in]nxDimension of X axis (fastest varying)
[in]nyDimension of Y axis (second fastest varying)
[in]nzDimension of Z axis (third fastest varying)
[in]ntDimension of Z axis (fourth fastest varying)
[in]dimsA vector specifying the number of dimensions and their lengths.
VAPoR::SignificanceMap::SignificanceMap ( const unsigned char *  map,
std::vector< size_t >  dims 
)
VAPoR::SignificanceMap::SignificanceMap ( const SignificanceMap )

Significance map copy constructor

VAPoR::SignificanceMap::~SignificanceMap ( )

Member Function Documentation

int VAPoR::SignificanceMap::Append ( const SignificanceMap smap)

Append a SignificanceMap

This method appends the coordinates in the map, smap, to this map, creating a new signficance map containing the entries from both this signficance map and smap. The ordering of the new map is as if the GetNextEntry() method of smap was called iteratively, storing the the returned coordinate with Set().

The dimensions of smap must match those of this map or error condition is returned.

Parameters
[in]smapAn encoded significance map returned by GetMap()
Return values
statusa negative value is returned on failure
int VAPoR::SignificanceMap::Clear ( size_t  idx)

Mark the indicated entry as insignificant

This method clears the indicated entry (marks it as insignificant)

Return values
statusa negative value is returned on failure
void VAPoR::SignificanceMap::Clear ( )

Clear entire map

int VAPoR::SignificanceMap::ClearXYZT ( size_t  x,
size_t  y = 0,
size_t  z = 0,
size_t  t = 0 
)
int VAPoR::SignificanceMap::GetCoordinates ( size_t  i,
size_t *  idx 
) const
int VAPoR::SignificanceMap::GetCoordinatesXYZT ( size_t  i,
size_t *  x,
size_t *  y = NULL,
size_t *  z = NULL,
size_t *  t = NULL 
) const

Return coordinates for an ordered entry in the map

Return the coordinates of the ith significant entry in the significant map. Note, the mapping between an entry number and it's coordinates returned by this function are no longer valid after the map is modified (set, cleared, or sorted). If the coordinate pointers, x,y,z,t are null, no value is returned for that coordinate.

Valid values for 'i' are in the range [0..GetNumSignificant()-1]

Return values
statusa negative value is returned on failure
void VAPoR::SignificanceMap::GetMap ( const unsigned char **  map,
size_t *  maplen 
)

Return the compressed representation of the significance map. The data returned are only suitable passing as an argument to the constructor.

Parameters
map[out]Encoded significance map data
maplen[out]Length of map in bytes
void VAPoR::SignificanceMap::GetMap ( unsigned char *  map)

Return the compressed representation of the significance map. The data returned are only suitable passing as an argument to the constructor.

Parameters
map[out]Encoded significance map data. Caller is responsible for allocating memory. The array map must be of size GetMapSize().
static size_t VAPoR::SignificanceMap::GetMapSize ( vector< size_t >  dims,
size_t  num_entries 
)
static

Return size in bytes of an encoded signficance map of given size

This static member method returns the size in bytes of an encoded signficance map that would be returned by GetMap() for a SignificanceMap of given dimension, dims, and number of entries, num_entries.

size_t VAPoR::SignificanceMap::GetMapSize ( size_t  num_entries) const

Return size in bytes of an encoded signficance map of given size

This method returns the size in bytes of an encoded signficance map that would be returned by GetMap() after the given number of entries, num_entries, were stored. This method can be used to determine the amount of space required to store an encoded signficance map after num_entries entries have been stored in it. In general, this is not the same value for the current significance map.

Parameters
num_entries[in]Number of entries in the signficance map
See also
GetMap()
size_t VAPoR::SignificanceMap::GetMapSize ( ) const
inline

Return size in bytes of current encoded signficance map

This method returns the size in bytes of the encoded, current signficance map that would be returned by GetMap().

See also
GetMap()

Definition at line 222 of file SignificanceMap.h.

References GetNumSignificant().

Referenced by VAPoR::Compressor::GetSigMapSize().

int VAPoR::SignificanceMap::GetNextEntry ( size_t *  idx)

Return the coordinates for the next signficant entry in the significance map. This method may be called iteratively until all map entries are turned. The GetNextEntryRestart() method may be used to reset the current entry to the first one in the map. A zero value is returned if the entry list is exhausted. The coordinates are returned in the order that they were set with Set() or SetXYZT().

Note
For sequential processing of map entries it is preferable to use this method over the indexed GetEntry() method.
Return values
statusa negative value is returned on failure
void VAPoR::SignificanceMap::GetNextEntryRestart ( )

Restart counters for GetNextEntry()

This method is used to restore internal counters used by the GetNextEntry() method

See also
GetMextEntry()
int VAPoR::SignificanceMap::GetNextEntryXYZT ( size_t *  x,
size_t *  y,
size_t *  z,
size_t *  t 
)
size_t VAPoR::SignificanceMap::GetNumSignificant ( ) const
inline

Return the number of significant entries in the map

Definition at line 139 of file SignificanceMap.h.

Referenced by GetMapSize().

void VAPoR::SignificanceMap::GetShape ( std::vector< size_t > &  dims) const
inline

Return the shape of a significance map

Definition at line 91 of file SignificanceMap.h.

void VAPoR::SignificanceMap::Invert ( )

Invert the signficance map

This method inverts the signficance map, making insignficant coordinates (those not found in the significance map) into significant coordinates. The ordering of the newly created map will be from smallest to largest coordinate.

See also
GetNextEntry()
SignificanceMap& VAPoR::SignificanceMap::operator= ( const SignificanceMap map)
int VAPoR::SignificanceMap::Reshape ( std::vector< size_t >  dims)

Set the shape (dimension) of a significance map

This method changes the shape (dimension) of a significance map

Parameters
[in]nxDimension of X axis (fastest varying)
[in]nyDimension of Y axis (second fastest varying)
[in]nzDimension of Z axis (third fastest varying)
[in]ntDimension of Z axis (fourth fastest varying)
[in]dimsA vector specifying the number of dimensions and their lengths.
int VAPoR::SignificanceMap::Reshape ( size_t  nx,
size_t  ny = 1,
size_t  nz = 1,
size_t  nt = 1 
)
int VAPoR::SignificanceMap::Set ( size_t  idx)

Mark a map entry as significant.

This method marks a particular coordinate as significant. The coordinate parameters, x, y, z, and t, must lie within the range [0..n-1], where n-1 is the value passed as the coordinates dimension to the constructor. No attempt is to prevent duplicate entries. If a coordinate is not specified its default value is zero.

Parameters
[in]xX coordinate
[in]yY coordinate
[in]zZ coordinate
[in]tT coordinate
[in]idxcoordinate specified as an offset from a linear array
Return values
statusa negative value is returned on failure
int VAPoR::SignificanceMap::SetMap ( const unsigned char *  map)

Reinitialize the significance map with the map, map , returned from a previous call to GetMap.

Parameters
[in]mapAn encoded significance map returned by GetMap()
See also
GetMap()
Return values
statusa negative value is returned on failure
int VAPoR::SignificanceMap::SetXYZT ( size_t  x,
size_t  y = 0,
size_t  z = 0,
size_t  t = 0 
)
void VAPoR::SignificanceMap::Sort ( )

Sort map entries

This method sorts the entries of the significance maps so that they are stored from smallest to largest. Once sorted, map entries returned by GetNextEntry() are guaranteed to be returned from smallest to largest

See also
GetNextEntry()
bool VAPoR::SignificanceMap::Test ( size_t  idx) const
inline

Return true if the indicated entry is significant. Test() returns false if the entry is out of range or in range, but not set

Parameters
[in]xX coordinate
[in]yY coordinate
[in]zZ coordinate
[in]tT coordinate
[in]idxcoordinate specified as an offset from a linear array

Definition at line 333 of file SignificanceMap.h.

Referenced by TestXYZT().

bool VAPoR::SignificanceMap::TestXYZT ( size_t  x,
size_t  y = 0,
size_t  z = 0,
size_t  t = 0 
) const
inline

Definition at line 347 of file SignificanceMap.h.

References Test().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const SignificanceMap sigmap 
)
friend

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