Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

BEdgeBreaker.h

00001 /*
00002  * Copyright (c) by Tech Soft America, LLC.
00003  * The information contained herein is confidential and proprietary to
00004  * Tech Soft America, LLC., and considered a trade secret as defined under
00005  * civil and criminal statutes.  Tech Soft America 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 America, LLC. is granted only under a
00009  * written non-disclosure agreement, expressly prescribing the scope and
00010  * manner of such use.
00011  *
00012  * $Header: /NewRoot/DWF Toolkit/v6/develop/global/src/dwf/w3dtk/BEdgeBreaker.h 1     9/12/04 8:47p Evansg $
00013  *
00014  *
00015  *
00016  * HEdgeBreaker.h
00017  *
00018  * This file describes the public interface to the edgebreaker module, plus some internal 
00019  * definitions that are shared between one or more edgebreaker source code files
00020  * 
00021  * Some notes about the interface:
00022  * in_out
00023  *   Parameters with names ending in "in_out" are used for both input and output.
00024  *   On the way in they say how much was allocated.  On the way out, they say
00025  *   how much was used.
00026  * faces
00027  *   The following is a description of the HOOPS face list (taken from the
00028  *   standard HOOPS reference manual)...
00029  *   "The face_list is an array of integers. The first integer is the
00030  *    number of vertices that should be connected to form the first face. For 
00031  *    example, "3" for a triangle. The next three integers (in this example) 
00032  *    are the offsets into the points array at which the three x-y-z's can 
00033  *    be found. The first point in the points array is considered to be at 
00034  *    offset zero, so "0, 1, 2" in the face_list array would form the triangle 
00035  *    from the first three entries in points."
00036  *   a face list by tristrips is (again from the HOOPS 3dgs reference manual)
00037  *   "an array of integers that describes the triangle strips. It is a list of an 
00038  *    unlimited number of independent triangle strips placed contiguously in memory, 
00039  *    one after another. Each triangle strip begins with the number of vertices 
00040  *    referenced, and then the list of vertices. Vertices 0-2 form one triangle. 
00041  *    For every n such that 2 < n <= number of vertices, a new triangle is introduced. 
00042  *    This new triangle will be [n-2, n-1, n] for even n, and [n-1, n-2, n] for odd n 
00043  *    (to maintain consistent handedness of the triangles). Degenerate triangles 
00044  *    (triangles which reference the same vertex more than once) are allowed. The 
00045  *    length of this array should be given as a number of integers, the number of 
00046  *    triangles plus 3 per independent triangle strip. "
00047  * pointmap
00048  *   Vertex id's, sorted by order of appearance in the compressed stream.  This
00049  *   array is needed for transmitting vertex attributes (e.g. normals or texture
00050  *   coordinates) in parallel with their locations.  For example:
00051  *   for( i = 0 ; i < pointmap_len ; i++ ) {
00052  *      *out++ = texcoords[ pointmap[i] ].u;
00053  *      *out++ = texcoords[ pointmap[i] ].v;
00054  *   }
00055  * pcount
00056  *   the **number** of xyz triplets in the array of vertex locations.
00057  * flen
00058  *   the number of integers in the face list
00059  */
00060 #ifndef __BEDGEBREAKER_H__
00061 #define __BEDGEBREAKER_H__
00062 
00063 #ifndef BSTREAM_DISABLE_EDGEBREAKER
00064 
00065 
00066 #define EB_DEFAULT (-1)
00067 
00068 typedef struct ET_Bounding_TAG {
00069     float x1, y1, z1;
00070     float x2, y2, z2;
00071 } ET_Bounding;
00072 
00073 typedef void *(*ET_Malloc_Action)(size_t size, void *user_data);
00074 typedef void(*ET_Free_Action)(void *ptr, void *user_data);
00075 typedef void(*ET_New_Vertex_Action)(int a, int b, int c, void *user_data);
00076 
00077 #define HINT_ONE_PIECE              0x0001
00078 #define HINT_WATERTIGHT             0x0002
00079 #define HINT_MANIFOLD               0x0004
00080 #define HINT_NO_HANDLES             0x0008
00081 #define HINT_NO_BACKWARDS_OR_HOLES  0x0010
00082 #define HINT_INPUT_BY_TRISTRIPS     0x0020
00083 
00084 #define STATUS_ERROR            0
00085 #define STATUS_NORMAL           1
00086 #define STATUS_COMPLETE         2
00087 #define STATUS_WATERTIGHT       3
00088 #define STATUS_TRY_AGAIN        4
00089 
00090 
00091 
00092 typedef struct eb_compress_configs_TAG {
00093     
00094     int x_quantization, y_quantization, z_quantization;
00095     
00096     int x_quantization_normals, y_quantization_normals, z_quantization_normals;
00097     
00098     float point_factor;         
00099     
00100     ET_Bounding *bounding;
00101     int hints;
00102     
00103     ET_Malloc_Action malloc_action;
00104     ET_Free_Action free_action;
00105     ET_New_Vertex_Action new_vertex_action;
00106     void *user_data;
00107     
00108     int target_version;
00109 } eb_compress_configs;
00110 extern int show_edgebreaker_compress_size( 
00111                         int pcount, 
00112                         int flen, 
00113                         int const *face_data, 
00114                         int *stream_len_out,
00115                         int *pointmap_count_out,
00116                         
00117                         eb_compress_configs const *configs
00118                         );
00119 extern int edgebreaker_compress( 
00120                         int pcount, 
00121                         float const *points, 
00122                         float const *normals, 
00123                         int flen, 
00124                         
00125                         int const *fdata_in,            
00126                         int *stream_len_in_out,
00127                         
00128                         void *stream_out,               
00129                         int *pointmap_len_in_out,
00130                         
00131                         int *pointmap_out,              
00132                         
00133                         eb_compress_configs const *configs      
00134                         );
00135 
00136 typedef struct eb_decompress_configs_TAG {
00137                         
00138     ET_Bounding const *bounding;
00139     
00140     ET_Malloc_Action malloc_action;
00141     ET_Free_Action free_action;
00142     ET_New_Vertex_Action new_vertex_action;
00143     void *user_data;
00144 } eb_decompress_configs;
00145 extern int show_edgebreaker_decompress_size( 
00146                         int stream_len, 
00147                         void const *stream, 
00148                         int *pcount_out, 
00149                         int *normal_count_out, 
00150                         int *flen_out 
00151                         );
00152 extern int edgebreaker_decompress( 
00153                         int stream_len, 
00154                         
00155                         void const *stream,             
00156                         int *pcount_in_out, 
00157                         float *points_out, 
00158                         float *normals_out, 
00159                         
00160                         bool *by_tristrips_out,
00161                         
00162                         int *flen_in_out,
00163                         
00164                         int *faces_out,
00165                         
00166                         eb_decompress_configs const *configs            
00167                         );
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175     
00176 
00177 
00178 typedef struct {
00179     char scheme;    
00180     char mtable_scheme;
00181     char points_scheme;
00182     char normals_scheme; 
00183     int opslen;     
00184     int mtablelen;  
00185     int pointslen;  
00186     int pcount;     
00187 } edgebreaker_header0;
00188 
00189 
00190 typedef struct {
00191     edgebreaker_header0 v0;
00192     int normalslen;
00193 } edgebreaker_header1;
00194 
00195 
00196 typedef struct EDGEBREAKER_HEADER_TAG {
00197     char scheme;    
00198     char mtable_scheme;
00199     char points_scheme;
00200     char normals_scheme; 
00201     int opslen;     
00202     int mtablelen;  
00203     int pointslen;  
00204     int pcount;     
00205     int normalslen;
00206 } edgebreaker_header;
00207 
00208 
00209 #define MTABLE_HAS_LENGTHS                  0x1
00210 #define MTABLE_HAS_M2STACKOFFSETS           0x2
00211 #define MTABLE_HAS_M2GATEOFFSETS            0x4
00212 #define MTABLE_HAS_DUMMIES                  0x8
00213 #define MTABLE_HAS_PATCHES                  0x10
00214 #define MTABLE_HAS_BOUNDING                 0x20
00215 #define MTABLE_HAS_QUANTIZATION             0x40
00216 #define MTABLE_HAS_QUANTIZATION_NORMALS     0x80
00217 
00218 typedef struct {
00219     int flags;
00220     
00221     int *mlengths;
00222     int mlengths_used;
00223     int mlengths_allocated;
00224     
00225     int *m2stackoffsets;
00226     int m2stackoffsets_used;
00227     int m2stackoffsets_allocated;
00228     
00229     int *m2gateoffsets;
00230     int m2gateoffsets_used;
00231     int m2gateoffsets_allocated;
00232     
00233     int *dummies;
00234     int dummies_used;
00235     int dummies_allocated;
00236     
00237     int *patches;
00238     int patches_used;
00239     int patches_allocated;
00240     
00241     ET_Bounding *bounding;
00242     
00243     int x_quantization;
00244     int y_quantization;
00245     int z_quantization;
00246     
00247     int x_quantization_normals;
00248     int y_quantization_normals;
00249     int z_quantization_normals;
00250 } mtable_info;
00251 
00252 
00253 
00254 typedef struct HALF_EDGE_TAG {
00255     int start;
00256     int twin;
00257 } half_edge;
00258 
00259 
00260 typedef struct {
00261     half_edge *edges;
00262     int allocated;
00263     int used;
00264     int *visitations;  
00265     
00266     int visitations_used;
00267 } half_edge_array;
00268 
00269 typedef struct {
00270     int *data;
00271     int allocated;
00272     int used;
00273 } int_stack;
00274 
00275 typedef struct ACTION_TABLE_TAG {
00276     ET_Malloc_Action malloc_action;
00277     ET_Free_Action free_action;
00278     ET_New_Vertex_Action new_vertex_action;
00279     void *user_data;
00280 } ET_Action_Table;
00281 #define EA_FREE(ptr) (actions->free_action(ptr,actions->user_data))
00282 #define EA_MALLOC(size) (actions->malloc_action(size,actions->user_data))
00283 
00284 typedef struct {
00285     unsigned int *data; 
00286     unsigned int *rdata;
00287     int allocated;      
00288     int used;           
00289     int bit;            
00290     int rused;          
00291     int rbit;           
00292     int can_reallocate; 
00293     int status;         
00294     
00295     unsigned int mask[33]; 
00296     
00297     unsigned int range[33]; 
00298 } varstream;
00299 
00300 
00301 typedef struct {
00302     int *loops;          
00303     int *loops_edges;    
00304     int loops_used;      
00305     int loops_edges_allocated; 
00306 
00307     int np_allocated;
00308     int *P;              
00309     int *N;              
00310 } loop_table;
00311 
00312 
00313 
00314 typedef short INT16;
00315 typedef int INT32;
00316 
00317     
00318 #define CASE_C 0
00319 #define CASE_L 1
00320 #define CASE_E 2
00321 #define CASE_R 3
00322 #define CASE_S 4
00323 #define CASE_M 5
00324 #define CASE_M2 6
00325 
00326 #define TONEXT4(i) (3 - (((i)-1)%4))
00327 
00328 #define MAXVAL(bits) ((1<<(bits))-1)
00329 
00330 #define BIG_FLOAT (1e20f)
00331 #define DEFAULT_QUANTIZATION (11)
00332 #define DEFAULT_POINT_FACTOR (1.5f)
00333 #define DEFAULT_HINTS (0)
00334 
00335 #define POINTSIZE 12 
00336 
00337 #define GARBAGE_VERTEX  ((int)0x80808080)
00338 #define DUMMY_VERTEX    ((int)0x80000003)
00339 #define GARBAGE ((int)0x80808080)           
00340 #define VERTEX_SPECIAL(x) ((unsigned int)(x) & 0x80000000)
00341 #define INVALIDATE_VERTEX(x) ((x) |= 0x80000000) 
00342 #define EA_VERTEX_INDEX(x) ((x) & ~0x80000000)
00343 #define PROXY_VERTEX_INDEX(proxy_hash,v) (VERTEX_SPECIAL(v)?lookup_vertex((proxy_hash),(v)):v)
00344 
00345 #define GARBAGE_EDGE ((int)0x80808080)
00346 #define MULTIPLE_EDGE ((int)0x80000001)
00347 #define EDGE_SPECIAL(x) ((unsigned int)(x) & 0x80000000)
00348 #define EDGE_INVALID(x) ((unsigned int)(x) & 0x80000000)
00349 #define INVALIDATE_EDGE(x) ((x) |= 0x80000000) 
00350 #define REAL_EDGE_INDEX(x) ((x) & ~0x80000000)
00351 
00352 
00353 #define I2V(x) ((void *)(POINTER_SIZED_INT)(x))
00354 #define V2I(x) ((int)(POINTER_SIZED_INT)(void *)(x))
00355 
00356 
00357 
00358 
00359 #define HALF_EDGE_INIT(h) ((h)->start=(h)->twin=GARBAGE_EDGE)
00360 
00361 
00362 #define HNEXT(i) (3*((i)/3) + ((i)+1)%3)
00363 #define HPREV(i) (3*((i)/3) + ((i)+2)%3)
00364 
00365 
00366     
00367 extern void mtable_info_init( mtable_info *m );
00368 extern void mtable_info_free( mtable_info *m );
00369 extern int lookup_vertex(const struct vhash_s *proxy_hash, int v);
00370 extern void predict( 
00371     half_edge_array const *ea, 
00372     int ei,                     
00373     int third_vertex_unknown,   
00374     char const *touched,
00375     struct vhash_s const *proxy_hash,
00376     int const *quantized_points,
00377     int *prediction_out );
00378 extern int old_predict( 
00379     int const *associations, 
00380     int const *points, 
00381     ET_Bounding const *bounding, 
00382     int x_quantization,
00383     int y_quantization,
00384     int z_quantization,
00385     int *out );
00386 extern int old_pack_points( 
00387     mtable_info *mtable, int *associations, edgebreaker_header *hptr,
00388     int original_pointcount, int const *pointmap, float const *points, 
00389     int buffsize, void *buffer_out, 
00390     eb_compress_configs const *configs );
00391 extern int old_unpack_points( 
00392     int const *associations, 
00393     edgebreaker_header const *hptr,
00394     void const *diffs_in, 
00395     float *points_out, 
00396     ET_Bounding const *bounding, 
00397     int x_quantization, int y_quantization, int z_quantization );
00398 extern int old_unpack_normals( 
00399     int const *associations, 
00400     edgebreaker_header const *hptr,
00401     void const *diffs_in, 
00402     float *normals_out, 
00403     int x_quantization_normals, int y_quantization_normals, int z_quantization_normals );
00404 extern int int_stack_init( int_stack *s );
00405 extern int int_stack_expand( int_stack *s );
00406 extern void int_stack_free( int_stack *s );
00407 extern int int_stack_pop( int_stack *s );
00408 extern int int_stack_pop_internal( int_stack *s, int offset, int *out );
00409 extern void int_stack_push( int_stack *s, int n );
00410 extern void int_stack_push_if_unique( int_stack *s, int n );
00411 extern int validate_associations( 
00412         int const *associations, 
00413         int pointcount );
00414 extern int half_edge_array_init( half_edge_array *ea, int initial_size );
00415 extern void half_edge_array_free( half_edge_array *ea );
00416 extern int half_edge_array_expand( half_edge_array *ea );
00417 extern int half_edge_array_append( half_edge_array *ea, half_edge **out );
00418 extern int validate_edge ( half_edge_array const *ea, half_edge const *a, loop_table const *loops );
00419 extern void *default_malloc( size_t size, void *user_data );
00420 extern void default_free( void *ptr, void *user_data );
00421 extern void default_new_vertex( int a, int b, int c, void *user_data );
00422 extern void vsinit_write( varstream *vs, int size, void *pointer );
00423 
00424 extern void vsinit_read( varstream *vs, int size, void *pointer );
00425 extern void vsfree( varstream *vs );
00426 extern void vsswap( varstream *vs );
00427 extern void vsput( varstream *vs, const int *numbits_array, int val );
00428 extern int vsget( varstream *vs, const int *numbits_array );
00429 
00430 
00431 
00432 extern ET_Action_Table *actions;
00433 extern int g_hints;
00434 
00435 #endif 
00436 #endif 
00437 
00438 

Generated on Tue May 17 12:05:59 2005 for Autodesk DWF 3D Toolkit by  doxygen 1.4.1