Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HStreamer.h
00001 //
00002 // Copyright (c) 2000 by Tech Soft 3D, LLC.
00003 // The information contained herein is confidential and proprietary to
00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under
00005 // civil and criminal statutes.  Tech Soft 3D 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 3D, LLC. is granted only under a
00009 // written non-disclosure agreement, expressly prescribing the scope and
00010 // manner of such use.
00011 //
00012 
00013 #ifndef _H_STREAMER_H_
00014 #define _H_STREAMER_H_
00015 
00016 #ifdef H_PACK_8
00017 #pragma pack(push)
00018 #pragma pack(8)
00019 #endif
00020 
00021 
00022 #include "HTools.h"
00023 #include "HStream.h"
00024 
00025 
00026 class HStreamerTK;
00027 class HStreamFileToolkit;
00028 class HStreamerBuffer;
00029 class HTClient;
00030 class Pause_Info;
00031 struct vlist_s;
00032 struct vhash_s;
00033 
00038 typedef void (*HStreamerConditionNoticeFunction)(unsigned int condition, void * user_data);
00039 
00043 #define HSTREAMER_CONDITION_COMPLETE_READ_PAUSES    0
00044 
00048 #define HSTREAMER_CONDITION_COMPLETE_SWEETENING     2
00049 
00053 #define HSTREAMER_CONDITION_VIEW_UPDATE             3
00054 
00058 #define HSTREAMER_CONDITION_NO_DICTIONARY           4
00059 
00063 #define HSTREAMER_CONDITION_VERSION_MISMATCH        5
00064 
00068 #define HSTREAMER_CONDITION_COMPLETE_READ_DICTIONARY    6
00069 
00070 
00071 
00073 
00081 class HStreamer
00082 {
00083     friend class HTK_HStreamer_Shell;
00084 
00085 public:
00086 
00090     HStreamer();
00091 
00095     ~HStreamer();
00096 
00110     void Setup( HC_KEY model_key, int n_pause=0 );
00111 
00117     void SetConditionNoticeFunction( HStreamerConditionNoticeFunction condition_notice_helper_function,
00118                                         void * user_data);
00119 
00124     void LoadFile( const char * filename );
00125 
00130     void Sweeten(HC_KEY key);
00131 
00140     void Sweeten( const HPoint& camera_position, 
00141                   const HPoint& camera_target, 
00142                   const HPoint& camera_up, 
00143                   const float field[2], 
00144                   const char * projection );
00145 
00146 
00147 
00149     HStreamFileToolkit * GetStreamFileToolkit() { return (HStreamFileToolkit*) m_ptk; };
00150 
00155     bool ReadStreamBufferQue();
00156 
00157 private:
00158 
00159     // cleans up the lists which contain new'ed objects
00160     void FreeKeyLodPairList(vlist_s*& plist);   
00161 
00162     // sweeten the next batch of entities on pending list
00163     void SweetenBatch();                            
00164     // sweeten entities on the unknown-size list
00165     void SweetenNext();                             
00166     
00167     // walks the HOOPS database begining at the start key to add each shell 
00168     // and mesh to the sweeten list for sweetening
00169     TK_Status TreeWalker (HC_KEY start_key, BStreamFileToolkit const * tk , int lod_level = -1);    
00170 
00171     // walks the HOOPS database begining at the start key and adds the geometry 
00172     // to the sweeten list for sweetening if it falls in the view of the camera supplied
00173     TK_Status TreeWalker(   HC_KEY start_key, 
00174                             BStreamFileToolkit const * tk , 
00175                             const HPoint& position, 
00176                             const HPoint& target, 
00177                             const HPoint& up,
00178                             const float field[2], 
00179                             const char * projection,
00180                             int lod_level = -1);
00181 
00182     // recursive utility function to walk HOOPS database
00183     TK_Status Walk (BStreamFileToolkit const * tk, float const * in_matrix, int test_case, int lod_level);
00184     
00185     // parses the buffer in to the model key
00186     TK_Status ParseBuffer(HStreamerTK * tk, HStreamerBuffer * block);   
00187     // parses the pause information 
00188     TK_Status ParsePauseInfo(HStreamerBuffer * block);                              
00189 
00190     // notifies the condition/error notice to the registered handler
00191     void NotifyCondition(unsigned int condition);                                   
00192 
00193     enum parse_stage {
00194         parse_Header,
00195         parse_FileInfo,
00196         parse_PauseInfo,
00197         parse_AllPauses,
00198         parse_Dictionary,
00199         parse_Single,
00200         parse_Normal,
00201         parse_Error
00202     };
00203 
00204     // the streamtoolkit to use for streaming
00205     HStreamerTK * m_ptk;                
00206     // MVO timer client registered with HTManager to recieve timer events
00207     HTClient * m_pBufferPollTimer;  
00208 
00209     int         m_nPauseJump;           // initial read to this pause in the streamfile
00210     vlist_s *   m_pDiscardedBlockIds;   // stream buffers requested but not of any significance any more
00211     vlist_s *   m_pSweetenList;         // list of shells for sweetening
00212     vlist_s *   m_pPendingSweetenList;  // list of shells which are requested for sweetening and are pending
00213     vhash_s *   m_pAlreadySweetenedList;// shells already sweetened 
00214     vlist_s *   m_pUnknownSizeList;     // shells of unknown size
00215     parse_stage m_ParseStage;           // current parsing state
00216     Pause_Info* m_PauseInfo;            // information about pause in the current hsf file
00217     HC_KEY      m_model_key;            // the segment key where the file has to be read
00218 
00219     // callback function for condition and error notices
00220     HStreamerConditionNoticeFunction    m_condition_notice_helper_function; 
00221     // user data to be passed to the condition notice function
00222     void *                              m_condition_notice_user_data;   
00223 
00224     // the id of the last of a batch of requests
00225     int m_sweeten_end_id;
00226 
00227 };
00228 
00229 
00230 #ifdef H_PACK_8
00231 #pragma pack(pop)
00232 #endif
00233 
00234 #endif
00235 
00236 
00237