HStreamer.h
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 #ifndef _H_STREAMER_H_
11 #define _H_STREAMER_H_
12 
13 #ifdef H_PACK_8
14 #pragma pack(push)
15 #pragma pack(8)
16 #endif
17 
18 
19 #include "HTools.h"
20 #include "HStream.h"
21 
22 
23 class HStreamerTK;
24 class HStreamFileToolkit;
25 class HStreamerBuffer;
26 class HTClient;
27 class Pause_Info;
28 struct vlist_s;
29 struct vhash_s;
30 
35 typedef void (*HStreamerConditionNoticeFunction)(unsigned int condition, void * user_data);
36 
40 #define HSTREAMER_CONDITION_COMPLETE_READ_PAUSES 0
41 
45 #define HSTREAMER_CONDITION_COMPLETE_SWEETENING 2
46 
50 #define HSTREAMER_CONDITION_VIEW_UPDATE 3
51 
55 #define HSTREAMER_CONDITION_NO_DICTIONARY 4
56 
60 #define HSTREAMER_CONDITION_VERSION_MISMATCH 5
61 
65 #define HSTREAMER_CONDITION_COMPLETE_READ_DICTIONARY 6
66 
67 
68 
70 
78 class HStreamer
79 {
80  friend class HTK_HStreamer_Shell;
81 
82 public:
83 
87  HStreamer();
88 
92  ~HStreamer();
93 
107  void Setup( HC_KEY model_key, int n_pause=0 );
108 
114  void SetConditionNoticeFunction( HStreamerConditionNoticeFunction condition_notice_helper_function,
115  void * user_data);
116 
121  void LoadFile( const char * filename );
122 
127  void Sweeten(HC_KEY key);
128 
137  void Sweeten( const HPoint& camera_position,
138  const HPoint& camera_target,
139  const HPoint& camera_up,
140  const float field[2],
141  const char * projection );
142 
143 
144 
146  HStreamFileToolkit * GetStreamFileToolkit() { return (HStreamFileToolkit*) m_ptk; };
147 
152  bool ReadStreamBufferQue();
153 
154 private:
155 
156  // cleans up the lists which contain new'ed objects
157  void FreeKeyLodPairList(vlist_s*& plist);
158 
159  // sweeten the next batch of entities on pending list
160  void SweetenBatch();
161  // sweeten entities on the unknown-size list
162  void SweetenNext();
163 
164  // walks the HOOPS database begining at the start key to add each shell
165  // and mesh to the sweeten list for sweetening
166  TK_Status TreeWalker (HC_KEY start_key, BStreamFileToolkit const * tk , int lod_level = -1);
167 
168  // walks the HOOPS database begining at the start key and adds the geometry
169  // to the sweeten list for sweetening if it falls in the view of the camera supplied
170  TK_Status TreeWalker( HC_KEY start_key,
171  BStreamFileToolkit const * tk ,
172  const HPoint& position,
173  const HPoint& target,
174  const HPoint& up,
175  const float field[2],
176  const char * projection,
177  int lod_level = -1);
178 
179  // recursive utility function to walk HOOPS database
180  TK_Status Walk (BStreamFileToolkit const * tk, float const * in_matrix, int test_case, int lod_level);
181 
182  // parses the buffer in to the model key
183  TK_Status ParseBuffer(HStreamerTK * tk, HStreamerBuffer * block);
184  // parses the pause information
185  TK_Status ParsePauseInfo(HStreamerBuffer * block);
186 
187  // notifies the condition/error notice to the registered handler
188  void NotifyCondition(unsigned int condition);
189 
190  enum parse_stage {
191  parse_Header,
192  parse_FileInfo,
193  parse_PauseInfo,
194  parse_AllPauses,
195  parse_Dictionary,
196  parse_Single,
197  parse_Normal,
198  parse_Error
199  };
200 
201  // the streamtoolkit to use for streaming
202  HStreamerTK * m_ptk;
203  // MVO timer client registered with HTManager to recieve timer events
204  HTClient * m_pBufferPollTimer;
205 
206  int m_nPauseJump; // initial read to this pause in the streamfile
207  vlist_s * m_pDiscardedBlockIds; // stream buffers requested but not of any significance any more
208  vlist_s * m_pSweetenList; // list of shells for sweetening
209  vlist_s * m_pPendingSweetenList; // list of shells which are requested for sweetening and are pending
210  vhash_s * m_pAlreadySweetenedList;// shells already sweetened
211  vlist_s * m_pUnknownSizeList; // shells of unknown size
212  parse_stage m_ParseStage; // current parsing state
213  Pause_Info* m_PauseInfo; // information about pause in the current hsf file
214  HC_KEY m_model_key; // the segment key where the file has to be read
215 
216  // callback function for condition and error notices
217  HStreamerConditionNoticeFunction m_condition_notice_helper_function;
218  // user data to be passed to the condition notice function
219  void * m_condition_notice_user_data;
220 
221  // the id of the last of a batch of requests
222  int m_sweeten_end_id;
223 
224 };
225 
226 
227 #ifdef H_PACK_8
228 #pragma pack(pop)
229 #endif
230 
231 #endif
232 
233 
234 
void SetConditionNoticeFunction(HStreamerConditionNoticeFunction condition_notice_helper_function, void *user_data)
The HStreamer class provides functionality for on-demand and view-dependent streaming of HSF files...
Definition: HStreamer.h:78
bool ReadStreamBufferQue()
#define HC_KEY
Definition: HTManager.h:157
void LoadFile(const char *filename)
HStreamFileToolkit * GetStreamFileToolkit()
Definition: HStreamer.h:146
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:121
void Sweeten(HC_KEY key)
void Setup(HC_KEY model_key, int n_pause=0)