Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HStreamer.h
00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc.
00002 //
00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
00004 // and considered a trade secret as defined under civil and criminal statutes.
00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
00006 // unauthorized use or misappropriation of its trade secrets.  Use of this information
00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
00009 
00010 #ifndef _H_STREAMER_H_
00011 #define _H_STREAMER_H_
00012 
00013 #ifdef H_PACK_8
00014 #pragma pack(push)
00015 #pragma pack(8)
00016 #endif
00017 
00018 
00019 #include "HTools.h"
00020 #include "HStream.h"
00021 
00022 
00023 class HStreamerTK;
00024 class HStreamFileToolkit;
00025 class HStreamerBuffer;
00026 class HTClient;
00027 class Pause_Info;
00028 struct vlist_s;
00029 struct vhash_s;
00030 
00035 typedef void (*HStreamerConditionNoticeFunction)(unsigned int condition, void * user_data);
00036 
00040 #define HSTREAMER_CONDITION_COMPLETE_READ_PAUSES    0
00041 
00045 #define HSTREAMER_CONDITION_COMPLETE_SWEETENING     2
00046 
00050 #define HSTREAMER_CONDITION_VIEW_UPDATE             3
00051 
00055 #define HSTREAMER_CONDITION_NO_DICTIONARY           4
00056 
00060 #define HSTREAMER_CONDITION_VERSION_MISMATCH        5
00061 
00065 #define HSTREAMER_CONDITION_COMPLETE_READ_DICTIONARY    6
00066 
00067 
00068 
00070 
00078 class HStreamer
00079 {
00080     friend class HTK_HStreamer_Shell;
00081 
00082 public:
00083 
00087     HStreamer();
00088 
00092     ~HStreamer();
00093 
00107     void Setup( HC_KEY model_key, int n_pause=0 );
00108 
00114     void SetConditionNoticeFunction( HStreamerConditionNoticeFunction condition_notice_helper_function,
00115                                         void * user_data);
00116 
00121     void LoadFile( const char * filename );
00122 
00127     void Sweeten(HC_KEY key);
00128 
00137     void Sweeten( const HPoint& camera_position, 
00138                   const HPoint& camera_target, 
00139                   const HPoint& camera_up, 
00140                   const float field[2], 
00141                   const char * projection );
00142 
00143 
00144 
00146     HStreamFileToolkit * GetStreamFileToolkit() { return (HStreamFileToolkit*) m_ptk; };
00147 
00152     bool ReadStreamBufferQue();
00153 
00154 private:
00155 
00156     // cleans up the lists which contain new'ed objects
00157     void FreeKeyLodPairList(vlist_s*& plist);   
00158 
00159     // sweeten the next batch of entities on pending list
00160     void SweetenBatch();                            
00161     // sweeten entities on the unknown-size list
00162     void SweetenNext();                             
00163     
00164     // walks the HOOPS database begining at the start key to add each shell 
00165     // and mesh to the sweeten list for sweetening
00166     TK_Status TreeWalker (HC_KEY start_key, BStreamFileToolkit const * tk , int lod_level = -1);    
00167 
00168     // walks the HOOPS database begining at the start key and adds the geometry 
00169     // to the sweeten list for sweetening if it falls in the view of the camera supplied
00170     TK_Status TreeWalker(   HC_KEY start_key, 
00171                             BStreamFileToolkit const * tk , 
00172                             const HPoint& position, 
00173                             const HPoint& target, 
00174                             const HPoint& up,
00175                             const float field[2], 
00176                             const char * projection,
00177                             int lod_level = -1);
00178 
00179     // recursive utility function to walk HOOPS database
00180     TK_Status Walk (BStreamFileToolkit const * tk, float const * in_matrix, int test_case, int lod_level);
00181     
00182     // parses the buffer in to the model key
00183     TK_Status ParseBuffer(HStreamerTK * tk, HStreamerBuffer * block);   
00184     // parses the pause information 
00185     TK_Status ParsePauseInfo(HStreamerBuffer * block);                              
00186 
00187     // notifies the condition/error notice to the registered handler
00188     void NotifyCondition(unsigned int condition);                                   
00189 
00190     enum parse_stage {
00191         parse_Header,
00192         parse_FileInfo,
00193         parse_PauseInfo,
00194         parse_AllPauses,
00195         parse_Dictionary,
00196         parse_Single,
00197         parse_Normal,
00198         parse_Error
00199     };
00200 
00201     // the streamtoolkit to use for streaming
00202     HStreamerTK * m_ptk;                
00203     // MVO timer client registered with HTManager to recieve timer events
00204     HTClient * m_pBufferPollTimer;  
00205 
00206     int         m_nPauseJump;           // initial read to this pause in the streamfile
00207     vlist_s *   m_pDiscardedBlockIds;   // stream buffers requested but not of any significance any more
00208     vlist_s *   m_pSweetenList;         // list of shells for sweetening
00209     vlist_s *   m_pPendingSweetenList;  // list of shells which are requested for sweetening and are pending
00210     vhash_s *   m_pAlreadySweetenedList;// shells already sweetened 
00211     vlist_s *   m_pUnknownSizeList;     // shells of unknown size
00212     parse_stage m_ParseStage;           // current parsing state
00213     Pause_Info* m_PauseInfo;            // information about pause in the current hsf file
00214     HC_KEY      m_model_key;            // the segment key where the file has to be read
00215 
00216     // callback function for condition and error notices
00217     HStreamerConditionNoticeFunction    m_condition_notice_helper_function; 
00218     // user data to be passed to the condition notice function
00219     void *                              m_condition_notice_user_data;   
00220 
00221     // the id of the last of a batch of requests
00222     int m_sweeten_end_id;
00223 
00224 };
00225 
00226 
00227 #ifdef H_PACK_8
00228 #pragma pack(pop)
00229 #endif
00230 
00231 #endif
00232 
00233 
00234