Alphabetical Class Index   Class Hierarchy   Compound Members   File Members   File List  

HStreamFileToolkit.h
1 // Copyright (c) 1998-2014 by 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 HBINFILETK_TOOLKIT
11 #define HBINFILETK_TOOLKIT
12 
13 
14 #ifndef HSTREAM_READONLY
15 
16 #ifndef DOXYGEN_SHOULD_SKIP_THIS
17 
18 class Internal_Key_Array {
19  friend class HStreamFileToolkit;
20  friend class Internal_Pending_Tag;
21  friend class Internal_Segment_Processor;
22  private:
23  Internal_Key_Array() { m_data = 0; }
24  ~Internal_Key_Array() { delete [] m_data; }
25 
26  int m_count;
27  HC_KEY *m_data;
28 };
29 
30 class Internal_Pending_Tag {
31  friend class HStreamFileToolkit;
32  friend class Internal_Segment_Processor;
33  friend class HTK_Referenced_Segment;
34  friend class HTK_Reference;
35  friend class HTK_Texture;
36  friend class HTK_Named_Style_Def;
37  private:
38  Internal_Pending_Tag() { m_next = 0; m_array = 0; }
39  ~Internal_Pending_Tag() { delete m_array; }
40 
41  Internal_Pending_Tag * m_next;
42  HC_KEY m_key; //m_key set to tk.m_last_keys[0], just for the purposes of matching tag requests
43  int m_variant;
44  Internal_Key_Array * m_array; //set to null unless we are associating multiple keys with a single tag call.
45 };
46 
47 
48 class Internal_Texture_List {
49  friend class HStreamFileToolkit;
50  friend class HTK_Image;
51  private:
52  Internal_Texture_List * m_next;
53  char * m_name;
54  char * m_image;
55  HC_KEY m_image_key;
56  bool m_do_write_image;
57 
58  public:
59  Internal_Texture_List (char const * name, char const * image, HC_KEY key = -1);
60  ~Internal_Texture_List();
61 };
62 
63 
65 class HBINFILETK_API HStreamFileToolkit; //forward declaration
66 
67 // special output-only pseudo-object
68 class HBINFILETK_API2 Internal_Segment_Processor : public BBaseOpcodeHandler {
69  protected:
70  char * m_name;
71  HC_KEY m_key;
72  bool m_top_level;
73  HC_KEY m_root;
74  BBaseOpcodeHandler * m_current_object;
75  BBaseOpcodeHandler * m_must_delete;
76  HC_KEY m_item_key;
77  int m_saved_count;
78  HC_KEY * m_saved_keys;
79  HC_KEY m_renumbered;
80  unsigned char m_renumbered_scope;
81  int m_priority;
82  bool m_has_priority;
83  int m_start_offset;
84  bool m_searching;
85  unsigned char m_use_polypolylines;
86  unsigned char m_polylines_already_handled;
87  bool m_geometry_attributes;
88  bool m_geometry_open;
89  BBaseOpcodeHandler * m_deferred;
90  int m_search_pass;
91  bool m_look_for_bounds;
93  void save_keys (HStreamFileToolkit & tk);
94  void restore_keys (HStreamFileToolkit & tk);
95 
96  public:
97  Internal_Segment_Processor (ID_Key key = -1, char const * name = 0);
98  ~Internal_Segment_Processor ();
99 
102  TK_Status Interpret (BStreamFileToolkit & tk, ID_Key key, int variant = 0);
103  TK_Status Interpret (BStreamFileToolkit & tk, ID_Key key, char const * special);
104  void Reset ();
106 
107  void SetRoot (HC_KEY root) { m_root = root; }
108  HC_KEY GetRoot () const { return m_root; }
109 };
110 
111 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
112 
113 #endif //HSTREAM_READONLY
114 
115 
116 
117 
118 
120 
138 class HBINFILETK_API2 HStreamFileToolkit : public BStreamFileToolkit {
139  friend class Internal_Segment_Processor;
140  friend class HTK_Open_Segment;
141  friend class HTK_Referenced_Segment;
142  friend class HTK_Reference;
143  friend class HTK_Texture;
144  friend class HTK_Image;
145  friend class HTK_Named_Style_Def;
146  private:
147  int m_hoops_version; /* Version of Hoops we are using */
148  Internal_Segment_List * m_unnamed_segments; /* Segments which need to be renamed to unnamed when able */
149 
150  HC_KEY * m_excluded_segments; /* keys of segments (if any) to skip during write */
151  int m_excluded_count; /* size of exclusion array */
152 
153 #ifndef HSTREAM_READONLY
154  Internal_Segment_Processor * m_segment_processor; /* Handler for top segment & revisited segments */
155  Internal_Pending_Tag * m_pending_tags; /* List of items to have tags attached. Tags should come absolutely last (even after user data), so tagging postponed to the end. It is a list to allow for recursion if we ever need it */
156  Internal_Texture_List * m_texture_list; /* Textures being processed */
157  bool m_non_segment_revisits; /* Does the revisit list contain something other than segments? */
158  int m_revisit_offset; /* File offset of start of current revisit object (including compression if appropriate) */
159  BBaseOpcodeHandler * m_thumbnail; /* handler for a thumbnail (if any) to write */
160  int m_local_attributes; /* flag presence of geometry-level attributes (used in GenerateOne) */
161  BBaseOpcodeHandler * m_must_delete; /* pointer to any temporary handler to discard when done */
162  char * m_prepend_root; /* a string to prepend on rooted segments */
163  int m_revisit_state; /* state of progress in revisit loop */
164 
165  bool issorted_revisit(Internal_Revisit_Item **array, int count);
166  void qsort_revisit(Internal_Revisit_Item ** first, Internal_Revisit_Item ** last) { qsort_revisit (first, last, 0); }
167  void qsort_revisit(Internal_Revisit_Item **, Internal_Revisit_Item **, int);
168  TK_Status sort_revisit();
169 
170  TK_Status find_textures();
171 
172 
173  enum Revisit {
174  Nothing,
175  Working,
176  Force
177  };
178 #endif
179 
180  public:
185 
186  ~HStreamFileToolkit ();
187  // clean out current state
188 
194  void Restart ();
195 
196  // normal processing functions
197 
216  TK_Status GenerateBuffer (char * b, int s, int & f, char const * start_segment = 0);
217 
218 
232  TK_Status GenerateOneItemBuffer (char * b, int s, int & f, HC_KEY item);
233 
234 
244  unsigned POINTER_SIZED_INT CountObjects (char const * start_segment = 0);
245 
246 
247  void ActivateContext (ID_Key key);
248  void DeactivateContext (ID_Key key);
249  void NewFileContext (ID_Key key);
250 
251 
258  int GetHoopsVersion() { if (m_hoops_version == 0) validate_hoops_version(); return m_hoops_version; }
259 
266  TK_Status StringToHandler (char const *type, BBaseOpcodeHandler **handler);
267 
274  TK_Status StringToOpcode (char const *type, unsigned char *opcode_out);
275 
276 
284  void SetThumbnail (BBaseOpcodeHandler * handler);
285 
296  void SetThumbnail (int format, int width, int height, unsigned char const * data);
297 
302  TK_Status Write_Stream_File ();
303 
309  void AddExcludedSegments (int count, HC_KEY const * keys);
314  void AddExcludedSegment (HC_KEY key) { AddExcludedSegments (1, &key); }
320  bool SegmentIsExcluded (HC_KEY key) const;
324  void ClearExcludedSegments ();
329  int GetExcludedSegmentCount () const { return m_excluded_count; }
334  HC_KEY const * GetExcludedSegments () const { return m_excluded_segments; }
335 
340  void SetPrependRootSegment(const char * segment);
345  const char * GetPrependRootSegment() { return m_prepend_root; }
346 
347 
351  bool MatchPreviousExRef () const;
352 
353  char const **m_search_strings;
354 
355  protected:
357  void validate_hoops_version();
359  void add_unnamed_segment (HC_KEY key);
361  void read_completed ();
363  void empty_lists ();
365  TK_Status tag (int variant);
367  unsigned HLONG count_segment_objects (HC_KEY key, char const * start_segment = 0);
368 
369 };
370 
371 
372 #endif //HBINFILETK_TOOLKIT
virtual void NewFileContext(ID_Key key)
Definition: BStreamFileToolkit.h:598
The HStreamFileToolkit class provides support for exporting/importing HOOPS Stream File information f...
Definition: HStreamFileToolkit.h:138
virtual void Reset()
The BStreamFileToolkit class provides support for importing/exporting HOOPS Stream File information...
Definition: BStreamFileToolkit.h:367
int GetExcludedSegmentCount() const
Definition: HStreamFileToolkit.h:329
#define HC_KEY
virtual void Restart()
Provides HOOPS/3dGS-specific handling of the TKE_Image opcode.
Definition: HOpcodeHandler.h:1291
const char * GetPrependRootSegment()
Definition: HStreamFileToolkit.h:345
virtual TK_Status Read(BStreamFileToolkit &tk)=0
Provides HOOPS/3dGS-specific handling of the TKE_Named_Style_Defs.
Definition: HOpcodeHandler.h:1409
virtual TK_Status Interpret(BStreamFileToolkit &tk, ID_Key key, int variant=0)
Provides HOOPS/3dGS-specific handling of the TKE_Reopen_Segment opcodes.
Definition: HOpcodeHandler.h:82
HC_KEY m_key
segment key
Definition: HOpcodeHandler.h:1411
int GetHoopsVersion()
Definition: HStreamFileToolkit.h:258
The BBaseOpcodeHandler abstract class is used as a base for derived classes which manage logical piec...
Definition: BOpcodeHandler.h:53
TK_Status
Codes which can be either passed to various toolkit functions, or indicate the result of a toolkit fu...
Definition: BStream.h:242
#define ID_Key
Definition: BStream.h:218
char * m_name
Definition: BOpcodeHandler.h:7875
Provides HOOPS/3dGS-specific handling of the TKE_Open_Segment opcode.
Definition: HOpcodeHandler.h:31
virtual TK_Status Clone(BStreamFileToolkit &tk, BBaseOpcodeHandler **handler) const
Definition: BOpcodeHandler.h:205
virtual void DeactivateContext(ID_Key key)
Definition: BStreamFileToolkit.h:589
HC_KEY const * GetExcludedSegments() const
Definition: HStreamFileToolkit.h:334
Provides HOOPS/3dGS-specific handling of the TKE_Texture.
Definition: HOpcodeHandler.h:1317
void AddExcludedSegment(HC_KEY key)
Definition: HStreamFileToolkit.h:314
virtual TK_Status Write(BStreamFileToolkit &tk)=0
Provides HOOPS/3dGS-specific handling of the TKE_Reference opcode.
Definition: HOpcodeHandler.h:118
virtual bool MatchPreviousExRef() const
Definition: BStreamFileToolkit.h:1178
virtual void ActivateContext(ID_Key key)
Definition: BStreamFileToolkit.h:582