rtVTK  0.6.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends
rl::RayLogger Class Reference

C++ ray tree storage management. More...

List of all members.

Classes

struct  CookieIO
 For writing header data. More...
struct  RayRecordIO
 For efficient disk rl::RayRecord I/O. More...
struct  TreeRecordIO
 For efficient disk rl::TreeRecord I/O. More...

Public Member Functions

 RayLogger ()
IOMode getMode () const
 Returns the current I/O mode.
rl::Error init (IOMode iomode, TraversalMode tmode, string fname)
 Initializes RayLogger.
void close ()
 Closes RayLogger. In WriteMode, finishes writing the file to disk.
rl::Error nextRay ()
rl::Error descendTree ()
 Moves to the child of the current ray in rl::DepthFirst rl::WriteMode and write-enabled rl::ImmediateMode.
rl::Error ascendTree ()
 Moves to the parent of the current ray in rl::DepthFirst rl::WriteMode and write-enabled rl::ImmediateMode.
rl::Error nextTree ()
 Advances to next tree in rl::ReadMode and rl::WriteMode.
rl::Error prevTree ()
 Regresses to previous tree in rl::ReadMode.
uint numTrees ()
 Returns the number of trees in rl::ReadMode and read-enabled rl::ImmediateMode.
uint rayStats (RayType type)
 Returns the number of rays of the given type in rl::ReadMode and read-enabled rl::ImmediateMode.
uint numRays ()
 Returns the number of rays in the current tree in rl::ReadMode and read-enabled rl::ImmediateMode.
uint maxDepth ()
 Returns the maximum ray depth in the current tree in rl::ReadMode and read-enabled rl::ImmediateMode.
rl::Error readTree (Tree &tree)
 Gives the current tree in rl::ReadMode and read-enabled rl::ImmediateMode.
rl::Error readRays ()
 Reads the rays of the current tree from disk in rl::ReadMode.
rl::Error populateTree (Tree &tree)
 Populates given tree with rays in memory.
rl::Error readRay (Ray &ray)
 Gives the current ray in rl::ReadMode and read-enabled rl::ImmediateMode, and advances to the next ray.
rl::Error startRays ()
 Advances to the first ray in rl::ReadMode and read-enabled rl::ImmediateMode.
rl::Error beginForest ()
 Begins a forest in rl::WriteMode.
rl::Error endForest ()
 Closes the forst and writes to disk in rl::WriteMode.
rl::Error beginTree (ushort px, ushort py)
 Begins a tree in rl::WriteMode; begins write-enable in rl::ImmediateMode.
rl::Error endTree ()
 Ends a tree in rl::WriteMode; begins read-enable in rl::ImmediateMode.
rl::Error addRay (const Point &, const Vector &, const float, const RayType, const void *=NULL, const size_t=0)
 Adds a ray in rl::WriteMode and rl::ImmediateMode.
rl::Error getError ()
 Returns the first error after the last call to the function.
string getErrorString ()
 Returns the string associated with getError().

Private Types

enum  iMode { Uninited, Read, Write }
 The set of internal states, supplementing rl::IOMode. More...
enum  ErrorLevel { Warning, Error }

Private Member Functions

rl::Error setError (rl::Error error_, string emsg_, ErrorLevel level)
 To clear the error.
void clearError ()
void NextRayDF (TRiter tree)
 Advances to the next ray in depth-first mode.
void ConvBFToDF (TRiter tree)
 Converts breadth-first ray trees to depth-first.
void ConvDFToBF (TRiter tree)
 Converts depth-first ray trees to breadth-first.
void ResetChildIndices (TRiter tree)
 Resets child indices of all rays in the tree.
void GetRayRecord (TRiter tree, uint parent)
 Reads ray records from disk recursively.
void GetMaxDepth (TRiter tree)
 Finds the maximum depth of the ray tree.

Private Attributes

IOMode iomode
 Remembers the I/O mode the user requested.
TraversalMode tmode
 Remembers the traversal mode.
iMode imode
 Remembers the internal state.
vector< TreeRecordtrees
 vector of rl::TreeRecord s that are in active use.
uint ctree
 Which tree is active.
uint ntrees
 The number of trees in the file, or written to disk so far.
uint nrays [NRayTypes]
 The number of rays in the file, or written to disk so far, by type.
fstream ftrees
 For tree I/O.
fstream frecords
 For record I/O.
fstream fdata
 For data I/O.
uint64_t offsetTrees
 Offset of trees within file.
uint64_t offsetRecords
 Offset of rays within file.
uint64_t offsetData
 Offset of user data within file.
BufferedReader< TreeRecordIO,
100, false > 
bfTreeReader
 Reads many trees at once for speed.
BufferedReader< RayRecordIO,
100, false > 
bfRecordReader
 Reads many rays at once for speed.
string fname
 Name of output file.
string treesname
 Name of temporary tree output file.
string recordsname
 Name of temporary ray output file.
string dataname
 Name of temporary data output file.
BufferedWriter< TreeRecordIO,
100, false > 
bfTreeWriter
 Writes many trees at once for speed.
BufferedWriter< RayRecordIO,
100, false > 
bfRecordWriter
 Writes many rays at once for speed.
rl::Error error
 The string associated with error.
string emsg
 To set the error, message, and level.

Static Private Attributes

static const char cookie [7] = "rlv0.2"
 ID cookie - currently "rlv0.2".

Friends

ostream & operator<< (ostream &, const RayRecordIO &)
 For human-readable ray output.
istream & operator>> (istream &, RayRecordIO &)
 For parsing human-readable ray files.
ostream & operator<< (ostream &, const TreeRecordIO &)
 For human-readable tree output.
istream & operator>> (istream &, TreeRecordIO &)
 For parsing human-readable ray files.

Detailed Description

C++ ray tree storage management.

The RayLogger class provides functions for persistent ray tree generation in either depth-first or breadth-first traversal mode and the ability to write files to disk, read files from disk, or manipulate a tree in memory.


Member Enumeration Documentation

enum rl::RayLogger::ErrorLevel [private]

For setting the error level when calling rl::RayLogger::setError.

Enumerator:
Warning 

don't send rl into the failed state

Error 

do send rl into the failed state

enum rl::RayLogger::iMode [private]

The set of internal states, supplementing rl::IOMode.

This enum specifies, within a mode, what it can and cannot do, beyond what iomode can, as it does not change while the class is open.

Enumerator:
Uninited 

uninitialized - cannot be read from or written to

Read 

reading is allowed - writing is not

Write 

writing is allowed - reading is not


Constructor & Destructor Documentation

default constructor - to initialize RayLogger, call rl::RayLogger::init.


Member Function Documentation

Error rl::RayLogger::addRay ( const Point &  o,
const Vector &  d,
const float  t,
const RayType  type,
const void *  data = NULL,
const size_t  nbytes = 0 
)

Adds a ray in rl::WriteMode and rl::ImmediateMode.

Parameters:
originThe origin of the ray.
directionThe direction the ray points.
tvalThe length of the ray, where a unit is the length of direction.
typeThe type of ray.
dataUser data for the ray.
nbytesThe number of bytes that the user data takes.

References rl::AddRay_InvalidContext, rl::AddRay_InvalidMode, rl::AddRay_InvalidTree, rl::AddRay_NoTrees, rl::AddRay_OneHeadRay, rl::AddRay_TreeEnded, rl::BreadthFirst, rl::RayRecord::child, ctree, rl::RayRecord::depth, rl::ImmediateMode, imode, iomode, rl::RayRecord::next, rl::NoError, nrays, rl::RayRecord::parent, rl::RayRecord::prev, setError(), tmode, trees, Write, and rl::WriteMode.

void rl::RayLogger::clearError ( ) [private]

References emsg, error, and rl::NoError.

Referenced by close(), and startRays().

void rl::RayLogger::ConvBFToDF ( TRiter  tree) [private]

Converts breadth-first ray trees to depth-first.

Referenced by endForest().

void rl::RayLogger::ConvDFToBF ( TRiter  tree) [private]

Converts depth-first ray trees to breadth-first.

Referenced by readRays().

Returns the first error after the last call to the function.

References error, and rl::NoError.

Returns the string associated with getError().

References emsg.

void rl::RayLogger::GetMaxDepth ( TRiter  tree) [private]

Finds the maximum depth of the ray tree.

Referenced by endTree(), and readRays().

IOMode rl::RayLogger::getMode ( ) const [inline]

Returns the current I/O mode.

References iomode.

Referenced by rtVTK::rlRenderer::render().

void rl::RayLogger::GetRayRecord ( TRiter  tree,
uint  parent 
) [private]
rl::Error rl::RayLogger::init ( IOMode  iomode,
TraversalMode  tmode,
string  fname 
)
void rl::RayLogger::NextRayDF ( TRiter  tree) [private]

Advances to the next ray in depth-first mode.

Referenced by endForest(), and readRay().

Returns the number of rays in the current tree in rl::ReadMode and read-enabled rl::ImmediateMode.

References ctree, imode, Read, and trees.

Referenced by rtVTK::rlRenderer::slotAdvanceTree(), and rtVTK::rlRenderer::slotRegressTree().

Returns the number of trees in rl::ReadMode and read-enabled rl::ImmediateMode.

References imode, iomode, ntrees, Read, and rl::ReadMode.

Returns the number of rays of the given type in rl::ReadMode and read-enabled rl::ImmediateMode.

Parameters:
typeThe type of ray to get the number of. rl::NRayTypes means get the total number of rays.

References imode, iomode, nrays, rl::NRayTypes, Read, and rl::ReadMode.

void rl::RayLogger::ResetChildIndices ( TRiter  tree) [private]

Resets child indices of all rays in the tree.

Referenced by endForest(), endTree(), readRays(), and startRays().

rl::Error rl::RayLogger::setError ( rl::Error  error_,
string  emsg_,
ErrorLevel  level 
) [private]

Friends And Related Function Documentation

ostream& operator<< ( ostream &  out,
const RayRecordIO rrout 
) [friend]

For human-readable ray output.

ostream& operator<< ( ostream &  out,
const TreeRecordIO rtout 
) [friend]

For human-readable tree output.

istream& operator>> ( istream &  in,
RayLogger::RayRecordIO rrin 
) [friend]

For parsing human-readable ray files.

istream& operator>> ( istream &  in,
RayLogger::TreeRecordIO rtin 
) [friend]

For parsing human-readable ray files.


Member Data Documentation

Reads many rays at once for speed.

Referenced by close(), GetRayRecord(), and init().

Writes many rays at once for speed.

Referenced by close(), endForest(), and init().

Reads many trees at once for speed.

Referenced by close(), and init().

Writes many trees at once for speed.

Referenced by close(), endForest(), and init().

const char rl::RayLogger::cookie = "rlv0.2" [static, private]

ID cookie - currently "rlv0.2".

Referenced by close(), and init().

uint rl::RayLogger::ctree [private]
string rl::RayLogger::dataname [private]

Name of temporary data output file.

Referenced by close(), and init().

string rl::RayLogger::emsg [private]

To set the error, message, and level.

Referenced by clearError(), getErrorString(), and setError().

The string associated with error.

Referenced by clearError(), getError(), setError(), and startRays().

fstream rl::RayLogger::fdata [private]

For data I/O.

Referenced by close(), endForest(), GetRayRecord(), and init().

string rl::RayLogger::fname [private]

Name of output file.

Referenced by close(), and init().

fstream rl::RayLogger::frecords [private]

For record I/O.

Referenced by close(), endForest(), init(), and readRays().

fstream rl::RayLogger::ftrees [private]

For tree I/O.

Referenced by close(), and init().

The number of rays in the file, or written to disk so far, by type.

Referenced by addRay(), close(), init(), and rayStats().

uint rl::RayLogger::ntrees [private]

The number of trees in the file, or written to disk so far.

Referenced by close(), endForest(), init(), and numTrees().

uint64_t rl::RayLogger::offsetData [private]

Offset of user data within file.

Referenced by GetRayRecord(), and init().

uint64_t rl::RayLogger::offsetRecords [private]

Offset of rays within file.

Referenced by init(), and readRays().

uint64_t rl::RayLogger::offsetTrees [private]

Offset of trees within file.

Referenced by init().

string rl::RayLogger::recordsname [private]

Name of temporary ray output file.

Referenced by close(), and init().

Remembers the traversal mode.

Referenced by addRay(), ascendTree(), descendTree(), endForest(), endTree(), init(), nextRay(), readRay(), and readRays().

vector<TreeRecord> rl::RayLogger::trees [private]
string rl::RayLogger::treesname [private]

Name of temporary tree output file.

Referenced by close(), and init().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends