geTKArray

Functions: Time-Keyed-Array support

Source file: …\genesis3d\OpenSource\Source\Actor\tkarray.h

Contents:

Functions: Create, CreateEmpty, CreateFromBinaryFile, WriteToBinaryFile, BSearch, Insert, DeleteElement, Destroy, Element, NumElements, ElementTime, ElementSize, SamplesAreTimeLinear

Types: geTKArray_TimeType, geTKArray

Overview: view

Additons for Genesis3D v1.6: None

Overview:

TKArray means Time-Keyed-Array. This module is designed primarily to support path.c . The idea is that there are these packed arrays of elements, sorted by a geTKArray_TimeType key. The key is assumed to be the first field in each element. The TKArray functions operate on this very specific array type. Error conditions are reported to errorlog

 Return to Contents

Types:

typedef geFloat geTKArray_TimeType;

NOTE: The contents of this structure have been intentionally left out of the interface, by the designers of this module. Think of this as a handle only. 

Return to Contents

 

typedef struct geTKArray geTKArray;

NOTE: The contents of this structure have been intentionally left out of the interface, by the designers of this module. Think of this as a handle only. 

Return to Contents

Constants: 

#define GE_TKA_TIME_TOLERANCE (0.00001f)

 

 Return to Contents

Functions:  

 geTKArray* GENESISCC geTKArray_Create(int ElementSize);

 creates new array with given attributes

 Return to Contents

geTKArray* GENESISCC geTKArray_CreateEmpty(int ElementSize, int ElementCount);

 creates new array with given element size and given count of uninitialized members

 Return to Contents

geTKArray* GENESISCC geTKArray_CreateFromBinaryFile(geVFile* pFile);     

stream positioned at array data

Creates a new array from the given stream.

 Return to Contents

geBoolean GENESISCC geTKArray_WriteToBinaryFile(const geTKArray* Array,   geVFile* pFile);     

Array is a sorted array to write

PFile is a stream positioned for writing

 Writes the array to the given stream.

 

 Return to Contents

int GENESISCC geTKArray_BSearch(const geTKArray* Array, geTKArray_TimeType Key);  

Array is a sorted array to searc.  Key is time to search for

 Searches for key in the Array. (assumes array is sorted)

 if key is found (within +-tolerance), the index to that element is returned.

 if key is not found, the index to the key just smaller than the

 given key is returned. (-1 if the key is smaller than the first element)

 search is only accurate to 2*TKA_TIME_TOLERANCE.

 if multiple keys exist within 2*TKA_TIME_TOLERANCE, this will find an arbitrary one of them.

 

 Return to Contents

geBoolean GENESISCC geTKArray_Insert(geTKArray* *Array, geTKArray_TimeType Key,  int * Index);   

Key is time to insert. Index is the new element index

 inserts a new element into Array.

 sets only the key for the new element - the rest is junk

 returns TRUE if the insertion was successful.

 returns FALSE if the insertion failed.

 if Array is empty (no elements, BasetypesIndexed.htm - NULLNULL pointer) it is allocated and filled

 with the one Key element

 Index is the index of the new element

 Return to Contents

geBoolean GENESISCC geTKArray_DeleteElement(geTKArray* *Array,  int N); 

N is element to delete

 deletes an element from Array.

 returns TRUE if the deletion was successful.

 returns FALSE if the deletion failed. (key not found or realloc failed)

 Return to Contents

void GENESISCC geTKArray_Destroy(geTKArray* *Array); 

 destroys array

 Return to Contents

void * GENESISCC geTKArray_Element(const geTKArray* Array, int N);

 returns a pointer to the Nth element of the array.

 Return to Contents

int GENESISCC geTKArray_NumElements(const geTKArray* Array);

 returns the number of elements in the array

 Return to Contents

geTKArray_TimeType GENESISCC geTKArray_ElementTime(const geTKArray* Array, int N);

 returns the Time associated with the Nth element of the array

 Return to Contents

int GENESISCC geTKArray_ElementSize(const geTKArray* A);

 returns the size of each element in the array

 Return to Contents

geBoolean GENESISCC geTKArray_SamplesAreTimeLinear(const geTKArray* Array, geFloat Tolerance);

 returns true if the samples are linear in time within a tolerance

 Return to Contents