Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

tkarray.h

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  TKARRAY.H                                                                                                                                                   */
00003 /*                                                                                      */
00004 /*  Author: Mike Sandige                                                                    */
00005 /*  Description: Time-keyed array interface.                                                                                    */
00006 /*                                                                                      */
00007 /*  The contents of this file are subject to the Genesis3D Public License               */
00008 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00009 /*  compliance with the License. You may obtain a copy of the License at                */
00010 /*  http://www.genesis3d.com                                                            */
00011 /*                                                                                      */
00012 /*  Software distributed under the License is distributed on an "AS IS"                 */
00013 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00014 /*  the License for the specific language governing rights and limitations              */
00015 /*  under the License.                                                                  */
00016 /*                                                                                      */
00017 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00018 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00019 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00020 /*                                                                                      */
00021 /****************************************************************************************/
00022 #ifndef GE_TKARRAY_H
00023 #define GE_TKARRAY_H
00024 /* TKArray
00025         (Time-Keyed-Array)
00026         This module is designed primarily to support path.c
00027 
00028         The idea is that there are these packed arrays of elements,
00029         sorted by a geTKArray_TimeType key.  The key is assumed to be the 
00030         first field in each element.
00031 
00032         the TKArray functions operate on this very specific array type.
00033 
00034         Error conditions are reported to errorlog
00035 */
00036 
00037 #include "basetype.h"
00038 #include "vfile.h"
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 typedef geFloat geTKArray_TimeType;
00045 
00046 #define GE_TKA_TIME_TOLERANCE (0.00001f)
00047 
00048 typedef struct geTKArray geTKArray;
00049 
00050 geTKArray *GENESISCC geTKArray_Create(int ElementSize);
00051         // creates new array with given attributes
00052 
00053 geTKArray *GENESISCC geTKArray_CreateEmpty(int ElementSize,int ElementCount);
00054         // creates new array with given element size and given count of uninitialized members
00055 
00056 geTKArray* GENESISCC geTKArray_CreateFromBinaryFile(
00057         geVFile* pFile);                                        // stream positioned at array data
00058         // Creates a new array from the given stream.
00059 
00060 geBoolean GENESISCC geTKArray_WriteToBinaryFile(
00061         const geTKArray* Array,                 // sorted array to write
00062         geVFile* pFile);                                        // stream positioned for writing
00063         // Writes the array to the given stream.
00064 
00065 
00066 int GENESISCC geTKArray_BSearch(
00067         const geTKArray *Array,                 // sorted array to search
00068         geTKArray_TimeType Key);                // searching for this time
00069         // Searches for key in the Array. (assumes array is sorted) 
00070         // if key is found (within +-tolerance), the index to that element is returned.
00071         // if key is not found, the index to the key just smaller than the 
00072         // given key is returned.  (-1 if the key is smaller than the first element)
00073         // search is only accurate to 2*TKA_TIME_TOLERANCE.  
00074         // if multiple keys exist within 2*TKA_TIME_TOLERANCE, this will find an arbitrary one of them.
00075 
00076 geBoolean GENESISCC geTKArray_Insert(
00077         geTKArray **Array,
00078         geTKArray_TimeType Key,                 // time to insert
00079         int *Index);                                    // new element index
00080         // inserts a new element into Array.
00081         // sets only the key for the new element - the rest is junk
00082         // returns TRUE if the insertion was successful.
00083         // returns FALSE if the insertion failed. 
00084         // if Array is empty (no elements, NULL pointer) it is allocated and filled 
00085         // with the one Key element
00086         // Index is the index of the new element 
00087 
00088 geBoolean GENESISCC geTKArray_DeleteElement(
00089         geTKArray **Array,
00090         int N);                                                 // element to delete
00091         // deletes an element from Array.
00092         // returns TRUE if the deletion was successful. 
00093         // returns FALSE if the deletion failed. (key not found or realloc failed)
00094 
00095 void GENESISCC geTKArray_Destroy(
00096         geTKArray **Array);     
00097         // destroys array
00098 
00099 void *GENESISCC geTKArray_Element(
00100         const geTKArray *Array,
00101         int N);
00102         // returns a pointer to the Nth element of the array.
00103 
00104 int GENESISCC geTKArray_NumElements(
00105         const geTKArray *Array);
00106         // returns the number of elements in the array
00107 
00108 geTKArray_TimeType GENESISCC geTKArray_ElementTime(
00109         const geTKArray *Array, 
00110         int N);
00111         // returns the Time associated with the Nth element of the array
00112 
00113 int GENESISCC geTKArray_ElementSize(
00114         const geTKArray *A);
00115         // returns the size of each element in the array
00116 
00117 geBoolean GENESISCC geTKArray_SamplesAreTimeLinear(const geTKArray *Array,geFloat Tolerance);
00118         // returns true if the samples are linear in time within a tolerance
00119 
00120 #ifdef __cplusplus
00121 }
00122 #endif
00123 
00124 
00125 
00126 #endif

Generated on Tue Sep 30 12:36:31 2003 for GTestAndEngine by doxygen 1.3.2