Alphabetical Class Index   Class Hierarchy   Compound Members   File Members   File List  

HStreamFileToolkit.h
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: ca2174b9b8556a842db9943940a65ffa4c833a18 $
13 //
14 
15 #ifndef HBINFILETK_TOOLKIT
16 #define HBINFILETK_TOOLKIT
17 
18 
19 #ifndef HSTREAM_READONLY
20 
21 #ifndef DOXYGEN_SHOULD_SKIP_THIS
22 
23 class Internal_Key_Array {
24  friend class HStreamFileToolkit;
25  friend class Internal_Pending_Tag;
26  friend class Internal_Segment_Processor;
27  private:
28  Internal_Key_Array() { m_data = 0; }
29  ~Internal_Key_Array() { delete [] m_data; }
30 
31  int m_count;
32  HC_KEY *m_data;
33 };
34 
35 class Internal_Pending_Tag {
36  friend class HStreamFileToolkit;
37  friend class Internal_Segment_Processor;
38  friend class HTK_Referenced_Segment;
39  friend class HTK_Reference;
40  friend class HTK_Texture;
41  friend class HTK_Named_Style_Def;
42  private:
43  Internal_Pending_Tag() { m_next = 0; m_array = 0; }
44  ~Internal_Pending_Tag() { delete m_array; }
45 
46  Internal_Pending_Tag * m_next;
47  HC_KEY m_key; //m_key set to tk.m_last_keys[0], just for the purposes of matching tag requests
48  int m_variant;
49  Internal_Key_Array * m_array; //set to null unless we are associating multiple keys with a single tag call.
50 };
51 
52 
53 class Internal_Texture_List {
54  friend class HStreamFileToolkit;
55  friend class HTK_Image;
56  private:
57  Internal_Texture_List * m_next;
58  char * m_name;
59  char * m_image;
60  HC_KEY m_image_key;
61  bool m_do_write_image;
62 
63  public:
64  Internal_Texture_List (char const * name, char const * image, HC_KEY key = -1);
65  ~Internal_Texture_List();
66 };
67 
68 
70 class HBINFILETK_API HStreamFileToolkit; //forward declaration
71 
72 // special output-only pseudo-object
73 class HBINFILETK_API2 Internal_Segment_Processor : public BBaseOpcodeHandler {
74  protected:
75  char * m_name;
76  HC_KEY m_key;
77  bool m_top_level;
78  HC_KEY m_root;
79  BBaseOpcodeHandler * m_current_object;
80  BBaseOpcodeHandler * m_must_delete;
81  HC_KEY m_item_key;
82  int m_saved_count;
83  HC_KEY * m_saved_keys;
84  HC_KEY m_renumbered;
85  unsigned char m_renumbered_scope;
86  long m_priority;
87  int m_start_offset;
88  bool m_searching;
89  bool m_use_polypolylines;
90  bool m_polylines_already_handled;
91  bool m_geometry_attributes;
92  bool m_geometry_open;
93  BBaseOpcodeHandler * m_deferred;
94  int m_search_pass;
96  void save_keys (HStreamFileToolkit & tk) alter;
97  void restore_keys (HStreamFileToolkit & tk) alter;
98 
99  public:
100  Internal_Segment_Processor (ID_Key key = -1, char const * name = 0);
101  ~Internal_Segment_Processor ();
102 
105  TK_Status Interpret (BStreamFileToolkit & tk, ID_Key key, int variant = 0) alter;
106  TK_Status Interpret (BStreamFileToolkit & tk, ID_Key key, char const * special) alter;
107  void Reset () alter;
108  TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **) const;
109 
110  void SetRoot (HC_KEY root) alter { m_root = root; }
111  HC_KEY GetRoot () const { return m_root; }
112 };
113 
114 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
115 
116 #endif //HSTREAM_READONLY
117 
118 
119 
120 
121 
123 
141 class HBINFILETK_API2 HStreamFileToolkit : public BStreamFileToolkit {
142  friend class Internal_Segment_Processor;
143  friend class HTK_Open_Segment;
144  friend class HTK_Referenced_Segment;
145  friend class HTK_Reference;
146  friend class HTK_Texture;
147  friend class HTK_Image;
148  friend class HTK_Named_Style_Def;
149  private:
150  int m_hoops_version; /* Version of Hoops we are using */
151  Internal_Segment_List * m_unnamed_segments; /* Segments which need to be renamed to unnamed when able */
152 
153  HC_KEY * m_excluded_segments; /* keys of segments (if any) to skip during write */
154  int m_excluded_count; /* size of exclusion array */
155 #ifndef HSTREAM_READONLY
156  Internal_Segment_Processor * m_segment_processor; /* Handler for top segment & revisited segments */
157  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 */
158  Internal_Texture_List * m_texture_list; /* Textures being processed */
159  bool m_non_segment_revisits; /* Does the revisit list contain something other than segments? */
160  int m_revisit_offset; /* File offset of start of current revisit object (including compression if appropriate) */
161  BBaseOpcodeHandler * m_thumbnail; /* handler for a thumbnail (if any) to write */
162  int m_local_attributes; /* flag presence of geometry-level attributes (used in GenerateOne) */
163  BBaseOpcodeHandler * m_must_delete; /* pointer to any temporary handler to discard when done */
164  char * m_prepend_root; /* a string to prepend on rooted segments */
165  int m_revisit_state; /* state of progress in revisit loop */
166 
167  bool issorted_revisit(Internal_Revisit_Item **array, int count);
168  void qsort_revisit(Internal_Revisit_Item ** first, Internal_Revisit_Item ** last) { qsort_revisit (first, last, 0); }
169  void qsort_revisit(Internal_Revisit_Item **, Internal_Revisit_Item **, int);
170  TK_Status sort_revisit();
171 
172  TK_Status find_textures();
173 
174 
175  enum Revisit {
176  Nothing,
177  Working,
178  Force
179  };
180 #endif
181 
182  public:
187 
188  ~HStreamFileToolkit ();
189  // clean out current state
190 
196  void Restart () alter;
197 
198  // normal processing functions
199 
218  TK_Status GenerateBuffer (char * b, int s, int alter & f, char const * start_segment = 0) alter;
219 
220 
234  TK_Status GenerateOneItemBuffer (char * b, int s, int alter & f, HC_KEY item) alter;
235 
236 
246  unsigned POINTER_SIZED_INT CountObjects (char const * start_segment = 0) alter;
247 
248 
249  void ActivateContext (ID_Key key);
250  void DeactivateContext (ID_Key key);
251  void NewFileContext (ID_Key key);
252 
253 
260  int GetHoopsVersion() { if (m_hoops_version == 0) validate_hoops_version(); return m_hoops_version; }
261 
268  TK_Status StringToHandler (char const *type, BBaseOpcodeHandler **handler);
269 
276  TK_Status StringToOpcode (char const *type, unsigned char *opcode_out);
277 
278 
286  void SetThumbnail (BBaseOpcodeHandler * handler) alter;
287 
298  void SetThumbnail (int format, int width, int height, unsigned char const * data) alter;
299 
304  TK_Status Write_Stream_File ();
305 
311  void AddExcludedSegments (int count, HC_KEY const * keys) alter;
316  void AddExcludedSegment (HC_KEY key) alter { AddExcludedSegments (1, &key); }
322  bool SegmentIsExcluded (HC_KEY key) const;
326  void ClearExcludedSegments () alter;
331  int GetExcludedSegmentCount () const { return m_excluded_count; }
336  HC_KEY const * GetExcludedSegments () const { return m_excluded_segments; }
337 
342  void SetPrependRootSegment(const char * segment);
347  const char * GetPrependRootSegment() { return m_prepend_root; }
348 
349 
353  bool MatchPreviousExRef () const;
354 
355  protected:
357  void validate_hoops_version();
359  void add_unnamed_segment (HC_KEY key) alter;
361  void read_completed () alter;
363  void empty_lists () alter;
365  TK_Status tag (int variant) alter;
367  unsigned HLONG count_segment_objects (HC_KEY key, char const * start_segment = 0) alter;
368 };
369 
370 
371 #endif //HBINFILETK_TOOLKIT
void AddExcludedSegment(HC_KEY key) alter
Definition: HStreamFileToolkit.h:316
virtual void NewFileContext(ID_Key key)
Definition: BStreamFileToolkit.h:553
The HStreamFileToolkit class provides support for exporting/importing HOOPS Stream File information f...
Definition: HStreamFileToolkit.h:141
#define alter
complementary to const, indicates we thought about it instead of a forgotten "const" ...
Definition: BStream.h:225
The BStreamFileToolkit class provides support for importing/exporting HOOPS Stream File information...
Definition: BStreamFileToolkit.h:328
#define HC_KEY
Provides HOOPS/3dGS-specific handling of the TKE_Image opcode.
Definition: HOpcodeHandler.h:1296
const char * GetPrependRootSegment()
Definition: HStreamFileToolkit.h:347
Provides HOOPS/3dGS-specific handling of the TKE_Named_Style_Defs.
Definition: HOpcodeHandler.h:1414
Provides HOOPS/3dGS-specific handling of the TKE_Reopen_Segment opcodes.
Definition: HOpcodeHandler.h:87
virtual TK_Status Interpret(BStreamFileToolkit &tk, ID_Key key, int variant=0) alter
virtual TK_Status Read(BStreamFileToolkit &tk) alter=0
virtual void Restart() alter
HC_KEY m_key
segment key
Definition: HOpcodeHandler.h:1416
int GetHoopsVersion()
Definition: HStreamFileToolkit.h:260
The BBaseOpcodeHandler abstract class is used as a base for derived classes which manage logical piec...
Definition: BOpcodeHandler.h:60
TK_Status
Codes which can be either passed to various toolkit functions, or indicate the result of a toolkit fu...
Definition: BStream.h:237
#define ID_Key
Definition: BStream.h:219
char * m_name
Definition: BOpcodeHandler.h:7323
Provides HOOPS/3dGS-specific handling of the TKE_Open_Segment opcode.
Definition: HOpcodeHandler.h:36
virtual void DeactivateContext(ID_Key key)
Definition: BStreamFileToolkit.h:544
HC_KEY const * GetExcludedSegments() const
Definition: HStreamFileToolkit.h:336
virtual TK_Status Write(BStreamFileToolkit &tk) alter=0
Provides HOOPS/3dGS-specific handling of the TKE_Texture.
Definition: HOpcodeHandler.h:1322
Provides HOOPS/3dGS-specific handling of the TKE_Reference opcode.
Definition: HOpcodeHandler.h:123
virtual bool MatchPreviousExRef() const
Definition: BStreamFileToolkit.h:1133
virtual void ActivateContext(ID_Key key)
Definition: BStreamFileToolkit.h:537