Alphabetical Class Index   Class Hierarchy   Compound Members   File Members   File List  

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TK_PolyPolypoint Class Reference

Handles the TKE_PolyPolyline opcode. More...

#include <BPolyPoly.h>

Public Types

enum  Suboptions {
  TKPP_COMPRESSED = 0x0001, TKPP_HAS_EXPLICIT_PRIMITIVE_COUNT = 0x0002, TKPP_ONE_PRIMITIVE_ONLY = 0x0004, TKPP_GLOBAL_QUANTIZATION = 0x0008,
  TKPP_ZERO_X = 0x0100, TKPP_SAME_X = 0x0200, TKPP_PER_PRIMITIVE_X = 0x0300, TKPP_ZERO_Y = 0x0400,
  TKPP_SAME_Y = 0x0800, TKPP_PER_PRIMITIVE_Y = 0x0C00, TKPP_ZERO_Z = 0x1000, TKPP_SAME_Z = 0x2000,
  TKPP_PER_PRIMITIVE_Z = 0x3000, TKPP_EXPANDED = 0x8000
}
 

Public Member Functions

TK_Status Clone (BStreamFileToolkit &tk, BBaseOpcodeHandler **handler) const
 
TK_Status Execute (BStreamFileToolkit &tk) alter
 
TK_Status Read (BStreamFileToolkit &tk) alter
 
TK_Status ReadAscii (BStreamFileToolkit &tk) alter
 
void Reset () alter
 
TK_Status SetLengths (int primitive_count, int const *lengths=0) alter
 
TK_Status SetPoints (int point_count, float const *points=0) alter
 
 TK_PolyPolypoint (unsigned char opcode)
 
TK_Status Write (BStreamFileToolkit &tk) alter
 
TK_Status WriteAscii (BStreamFileToolkit &tk) alter
 
- Public Member Functions inherited from BBaseOpcodeHandler
 BBaseOpcodeHandler (int op)
 
char const * GetLoggingString () const
 
char alterGetLoggingString () alter
 
virtual TK_Status Interpret (BStreamFileToolkit &tk, ID_Key key, int variant=0) alter
 
virtual TK_Status Interpret (BStreamFileToolkit &tk, ID_Key key, char const *special) alter
 
void LogDebug (BStreamFileToolkit &tk, char const *string=0) alter
 
virtual bool Match_Instance (BStreamFileToolkit const &tk, Recorded_Instance alter *instance) alter
 
virtual bool NeedsContext (BStreamFileToolkit &tk) const
 
bool NeedsTag () const
 
unsigned char Opcode () const
 
int Pass (BStreamFileToolkit &tk) const
 
void SetLoggingString (char const *segment) alter
 
void SetLoggingString (int length) alter
 
void SetNeedsTag (bool n) alter
 
TK_Status Tag (BStreamFileToolkit &tk, int variant=-1) const
 
bool Tagging (BStreamFileToolkit &tk) const
 
- Public Member Functions inherited from BControlledMemoryObject
void operator delete (void *p)
 force deallocation to happen in the stream toolkit's scope
 
void * operator new (size_t size)
 force allocation to happen in the stream toolkit's scope
 

Protected Member Functions

TK_Status analyze_dimensionality (BStreamFileToolkit &tk) alter
 
TK_Status compute_line_extend_points (BStreamFileToolkit &tk) alter
 
TK_Status compute_trivial_points (BStreamFileToolkit &tk) alter
 
TK_Status expand_lengths (BStreamFileToolkit &tk) alter
 
TK_Status figure_num_floats (BStreamFileToolkit &tk) alter
 
TK_Status mangle (BStreamFileToolkit &tk) alter
 
TK_Status process_line_extend_points (BStreamFileToolkit &tk) alter
 
TK_Status process_trivial_points (BStreamFileToolkit &tk) alter
 
TK_Status read_compressed_points (BStreamFileToolkit &tk) alter
 
TK_Status read_trivial_leftovers (BStreamFileToolkit &tk) alter
 
TK_Status unmangle (BStreamFileToolkit &tk) alter
 
TK_Status validate_primitive_count (BStreamFileToolkit &tk) alter
 
TK_Status write_compressed_points (BStreamFileToolkit &tk) alter
 
TK_Status write_trivial_leftovers (BStreamFileToolkit &tk) alter
 
- Protected Member Functions inherited from BBaseOpcodeHandler
void add_segment (BStreamFileToolkit &tk, ID_Key key) alter
 for internal use only
 
void adjust_written (BStreamFileToolkit &tk, int count) alter
 for internal use only
 
void bytes_to_floats (unsigned char const *in, float alter *out, int count) const
 for internal use only
 
void decrease_nesting (BStreamFileToolkit &tk, int amount=1) alter
 for internal use only
 
bool Find_Instance (BStreamFileToolkit &tk, int val1, int val2, int val3) alter
 
bool Find_Item (BStreamFileToolkit &tk, ID_Key key) const
 
void fix (int *i, int n)
 for internal use only
 
void fix (short *s, int n)
 for internal use only
 
void fix_in (float *f, int n)
 for internal use only
 
void fix_out (float *f, int n)
 for internal use only
 
short flip (short s)
 for internal use only
 
int flip (int i)
 for internal use only
 
void floats_to_bytes (float const *in, unsigned char alter *out, int count) const
 for internal use only
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, int *rInts, unsigned int n) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, unsigned char &value) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, char &value) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, unsigned short &value) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, short &value) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, int &value) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, float &value) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, float *rFloats, unsigned int n) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, char *m_string, unsigned int n) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, unsigned char *m_string, unsigned int n) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, int *rInts, unsigned int n) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, short *rShorts, unsigned int n) alter
 
TK_Status GetAsciiData (BStreamFileToolkit &tk, const char *tag, unsigned short *rShorts, unsigned int n) alter
 
TK_Status GetAsciiHex (BStreamFileToolkit &tk, const char *tag, unsigned char &value) alter
 
TK_Status GetAsciiHex (BStreamFileToolkit &tk, const char *tag, int &value) alter
 
TK_Status GetAsciiHex (BStreamFileToolkit &tk, const char *tag, char &value) alter
 
TK_Status GetAsciiHex (BStreamFileToolkit &tk, const char *tag, unsigned short &value) alter
 
TK_Status GetAsciiImageData (BStreamFileToolkit &tk, const char *tag, unsigned char *rValues, unsigned int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, char *b, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, short *s, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, int *i, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, float *f, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, unsigned char *b, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, unsigned short *s, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, unsigned int *i, int n) alter
 
TK_Status GetData (BStreamFileToolkit &tk, char &c) alter
 
TK_Status GetData (BStreamFileToolkit &tk, short &s) alter
 
TK_Status GetData (BStreamFileToolkit &tk, int &i) alter
 
TK_Status GetData (BStreamFileToolkit &tk, unsigned char &b) alter
 
TK_Status GetData (BStreamFileToolkit &tk, unsigned short &s) alter
 
TK_Status GetData (BStreamFileToolkit &tk, unsigned int &i) alter
 
TK_Status GetData (BStreamFileToolkit &tk, float &f) alter
 
void increase_nesting (BStreamFileToolkit &tk, int amount=1) alter
 for internal use only
 
ID_Key last_key (BStreamFileToolkit &tk) const
 obsolete
 
void log_opcode (BStreamFileToolkit &tk, unsigned int sequence, unsigned char opcode) alter
 for internal use only
 
TK_Status LookatData (BStreamFileToolkit &tk, unsigned char &b) alter
 
BBaseOpcodeHandler alterOpcode_Handler (BStreamFileToolkit &tk, unsigned char op) const
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, char const *b, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, short const *s, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, int const *i, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, float const *f, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, unsigned char const *b, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, unsigned short const *s, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, unsigned int const *i, int n) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, char const &c) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, short const &s) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, int const &i) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, unsigned char const &b) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, unsigned short const &s) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, unsigned int const &i) alter
 
TK_Status PutAsciiData (BStreamFileToolkit &tk, char const *tag, float const &f) alter
 
TK_Status PutAsciiFlag (BStreamFileToolkit &tk, char const *tag, int const &i) alter
 
TK_Status PutAsciiHex (BStreamFileToolkit &tk, char const *tag, int const &i) alter
 
TK_Status PutAsciiMask (BStreamFileToolkit &tk, char const *tag, int const &i) alter
 
TK_Status PutAsciiOpcode (BStreamFileToolkit &tk, int adjust=1, bool is_end=false, bool want_newline=true) alter
 
TK_Status PutData (BStreamFileToolkit &tk, char const *b, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, short const *s, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, int const *i, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, float const *f, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, unsigned char const *b, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, unsigned short const *s, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, unsigned int const *i, int n) alter
 
TK_Status PutData (BStreamFileToolkit &tk, char const &c) alter
 
TK_Status PutData (BStreamFileToolkit &tk, short const &s) alter
 
TK_Status PutData (BStreamFileToolkit &tk, int const &i) alter
 
TK_Status PutData (BStreamFileToolkit &tk, unsigned char const &b) alter
 
TK_Status PutData (BStreamFileToolkit &tk, unsigned short const &s) alter
 
TK_Status PutData (BStreamFileToolkit &tk, unsigned int const &i) alter
 
TK_Status PutData (BStreamFileToolkit &tk, float const &f) alter
 
TK_Status PutEndXMLTag (BStreamFileToolkit &tk, char const *tag) alter
 
TK_Status PutOpcode (BStreamFileToolkit &tk, int adjust=1) alter
 
TK_Status PutStartXMLTag (BStreamFileToolkit &tk, char const *tag) alter
 
TK_Status Read_Referenced_Segment (BStreamFileToolkit &tk, int &i_progress) alter
 
TK_Status ReadAsciiLine (BStreamFileToolkit &tk, unsigned int *readSize=0) alter
 
TK_Status ReadAsciiWord (BStreamFileToolkit &tk, unsigned int *readSize=0) alter
 
TK_Status ReadEndOpcode (BStreamFileToolkit &tk) alter
 
void Record_Instance (BStreamFileToolkit &tk, ID_Key key, int variant, int val1, int val2, int val3) const
 
void Remember_Item (BStreamFileToolkit &tk, ID_Key key) const
 
ID_Key remove_segment (BStreamFileToolkit &tk) alter
 for internal use only
 
bool RemoveAngularBrackets (char *string) alter
 
bool RemoveQuotes (char *string) alter
 
void Revisit (BStreamFileToolkit &tk, float priority=0.0f, int variant=0) const
 
void set_last_key (BStreamFileToolkit &tk, ID_Key key) alter
 sets the given key as "most recent" on the toolkit for the purposes of associating keys with indices
 
TK_Status SkipNewlineAndTabs (BStreamFileToolkit &tk, unsigned int *readSize=0) alter
 
bool validate_count (int count, int limit=1<< 24) const
 

Protected Attributes

float m_bbox [6]
 A bounding box around the unrestricted dimensions. If the data is 2d, only the first 4 values are used, and it becomes a bounding rectangle.
 
int m_bits_per_sample
 the number of bits per sample. Should be tk.GetNumVertexBits()/3
 
unsigned char m_compression_scheme
 If the TKPP_COMPRESSED bit is set in m_subop, this variable tracks the specific compression algorithm used.
 
int * m_lengths
 The length of each primitive.
 
int m_lengths_allocated
 The number of array elements that we have allocated for primitive lengths.
 
int m_point_count
 The number of points.
 
float * m_points
 The points array.
 
int m_points_allocated
 The number of points for which we have allocated space (to save time, we only reallocate the points array if it needs to be expanded, not on every call to Reset()).
 
int m_points_num_dimensions
 The number of unrestricted dimensions in the points array that must be completely specified.
 
int m_points_num_floats
 The number of independent floating point values required to specify the points array (equals m_point_count*3 for 3d data, but less for 2d)
 
int m_primitive_count
 The number of primitives. Omitted from read/write (it can be deduced from the lengths array) unless TKPP_HAS_EXPLICIT_PRIMITIVE_COUNT bit is set.
 
int m_progress
 tracks progress during special situations
 
unsigned short m_subop
 Suboptions. Among other things, it specifies all 2d restrictions that can be made on the points. Be careful when testing for the 2d bits, because some have multiple bits set. For this reason, you should use the form if((m_subop & mask) == value) instead of if(m_subop & bit)
 
int m_substage
 tracks progress during helper functions
 
int m_templen
 the length of all stragglers left behind (e.g. an array of floats of length m_primitive_count if TKPP_PER_PRIMITIVE_X subop bit is set)
 
float m_temprange [2]
 1d bounds of the stragglers
 
unsigned char * m_workspace
 Raw data after packing.
 
int m_workspace_allocated
 The amount of workspace area allocated.
 
int m_workspace_used
 The amount of workspace area used.
 
- Protected Attributes inherited from BBaseOpcodeHandler
char * m_ascii_buffer
 
int m_ascii_length
 
int m_ascii_progress
 Tracks the amount of data that has been read/written so far by GetAscii functions.
 
int m_ascii_size
 
int m_ascii_stage
 
unsigned char m_byte
 temporary
 
char m_char
 temporary
 
int m_debug_allocated
 
int m_debug_length
 
char * m_debug_string
 
int m_int
 temporary
 
bool m_needs_tag
 Indicate if this object explicitly needs tagging.
 
unsigned char m_opcode
 The opcode being handled by this particular object.
 
int m_progress
 Tracks the amount of data that has been read/written so far.
 
int m_stage
 The writing stage.
 
unsigned short m_unsigned_short
 temporary
 

Additional Inherited Members

- Static Protected Member Functions inherited from BBaseOpcodeHandler
static float read_float (char const *cp, char const *alter *newcpp=0)
 
static float read_float (char const *cp, char alter *alter *newcpp)
 for internal use only
 
static char * write_float (char *buffer, double f)
 for internal use only
 

Detailed Description

Handles the TKE_PolyPolyline opcode.

TK_Polypoint provides support for writing/reading the TKE_PolyPolyline opcode objects to/from an HSF file.

TKE_PolyPolyline is an alternative to TKE_Polyline and TKE_Line. It is a more compressed way of handling large numbers of polylines and lines. The idea is that by grouping primitives together, better compression algorithms can be run for them. This class utilizes some of the same compression schemes that are implemented in TK_Shell.

This class is especially optimal for dealing with 2d data. With all of the 12 combinations ("zero", "constant", "per-primitive" or "unrestricted" along any of the 3 standard axes X, Y and/or Z), we leverage the restrictions that we can make to compress as deeply as possible. There is no provision for point data that is "mostly" 2d, however, so such data will be encoded as 3d. For this reason, performance will improve if all 2d lines and polylines can be put in a segment or segments that are separate from any 3d line data.

The HOOPS/3dGS scene-graph supports 'polyline' and 'polygon' primitives which are both defined by a point count and points array.

Member Enumeration Documentation

a few control values, and a lot of bits to indicate degenerate dimensions (which can be either omitted completely or only partially specified).

Constructor & Destructor Documentation

TK_PolyPolypoint::TK_PolyPolypoint ( unsigned char  opcode)

constructor

Member Function Documentation

TK_Status TK_PolyPolypoint::analyze_dimensionality ( BStreamFileToolkit tk)
protected

Efficiently searches the points array for any restrictions that can be made on the points in order to aid compression

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::Clone ( BStreamFileToolkit tk,
BBaseOpcodeHandler **  handler 
) const
virtual

Copies the opcode handler

Parameters
tkA reference to the BStreamFileToolkit object.
handlerA pointer to the opcode handler object. Passed by reference.
Returns
The result of the function call.

Reimplemented from BBaseOpcodeHandler.

TK_Status TK_PolyPolypoint::compute_line_extend_points ( BStreamFileToolkit tk)
protected

compresses the m_points into m_workspace, an array of unsigned char's according to the CS_LINE_EXTEND compression scheme. CS_LINE_EXTEND is currently unused because of poor performance.

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::compute_trivial_points ( BStreamFileToolkit tk)
protected

compresses the m_points into m_workspace, an array of unsigned char's according to the CS_TRIVIAL compression scheme

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::Execute ( BStreamFileToolkit tk)
virtual

Processes the binary data that has been read for the current object, which involves passing the data to application-specific data structures.

Parameters
tkA reference to the BStreamFileToolkit object.
Returns
The result of the function call.

Reimplemented from BBaseOpcodeHandler.

TK_Status TK_PolyPolypoint::expand_lengths ( BStreamFileToolkit tk)
protected

A small helper to reallocate the lengths array in the event that we run out of space.

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::figure_num_floats ( BStreamFileToolkit tk)
protected

Calculates the number of independent floating point values needed to encode the points array

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::mangle ( BStreamFileToolkit tk)
protected

Reorganizes the values in m_points so that unrestricted dimensions appear first, followed by whatever floats are needed to encode the restricted dimensions. Intended for use during the write phase.,

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::process_line_extend_points ( BStreamFileToolkit tk)
protected

uncompresses m_workspace back into m_points according to CS_LINE_EXTEND. CS_LINE_EXTEND is currently unused because of poor performance.

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::process_trivial_points ( BStreamFileToolkit tk)
protected

uncompresses m_workspace back into m_points according to CS_TRIVIAL

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::Read ( BStreamFileToolkit tk)
virtual

Reads data from the toolkit buffer, decodes/decompresses it, and maps it to the opcode handlers data members. User-defined classes which need to write out custom data should utilize one of the available GetData() methods.

Parameters
tkA reference to the BStreamFileToolkit object.
Returns
The result of the function call.

Implements BBaseOpcodeHandler.

TK_Status TK_PolyPolypoint::read_compressed_points ( BStreamFileToolkit tk)
protected

reads the m_workspace, which will later be decompressed into m_points according to whatever m_compression_scheme was specified

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::read_trivial_leftovers ( BStreamFileToolkit tk)
protected

read the "leftovers" (see (see TK_PolyPolypoint::write_trivial_leftovers)

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
void TK_PolyPolypoint::Reset ( )
virtual

Resets the current opcode handler. This is called by the toolkit when it is done processing an opcode. This method reinitializes any opcode handler variables and frees up temporary data.

Reimplemented from BBaseOpcodeHandler.

TK_Status TK_PolyPolypoint::SetLengths ( int  primitive_count,
int const *  lengths = 0 
)

Sets the point array. Allocates a buffer which will hold 'primitive_count' integers, and if specified, copies the 'points' into the buffer.

Parameters
primitive_countthe number of polylines that this instance of the opcode handler contains.
lengthsif provided, an array with point_count values to provide the length (number of vertices) of each polyline. If not provided, all lengths are initialized to zero (just assume that they will be set at some other time.
Returns
a status value to indicate success or failure.
TK_Status TK_PolyPolypoint::SetPoints ( int  point_count,
float const *  points = 0 
)

Sets the point array. Allocates a buffer which will hold 'point_count' float triplets, and if specified, copies the 'points' into the buffer

Parameters
point_countthe aggregate total number of points in this instance of the opcode.
pointsif provided, the actual floating-point values of the vertices.
Returns
a status value to indicate success or failure.
TK_Status TK_PolyPolypoint::unmangle ( BStreamFileToolkit tk)
protected

Undoes during the read phase everything that mangle() does at write time.

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::validate_primitive_count ( BStreamFileToolkit tk)
protected

Computes the primitive count if such has not been done already

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::Write ( BStreamFileToolkit tk)
virtual

Encodes/compresses data and writes data to the toolkit buffer. User-defined classes which need to write out custom data should utilize one of the available PutData() methods, and first write out the opcode associated with the group of binary data followed by the data itself.

Parameters
tkA reference to the BStreamFileToolkit object.
Returns
The result of the function call.

Implements BBaseOpcodeHandler.

TK_Status TK_PolyPolypoint::write_compressed_points ( BStreamFileToolkit tk)
protected

writes the points array according to whatever compression scheme was put into m_workspace

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure
TK_Status TK_PolyPolypoint::write_trivial_leftovers ( BStreamFileToolkit tk)
protected

if m_points can be rearranged into 2d (see TK_PolyPolypoint::mangle), there will be a 1d array (possibly of 0 or 1 length) of "leftovers". write it.

Parameters
tkthe toolkit
Returns
a status value to indicate success or failure

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