HOOPS/3dGS I.M. Interface

     << Back      Full Index      Forward >>


lod_main.h

00001 #ifndef MXMAIN_INCLUDED 
00002 #define MXMAIN_INCLUDED
00003 
00004 /************************************************************************
00005 
00006   MxMain.h
00007 
00008   This file contains the structures and function prototypes needed for 
00009   communication with the outside world.  In converting between HOOPS and
00010   non-hoops versions of the LOD module, this is the only file that should
00011   need changes (for non-HOOPS representations of 3d models, MxMain.c may
00012   also need some changes).
00013 
00014   Copyright (C) 1998 Michael Garland.  See "COPYING.txt" for details.
00015   
00016   $Id: lod__main_8h-source.html,v 1.4 2008-02-21 21:41:00 stage Exp $
00017 
00018  ************************************************************************/
00019 
00020 #ifdef MX_DEBUG
00021 #include <assert.h>
00022 #define MX_ASSERT(x) assert(x)
00023 #else
00024 #define MX_ASSERT(x)
00025 #endif
00026 
00027 /* Declarations copied from hi_proto.h 
00028  * These are the only HOOPS functions that the LOD module may use,
00029  * and even these should be accessed only through macros in this file.
00030  */
00031 #ifndef HI_PROTO_DEFINED
00032   extern void HI_Copy_Anything( void const *in, long size, void *out );
00033   extern void HI_Free( void *p, long size );
00034   extern void *HI_Allocate( long size, int allow_failure );
00035   extern void HI_Error( int category, int specific, char * );
00036 #endif /* ifndef HI_PROTO_DEFINED */
00037 
00038 /* some wrappers to use around memory allocation and freeing */
00039 #define MX_ALLOC(size) (HI_Allocate( size, 0 ))
00040 #define MX_FREE(ptr,size) (HI_Free( ptr, size ))
00041 #define MX_COPY(src,size,dest) (HI_Copy_Anything((src),(size),(dest)))
00042 #define MX_REALLOC(ptr,oldsize,newsize)                 \
00043 {                                                       \
00044     /* brute force. reallocate from scratch */          \
00045     void *tmp = (ptr);                                  \
00046     (ptr) = MX_ALLOC( (newsize) );                      \
00047     HI_Copy_Anything( tmp, (oldsize), (ptr) );          \
00048     MX_FREE( tmp, (oldsize) );                          \
00049 }
00050 
00051 
00052 /*
00053  * LOD-specific error codes
00054  */
00055 #define HEC_LOD_MODULE                  111 /* must match hpserror.h */
00056 #define ERR_INSUFFICIENT_MEMORY           1
00057 
00058 #define MX_ERROR(code,explanation) \
00059     (HI_Error( HEC_LOD_MODULE, code, explanation ) )
00060 
00061 
00062 #define MX_USE_DEFAULT          -1
00063 
00064 /* for placement policy */
00065 #define MX_PLACE_ENDPOINTS  0
00066 #define MX_PLACE_ENDORMID   1 
00067 #define MX_PLACE_LINE       2
00068 #define MX_PLACE_OPTIMAL    3
00069 #define MX_PLACE_OPTIMAL_BB 4
00070 
00071 /* for weighting policy */
00072 #define MX_WEIGHT_UNIFORM       0
00073 #define MX_WEIGHT_AREA          1
00074 #define MX_WEIGHT_ANGLE         2
00075 #define MX_WEIGHT_AVERAGE       3
00076 #define MX_WEIGHT_AREA_UNSCALED 4
00077 #define MX_WEIGHT_RAWNORMALS    5
00078 
00079 /* for target units */
00080 #define MX_PERCENT      1
00081 #define MX_LEVEL        2
00082 
00083 /* a "-1" in any of these fields indicates that the default should be used */
00084 typedef struct MxConfig_TAG
00085 {
00086     int     placement_policy;
00087     int     weighting_policy;
00088     float   boundary_weight;
00089     float   compactness_ratio;
00090     float   meshing_penalty;
00091     int     will_join_only;
00092     float   ratio;
00093     int     max_degree;
00094 
00095 } MxConfig;
00096 
00097 typedef struct MxShell_TAG {
00098     float  *points;
00099     int    pcount;
00100     int    *faces; /* hoops HC_Insert_Shell() format, but w/o the negative faces */
00101     int    flen; 
00102 } MxShell;
00103 
00104 typedef struct MxShellChain_TAG {
00105     MxShell                  sh;
00106     struct MxShellChain_TAG *next;
00107 } MxShellChain;
00108 
00109 
00110 /* tjh: "int *list" has the following interpretation:
00111  * a list contains as many tristrips with compatible vertex, face, 
00112  *     and edge attributes as are in the polyhedron.
00113  * 1st 2 entries are indices into points array.
00114  * Next, point indices and face indices alternate, until the end of the tristrip.
00115  * The end of the tristrip is marked with unary negation (i.e. x becomes ~x)
00116  * Note that -x was ruled out because -0 == 0, and the flag could be missed.
00117  * After the last point/face pair, the process starts again.
00118  * 
00119  * MxTristrip is identical to HT_Base_Tristrip, minus the face attributes
00120  * compatible via type cast from HT_Base_Tristrip, but not vice versa 
00121  * this description matches the one in phedron.h
00122  */
00123 typedef struct MxTristrip_TAG {
00124     struct MxTristrip_TAG   *next;
00125     int                     *list;
00126     int                     list_length;
00127 } MxTristrip;
00128 
00129 
00130 
00131 /*
00132  *  LOD module entry points
00133  */
00134 
00135 /* needed by Compute_Optimized_Shell */
00136 extern void HI_LOD_Execute(
00137     int plist_len, const float *plist,
00138     int flist_len, const int *flist, 
00139     MxConfig *cfg_ptr,                  /* pass NULL for all default values */
00140     int *plist_len_out, float *plist_out, 
00141     int *flist_len_out, int *flist_out, 
00142     int *pmap, int *fmap     
00143 );
00144 
00145 /* needed by Std_3d_Polyhedron */
00146 extern MxShellChain *HI_LOD_Chain_Execute_By_Tristrips(
00147     int plist_len, const float *plist,
00148     const MxTristrip *t,
00149     MxConfig *cfg_ptr,                  /* pass NULL for all default values */
00150     int depth
00151 );
00152 
00153 #endif
00154 
00155 
00156 
00157 
Main Index
HOOPS/3dGS I.M. Interface

     << Back      Full Index      Forward >>