The HStreamFileToolkit class provides support for exporting/importing HOOPS Stream File information from/to a HOOPS/3dGS scene-graph. More...

#include <HStreamFileToolkit.h>

Public Types

enum  DoubleAdded { ATTRIBUTES = 0x01, GEOMETRY = 0x02 }
 
enum  DoubleMode {
  AUTOMATIC, RETAIN_AS_IS, FLOAT_IF_SAFE, FORCE_FLOAT,
  FORCE_DOUBLE
}
 

Public Member Functions

void ActivateContext (ID_Key key)
 
void AddDoubleType (int type)
 internal use
 
void AddExcludedSegment (HC_KEY key)
 
void AddExcludedSegments (int count, HC_KEY const keys[])
 
void ClearExcludedSegments ()
 
unsigned POINTER_SIZED_INT CountObjects (char const *start_segment=0)
 
void DeactivateContext (ID_Key key)
 
TK_Status GenerateBuffer (char *b, int s, int &f, char const *start_segment=0)
 
TK_Status GenerateOneItemBuffer (char *b, int s, int &f, HC_KEY item)
 
int GetAddedDoubleTypes () const
 
int GetAttributePrecisionMode ()
 
int GetExcludedSegmentCount () const
 
HC_KEY const * GetExcludedSegments () const
 
int GetHoopsVersion ()
 
const char * GetPrependRootSegment ()
 
 HStreamFileToolkit ()
 
bool MatchPreviousExRef () const
 
void NewFileContext (ID_Key key)
 
void Restart ()
 
bool SegmentIsExcluded (HC_KEY key) const
 
void SetAttributePrecisionMode (int mode)
 
void SetPrependRootSegment (const char *segment)
 
void SetThumbnail (BBaseOpcodeHandler *handler)
 
void SetThumbnail (int format, int width, int height, unsigned char const *data)
 
TK_Status StringToHandler (char const *type, BBaseOpcodeHandler **handler)
 
TK_Status StringToOpcode (char const *type, unsigned char *opcode_out)
 
TK_Status Write_Stream_File ()
 
- Public Member Functions inherited from BStreamFileToolkit
TK_Status AddBounds (ID_Key key, float const bounds[])
 
bool AddExternalReference (char const *ref, ID_Key context)
 
bool AddExternalReference (__wchar_t const *ref, ID_Key context)
 
TK_Status AddIndexKeyPair (int index, ID_Key key)
 
void AddSegment (ID_Key key)
 
TK_Status AddVariant (ID_Key key, int variant, int value1, int value2=-1)
 
TK_Status AppendLastKey (ID_Key key)
 
 BStreamFileToolkit ()
 
void ClearLastKey ()
 
void ClearPauses ()
 
virtual TK_Status CloseFile ()
 
virtual TK_Status CloseGeometry ()
 
void CloseLogFile ()
 
int CurrentBufferLength ()
 
ID_Key CurrentSegment ()
 
virtual TK_Status Error (char const *msg=0) const
 
int GeneratedSoFar () const
 
bool GeometryIsOpen () const
 
bool GetAsciiMode ()
 
TK_Status GetBounds (ID_Key key, float bounds[]) const
 
int GetBufferLimit () const
 
__wchar_t const * GetCurrentFile () const
 
void GetCurrentFile (__wchar_t const *&filename) const
 
int GetDictionaryFormat () const
 
int GetDictionaryOffset () const
 
int GetDictionaryOptions () const
 
int GetDictionarySize () const
 
wchar_t const * GetExternalReference () const
 
void GetExternalReference (__wchar_t const *&exref) const
 
ID_Key GetExternalReferenceContext () const
 
unsigned int GetFileOffset () const
 Gets the file offset, a displacement to be added to positions used in the dictionary (for example, in case the data is appended to another file)
 
virtual TK_Status GetFileSize (unsigned HLONG &size)
 
int GetFirstPause () const
 
int GetFlags () const
 
int GetJpegQuality () const
 
TK_Status GetLastKey (ID_Key &key) const
 
char const * GetLogFile () const
 
bool GetLogging () const
 
unsigned int GetLoggingOptions (unsigned int mask=~0) const
 
int GetNumColorBits () const
 
int GetNumIndexBits () const
 
int GetNumNormalBits () const
 
int GetNumParameterBits () const
 
int GetNumVertexBits () const
 
TK_Status GetOffset (ID_Key key, int variant, int &offset) const
 
TK_Status GetOffset (ID_Key key, int variant, int &offset, int &length) const
 
TK_Status GetOffset (ID_Key key, int variant, int &offset, int &length, __wchar_t const *&filename) const
 
BBaseOpcodeHandlerGetOpcodeHandler (int which) const
 
int GetPauseCount () const
 
int const * GetPauseTable () const
 
int GetPosition () const
 
TK_Progress_Callback GetProgressCallback () const
 
void * GetProgressValue () const
 
float GetQuantizationError () const
 
int GetReadFlags (int mask=~0) const
 
int GetTabs ()
 
int GetTargetVersion () const
 
int GetVersion () const
 
float const * GetWorldBounding () const
 
int GetWriteFlags (int mask=~0) const
 
bool HeaderCommentSeen () const
 
TK_Status IndexToKey (int index, ID_Key &key) const
 
TK_Status KeyToIndex (ID_Key key, int &index) const
 
virtual TK_Status LocateDictionary ()
 
virtual TK_Status LocateEntity (ID_Key key, int variant)
 
void LogEntry (char const *string) const
 
void LogEntry (__wchar_t const *string) const
 
bool NextExternalReference ()
 
unsigned int NextOpcodeSequence ()
 
int NextTagIndex ()
 
unsigned int ObjectsSoFar () const
 
virtual TK_Status OpenFile (char const *name, bool write=false)
 
virtual TK_Status OpenFile (__wchar_t const *name, bool write=false)
 
virtual TK_Status OpenGeometry ()
 
TK_Status OpenLogFile (char const *filename, char const *mode)
 
virtual TK_Status ParseBuffer (char const *b, int s, TK_Status mode=TK_Normal)
 
int PeekTagIndex () const
 
virtual TK_Status PositionFile (int offset)
 
TK_Status PrepareBuffer (char *b, int s)
 
TK_Status Read_Stream_File ()
 
virtual TK_Status ReadBuffer (char *buffer, int size, int &amount_read)
 
void RecordPause (int offset)
 
ID_Key RemoveSegment ()
 
void ReportQuantizationError (float error)
 
void ReportQuantizationError (int bits_per_sample, float const *bounding, int num_dimensions=3)
 
void ResetQuantizationError ()
 
ID_Key RevisitKey () const
 
ID_Key RevisitOwner () const
 
TK_Status SelectFile (char const *name)
 
TK_Status SelectFile (__wchar_t const *name)
 
TK_Status SetAsciiMode (bool whether)
 
void SetBufferLimit (int limit)
 
void SetDictionaryFormat (int format=3, int options=TK_Dictionary_Bounding_Volumes)
 
void SetDictionaryOffset (int offset)
 
void SetDictionarySize (int size)
 
void SetFilename (char const *name)
 
void SetFilename (__wchar_t const *name)
 
void SetFileOffset (unsigned int offset)
 Sets the file offset, a displacement to be added to positions used in the dictionary (for example, in case the data is appended to another file)
 
void SetFirstPause (int offset)
 
void SetFlags (int flags)
 
void SetJpegQuality (int quality=75)
 
void SetLastKey (ID_Key key)
 
void SetLogFile (char const *filename=0)
 
void SetLogging (bool setting)
 
void SetLoggingOptions (unsigned int options=~0)
 
void SetNewFile (char const *name)
 
void SetNewFile (__wchar_t const *name)
 
void SetNumColorBits (int numbits)
 
void SetNumIndexBits (int numbits)
 
void SetNumNormalBits (int numbits)
 
void SetNumParameterBits (int numbits)
 
void SetNumVertexBits (int numbits)
 
void SetOpcodeHandler (int which, BBaseOpcodeHandler *handler)
 
void SetOpcodeSequence (unsigned int seq=0)
 
void SetPostwalkHandler (BBaseOpcodeHandler *handler)
 
void SetPrewalkHandler (BBaseOpcodeHandler *handler)
 
void SetProgressCallback (TK_Progress_Callback cb=0)
 
void SetProgressValue (void *value)
 
void SetReadFlags (int flags)
 
void SetReadVersion (int version)
 
void SetTabs (int)
 
void SetTargetVersion (int version)
 
void SetWorldBounding (float const bbox[])
 
void SetWorldBoundingBySphere (float const pt[], float radius)
 
void SetWriteFlags (int flags)
 
int Unused () const
 
virtual TK_Status WriteBuffer (char *buffer, int size)
 
- Public Member Functions inherited from BControlledMemoryObject
void operator delete (void *p)
 force deallocation to happen in the stream toolkit's scope
 
void * operator new (size_t size)
 force allocation to happen in the stream toolkit's scope
 

Public Attributes

char const ** m_search_strings
 

Protected Member Functions

void add_unnamed_segment (HC_KEY key)
 internal use
 
unsigned HLONG count_segment_objects (HC_KEY key, char const *start_segment=0)
 internal use
 
void empty_lists ()
 internal use
 
virtual void FileDone ()
 
void read_completed ()
 internal use
 
TK_Status tag (int variant)
 internal use
 
void validate_hoops_version ()
 internal use
 

Friends

class HTK_Delete_Object
 
class HTK_Image
 
class HTK_Named_Style_Def
 
class HTK_Open_Segment
 
class HTK_Reference
 
class HTK_Referenced_Segment
 
class HTK_Texture
 
class Internal_Segment_Processor
 

Additional Inherited Members

- Static Public Member Functions inherited from BStreamFileToolkit
static int ParseVersion (char const *block)
 
static bool SupportsAsciiMode ()
 
- Protected Attributes inherited from BStreamFileToolkit
void * m_file
 

Detailed Description

The HStreamFileToolkit class provides support for exporting/importing HOOPS Stream File information from/to a HOOPS/3dGS scene-graph.

The HSF file reading process involves reading the opcode at the start of each piece of binary information, and calling the Read method of the associated opcode handler. After the opcode handler reports that reading is complete, the Execute method should be called. The ParseBuffer method of the BStreamFileToolkit object encapsulates this process.

The HSF file writing process involves determining the proper opcode for each piece of binary information, and calling the Interpret method of the associated opcode handler. After interpretation is complete,
the Write method of the opcode handler should be called until writing is complete.
The GenerateBuffer method of the HStreamFileToolkit encapsualetes this process.

This class provides a HOOPS/3dGS-specific implementation of the BStreamFileToolkit object. It has HOOPS/3dGS-specific opcode handlers registered with it (of the naming convention HTK_XXX). These opcode handlers overload the following two methods of the base opcode handler:

  • Interpret : this method will query the HOOPS/3dGS scene-graph (meaning, extract the graphics data); the data will then be written out to an HSF via the Write method
  • Execute : this method will map the HSF data to custom data structures after it has been read in from the HSF file via the Read method

Member Enumeration Documentation

◆ DoubleMode

Enumerator
AUTOMATIC 

handling choice is left to the importer

RETAIN_AS_IS 

data is kept in the format from the file

FLOAT_IF_SAFE 

data is converted to float if it appears safe, otherwise it is retained as double

FORCE_FLOAT 

data is forced to single-precision

FORCE_DOUBLE 

data is forced to double-precision

Constructor & Destructor Documentation

◆ HStreamFileToolkit()

HStreamFileToolkit::HStreamFileToolkit ( )

Default constructor for an HStreamFileToolkit object

Member Function Documentation

◆ ActivateContext()

void HStreamFileToolkit::ActivateContext ( ID_Key  key)
virtual

While parsing a buffer it may be necessary to keep a context. This method will be called by ParseBuffer to activate a context, and should be overloaded to provide custom context-activation.

Parameters
keyA context identifier

Reimplemented from BStreamFileToolkit.

◆ AddExcludedSegment()

void HStreamFileToolkit::AddExcludedSegment ( HC_KEY  key)
inline

Adds one key to the list of segments to skip during write

Parameters
keythe key of one segment

◆ AddExcludedSegments()

void HStreamFileToolkit::AddExcludedSegments ( int  count,
HC_KEY const  keys[] 
)

Adds to the list of keys indicating segments to skip during write

Parameters
countthe number of keys in the array
keysthe array of keys of segments

◆ ClearExcludedSegments()

void HStreamFileToolkit::ClearExcludedSegments ( )

Clears the list of excluded segments;

◆ CountObjects()

unsigned POINTER_SIZED_INT HStreamFileToolkit::CountObjects ( char const *  start_segment = 0)

Traverses the HOOPS database beginning at the currently open segment and estimates the number of objects that will be written by a matching call (or series of calls) to GenerateBuffer()

A HOOPS/3dGS segment must currently be open before calling CountObjects, or a segment must be specified.

Parameters
start_segmentExplicit name of a Hoops segment to process (current segment if null).
Returns
The result of the function call.

◆ DeactivateContext()

void HStreamFileToolkit::DeactivateContext ( ID_Key  key)
virtual

While parsing a buffer it may be necessary to keep a context. This method will be called by ParseBuffer to deactivate a context, and should be overloaded to provide custom context-deactivation.

Parameters
keyA context identifier

Reimplemented from BStreamFileToolkit.

◆ GenerateBuffer()

TK_Status HStreamFileToolkit::GenerateBuffer ( char *  b,
int  s,
int &  f,
char const *  start_segment = 0 
)

Traverses the HOOPS database beginning at the currently open segment and calls the Interpret method of the opcode handler associated with each object encountered. The Interpret methods of the default object handlers query the HOOPS database to obtain segment, geometry and attribute information. After interpretation is complete, GenerateBuffer continually calls the Write method of the opcode handler until writing is complete. The Write methods of the default handlers convert the HOOPS database information into a specific binary format.

A HOOPS segment must currently be open before calling GenerateBuffer, or a segment name must be given.

If the buffer being generated ends in the middle of an object, it will be saved along with any HOOPS database state information and the next buffer will be appended to it.

Parameters
bA character pointer. Returned to user.
sAn integer denoting the length of the buffer in bytes.
fAn integer denoting the length of the buffer that was written back, in bytes.
start_segmentExplicit name of a hoops segment to process (currently open segment if null)
Returns
The result of the function call.

◆ GenerateOneItemBuffer()

TK_Status HStreamFileToolkit::GenerateOneItemBuffer ( char *  b,
int  s,
int &  f,
HC_KEY  item 
)

This method is similar to GenerateBuffer. However, instead of traversing the HOOPS database beginning at the currently open segment, only the item specified will be processed.
If the buffer being generated ends in the middle of an object, it will be saved along with any HOOPS database state information and the next buffer will be appended to it.

Parameters
bA character pointer. Returned to user.
sAn integer denoting the length of the buffer in bytes.
fAn integer denoting the length of the buffer that was written back, in bytes.
itemKey of the single segment or piece of geometry to process.
Returns
The result of the function call.

◆ GetAddedDoubleTypes()

int HStreamFileToolkit::GetAddedDoubleTypes ( ) const
inline

Sets the manner in which double-precision geometries are handled

Parameters
modehandling mode



Returns the chosen the manner in which double-precision geometries are handled

Returns
double-precision handling mode

Indicates whether double-precision data was added to the database

Returns
bitmask of types which were added as double-precision

◆ GetAttributePrecisionMode()

int HStreamFileToolkit::GetAttributePrecisionMode ( )
inline

Returns the chosen the manner in which double-precision attributes (primarily modelling matrices) are handled

Returns
double-precision handling mode

◆ GetExcludedSegmentCount()

int HStreamFileToolkit::GetExcludedSegmentCount ( ) const
inline

Gets the current number of keys of excluded segments

Returns
number of keys

◆ GetExcludedSegments()

HC_KEY const* HStreamFileToolkit::GetExcludedSegments ( ) const
inline

Gets the array of keys of excluded segments

Returns
the array of keys of excluded segments

◆ GetHoopsVersion()

int HStreamFileToolkit::GetHoopsVersion ( )
inline

Determines the version of HOOPS/3dGS the toolkit is using. Some features may not be present on older versions or may be handled differently or can be emulated; querying the version allows opcode handlers to adjust their behaviour accordingly.

Returns
The version times 100, for instance, version 7.15 would be returned as 715.

◆ GetPrependRootSegment()

const char* HStreamFileToolkit::GetPrependRootSegment ( )
inline

Gets the segment to prepend to rooted segments well reading

Parameters
segmentname of segment

◆ MatchPreviousExRef()

bool HStreamFileToolkit::MatchPreviousExRef ( ) const
virtual

See if we can match a previous ExRef and just include the segment it generated

Returns
true if the function matched and handled the reference, false if we need to try to read the reference

Reimplemented from BStreamFileToolkit.

◆ NewFileContext()

void HStreamFileToolkit::NewFileContext ( ID_Key  key)
virtual

While processing External_References a previously visited context will be revisited. This method will be called by the default Read_Stream_File to indicate that context should be prepared to receive content, and should be overloaded to provide custom preparation. This might include operations such as clearing out any placeholder geometry.

Parameters
keyA context identifier

Reimplemented from BStreamFileToolkit.

◆ Restart()

void HStreamFileToolkit::Restart ( )
virtual

Initializes the file toolkit. This is useful if a single toolkit object is to be used for dealing with different files, rather than deleting the current toolkit object and creating a new instance. Call this function after processing of the current file is complete.

Reimplemented from BStreamFileToolkit.

◆ SegmentIsExcluded()

bool HStreamFileToolkit::SegmentIsExcluded ( HC_KEY  key) const

Determines if a particular segment key is on the exclusion list

Parameters
keykey of the segment to be checked
Returns
true if the segment is to be excluded

◆ SetAttributePrecisionMode()

void HStreamFileToolkit::SetAttributePrecisionMode ( int  mode)
inline

Sets the manner in which double-precision attributes (primarily modelling matrices) are handled

Parameters
modehandling mode

◆ SetPrependRootSegment()

void HStreamFileToolkit::SetPrependRootSegment ( const char *  segment)

Sets a segment to prepend to rooted segments well reading

Parameters
segmentname of segment

◆ SetThumbnail() [1/2]

void HStreamFileToolkit::SetThumbnail ( BBaseOpcodeHandler handler)

Registers an opcode handler which will be called by the toolkit after the header and before it gets into other processing (and possibly compressing data). This allows the user to include a simple thumbnail image which an application might load as a preview for things like file selection.

Parameters
handlerA pointer to an BBaseOpcodeHandler object.

◆ SetThumbnail() [2/2]

void HStreamFileToolkit::SetThumbnail ( int  format,
int  width,
int  height,
unsigned char const *  data 
)

Generates an opcode handler preset with the provided image data which will be called by the toolkit after the header and before it gets into other processing (and possibly compressing data). This allows the user to include a simple thumbnail image which an application might load as a preview for things like file selection.

Parameters
formatformat of the thumbnail. Formats are specified in TKO_Thumbnail_Formats
widthwidth of the thumbnail image
heightheight of the thumbnail image
dataarray of thumbnail image data

◆ StringToHandler()

TK_Status HStreamFileToolkit::StringToHandler ( char const *  type,
BBaseOpcodeHandler **  handler 
)

Generates clones of OpcodeHandlers to interpret geometry lists, such as those found in LODs intended primarily (but not exclusively) for internal use.

Parameters
typethe string returned from HOOPS' Find_Contents.
handlerthe opcode handler (returned to user)
Returns
TK_Error on failure.

◆ StringToOpcode()

TK_Status HStreamFileToolkit::StringToOpcode ( char const *  type,
unsigned char *  opcode_out 
)

maps HOOPS strings to the opcodes that handle them. intended primarily (but not exclusively) for internal use.

Parameters
typethe string returned from HOOPS' Find_Contents.
opcode_outthe opcode (returned to user), assigned to one of the TKE_Object_Types as defined in BOpcodeEnums.h
Returns
TK_Error on failure.

◆ Write_Stream_File()

TK_Status HStreamFileToolkit::Write_Stream_File ( )

Writes the file associated with the toolkit (internal utility).

Returns
The result of the function call.

The documentation for this class was generated from the following file: