Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

HStreamFileToolkit.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 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  friend class HTK_Delete_Object;
147  private:
148  int m_hoops_version; /* Version of Hoops we are using */
149  Internal_Segment_List * m_unnamed_segments; /* Segments which need to be renamed to unnamed when able */
150 
151  HC_KEY * m_excluded_segments; /* keys of segments (if any) to skip during write */
152  int m_excluded_count; /* size of exclusion array */
153 
154 #ifndef HSTREAM_READONLY
155  Internal_Segment_Processor * m_segment_processor; /* Handler for top segment & revisited segments */
156  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 */
157  Internal_Texture_List * m_texture_list; /* Textures being processed */
158  bool m_non_segment_revisits; /* Does the revisit list contain something other than segments? */
159  int m_revisit_offset; /* File offset of start of current revisit object (including compression if appropriate) */
160  BBaseOpcodeHandler * m_thumbnail; /* handler for a thumbnail (if any) to write */
161  int m_local_attributes; /* flag presence of geometry-level attributes (used in GenerateOne) */
162  BBaseOpcodeHandler * m_must_delete; /* pointer to any temporary handler to discard when done */
163  char * m_prepend_root; /* a string to prepend on rooted segments */
164  int m_revisit_state; /* state of progress in revisit loop */
165 
166  int m_attribute_precision_mode;
167  int m_geometry_precision_mode;
168  int m_double_added;
169 
170  void * m_deferred_styles_ptr;
171  void cleanup_deferred_styles();
172  void apply_deferred_styles();
173 
174  bool issorted_revisit(Internal_Revisit_Item *array[], int count);
175  void qsort_revisit(Internal_Revisit_Item ** first, Internal_Revisit_Item ** last) { qsort_revisit (first, last, 0); }
176  void qsort_revisit(Internal_Revisit_Item **, Internal_Revisit_Item **, int);
177  TK_Status sort_revisit();
178 
179  TK_Status find_textures();
180 
181 
182  enum Revisit {
183  Nothing,
184  Working,
185  Force
186  };
187 #endif
188 
189  public:
194 
195  ~HStreamFileToolkit ();
196  // clean out current state
197 
203  void Restart ();
204 
205  // normal processing functions
206 
225  TK_Status GenerateBuffer (char * b, int s, int & f, char const * start_segment = 0);
226 
227 
241  TK_Status GenerateOneItemBuffer (char * b, int s, int & f, HC_KEY item);
242 
243 
253  unsigned POINTER_SIZED_INT CountObjects (char const * start_segment = 0);
254 
255 
256  void ActivateContext (ID_Key key);
257  void DeactivateContext (ID_Key key);
258  void NewFileContext (ID_Key key);
259 
260 
267  int GetHoopsVersion() { if (m_hoops_version == 0) validate_hoops_version(); return m_hoops_version; }
268 
275  TK_Status StringToHandler (char const *type, BBaseOpcodeHandler **handler);
276 
283  TK_Status StringToOpcode (char const *type, unsigned char *opcode_out);
284 
285 
293  void SetThumbnail (BBaseOpcodeHandler * handler);
294 
305  void SetThumbnail (int format, int width, int height, unsigned char const * data);
306 
311  TK_Status Write_Stream_File ();
312 
318  void AddExcludedSegments (int count, HC_KEY const keys[]);
323  void AddExcludedSegment (HC_KEY key) { AddExcludedSegments (1, &key); }
329  bool SegmentIsExcluded (HC_KEY key) const;
333  void ClearExcludedSegments ();
338  int GetExcludedSegmentCount () const { return m_excluded_count; }
343  HC_KEY const * GetExcludedSegments () const { return m_excluded_segments; }
344 
349  void SetPrependRootSegment(const char * segment);
354  const char * GetPrependRootSegment() { return m_prepend_root; }
355 
356 
360  bool MatchPreviousExRef () const;
361 
362  char const **m_search_strings;
363 
364 
365  enum DoubleMode {
370  FORCE_DOUBLE
371  };
372 
373  enum DoubleAdded {
374  ATTRIBUTES = 0x01,
375  GEOMETRY = 0x02
376  };
377 
378 
383  void SetAttributePrecisionMode(int mode) { m_attribute_precision_mode = mode; }
388  int GetAttributePrecisionMode() { return m_attribute_precision_mode; }
389  // /*!
390  // Sets the manner in which double-precision geometries are handled
391  // \param mode handling mode
392  // */
393  // void SetGeometryPrecisionMode(int mode) { m_geometry_precision_mode = mode; }
394  // /*!
395  // Returns the chosen the manner in which double-precision geometries are handled
396  // \return double-precision handling mode
397  // */
398  // int GetGeometryPrecisionMode() { return m_geometry_precision_mode; }
399 
403  int GetAddedDoubleTypes() const { return m_double_added; }
404 
405 
406 
408  void AddDoubleType(int type) { m_double_added |= type; }
409 
410 
411  protected:
413  void validate_hoops_version();
415  void add_unnamed_segment (HC_KEY key);
417  void read_completed ();
419  void empty_lists ();
421  TK_Status tag (int variant);
423  unsigned HLONG count_segment_objects (HC_KEY key, char const * start_segment = 0);
424 
425  virtual void FileDone() {
426  apply_deferred_styles();
427  }
428 
429 };
430 
431 
432 #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
Provides HOOPS/3dGS-specific handling of the TKE_Delete_Object opcode.
Definition: HOpcodeHandler.h:187
virtual void Reset()
The BStreamFileToolkit class provides support for importing/exporting HOOPS Stream File information...
Definition: BStreamFileToolkit.h:367
data is kept in the format from the file
Definition: HStreamFileToolkit.h:367
int GetExcludedSegmentCount() const
Definition: HStreamFileToolkit.h:338
virtual void Restart()
Provides HOOPS/3dGS-specific handling of the TKE_Image opcode.
Definition: HOpcodeHandler.h:1335
const char * GetPrependRootSegment()
Definition: HStreamFileToolkit.h:354
virtual TK_Status Read(BStreamFileToolkit &tk)=0
#define HC_KEY
Provides HOOPS/3dGS-specific handling of the TKE_Named_Style_Defs.
Definition: HOpcodeHandler.h:1493
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:104
int GetAddedDoubleTypes() const
Definition: HStreamFileToolkit.h:403
HC_KEY m_key
segment key
Definition: HOpcodeHandler.h:1495
int GetHoopsVersion()
Definition: HStreamFileToolkit.h:267
data is forced to single-precision
Definition: HStreamFileToolkit.h:369
handling choice is left to the importer
Definition: HStreamFileToolkit.h:366
void SetAttributePrecisionMode(int mode)
Definition: HStreamFileToolkit.h:383
The BBaseOpcodeHandler abstract class is used as a base for derived classes which manage logical piec...
Definition: BOpcodeHandler.h:55
TK_Status
Codes which can be either passed to various toolkit functions, or indicate the result of a toolkit fu...
Definition: BStream.h:272
#define ID_Key
Definition: BStream.h:248
data is converted to float if it appears safe, otherwise it is retained as double ...
Definition: HStreamFileToolkit.h:368
int GetAttributePrecisionMode()
Definition: HStreamFileToolkit.h:388
char * m_name
Definition: BOpcodeHandler.h:6816
Provides HOOPS/3dGS-specific handling of the TKE_Open_Segment opcode.
Definition: HOpcodeHandler.h:53
virtual TK_Status Clone(BStreamFileToolkit &tk, BBaseOpcodeHandler **handler) const
Definition: BOpcodeHandler.h:217
virtual void DeactivateContext(ID_Key key)
Definition: BStreamFileToolkit.h:589
HC_KEY const * GetExcludedSegments() const
Definition: HStreamFileToolkit.h:343
Provides HOOPS/3dGS-specific handling of the TKE_Texture.
Definition: HOpcodeHandler.h:1361
void AddExcludedSegment(HC_KEY key)
Definition: HStreamFileToolkit.h:323
virtual TK_Status Write(BStreamFileToolkit &tk)=0
DoubleMode
Definition: HStreamFileToolkit.h:365
void AddDoubleType(int type)
internal use
Definition: HStreamFileToolkit.h:408
Provides HOOPS/3dGS-specific handling of the TKE_Reference opcode.
Definition: HOpcodeHandler.h:140
virtual bool MatchPreviousExRef() const
Definition: BStreamFileToolkit.h:1205
virtual void ActivateContext(ID_Key key)
Definition: BStreamFileToolkit.h:582