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