TK_PolyPolypoint

class TK_PolyPolypoint

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.

Inherits from: BBaseOpcodeHandler

Enumerations

Methods

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

tk: the 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

tk: the 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

tk: the toolkit

Returns

a status value to indicate success or failure
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

tk: the 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

tk: the toolkit

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

tk: the 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

tk: the 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

tk: the toolkit

Returns

a status value to indicate success or failure
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

tk: the 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

tk: the toolkit

Returns

a status value to indicate success or failure
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

tk: the toolkit

Returns

a status value to indicate success or failure
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

tk: the 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

tk: the 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

tk: the toolkit

Returns

a status value to indicate success or failure
TK_PolyPolypoint::TK_PolyPolypoint(unsigned char opcode)

constructor

TK_PolyPolypoint::~TK_PolyPolypoint()
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

tk: A reference to the BStreamFileToolkit object.

Returns

The result of the function call.
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

tk: A reference to the BStreamFileToolkit object.

Returns

The result of the function call.
TK_Status TK_PolyPolypoint::Clone(BStreamFileToolkit &tk, BBaseOpcodeHandler **handler) const

const virtual

Copies the opcode handler

Parameters

tk: A reference to the BStreamFileToolkit object.

handler: A pointer to the opcode handler object. Passed by reference.

Returns

The result of the function call.
TK_Status TK_PolyPolypoint::ReadAscii(BStreamFileToolkit &tk)
TK_Status TK_PolyPolypoint::WriteAscii(BStreamFileToolkit &tk)
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

tk: A reference to the BStreamFileToolkit object.

Returns

The result of the function call.
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.

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_count: the aggregate total number of points in this instance of the opcode.

points: if provided, the actual floating-point values of the vertices.

Returns

a status value to indicate success or failure.
TK_Status TK_PolyPolypoint::SetDPoints(int point_count, double const points[] = 0)

Sets the double-precision point array. Allocates a buffer which will hold ‘point_count’ double triplets, and if specified, copies the ‘points’ into the buffer

Parameters

point_count: the aggregate total number of points in this instance of the opcode.

points: if provided, the actual double-precision floating-point values of the vertices.

Returns

a status value to indicate success or failure.
TK_Status TK_PolyPolypoint::SetLengths(int primitive_count, int const lengths[] = 0)

Sets the lengths array. Allocates a buffer which will hold ‘primitive_count’ integers, and if specified, copies the ‘lengths’ into the buffer.

Parameters

primitive_count: the number of polylines that this instance of the opcode handler contains.

lengths: if 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.

Variables

int TK_PolyPolypoint::m_point_count

protected

int

The number of points.

int TK_PolyPolypoint::m_points_allocated

protected

int

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()).

float *TK_PolyPolypoint::m_points

protected

float

The points array.

double *TK_PolyPolypoint::m_dpoints

protected

double

The points array.

int TK_PolyPolypoint::m_points_num_floats

protected

int

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 TK_PolyPolypoint::m_points_num_dimensions

protected

int

The number of unrestricted dimensions in the points array that must be completely specified.

int TK_PolyPolypoint::m_primitive_count

protected

int

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 TK_PolyPolypoint::m_lengths_allocated

protected

int

The number of array elements that we have allocated for primitive lengths.

int *TK_PolyPolypoint::m_lengths

protected

int

The length of each primitive.

float TK_PolyPolypoint::m_bbox[6]

protected

float

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.

float TK_PolyPolypoint::m_dbbox[6]

protected

float

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 TK_PolyPolypoint::m_templen

protected

int

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 TK_PolyPolypoint::m_temprange[2]

protected

float

1d bounds of the stragglers

float TK_PolyPolypoint::m_dtemprange[2]

protected

float

1d bounds of the stragglers

unsigned short TK_PolyPolypoint::m_subop

protected

unsigned short

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)

unsigned char TK_PolyPolypoint::m_compression_scheme

protected

unsigned char

If the TKPP_COMPRESSED bit is set in m_subop, this variable tracks the specific compression algorithm used.

unsigned char *TK_PolyPolypoint::m_workspace

protected

unsigned char

Raw data after packing.

int TK_PolyPolypoint::m_workspace_used

protected

int

The amount of workspace area used.

int TK_PolyPolypoint::m_workspace_allocated

protected

int

The amount of workspace area allocated.

int TK_PolyPolypoint::m_bits_per_sample

protected

int

the number of bits per sample. Should be tk.GetNumVertexBits()/3

int TK_PolyPolypoint::m_substage

protected

int

tracks progress during helper functions