Alphabetical Class Index   Class Hierarchy   Compound Members   File Members   File List  

BStream.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2000 by Tech Soft 3D, LLC.
00003 // The information contained herein is confidential and proprietary to
00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under
00005 // civil and criminal statutes.  Tech Soft 3D shall pursue its civil
00006 // and criminal remedies in the event of unauthorized use or misappropriation
00007 // of its trade secrets.  Use of this information by anyone other than
00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a
00009 // written non-disclosure agreement, expressly prescribing the scope and
00010 // manner of such use.
00011 //
00012 // $Id: 3aaf77e353c5eccb984090f0f03f14f410055bf0 $
00013 //
00014 
00016 
00021 #ifndef BBINFILETKHEADER
00022 #define BBINFILETKHEADER
00023 
00024 #ifndef _MSC_VER
00025 #define __wchar_t wchar_t
00026 #endif
00027 
00028 #ifdef __ia64
00029     #ifndef __HP_aCC
00030         #error C++ compiler required
00031     #endif
00032 #else
00033     #ifndef __cplusplus
00034         #error C++ compiler required
00035     #endif
00036 #endif
00037 
00042 #if defined(_MSC_VER) && !defined(BSTREAM_STATIC_LIB)
00043     #ifdef BBINFILETK_EXPORTS
00044         #define BBINFILETK_API2  __declspec (dllexport)
00045     #else
00046         #define BBINFILETK_API2  __declspec (dllimport)
00047     #endif
00048 #else
00049     #define BBINFILETK_API2
00050 #endif
00051 
00052 
00056 #ifdef TEST_RIG_1
00057     #define BBINFILETK_API
00058 #else
00059     #define BBINFILETK_API BBINFILETK_API2
00060 #endif
00061 
00062 
00066 #define TK_File_Format_Version       1980   // 19.80
00067 
00069 //    but are mentioned in the spec as test points for format changes)
00070 #ifdef CREATE_FILE_FORMAT_HISTORY_TABLE
00071     BBINFILETK_API int TK_File_Format_History[] = {
00072         //  Format   Release     Notes
00073         //------------------------------------------------------------------------------------------
00074         //  1980    //          reformatting includes & styles (conditions and filters)
00075         //  1975    //          double precision
00076         //  1950    //          text font layout
00077             1910,   //          mask transform "offset"
00078             1905,   //          object space clip region
00079             1900,   // 1900
00080         //  1840    //          text region fitting
00081         //  1835    //          png and texture source dimensions
00082         //  1830    //          texture camera
00083         //  1825    //          conditional actions
00084         //  1820    //          separate edge join cutoff
00085         //  1815    //          named styles
00086         //  1810    //          material shaders
00087         //  1805    //          compressed images directly supported in graphics system (jpeg, targa, dxt, luminance8)
00088             1800,   // 1800
00089         //  1790    //          hlr transparency cutoff
00090         //  1785    //          contour and isoline options, diffuse texture tint, diffuse color tint
00091         //  1780    //          new indexed user data
00092         //  1775    //          new text alignment format, explicit patterns
00093         //  1770    //          text character color & horizontal offset, vertex displacement, hlr render text, max extent level
00094         //  1765    //          force defer, vertex decimation, model type
00095         //  1760    //          transparency depth writing
00096         //  1755    //          rgba vertex colors
00097         //  1750    //          hard extent culling
00098             1715,   // 17.1         vertex displacement backport
00099             1710,   //          ignore subsegment locks
00100             1700,   // 1700
00101         //  1660    //          camera relative lights
00102         //  1655    //          reflection visibility
00103         //  1650    //          ambient up vector, separate ambient colors, gooch options, marker index interpolation
00104             1615,   //          anti-alias
00105             1610,   // 1610
00106         //  1605    //          infinite ray, zsort options, geometry options
00107             1600,   // 1600
00108         //  1555    //          fix to some color types
00109         //  1550    //          colors can now have Geo_Extended2, shadow map/simple reflection rendering options
00110         //  1520    //          geometry reference
00111         //  1515    //          shadow map options, selection level, display list levels, simple reflection, infinite line opcode
00112         //  1510    //          maximum extent mode
00113         //  1505    //          screen range, depth images
00114             1500,   // 1500
00115         //  1415    //          obscuration use octree
00116         //  1410    //          simple shadow opacity, anisotropic texture filter
00117         //  1405    //          join cutoff angle, ordered drawing heuristics
00118             1401,   // 1410     internal polyline selection limit
00119             1400,   // 1400
00120         //  1345    //          string format color maps
00121         //  1340    //          rgba image compression
00122         //  1335    //          general displacement
00123         //  1330    //          priority
00124         //  1325    //          text greeking mode, extended text renderer & text preference
00125         //  1320    //          Heuristic_Detail_Selection, nonculled edge visibility
00126         //  1315    //          distance threshold LOD option, new fallback type "bounding none"
00127         //  1310    //          depth peeling
00128         //  1305    //          cutting section, adjacent edge visibility, force grayscale
00129             1300,   // 1300
00130         //  1220    //          font bold/italic/renderer, cut geometry color locks
00131         //  1215    //          circular center
00132         //  1210    //          geometry-level attributes, text character attributes, unicode32, image tint
00133         //  1205    //          obscuration pixel threshold, subpixel culling, hard edge angle
00134             1200,   // 1200
00135         //  1175    //          explicit parameter width, uncompressed parameters
00136         //  1170    //          camera relative lights, simple shadow mode
00137         //  1165    //          extended texture definitions
00138         //  1160    //          glyph definitions & line styles
00139         //  1155    //          spheres, texture downsamping, compressed dictionary, image reference
00140         //  1150    //          conditions, new hlr options (color, weight)
00141             1105,   //          additional polyhedron attributes
00142             1100,   // 1100
00143         //  1002    //          simple shadow options, text region
00144         //  1001    //          camera near_limit, mask transform, image size/scale, new texture options
00145             1000,   // 1000
00146         //   908    //          threshold type in LOD options
00147         //   907    //          polar normals
00148         //   906    //          edgebreaker changes
00149         //   905    //          hlr silhouette cleanup, unicode_options
00150              900,   //  900
00151         //   806    //          bounding box inheritance, cut geometry options, fast hidden line,
00152         //                      hidden line render faces, depth range, gradient window patterns,
00153         //                      additional NURBS surface controls
00154         //   805    //          polycylinder attributes, ExRef, URL
00155              800,   //  800
00156              710,   //  760     new transparency controls, dictionary format 2
00157         //   705,   //          PolyCylinder, Extended Heuristics, XML, LoD collections, Shell Regions
00158         //   702,   //          PolyPolypoint
00159              700,   //  700
00160         //   652,   //          null shell
00161              651,   //  661
00162         //   650,   //          NURBS Surface, Cylinder, Extended Rendering_Options, Defined Fonts, Selectability
00163         //                      extensive polyhedron data & compression changes
00164         //   610,   //          View
00165         //   600,   //          Stream version generally synched to Hoops version
00166         //   601,   //          support longer text string
00167              105,   //  600     Generate_Dictionary changed to Suppress_Dictionary
00168              100,   //  500     Initial release
00169                0    //          [list termination]
00170     };
00171 #else
00172     extern BBINFILETK_API int TK_File_Format_History[];
00173 #endif
00174 
00175 
00176 #define TK_DEFAULT_BUFFER_SIZE     32768    
00177 
00178 
00179 
00180 #ifdef HSTREAM_READONLY
00181     #ifndef BSTREAM_READONLY
00182         #define BSTREAM_READONLY
00183     #endif
00184 #endif
00185 #ifdef BSTREAM_READONLY
00186     extern char const stream_readonly[];
00187 #endif
00188 #ifdef BSTREAM_DISABLE_QUANTIZATION
00189     extern char const stream_disable_quantization[];
00190 #endif
00191 #ifdef BSTREAM_DISABLE_EDGEBREAKER
00192     extern char const stream_disable_edgebreaker[];
00193 #endif
00194 #ifdef BSTREAM_DISABLE_REPULSE_COMPRESSION
00195     extern char const stream_disable_repulse_compression[];
00196 #endif
00197 #ifdef BSTREAM_DISABLE_ASCII
00198     extern char const stream_disable_ascii[];
00199 #endif
00200 
00201 
00202 #include <math.h>
00203 #include <string.h>
00204 #include <stdio.h>
00205 
00206 #ifdef NEED_BOOL_TYPE
00207     #undef NEED_BOOL_TYPE
00208     typedef int bool;
00209 
00210     const bool true = !0;
00211     const bool false = 0;
00212 #endif
00213 
00214 
00219 #if defined(WIN64) || defined(_WIN64)
00220 #   define  ID_Key      __int64
00221 #else
00222 #   define  ID_Key      long
00223 #endif
00224 
00225 
00226 
00227 #ifndef alter
00228 #   define alter   
00229 #endif
00230 
00231 
00232 #ifndef HPS_CORE_BUILD
00233 template <typename T>   void Swap (T & a, T & b) { T tmp = a; a = b; b = tmp; }
00234 #endif
00235 
00236 
00241 
00242 
00246 enum TK_Status {
00247     TK_Normal   = 0, 
00248     TK_Error    = 1, 
00249     TK_Pause    = 2, 
00250     TK_Single   = 3, 
00251     TK_Pending  = 4, 
00252     TK_Revisit  = 5, 
00253     TK_Complete = 6, 
00254     TK_Version  = 7, 
00255     TK_NotFound = 8, 
00256     TK_Abort    = 9,  
00257     TK_LibraryNotFound = 10 
00258 };
00262 
00263 
00269 enum TK_File_Write_Options {
00270     TK_Suppress_LOD                = 0x00000002, 
00271     TK_Full_Resolution_Vertices    = 0x00000004, 
00272     TK_Full_Resolution_Normals     = 0x00000008, 
00273     TK_First_LOD_Is_Bounding_Box   = 0x00000010, 
00274     TK_Force_Tags                  = 0x00000020, 
00275     TK_Disable_Priority_Heuristic  = 0x00000040, 
00276     TK_Disable_Global_Compression  = 0x00000100, 
00277     TK_Disable_Instancing          = 0x00000200, 
00278     TK_Generate_Dictionary         = 0x00000400, 
00279     TK_Connectivity_Compression    = 0x00000800, 
00280     TK_Disable_Tristrips           = 0x00001000, 
00281     TK_Disable_Compound_Primitives = 0x00002000, 
00282     TK_Global_Quantization         = 0x00004000, 
00283     TK_Full_Resolution_Parameters  = 0x00008000, 
00284     TK_Full_Resolution_Colors      = 0x00010000, 
00285     TK_Full_Resolution_Index_Colors= 0x00020000, 
00286     TK_Communicator_Mode           = 0x00040000, 
00287     TK_Full_Resolution = (TK_Full_Resolution_Vertices|TK_Full_Resolution_Normals|TK_Full_Resolution_Parameters|TK_Full_Resolution_Colors|TK_Full_Resolution_Index_Colors) 
00288 };
00289 
00290 
00294 enum TK_Dictionary_Options {
00295     TK_Dictionary_Bounding_Volumes  = 0x00000001  
00296 };
00297 
00298 
00302 enum TK_File_Read_Options {
00303     TK_Flag_Unhandled_Opcodes     = 0x00000001,  
00304     TK_Ignore_Version             = 0x00000002,  
00305     TK_Skip_External_References   = 0x00000004,  
00306     TK_Ignore_Bounding_LODs       = 0x00000008   
00307 };
00308 
00312 enum TK_Debug_Logging_Options {
00313     TK_Logging_Sequence           = 0x00000001,  
00314     TK_Logging_Tagging            = 0x00000002,  
00315     TK_Logging_Segment_Names      = 0x00000004   
00316 };
00317 
00318 
00322 enum TK_General_Flags {
00323     // for Geometryoes and some attributes
00324     TK_Double_Precision     = 0x01,     
00325 
00326     // for includes and styles
00327     TK_Has_Condition        = 0x01,     
00328     TK_Has_Filter           = 0x02      
00329 };
00330 
00331 
00332 #include "BOpcodeHandler.h"
00333 #include "BStreamFileToolkit.h"
00334 
00340 
00341 
00351 #ifndef SWIG
00352 TK_Status BBINFILETK_API TK_Read_Stream_File  (char const * filename, BStreamFileToolkit * tk);
00353 #endif
00354 
00356 
00365 #ifndef SWIG
00366 TK_Status BBINFILETK_API TK_Read_Stream_File  (char const * filename, int flags = 0);
00367 #endif
00368 
00369 
00370 
00371 
00373 TK_Status BBINFILETK_API TK_Read_Stream_File  (__wchar_t const * filename, BStreamFileToolkit * tk);
00374 #ifdef _MSC_VER
00375 TK_Status BBINFILETK_API TK_Read_Stream_File  (unsigned short const * filename, BStreamFileToolkit * tk);
00376 #endif
00377 
00379 TK_Status BBINFILETK_API TK_Read_Stream_File  (__wchar_t const * filename, int flags = 0);
00380 #ifdef _MSC_VER
00381 TK_Status BBINFILETK_API TK_Read_Stream_File  (unsigned short const * filename, int flags = 0);
00382 #endif
00383 
00384 
00386 
00393 #ifndef SWIG
00394 TK_Status BBINFILETK_API TK_Read_Stream_File  (char const * filename, int flags, BStreamFileToolkit * tk);
00395 #endif
00396 
00398 #endif
00399