Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

BStreamFileToolkit.h

00001 //
00002 // Copyright (c) 2000 by Tech Soft America, LLC.
00003 // The information contained herein is confidential and proprietary to
00004 // Tech Soft America, LLC., and considered a trade secret as defined under
00005 // civil and criminal statutes.  Tech Soft America shall pursue its civil
00006 // and criminal remedies in the event of unauthorized use or misappropriation
00007 // of its trade secrets.  Use of this information by anyone other than
00008 // authorized employees of Tech Soft America, LLC. is granted only under a
00009 // written non-disclosure agreement, expressly prescribing the scope and
00010 // manner of such use.
00011 //
00012 //
00013 //
00014 //  Copyright (c) 1996-2005 by Autodesk, Inc.
00015 //
00016 //  By using this code, you are agreeing to the terms and conditions of
00017 //  the License Agreement included in the documentation for this code.
00018 //
00019 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00020 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00021 //  WORKS WHICH INCORPORATE IT.
00022 //
00023 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00024 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00025 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00026 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00027 //
00028 //  Use, duplication, or disclosure by the U.S. Government is subject to
00029 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00030 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00031 //  Data and Computer Software), as applicable.
00032 //
00033 //
00034 // $Header: /Components/Internal/DWF Toolkit/v7.0.1/develop/global/src/dwf/w3dtk/BStreamFileToolkit.h 3     5/10/05 1:02a Evansg $
00035 //
00036 
00037 #ifndef BBINFILETK_TOOLKIT
00038 #define BBINFILETK_TOOLKIT
00039 
00040 
00041 #include "dwfcore/InputStream.h"
00042 using namespace DWFCore;
00043 
00044 #include "dwf/Toolkit.h"
00045 
00046 
00052 class BBINFILETK_API BControlledMemoryObject {
00053     public:
00054         void * operator new (size_t size);  
00055         void   operator delete (void * p);  
00056 };
00057 
00058 class BBaseOpcodeHandler;
00059 
00060 
00061 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00062 
00063 /*
00064    Buffers data so basic handlers can deal with simple Get/Put calls of basic data types (and arrays of those types).
00065    Handles both reading and writing, ZLIB compressed or uncompressed.
00066 */
00067 class BBINFILETK_API Internal_Data_Accumulator {
00068     private:
00069         char *          m_pending_buffer;           /*< The whole burrito. */
00070         int             m_pending_buffer_allocated; /*< How big the buffer is (so we know when to reallocate) */
00071         char *          m_pending_position;         /*< Start of actual data to be processed.*/
00072         int             m_pending_size;             /*< Size of actual data. */
00073 
00074         char *          m_buffer_data;              /*< The buffer shown to the user (i.e. passed to GenerateBuffer or ParseBuffer) */
00075         int             m_buffer_size;              /*< The size of the user's buffer */
00076 
00077         int             m_failed_size;              /*< When a read fails because of insufficient data, how much space would have been required for success? */
00078 
00079         int             m_generated;                /*< How much has been written into the user's buffer (after considering compression).  */
00080 
00081         struct z_stream_s * m_z_stream;             /*< The control structure for ZLIB */
00082         bool            m_compressed;               /*< are we in compressed mode? */
00083         bool            m_writing;                  /*< are we compressing or decompressing? */
00084         int             m_original_size;            /*< size of buffer originally passed in */
00085 
00086     public:
00087         Internal_Data_Accumulator () : m_pending_buffer (0), m_pending_buffer_allocated (0),
00088                                        m_pending_position (0), m_pending_size (0),
00089                                        m_failed_size (0), m_generated (0),
00090                                        m_z_stream (0), m_compressed (false), m_writing (false) {}
00091         ~Internal_Data_Accumulator ();
00092 
00093         void        set_data (char * b, int s) alter { m_buffer_data = b; m_original_size = m_buffer_size = s; }
00094         void        save (void) alter;
00095         TK_Status   consume (void) alter;
00096 
00097         TK_Status   read (char alter * b, int s) alter;
00098         TK_Status   write (char const * b, int s) alter;
00099         TK_Status   lookat (char alter & b) alter;
00100 
00101         int         get_original_buffer_size(){return m_original_size; }
00102 
00103         void        restart (void) alter;
00104         void        clean (void) alter;
00105         int         unused (void) const     { return m_buffer_size; }
00106         int         generated (void) const  { return m_generated; }
00107 
00108         TK_Status   start_compression (void) alter;
00109         TK_Status   stop_compression (bool flush) alter;
00110         TK_Status   start_decompression (void) alter;
00111         TK_Status   stop_decompression (bool force) alter;
00112         bool        compressed (void) const { return m_compressed; }
00113 
00114         TK_Status   error (char const * msg = 0) const;
00115 };
00116 
00117 
00118 /*
00119     Provides index <-> key translation, plus storage of additional item-specific data, such as
00120     file offset and size and bounding volume.
00121 */
00122 struct IT_Index_Key_Extra {
00123     int     m_variants[8][2];
00124     int     m_options;
00125     float   m_bounds[6];
00126 };
00127 
00128 class BBINFILETK_API Internal_Translator {
00129     friend class TK_Dictionary; // note, dictionary writer tied closely to this implementation
00130     private:
00131         // array -- index to key is trivial
00132         int                     m_size;
00133         int                     m_used;
00134 
00135         struct Index_Key_Pair {
00136             int                 m_index;
00137             ID_Key              m_key;
00138             IT_Index_Key_Extra *m_extra;
00139         } *                     m_pairs;
00140 
00141         enum Options {
00142             Bounds_Valid    = 0x0001,
00143 
00144             Extended        = 0x0080    // reserved
00145         };
00146 
00147         // hash of key to locate potential indices for key to index lookup
00148         struct Hash_Block {
00149             Hash_Block *    m_next;
00150             int             m_used;
00151             int             m_indices[32];
00152         } *                     m_blocks[1024];
00153 
00154 
00155     public:
00156         Internal_Translator () : m_size (0), m_used (0), m_pairs (0) { memset (m_blocks, 0, 1024*sizeof(void *)); }
00157         ~Internal_Translator ();
00158 
00159         TK_Status   add_pair (int index, ID_Key key) alter;
00160         TK_Status   add_variant (ID_Key key, int variant, int value1, int value2 = 0) alter;
00161         TK_Status   add_bounds (ID_Key key, float const * bounds) alter;
00162         TK_Status   index_to_key (int index, ID_Key alter & key) const;
00163         TK_Status   key_to_index (ID_Key key, int alter & index) const;
00164         TK_Status   key_variant_offset (ID_Key key, int variant,
00165                                         int alter & offset, int alter & length, int alter & index) const;
00166         TK_Status   key_bounds (ID_Key key, float alter * bounds) const;
00167         int         used (void) const { return m_used; }
00168 
00169         void        clean (void) alter;
00170 
00171         // older forms:
00172         TK_Status   key_variant_offset (ID_Key key, int variant, int alter & offset) const {
00173                         auto        int                 length, index;
00174                         return key_variant_offset (key, variant, offset, length, index);
00175                     }
00176         TK_Status   key_variant_offset (ID_Key key, int variant, int alter & offset, int alter & length) const {
00177                         auto        int                 index;
00178                         return key_variant_offset (key, variant, offset, length, index);
00179                     }
00180 
00181 };
00182 
00183 
00184 class BBINFILETK_API Internal_Key_Record {
00185     private:
00186         // hash of key to list of recorded segments
00187         struct Hash_Block {
00188             Hash_Block *    m_next;
00189             int             m_used;
00190             ID_Key          m_keys[32];
00191         } *                     m_blocks[1024];
00192 
00193 
00194     public:
00195         Internal_Key_Record () { memset (m_blocks, 0, 1024*sizeof(void *)); }
00196         ~Internal_Key_Record ();
00197 
00198         TK_Status   add_key (ID_Key key) alter;
00199         TK_Status   find_key (ID_Key key) const;
00200 
00201         void        clean (void) alter;
00202 };
00203 
00204 
00205 
00206 // control memory on these objects, not sure who might be creating/destroying them
00207 
00208 class Internal_Segment_List : public BControlledMemoryObject {
00209     public:
00210         Internal_Segment_List *     m_next;
00211         ID_Key                      m_key;
00212 
00213     public:
00214         Internal_Segment_List (ID_Key k) : m_next (0), m_key (k) {}
00215 
00216         ID_Key  key (void) const { return m_key; }
00217 };
00218 
00219 class Internal_Revisit_Item : public BControlledMemoryObject {
00220     public:
00221         Internal_Revisit_Item * m_next;
00222         ID_Key                  m_key;
00223         ID_Key                  m_owner;
00224         int                     m_lod;
00225         float                   m_priority;
00226         char                    m_opcode;
00227 };
00228 
00229 
00230 class Internal_ExRef_List : public BControlledMemoryObject {
00231     public:
00232         Internal_ExRef_List *   m_next;
00233         char *                  m_ref;
00234         ID_Key                  m_context;
00235 
00236     public:
00237         Internal_ExRef_List (char const * ref, ID_Key context);
00238         ~Internal_ExRef_List ();
00239 
00240         char const *    Reference (void) const { return m_ref; }
00241         ID_Key          Context (void) const { return m_context; }
00242 };
00243 
00244 
00245 class BBINFILETK_API Recorded_Instance : public BControlledMemoryObject {
00246     public:
00247         Recorded_Instance *     m_next;
00248 
00249         ID_Key                  m_key;
00250         int                     m_variant;
00251         int                     m_values[3];
00252 
00253         float                   m_local_basis[16];      // matrix from our basis to identity
00254         int                     m_basis_indices[4];
00255         float                   m_arbitrary_point[3];
00256         int                     m_arbitrary_index;
00257         bool                    m_basis_valid;
00258 
00259         unsigned char           m_opcode;
00260 
00261 #ifdef _DEBUG
00262         int                     m_times_used;
00263 #endif
00264 
00265         Recorded_Instance (ID_Key key, int variant, unsigned char op, int val1, int val2, int val3)
00266             : m_next (0), m_key (key), m_variant (variant), m_basis_valid (false), m_opcode (op) {
00267             m_values[0] = val1;     m_values[1] = val2;     m_values[2] = val3;
00268 #ifdef _DEBUG
00269             m_times_used = 0;
00270 #endif
00271         }
00272 
00273         bool basis_valid (void) const { return m_basis_valid; }
00274         bool generate_basis (int count, float const * points) alter;
00275 };
00276 
00277 class Internal_Segment_Processor;
00278 
00279 /*
00280     Callback which can be used for reporting progress during writing/reading.
00281     During writing:
00282         so_far is number of "objects" written, expected is the number the toolkit will likely write.
00283         Note: the toolkit won't know about objects in pre/post-walk handlers or extra objects due to
00284             overloading the default classes, so "so_far" may exceed "expected"
00285     During reading:
00286         so_far is the number of bytes processed, expected is the file size.
00287     user_data allows the application to pass any necessary values through.
00288     returns a flag which indicates whether the processing should continue.
00289 */
00290 typedef bool (*TK_Progress_Callback) (unsigned long so_far, unsigned long expected, void * user_data);
00291 
00292 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00293 
00294 
00295 
00297 
00330 class BBINFILETK_API BStreamFileToolkit : public BControlledMemoryObject {
00331     friend class BBaseOpcodeHandler;
00332     friend class TK_Default;
00333     friend class TK_Comment;
00334     friend class TK_Header;
00335     friend class TK_Compression;
00336     friend class TK_Dictionary;
00337     friend class Internal_Segment_Processor;
00338     friend class TK_Shell;
00339 
00340     friend class TK_Tag;
00341     friend class TK_Instance;
00342     protected:
00343 
00344 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00345 
00346         Internal_Data_Accumulator       m_accumulator;          
00347         Internal_Translator             m_translator;           
00349         BBaseOpcodeHandler *            m_objects[256];         
00350         BBaseOpcodeHandler *            m_default_object;       
00351         int                             m_prewalk_count;
00352         int                             m_postwalk_count;
00353         BBaseOpcodeHandler **           m_prewalk;              
00354         BBaseOpcodeHandler **           m_postwalk;             
00355         BBaseOpcodeHandler *            m_current_object;       
00356         Internal_Segment_List *         m_active_segments;      
00357         Internal_Key_Record             m_visited_segments;     
00358         ID_Key                          m_context_key;          
00359         ID_Key *                        m_last_keys;            
00360         int                             m_last_keys_used;
00361         int                             m_last_keys_allocated;
00362         Internal_Revisit_Item *         m_revisit;              
00363         Internal_Revisit_Item *         m_revisit_working;      
00364         int                             m_stage;                
00365         int                             m_substage;             
00366         int                             m_pass;                 
00367         int                             m_tag_count;            
00368         int                             m_position;             
00369         unsigned int                    m_offset;               
00370         int                             m_unused;               
00371         int                             m_write_flags;          
00372         int                             m_read_flags;           
00373         int                             m_num_normal_bits;      
00374         int                             m_num_vertex_bits;      
00375         int                             m_num_parameter_bits;   
00376         int                             m_num_color_bits;       
00377         int                             m_num_index_bits;       
00378         int                             m_file_version;         
00379         int                             m_target_version;       
00380         bool                            m_header_comment_seen;  
00381         char *                          m_log_file;             
00382         FILE *                          m_log_fp;               
00383         bool                            m_logging;              
00384         unsigned int                    m_logging_options;      
00385         unsigned int                    m_log_line_length;      
00386         unsigned int                    m_opcode_sequence;      
00387         unsigned int                    m_objects_written;      
00388         TK_Progress_Callback            m_progress_callback;    
00389         void *                          m_progress_value;       
00390         int                             m_buffer_limit;         
00391         int                             m_nesting_level;        
00392         int                             m_dictionary_format;    
00393         int                             m_dictionary_options;   
00394         Recorded_Instance *             m_instance_hash[256];   
00395         int                             m_jpeg_quality;         
00396         int *                           m_pause_table;          
00397         int                             m_pause_table_size;     
00398         unsigned short                  m_num_pauses;           
00399         float *                         m_world_bounding;       
00400         Internal_ExRef_List *           m_external_references;  
00401         Internal_ExRef_List *           m_external_ref_tail;    
00403         char **                         m_file_names;           
00404         int *                           m_file_indices;         
00405         int                             m_file_count;           
00406         int                             m_files_allocated;      
00407         char *                          m_filename;             
00408         int                             m_index_base;           
00409         float                           m_quantization_error;   
00411         int                             m_save_write_flags;     
00413         /* Internal use.
00414          * A quick utility to verify that an array is in fact sorted.
00415          * FOR DEBUGGING ONLY
00416          */
00417         bool issorted_revisit(Internal_Revisit_Item **array, int count);
00418 
00423         void qsort_revisit(Internal_Revisit_Item **, Internal_Revisit_Item **);
00424         TK_Status sort_revisit();
00425 
00426         virtual void read_completed () alter;
00427 
00428 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00429 
00430 
00431     protected:
00432 
00434         void *                          m_file;
00435         DWFInputStream*                 _pInputStream;
00436 
00437     public:
00438 
00442         BStreamFileToolkit (void);
00443         virtual ~BStreamFileToolkit ();
00444 
00480         TK_Status   ParseBuffer (char const * b, int s, TK_Status mode = TK_Normal) alter;
00481 
00482 
00488         TK_Status   PrepareBuffer(char * b, int s) alter;
00489 
00491         int         CurrentBufferLength() {return m_accumulator.get_original_buffer_size() -
00492                                                   m_accumulator.unused();}
00493 
00499         virtual void    ActivateContext (ID_Key key) { (void)key; }
00500 
00506         virtual void    DeactivateContext (ID_Key key) { (void)key; }
00507 
00515         virtual void    NewFileContext (ID_Key key) { (void)key; }
00516 
00522         int             GeneratedSoFar (void) const { return m_accumulator.generated(); }
00523 
00528         unsigned int    ObjectsSoFar (void) const { return m_objects_written; }
00529 
00536         void        SetOpcodeHandler (int which, BBaseOpcodeHandler * handler) alter;
00537 
00545         void        SetPrewalkHandler (BBaseOpcodeHandler * handler) alter;
00546 
00547 
00555         void        SetPostwalkHandler (BBaseOpcodeHandler * handler) alter;
00556 
00558         BBaseOpcodeHandler *    GetOpcodeHandler (int which) const { return m_objects[which]; }
00559 
00565         virtual void    Restart (void) alter;
00566 
00567         // access to index <-> key tranlation
00574         TK_Status   IndexToKey (int index, ID_Key alter & key) const;
00575 
00582         TK_Status   KeyToIndex (ID_Key key, int alter & index) const;
00583 
00590         TK_Status   AddIndexKeyPair (int index, ID_Key key) alter
00591                                         { return m_translator.add_pair (index, key); }
00592 
00601         TK_Status   AddVariant (ID_Key key, int variant, int value1, int value2 = -1) alter
00602                                         { return m_translator.add_variant (key, variant, value1, value2);   }
00603 
00610         TK_Status   AddBounds (ID_Key key, float const * bounds) alter
00611                                         { return m_translator.add_bounds (key, bounds);                     }
00612 
00620         TK_Status   GetOffset (ID_Key key, int variant, int alter & offset) const
00621                                         { return m_translator.key_variant_offset (key, variant, offset);            }
00622 
00631         TK_Status   GetOffset (ID_Key key, int variant, int alter & offset, int alter & length) const
00632                                         { return m_translator.key_variant_offset (key, variant, offset, length);    }
00633 
00643         TK_Status   GetOffset (ID_Key key, int variant,
00644                                int alter & offset, int alter & length, char const * alter & filename) const;
00645 
00652         TK_Status   GetBounds (ID_Key key, float alter * bounds) const
00653                                         { return m_translator.key_bounds (key, bounds);                             }
00654 
00659         int         NextTagIndex (void) alter   { return m_tag_count++; }
00664         int         PeekTagIndex (void) const   { return m_tag_count; }
00665 
00671         void            SetNewFile (char const * name) alter;
00676         char const *    GetCurrentFile (void) const    { return m_filename; }
00683         TK_Status       SelectFile (char const * name) alter;
00684 
00692         virtual TK_Status   OpenFile (char const * name, bool write = false) alter;
00693 
00694         //
00695         // Lets the toolkit read directly from a stream rather than assuming
00696         // a disk file will be the source of the data feed.
00697         //
00698         virtual TK_Status   OpenStream( DWFInputStream& rReadStream ) alter;
00699         virtual TK_Status   CloseStream() alter;
00700 
00705         virtual TK_Status   CloseFile (void) alter;
00706 
00716         virtual TK_Status   ReadBuffer (char alter * buffer, int size, int alter & amount_read) alter;
00717 
00726         virtual TK_Status   WriteBuffer (char alter * buffer, int size) alter;
00727 
00737         virtual TK_Status   PositionFile (int offset) alter;
00738 
00747         virtual TK_Status   GetFileSize (unsigned long & size) alter;
00748 
00749 
00761         virtual TK_Status   LocateDictionary (void) alter;
00762 
00773         virtual TK_Status   LocateEntity (ID_Key key, int variant) alter;
00774 
00775         int         GetFlags (void) const       { return GetWriteFlags(); }     
00776         void        SetFlags (int flags) alter  { SetWriteFlags(flags); }       
00780         void        SetWriteFlags (int flags) alter     { m_write_flags = flags; }
00786         int         GetWriteFlags (int mask = ~0) const { return m_write_flags & mask; }
00787 
00789         void        SetReadFlags (int flags) alter      { m_read_flags = flags; }
00795         int         GetReadFlags (int mask = ~0) const  { return m_read_flags & mask; }
00796 
00797 
00798         int         GetNumNormalBits (void) const { return m_num_normal_bits; } 
00804         void        SetNumNormalBits (int numbits) alter  { m_num_normal_bits = numbits; }
00805 
00806         int         GetNumVertexBits (void) const { return m_num_vertex_bits; } 
00808         void        SetNumVertexBits (int numbits) alter  { m_num_vertex_bits = numbits; }
00809         int         GetNumParameterBits (void) const { return m_num_parameter_bits; } 
00810         void        SetNumParameterBits (int numbits) alter  { m_num_parameter_bits = numbits; }        
00811         int         GetNumColorBits (void) const { return m_num_color_bits; } 
00812         void        SetNumColorBits (int numbits) alter  { m_num_color_bits = numbits; }        
00813         int         GetNumIndexBits (void) const { return m_num_index_bits; } 
00814         void        SetNumIndexBits (int numbits) alter  { m_num_index_bits = numbits; }        
00817         void        SetJpegQuality (int quality = 75) alter     { m_jpeg_quality = quality; }
00819         int         GetJpegQuality (void) const                 { return m_jpeg_quality;    }
00820 
00821         int         GetVersion (void) const     { return m_file_version; }  
00823         void        SetTargetVersion (int version) alter     { m_target_version = version; }  
00824         int         GetTargetVersion (void) const     { return m_target_version; }  
00826 
00827         unsigned int    GetFileOffset (void) const                  { return m_offset;      }
00829         void            SetFileOffset (unsigned int offset) alter   { m_offset = offset;    }
00831         int             Unused (void) const                     { return m_unused; }
00835         virtual TK_Status   Error(char const * msg = 0) const;
00836 
00838         char const *GetLogFile (void) const                     { return m_log_file;    }
00840         void        SetLogFile (char const * filename = 0) alter;
00841 
00843         bool        GetLogging (void) const                     { return m_logging;     }
00847         void        SetLogging (bool setting) alter             { m_logging = setting;  }
00848 
00850         unsigned int    GetLoggingOptions (unsigned int mask = ~0) const
00851                                                                 { return m_logging_options & mask; }
00853         void        SetLoggingOptions (unsigned int options = 0) alter
00854                                                                 { m_logging_options = options;  }
00855 
00860         TK_Status   OpenLogFile (char const * filename, char const * mode) alter;
00862         void        LogEntry (char const * string) alter;
00864         void        CloseLogFile (void) alter;
00865 
00867         unsigned int    NextOpcodeSequence (void) alter                 { return ++m_opcode_sequence;   }
00869         void            SetOpcodeSequence (unsigned int seq=0) alter    { m_opcode_sequence = seq;      }
00870 
00872         bool        HeaderCommentSeen(void) const                       { return m_header_comment_seen; }
00873 
00875         TK_Progress_Callback    GetProgressCallback (void) const        { return m_progress_callback;   }
00877         void    SetProgressCallback (TK_Progress_Callback cb = 0) alter { m_progress_callback = cb;     }
00878 
00880         void *      GetProgressValue (void) const                       { return m_progress_value;      }
00882         void        SetProgressValue (void * value) alter               { m_progress_value = value;     }
00883 
00885         int         GetBufferLimit (void) const                         { return m_buffer_limit;      }
00887         void        SetBufferLimit (int limit) alter    {
00888                             m_buffer_limit = (0 < limit && limit < TK_DEFAULT_BUFFER_SIZE) ?
00889                                              limit : TK_DEFAULT_BUFFER_SIZE;
00890                         }
00891 
00893         void        SetLastKey (ID_Key key) alter;
00895         TK_Status   AppendLastKey (ID_Key key) alter;
00897         void        ClearLastKey () alter;
00899         TK_Status   GetLastKey (ID_Key &key) const;
00900 
00906         void        SetDictionaryFormat (int format = 2, int options = TK_Dictionary_Bounding_Volumes) alter
00907                                         { m_dictionary_format = format; m_dictionary_options = options; }
00912         int         GetDictionaryFormat (void) const    { return m_dictionary_format;     }
00917         int         GetDictionaryOptions (void) const   { return m_dictionary_options;    }
00918 
00923         void        RecordPause (int offset) alter;
00927         void        ClearPauses (void) alter            { m_num_pauses = 0;     }
00932         int         GetPauseCount (void) const          { return m_num_pauses;  }
00937         int const * GetPauseTable (void) const          { return m_pause_table; }
00938 
00940         void        SetFirstPause (int offset) alter    { if (GetPauseCount() == 0) RecordPause (offset);
00941                                                           else m_pause_table[0] = offset;                   }
00943         int         GetFirstPause (void) const          { return (m_num_pauses > 0) ? m_pause_table[0] : 0; }
00944 
00948         int         GetPosition (void) const            { return m_position;        }
00949 
00954         void        SetWorldBounding( float const *bbox );
00955 
00961         void        SetWorldBoundingBySphere( float const *pt, float radius );
00962 
00964         float const * GetWorldBounding() const          { return m_world_bounding; }
00965 
00966 
00971         void        AddExternalReference (char const * ref, ID_Key context) alter;
00975         bool        NextExternalReference (void) alter;
00979         char const *GetExternalReference (void) const {
00980                             return  (m_external_references != 0) ? m_external_references->m_ref : 0;
00981                         }
00985         ID_Key      GetExternalReferenceContext (void) const {
00986                             return  (m_external_references != 0) ? m_external_references->m_context : 0;
00987                         }
00988 
00992         void        AddSegment (ID_Key key) alter;
00996         ID_Key      RemoveSegment (void) alter;
01000         ID_Key      CurrentSegment (void) alter { return (m_active_segments != 0) ? m_active_segments->key() : -1; }
01002         void ResetQuantizationError() { m_quantization_error = 0; }
01006         void ReportQuantizationError( float error ) { if (error > m_quantization_error) m_quantization_error = error; };
01010         void ReportQuantizationError( int bits_per_sample, float const *bounding, int num_dimensions = 3 );
01014         float GetQuantizationError() const { return m_quantization_error; }
01015 
01016     protected:
01017 
01018 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01019 
01020         // normal data access for objects
01021         TK_Status   read (char alter * b, int n) alter      { return m_accumulator.read (b, n); }
01022         TK_Status   write (char const * b, int n) alter     { return m_accumulator.write (b, n); }
01023         TK_Status   lookat (char alter & b) alter           { return m_accumulator.lookat (b); }
01024 
01025         // used by segment handlers to make sure we know which segment should be "open"
01026         void        add_segment (ID_Key key) alter { AddSegment (key); }
01027         ID_Key      remove_segment (void) alter { return RemoveSegment(); }
01028 
01029         // used by renumber key, maybe by lookup functions (to be implemented...)
01031         void        set_last_key (ID_Key key) alter { SetLastKey( key ); }
01032         ID_Key      context_key (void) const { return m_context_key; }
01033         void        set_context_key (ID_Key key) alter;
01035         ID_Key      last_key (void) const {
01036             if( m_last_keys_used == 1 )
01037                 return m_last_keys[0];
01038             else
01039                 return -1;
01040         }
01041 
01042         // keep track of visited segments (for things like include)
01043         void        remember_segment (ID_Key key) alter;
01044         bool        find_segment (ID_Key key) const;
01045 
01047         BBaseOpcodeHandler alter *  opcode_handler (int index) const { return m_objects[index]; }
01048 
01049         void        adjust_written (int count) alter    { m_objects_written += count; }
01050 
01051         int         pass (void) const { return m_pass; }
01052 
01054         TK_Status   revisit (unsigned char opcode, float priority, int lod=0) alter;
01055 
01057         void        record_instance (ID_Key key, int variant, BBaseOpcodeHandler const * object,
01058                                      int val1, int val2 = 0, int val3 = 0) alter;
01059 
01061         bool        find_instance (BBaseOpcodeHandler * object, int val1, int val2 = 0, int val3 = 0) const;
01062 
01064         int         position (void) const           { return m_position; }
01065         void        set_position (int pos) alter    { m_position = pos; }
01066         void        mark_position (void) alter      { set_position (GeneratedSoFar()); }
01067 
01072         virtual TK_Status   tag (int variant) alter;
01073 
01074         void        increase_nesting (int amount = 1) alter { m_nesting_level += amount; }
01075         void        decrease_nesting (int amount = 1) alter { m_nesting_level -= amount; }
01076 
01077         // utility
01078         TK_Status   start_compression (void) alter      { return m_accumulator.start_compression(); }
01079         TK_Status   stop_compression (void) alter       { return m_accumulator.stop_compression(true); }
01080         TK_Status   start_decompression (void) alter                { return m_accumulator.start_decompression(); }
01081         TK_Status   stop_decompression (bool force = false) alter   { return m_accumulator.stop_decompression(force); }
01082         virtual void    empty_lists (void) alter;
01083 
01084 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01085 
01086 };
01087 
01088 
01089 #endif //BBINFILETK_TOOLKIT

Generated on Tue May 17 12:06:00 2005 for Autodesk DWF 3D Toolkit by  doxygen 1.4.1