HOOPS/3dGS I.M. Interface

     << Back      Full Index      Forward >>


phedron.h

00001 /*
00002  * Copyright (c) 1998 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: phedron_8h-source.html,v 1.29 2008-03-10 07:09:28 stage Exp $
00013  */
00014 
00015 #ifndef PHEDRON_DEFINED
00016 
00017 #ifndef DATABASE_DEFINED
00018 #include "database.h"
00019 #endif
00020 
00021 
00022 /*
00023  * Polymarkers are assembled a bit differently than polyedges and tristrips,
00024  * because it's not important to group like-colored markers together.
00025  * This affects the MASK and the macros below.
00026  */
00027 typedef unsigned int HT_Local_Vertex_Flags;
00028 #define LVA_EXPLICIT_VISIBLE                (HT_Local_Vertex_Flags)0x00000001
00029 #define LVA_EXPLICIT_INVISIBLE              (HT_Local_Vertex_Flags)0x00000002
00030 #define LVA_ANY_EXPLICIT_VISIBILITY         (HT_Local_Vertex_Flags)0x00000003
00031 #define LVA_EXPLICIT_MCOLOR_BY_VALUE        (HT_Local_Vertex_Flags)0x00000004
00032 #define LVA_EXPLICIT_MCOLOR_BY_FINDEX       (HT_Local_Vertex_Flags)0x00000008
00033 #define LVA_ANY_EXPLICIT_MCOLOR             (HT_Local_Vertex_Flags)0x0000000C
00034 #define LVA_EXPLICIT_ECOLOR_BY_VALUE        (HT_Local_Vertex_Flags)0x00000010
00035 #define LVA_EXPLICIT_ECOLOR_BY_FINDEX       (HT_Local_Vertex_Flags)0x00000020
00036 #define LVA_ANY_EXPLICIT_ECOLOR             (HT_Local_Vertex_Flags)0x00000030
00037 #define LVA_EXPLICIT_FCOLOR_BY_VALUE        (HT_Local_Vertex_Flags)0x00000040
00038 #define LVA_EXPLICIT_FCOLOR_BY_FINDEX       (HT_Local_Vertex_Flags)0x00000080
00039 #define LVA_ANY_EXPLICIT_FCOLOR             (HT_Local_Vertex_Flags)0x000000C0
00040 #define LVA_ANY_EXPLICIT_COLOR_BY_VALUE     (HT_Local_Vertex_Flags)0x00000054
00041 #define LVA_ANY_EXPLICIT_COLOR_BY_FINDEX    (HT_Local_Vertex_Flags)0x000000A8
00042 #define LVA_ANY_EXPLICIT_COLOR              (HT_Local_Vertex_Flags)0x000000FC
00043 #define LVA_EXPLICIT_SIZE                   (HT_Local_Vertex_Flags)0x00000100
00044 #define LVA_EXPLICIT_SYMBOL                 (HT_Local_Vertex_Flags)0x00000200
00045 #define LVA_EXPLICIT_NORMAL                 (HT_Local_Vertex_Flags)0x00000400
00046 #define LVA_EXPLICIT_PARAMETER              (HT_Local_Vertex_Flags)0x00001000
00047 #define LVA_IMPLICIT_PARAMETER              (HT_Local_Vertex_Flags)0x00002000
00048 #define LVA_POLYMARKER_MASK                 (HT_Local_Vertex_Flags)0x00000303
00049 #define LVA_NEGATIVE_GAUSSIAN               (HT_Local_Vertex_Flags)0x00004000
00050 #define LVA_DIRTY                           (HT_Local_Vertex_Flags)0x00008000
00051 #define LVA_SPLIT_FOR_FACE_COLORS           (HT_Local_Vertex_Flags)0x00010000
00052 #define LVA_SPLIT_FOR_FACE_NORMALS          (HT_Local_Vertex_Flags)0x00020000
00053 #define LVA_SPLIT_FOR_FACE_PARAMETERS       (HT_Local_Vertex_Flags)0x00040000
00054 #define LVA_SPLIT_FOR_EDGE_COLORS           (HT_Local_Vertex_Flags)0x00100000
00055 #define LVA_SPLIT_FOR_EDGE_NORMALS          (HT_Local_Vertex_Flags)0x00200000
00056 #define LVA_SPLIT_FOR_EDGE_PARAMETERS       (HT_Local_Vertex_Flags)0x00400000
00057 
00058 struct HT_One_Vertex_Attributes{
00059     HT_RGB                      color;          /* marker color, that is */
00060     HT_Color_Float_Index        findex;         /* marker color, that is */
00061     float                       size;
00062     HT_Glyph                    *glyph;
00063     unsigned char               glyph_symbol;
00064     HT_Local_Vertex_Flags       flags;
00065 };
00066 
00067 struct HT_LVA_Symbol{
00068     HT_LVA_Symbol       *next;
00069     HT_Reference_Count  refcount;
00070     HT_Name             name;
00071     HT_Integer32        key;
00072     unsigned char       id;
00073 };
00074 
00075 struct HT_Face_Vertex_Pair {
00076     int         face;           /* on first entry also used as count */
00077     int         vertex;         /* on first entry also used as 'unsplit' count */
00078 };
00079 
00080 
00081 struct HT_Local_Vertex_Attributes{
00082     /* All arrays of size = point_count+extra_point_count except symbols lookup*/
00083 
00084     HT_Local_Vertex_Flags       *flags;
00085     HT_Face_Vertex_Pair         **face_specific_lookup; /* face-vertex pairings */
00086     int                         *face_specific_reverse;
00087 
00088     HT_RGB                      *mcolors; /* marker colors by value */
00089     HT_RGB                      *ecolors; /* edge colors by value */
00090     HT_RGB                      *fcolors; /* face colors by value */
00091     HT_Color_Float_Index        *mfindices; /* marker colors by findex */
00092     HT_Color_Float_Index        *efindices; /* edge colors by findex */
00093     HT_Color_Float_Index        *ffindices; /* face colors by findex */
00094     float                       *sizes;
00095     unsigned char               *symbols;
00096     HT_LVA_Symbol               *symbols_list;
00097     HT_Vector                   *normals;
00098 
00099     HT_Parameter                *params;
00100     HT_Integer32                param_width;
00101     HT_Parameter                *natural_params;
00102     HT_Parameter                *implicit_params;
00103     HT_Integer32                implicit_param_width;
00104     HT_Parameter_Flags          implicit_param_flags;
00105 
00106     int                         explicit_visible_count;
00107     int                         explicit_invisible_count;
00108     int                         explicit_mcolor_by_value_count;
00109     int                         explicit_mcolor_by_findex_count;
00110     int                         explicit_ecolor_by_value_count;
00111     int                         explicit_ecolor_by_findex_count;
00112     int                         explicit_fcolor_by_value_count;
00113     int                         explicit_fcolor_by_findex_count;
00114     int                         explicit_size_count;
00115     int                         explicit_symbol_count;
00116     int                         explicit_parameter_count;
00117     int                         explicit_normal_count;
00118     int                         negative_gaussian_count;
00119 };
00120 
00121 #define INIT_ONE_VERTEX_ATTRIBUTES(va) do { \
00122             (va).color.red   = 0.0f;        \
00123             (va).color.green = 0.0f;        \
00124             (va).color.blue  = 0.0f;        \
00125             (va).findex = 0.0f;             \
00126             (va).size = 0.0f;               \
00127             (va).glyph = 0;                 \
00128             (va).glyph_symbol = 0;          \
00129             (va).flags = 0;                 \
00130         } while (0)
00131 
00132 #define COPY_ONE_VERTEX_ATTRIBUTES(src_va, dest_va) do {    \
00133             (dest_va).color.red   = (src_va).color.red;     \
00134             (dest_va).color.green = (src_va).color.green;   \
00135             (dest_va).color.blue  = (src_va).color.blue;    \
00136             (dest_va).findex  = (src_va).findex;            \
00137             (dest_va).size = (src_va).size;                 \
00138             (dest_va).glyph = (src_va).glyph;               \
00139             (dest_va).glyph_symbol = (src_va).glyph_symbol; \
00140             (dest_va).flags = (src_va).flags;               \
00141         } while (0)
00142 
00143 #define PACK_ONE_VERTEX_ATTRIBUTES(lva_ptr, index, va) do {             \
00144             (va).flags = (lva_ptr)->flags[index] & LVA_POLYMARKER_MASK; \
00145             if ((lva_ptr)->mcolors != null) {                           \
00146                 (va).color.red   = (lva_ptr)->mcolors[index].red;       \
00147                 (va).color.green = (lva_ptr)->mcolors[index].green;     \
00148                 (va).color.blue  = (lva_ptr)->mcolors[index].blue;      \
00149             }                                                           \
00150             if ((lva_ptr)->mfindices != null)                           \
00151                 (va).findex = (lva_ptr)->mfindices[index];              \
00152             if ((lva_ptr)->sizes != null)                               \
00153                 (va).size = (lva_ptr)->sizes[index];                    \
00154             if ((lva_ptr)->symbols != null)                             \
00155                 (va).glyph_symbol = (lva_ptr)->symbols[index];          \
00156         } while (0)
00157 
00158 #define EQUAL_LOCAL_AND_ONE_VERTEX_ATTRIBUTES(lva_ptr, index, va)                                   \
00159         (((va).flags & LVA_POLYMARKER_MASK) == ((lva_ptr)->flags[index] & LVA_POLYMARKER_MASK) &&   \
00160          ((lva_ptr)->sizes == null || (va).size == (lva_ptr)->sizes[index]) &&                      \
00161          ((lva_ptr)->symbols == null || (va).glyph_symbol == (lva_ptr)->symbols[index]))
00162 
00163 #define EQUAL_ONE_VERTEX_ATTRIBUTES(va1, va2)                                                       \
00164         (((va1).flags & LVA_POLYMARKER_MASK) == ((va2).flags & LVA_POLYMARKER_MASK) &&              \
00165          (!BIT ((va1).flags, LVA_EXPLICIT_SIZE) || (va1).size == (va2).size) &&                     \
00166          (!BIT ((va1).flags, LVA_EXPLICIT_SYMBOL) || (va1).glyph_symbol == (va2).glyph_symbol))
00167 
00168 /*
00169  * The unsigned short cast below must match the base type of Local_Vertex_Flags.
00170  * The cast is required in order to make the relational operator meaningful.
00171  */
00172 #define LESS_ONE_VERTEX_ATTRIBUTES(va1, va2)                    \
00173         ((unsigned short)((va1).flags & LVA_POLYMARKER_MASK) <  \
00174          (unsigned short)((va2).flags & LVA_POLYMARKER_MASK) || \
00175          (va1).flags == (va2).flags &&                          \
00176          ((va1).size < (va2).size ||                            \
00177           (va1).size == (va2).size &&                           \
00178           (va1).glyph_symbol < (va2).glyph_symbol))
00179 
00180 
00181 typedef unsigned short HT_Local_Edge_Flags;
00182 #define LEA_EXPLICIT_VISIBLE            (HT_Local_Edge_Flags)0x0001
00183 #define LEA_EXPLICIT_INVISIBLE          (HT_Local_Edge_Flags)0x0002
00184 #define LEA_ANY_EXPLICIT_VISIBILITY     (HT_Local_Edge_Flags)0x0003
00185 #define LEA_EXPLICIT_COLOR_BY_VALUE     (HT_Local_Edge_Flags)0x0004
00186 #define LEA_EXPLICIT_COLOR_BY_FINDEX    (HT_Local_Edge_Flags)0x0008
00187 #define LEA_ANY_EXPLICIT_COLOR          (HT_Local_Edge_Flags)0x000C
00188 #define LEA_EXPLICIT_PATTERN            (HT_Local_Edge_Flags)0x0010
00189 #define LEA_EXPLICIT_WEIGHT             (HT_Local_Edge_Flags)0x0020
00190 #define LEA_HAS_VCOLOR_BY_DEFAULT       (HT_Local_Edge_Flags)0x0040
00191 #define LEA_HAS_VCOLOR_BY_VALUE         (HT_Local_Edge_Flags)0x0080
00192 #define LEA_HAS_VCOLOR_BY_FINDEX        (HT_Local_Edge_Flags)0x0100
00193 #define LEA_HAS_VCOLOR_WHICHEVER        (HT_Local_Edge_Flags)0x01C0
00194 #define LEA_PERIMETER                   (HT_Local_Edge_Flags)0x0200
00195 #define LEA_MESH_QUAD                   (HT_Local_Edge_Flags)0x0400
00196 #define LEA_EXPLICIT_NORMAL             (HT_Local_Edge_Flags)0x0800
00197 #define LEA_HARD                        (HT_Local_Edge_Flags)0x1000
00198 #define LEA_ADJACENT                    (HT_Local_Edge_Flags)0x2000
00199 
00200 
00201 struct HT_One_Edge_Attributes{
00202     HT_RGB                      color;          /* edge color, that is */
00203     HT_Color_Float_Index        findex;         /* edge color, that is */
00204     float                       weight;
00205     unsigned char               pattern;
00206     HT_Line_Style const         *line_style;
00207     HT_Local_Edge_Flags         flags;
00208 };
00209 
00210 #define INIT_ONE_EDGE_ATTRIBUTES(ea) do {   \
00211             (ea).color.red   = 0.0f;        \
00212             (ea).color.green = 0.0f;        \
00213             (ea).color.blue  = 0.0f;        \
00214             (ea).findex  = 0.0f;            \
00215             (ea).weight  = 0.0f;            \
00216             (ea).pattern = 0;               \
00217             (ea).line_style = 0;            \
00218             (ea).flags   = 0;               \
00219         } while (0)
00220 
00221 #define COPY_ONE_EDGE_ATTRIBUTES(src_ea, dest_ea) do {      \
00222             (dest_ea).color.red   = (src_ea).color.red;     \
00223             (dest_ea).color.green = (src_ea).color.green;   \
00224             (dest_ea).color.blue  = (src_ea).color.blue;    \
00225             (dest_ea).findex  = (src_ea).findex;            \
00226             (dest_ea).weight  = (src_ea).weight;            \
00227             (dest_ea).pattern = (src_ea).pattern;           \
00228             (dest_ea).line_style = (src_ea).line_style;     \
00229             (dest_ea).flags   = (src_ea).flags;             \
00230         } while (0)
00231 
00232 #define PACK_ONE_EDGE_ATTRIBUTES(lea_ptr, index, ea) do {               \
00233             (ea).flags = (lea_ptr)->flags[index] & ~LEA_EXPLICIT_NORMAL;    \
00234             if ((lea_ptr)->colors != null) {                            \
00235                 (ea).color.red   = (lea_ptr)->colors[index].red;        \
00236                 (ea).color.green = (lea_ptr)->colors[index].green;      \
00237                 (ea).color.blue  = (lea_ptr)->colors[index].blue;       \
00238             }                                                           \
00239             if ((lea_ptr)->findices != null)                            \
00240                 (ea).findex = (lea_ptr)->findices[index];               \
00241             if ((lea_ptr)->weights != null)                             \
00242                 (ea).weight = (lea_ptr)->weights[index];                \
00243             if ((lea_ptr)->patterns != null)                            \
00244                 (ea).pattern = (lea_ptr)->patterns[index];              \
00245         } while (0)
00246 
00247 #define EQUAL_LOCAL_AND_ONE_EDGE_ATTRIBUTES(lea_ptr, index, ea)                                 \
00248         (((ea).flags & ~LEA_EXPLICIT_NORMAL) == ((lea_ptr)->flags[index] & ~LEA_EXPLICIT_NORMAL) && \
00249          ((lea_ptr)->colors == null ||                                                          \
00250             (ea).color.red   == (lea_ptr)->colors[index].red   &&                               \
00251             (ea).color.green == (lea_ptr)->colors[index].green &&                               \
00252             (ea).color.blue  == (lea_ptr)->colors[index].blue) &&                               \
00253          ((lea_ptr)->weights == null || (ea).weight == (lea_ptr)->weights[index]) &&            \
00254          ((lea_ptr)->findices == null || (ea).findex == (lea_ptr)->findices[index]) &&          \
00255          ((lea_ptr)->patterns == null || (ea).pattern == (lea_ptr)->patterns[index]))
00256 
00257 #define EQUAL_ONE_EDGE_ATTRIBUTES(ea1, ea2, mask)                                                   \
00258     (((ea1).flags & (mask)) == ((ea2).flags & (mask)) &&                                                            \
00259      (!BIT ((ea1).flags&(mask), LEA_EXPLICIT_PATTERN) || (ea1).pattern == (ea2).pattern) &&     \
00260      (!BIT ((ea1).flags&(mask), LEA_EXPLICIT_WEIGHT) || (ea1).weight == (ea2).weight) &&            \
00261      (!BIT ((ea1).flags&(mask), LEA_EXPLICIT_COLOR_BY_FINDEX) || (ea1).findex == (ea2).findex) &&   \
00262      (!BIT ((ea1).flags&(mask), LEA_EXPLICIT_COLOR_BY_VALUE) ||                                 \
00263         (ea1).color.red   == (ea2).color.red   &&                                           \
00264         (ea1).color.green == (ea2).color.green &&                                           \
00265         (ea1).color.blue  == (ea2).color.blue))
00266 
00267 #define LESS_ONE_EDGE_ATTRIBUTES(ea1, ea2)              \
00268         ((ea1).flags < (ea2).flags ||                   \
00269          (ea1).flags == (ea2).flags &&                  \
00270          ((ea1).weight < (ea2).weight ||                \
00271           (ea1).weight == (ea2).weight &&               \
00272           ((ea1).pattern < (ea2).pattern ||             \
00273            (ea1).pattern == (ea2).pattern &&            \
00274            ((ea1).findex < (ea2).findex ||              \
00275             (ea1).findex == (ea2).findex &&             \
00276             ((ea1).color.red  <  (ea2).color.red    ||  \
00277              (ea1).color.red  == (ea2).color.red    &&  \
00278              ((ea1).color.green < (ea2).color.green  || \
00279               (ea1).color.green == (ea2).color.green && \
00280               (ea1).color.blue  <  (ea2).color.blue))))))
00281 
00282 struct HT_LEA_Pattern {
00283     HT_LEA_Pattern * next;
00284     HT_Reference_Count  refcount;
00285     HT_Name             name;
00286     HT_Integer32        key;
00287     unsigned char       id;
00288 };
00289 
00290 struct HT_Local_Edge_Attributes{
00291     /* All arrays of size = edge_count  except pattern list*/
00292 
00293     HT_Local_Edge_Flags         *flags;
00294 
00295     HT_RGB                      *colors;
00296     HT_Color_Float_Index        *findices;
00297     unsigned char               *patterns; 
00298     HT_LEA_Pattern              *patterns_list;
00299     float                       *weights;
00300     HT_Vector                   *normals;
00301 
00302     int                         explicit_visible_count;
00303     int                         explicit_invisible_count;
00304     int                         explicit_color_by_value_count;
00305     int                         explicit_color_by_findex_count;
00306     int                         explicit_pattern_count;
00307     int                         explicit_weight_count;
00308     int                         explicit_normal_count;
00309 };
00310 
00311 
00312 
00313 typedef unsigned short HT_Local_Face_Flags;
00314 #define LFA_EXPLICIT_VISIBLE            (HT_Local_Face_Flags)0x0001
00315 #define LFA_EXPLICIT_INVISIBLE          (HT_Local_Face_Flags)0x0002
00316 #define LFA_ANY_EXPLICIT_VISIBILITY     (HT_Local_Face_Flags)0x0003
00317 #define LFA_EXPLICIT_COLOR_BY_VALUE     (HT_Local_Face_Flags)0x0004
00318 #define LFA_EXPLICIT_COLOR_BY_FINDEX    (HT_Local_Face_Flags)0x0008
00319 #define LFA_ANY_EXPLICIT_COLOR          (HT_Local_Face_Flags)0x000C
00320 #define LFA_HAS_VCOLOR_BY_DEFAULT       (HT_Local_Face_Flags)0x0010
00321 #define LFA_HAS_VCOLOR_BY_VALUE         (HT_Local_Face_Flags)0x0020
00322 #define LFA_HAS_VCOLOR_BY_FINDEX        (HT_Local_Face_Flags)0x0040
00323 #define LFA_HAS_VCOLOR_WHICHEVER        (HT_Local_Face_Flags)0x0070
00324 #define LFA_EXPLICIT_PATTERN            (HT_Local_Face_Flags)0x0080
00325 #define LFA_EXPLICIT_NORMAL             (HT_Local_Face_Flags)0x0100
00326 #define LFA_RESORT_REQUIRED             (HT_Local_Face_Flags)0x0200
00327 #define LFA_SUBSTRIP_MASK               (HT_Local_Face_Flags)0x00EF
00328 #define LFA_TRISTRIP_MASK               (HT_Local_Face_Flags)0x00FF
00329 
00330 struct HT_One_Face_Attributes {
00331     HT_RGB                      color;          /* face color, that is */
00332     HT_Color_Float_Index        findex;         /* face color, that is */
00333     unsigned char               pattern;        /* as in patterns.h */
00334     int                         region;
00335     HT_Local_Face_Flags         flags;
00336 };
00337 
00338 #define INIT_ONE_FACE_ATTRIBUTES(fa) do {   \
00339             (fa).color.red   = 0.0f;        \
00340             (fa).color.green = 0.0f;        \
00341             (fa).color.blue  = 0.0f;        \
00342             (fa).findex = 0.0f;             \
00343             (fa).pattern = 0;               \
00344             (fa).region = 0;                \
00345             (fa).flags = 0;                 \
00346         } while (0)
00347 
00348 #define COPY_ONE_FACE_ATTRIBUTES(src_fa, dest_fa) do {      \
00349             (dest_fa).color.red   = (src_fa).color.red;     \
00350             (dest_fa).color.green = (src_fa).color.green;   \
00351             (dest_fa).color.blue  = (src_fa).color.blue;    \
00352             (dest_fa).findex = (src_fa).findex;             \
00353             (dest_fa).pattern = (src_fa).pattern;           \
00354             (dest_fa).region = (src_fa).region;             \
00355             (dest_fa).flags = (src_fa).flags;               \
00356         } while (0)
00357 
00358 #define PACK_ONE_FACE_ATTRIBUTES(lfa_ptr, index, fa) do {               \
00359             (fa).flags = (lfa_ptr)->flags[index] & LFA_TRISTRIP_MASK;   \
00360             if ((lfa_ptr)->colors != null) {                            \
00361                 (fa).color.red   = (lfa_ptr)->colors[index].red;        \
00362                 (fa).color.green = (lfa_ptr)->colors[index].green;      \
00363                 (fa).color.blue  = (lfa_ptr)->colors[index].blue;       \
00364             }                                                           \
00365             if ((lfa_ptr)->findices != null)                            \
00366                 (fa).findex = (lfa_ptr)->findices[index];               \
00367             if ((lfa_ptr)->patterns != null)                            \
00368                 (fa).pattern = (lfa_ptr)->patterns[index];              \
00369             if ((lfa_ptr)->regions != null)                             \
00370                 (fa).region = (lfa_ptr)->regions[index];                \
00371         } while (0)
00372 
00373 #define EQUAL_LOCAL_AND_ONE_FACE_ATTRIBUTES(lfa_ptr, index, fa)                         \
00374         ((fa).flags == ((lfa_ptr)->flags[index] & LFA_TRISTRIP_MASK) &&                 \
00375          ((lfa_ptr)->colors == null ||                                                  \
00376             (fa).color.red   == (lfa_ptr)->colors[index].red   &&                       \
00377             (fa).color.green == (lfa_ptr)->colors[index].green &&                       \
00378             (fa).color.blue  == (lfa_ptr)->colors[index].blue) &&                       \
00379          ((lfa_ptr)->findices == null || (fa).findex == (lfa_ptr)->findices[index]) &&  \
00380          ((lfa_ptr)->patterns == null || (fa).pattern == (lfa_ptr)->patterns[index]) && \
00381          ((lfa_ptr)->regions == null || (fa).region == (lfa_ptr)->regions[index]))
00382 
00383 #define EQUAL_ONE_FACE_ATTRIBUTES(fa1, fa2, mask)                                                       \
00384         (((fa1).flags & (mask)) == ((fa2).flags & (mask)) &&                                                            \
00385          ((fa1).region == (fa2).region ||                                                       \
00386             ((fa1).flags & LFA_SUBSTRIP_MASK) == 0 &&                                           \
00387             !BIT (OUR(system_flags), Sysop_TRISTRIP_PER_REGION)) &&                             \
00388          (!BIT ((fa1).flags&(mask), LFA_EXPLICIT_PATTERN) || (fa1).pattern == (fa2).pattern) &&     \
00389          (!BIT ((fa1).flags&(mask), LFA_EXPLICIT_COLOR_BY_FINDEX) || (fa1).findex == (fa2).findex) &&   \
00390          (!BIT ((fa1).flags&(mask), LFA_EXPLICIT_COLOR_BY_VALUE) ||                                 \
00391             (fa1).color.red   == (fa2).color.red   &&                                           \
00392             (fa1).color.green == (fa2).color.green &&                                           \
00393             (fa1).color.blue  == (fa2).color.blue))
00394 
00395 #define LESS_ONE_FACE_ATTRIBUTES(fa1, fa2)              \
00396         ((fa1).flags < (fa2).flags ||                   \
00397          (fa1).flags == (fa2).flags &&                  \
00398          ((fa1).region < (fa2).region ||                \
00399           (fa1).region == (fa2).region &&               \
00400           ((fa1).pattern < (fa2).pattern ||             \
00401            (fa1).pattern == (fa2).pattern &&            \
00402            ((fa1).findex < (fa2).findex ||              \
00403             (fa1).findex == (fa2).findex &&             \
00404             ((fa1).color.red   <  (fa2).color.red   ||  \
00405              (fa1).color.red   == (fa2).color.red   &&  \
00406              ((fa1).color.green <  (fa2).color.green || \
00407               (fa1).color.green == (fa2).color.green && \
00408               (fa1).color.blue  <  (fa2).color.blue))))))
00409 
00410 struct HT_Local_Face_Attributes{
00411     /* All arrays of size = face_count */
00412 
00413     HT_Local_Face_Flags         *flags;
00414 
00415     HT_RGB                      *colors;
00416     HT_Color_Float_Index        *findices;
00417     unsigned char               *patterns; /* as in patterns.h */
00418     HT_Plane                    *normals;
00419 
00420     int                         *regions;
00421 
00422     int                         explicit_visible_count;
00423     int                         explicit_invisible_count;
00424     int                         explicit_color_by_value_count;
00425     int                         explicit_color_by_findex_count;
00426     int                         explicit_pattern_count;
00427     int                         explicit_normal_count;
00428 };
00429 
00430 
00431 #define         Same_NONE               0x00
00432 #define         Same_VERTEX_COLORS      0x01
00433 #define         Same_FACE_COLORS        0x02
00434 #define         Same_EDGE_COLORS        0x04
00435 
00436 
00437 /* note: face_indices is padded with 2 dummy values at the start of every strip 
00438  * so that vertex_indices and face_indices say in synch. */
00439 struct HT_Tristrip {
00440     HT_Tristrip                 *next;
00441 
00442     int                         strips;
00443     int                         total;
00444     int *                       lengths;
00445     int *                       vertex_indices;
00446     int *                       face_indices;
00447 
00448     int                         point_count;
00449     int                         face_count;
00450 
00451     HT_Point                    *points;
00452     HT_RGB                      *vertex_colors;
00453     float                       *vertex_findices;
00454     HT_Vector                   *vertex_normals;
00455     HT_Parameter                *vertex_params;
00456     HT_Integer32                vertex_param_width;
00457     HT_Parameter_Flags          vertex_param_flags;
00458     HT_RGB                      *face_colors;
00459     HT_Plane                    *face_normals;
00460     int                         *screen_plane_facings;
00461 
00462     int                         lengths_allocated;
00463     int                         vi_allocated;
00464     int                         fi_allocated;
00465 
00466     bool                    color_interpolated;
00467     bool                    single_colored;
00468 
00469     int                         same_colors;
00470 
00471     HT_One_Face_Attributes      face_attributes;
00472 
00473     HT_Activity                 activity;
00474     HT_Activity                 old_activity;
00475     HT_Display_List *           display_lists;
00476     unsigned int                rendo_flags;
00477     unsigned int                special_flags;
00478     unsigned int                flags;
00479 
00480     HT_Polyhedron_Status *status;
00481 
00482     HT_Reference_Count          refcount;
00483 
00484 #   ifdef CADDS5
00485     int                         *list;
00486 #   endif
00487 
00488 };
00489 
00490 struct HT_Polyedge {
00491     HT_Polyedge *               next;
00492 
00493     int                         strips;
00494     int                         total;
00495     int *                       lengths;
00496     int *                       vertex_indices;
00497     int *                       edge_indices;
00498 
00499     int                         point_count;
00500     int                         edge_count;
00501     HT_Point                    *points;
00502     HT_RGB                      *vertex_colors;
00503     float                       *vertex_findices;
00504     HT_Vector                   *vertex_normals;
00505     HT_Parameter                *vertex_params;
00506     HT_Integer32                vertex_param_width;
00507     HT_Parameter_Flags          vertex_param_flags;
00508     HT_RGB                      *edge_colors;
00509     HT_Vector                   *edge_normals;
00510 
00511     HT_Display_List             *display_lists;
00512     HT_Polyhedron_Status        *status;
00513 #   ifdef CADDS5
00514     int                         *list;
00515 #   endif
00516 
00517     int                         lengths_allocated;
00518     int                         vi_allocated;
00519     int                         ei_allocated;
00520 
00521     bool                        color_interpolated;
00522     bool                        single_colored;
00523     int                         same_colors;
00524 
00525     HT_One_Edge_Attributes      edge_attributes;
00526 
00527     HT_Activity                 activity;
00528     HT_Activity                 old_activity;
00529     unsigned int                rendo_flags;
00530     unsigned int                special_flags;
00531     unsigned int                flags;
00532 
00533     HT_Reference_Count          refcount;
00534 
00535 };
00536 
00537 struct HT_Polymarker {
00538     HT_Polymarker *             next;
00539 
00540     int                         length;
00541     int *                       vertex_indices;
00542 
00543     int                         point_count;
00544     HT_Point                    *points;
00545     HT_RGB                      *vertex_colors;
00546     float                       *vertex_findices;
00547     HT_Vector                   *vertex_normals;
00548     HT_Parameter                *vertex_params;
00549     HT_Integer32                vertex_param_width;
00550 
00551     int                         vi_allocated;
00552 
00553     bool                        color_interpolated;
00554     bool                        single_colored;
00555 
00556     int                         same_colors;
00557 
00558     HT_One_Vertex_Attributes    vertex_attributes;
00559 
00560     HT_Activity                 activity;
00561     HT_Activity                 old_activity;
00562     HT_Display_List *           display_lists;
00563     unsigned int                rendo_flags;
00564     unsigned int                special_flags;
00565     unsigned int                flags;
00566 
00567     HT_Polyhedron_Status        *status;
00568 
00569 #   ifdef CADDS5
00570     int                         *list;
00571 #   endif
00572 
00573 };
00574 
00575 
00576 
00577 
00578 typedef unsigned int    HT_Polyhedron_Flags;
00579 #define PHF_CLOSED                              (HT_Polyhedron_Flags)0x0001
00580 #define PHF_CLOSED_VALID                        (HT_Polyhedron_Flags)0x0002
00581 #define PHF_UNIFORM_HANDEDNESS                  (HT_Polyhedron_Flags)0x0004
00582 
00583 #define PHF_VERTEX_NORMALS_VALID                (HT_Polyhedron_Flags)0x0008
00584 #define PHF_FACE_NORMALS_VALID                  (HT_Polyhedron_Flags)0x0010
00585 #define PHF_EDGE_NORMALS_VALID                  (HT_Polyhedron_Flags)0x0020
00586 
00587 #define PHF_MANIFOLD                            (HT_Polyhedron_Flags)0x0040
00588 #define PHF_MANIFOLD_VALID                      (HT_Polyhedron_Flags)0x0080
00589 
00590 #define PHF_POINTS_BY_REFERENCE                 (HT_Polyhedron_Flags)0x0100
00591 #define PHF_VERTEX_NORMALS_BY_REFERENCE         (HT_Polyhedron_Flags)0x0200
00592 #define PHF_SHELL_FACE_LIST_BY_REFERENCE        (HT_Polyhedron_Flags)0x0400
00593 
00594 #define PHF_IMPLICIT_NORMALS_REVERSED           (HT_Polyhedron_Flags)0x0800
00595 #define PHF_FACE_PLANES_VALID                   (HT_Polyhedron_Flags)0x1000
00596 
00597 #define PHF_TRISTRIP_RESORT_REQUIRED            (HT_Polyhedron_Flags)0x2000
00598 #define PHF_NEGATIVE_GAUSSIANS_VALID            (HT_Polyhedron_Flags)0x4000
00599 
00600 
00601 struct HT_Polyhedron_Common {
00602     HT_GHeader          h;
00603 
00604     /* Original data */
00605 
00606     HT_Point            *points;
00607 
00608     /* Accumulated & Derived Data */
00609 
00610     HT_Polyhedron_Flags polyhedron_flags;     /* (assumed to be 2 bytes) */
00611 
00612     /*
00613      * If the bit is on then the corresponding bit (or attribute)
00614      * in each list header can be trusted to be currently accurate.
00615      */
00616     HT_Local_Vertex_Flags       valid_polymarker_flags;
00617     HT_Local_Edge_Flags         valid_polyedge_flags;
00618     HT_Local_Face_Flags         valid_tristrip_flags;
00619 
00620 
00621     int                 point_count;
00622     int                 face_count;
00623     int                 edge_count;     /* -1 if not known */
00624 
00625     int                 extra_point_count;
00626 
00627     /*
00628      * The following provide vertex/face/edge local attributes. Their allocation
00629      * is deferred until the first time they are actually needed - until
00630      * the first attributes are set by the user, or someone needs to validate them
00631      */
00632     HT_Local_Vertex_Attributes  local_vertex_attributes;
00633     HT_Local_Edge_Attributes    local_edge_attributes;
00634     HT_Local_Face_Attributes    local_face_attributes;
00635 
00636     /* angle used by the current hard-edge polyedges */
00637 
00638     float                       hard_edge_dihedral;
00639 
00640 
00641 
00642     /*
00643      * Information for actually drawing
00644      */
00645 
00646 
00647     /*
00648      * 'polymarkers' are the optimized marker lists.  This list will
00649      * be allocated the first time markers actually need to be displayed.
00650      */
00651     HT_Polymarker               *polymarkers;
00652 
00653     /*
00654      * 'polyedges' are the optimized edge lists. This list will
00655      * be allocated the first time edges actually need to be displayed.
00656      */
00657     HT_Polyedge                 *polyedges;
00658 
00659     /*
00660      * 'tristrips' are the optimized face lists. This list will
00661      * be allocated the first time faces actually need to be displayed.
00662      */
00663     HT_Tristrip                 *tristrips;
00664 
00665     /* The bounding box is used to speed up the clipping */
00666     HT_Bounding                 bounding;
00667 
00668     /* linked list of alternative representations */
00669     HT_LOD_Node         *lodbase;
00670 };
00671 
00672 
00673 struct HT_Mesh {
00674     /* Data that's common to shells and meshes */
00675     HT_Polyhedron_Common        common;
00676 
00677     /* Other original [user specified, topologic] data */
00678     int                         rows;
00679     int                         columns;
00680 
00681     /* Other accumulated and derived data */
00682 
00683     /*
00684      * The edge attributes are stored, for each mesh vertex, as the edge
00685      * to the right, upwards, and diagonally up and to the left. For
00686      * convenience, space is provided for the attributes even when the
00687      * edge itself is off the mesh.
00688      */
00689 };
00690 
00691 
00692 /*
00693  * one destination vertex can define each edge;
00694  * used by edge attributes, etc.
00695  */
00696 struct HT_Edge_Geometry_Info {
00697     int                 destination;      /* offset within 'points' */
00698 };
00699 
00700 
00701 /*
00702  * two faces can define each edge;
00703  * used by silhouette code.
00704  */
00705 struct HT_Edge_To_Face {
00706     int                 face1; /* face1 always indicates a real face */
00707     int                 face2;
00708 #   define              ETF_NOT_USED    (-1)
00709 #   define              ETF_OVERUSED    (-2)    /* if more than 2 faces */
00710 };
00711 
00712 #define REGION_LOW_HIGH_EXTRA 3 /* 1 for the low index, 2 for the high index, 3 for a validity flag. */
00713 #define REGION_RANGE_LOW_OFFSET 0
00714 #define REGION_RANGE_HIGH_OFFSET 1
00715 #define REGION_RANGE_VALIDITY_OFFSET 2
00716 
00717 struct HT_Shell {
00718     /* Data that's common to shells and meshes */
00719     HT_Polyhedron_Common        common;
00720 
00721     /* Other original [user specified, topologic] data */
00722     bool                        face_list_valid;
00723     int                         face_list_length;
00724     int                         *face_list;
00725 
00726     /* Other accumulated and derived data */
00727 
00728     /*
00729      * Edge topology info is saved permanently because, unlike faces and points,
00730      * the mapping from the "Open_Edge" info to the correct edge_attribute
00731      * block is not simple.
00732      *
00733      * 'Edges' is a list, sorted by source vertex, of destination vertices.
00734      * The source vertex is implied from the info in Vertex_To_Edge.
00735      *
00736      * 'Vertex_to_edge' maps each source vertex to the beginning of
00737      * its collection of destination vertices within the 'edges'
00738      * array. The number of such vertices is "vertex_to_edge[I+1] -
00739      * vertex_to_edge[I]", so this array is dimensioned and
00740      * maintained through "last"+1 for convenience.
00741      *
00742      * The struct is used in the hopes of adding some clarity.
00743      *
00744      * The creation of these arrays is deferred until either 
00745      *  a) the first Open_Edge
00746      *  b) the first time silhouettes are made visible.
00747      * 
00748      * Note that there is only one record for each connection.  For any given
00749      * vertex 'i', you can look up vertices with index > i.  So if j>i and i->j 
00750      * is a valid connection, i->j will exist between vertex_to_edge[i] and vertex_to_edge[i+1]
00751      * but j->i will not be in the range vertex_to_edge[j] and vertex_to_edge[j+1]
00752      */
00753     HT_Edge_Geometry_Info       *edges;           /* size = edge_count */
00754     HT_Edge_Geometry_Info       **vertex_to_edge; /* within 'edges', size=point_count+1 */
00755 
00756     /*
00757      * The list of faces associated with each edge are used during
00758      * silhouette-edge calculation.
00759      */
00760     HT_Edge_To_Face             *edge_to_face;    /* size = edge_count */
00761 };
00762 
00763 
00764 
00765 union HT_Polyhedron {
00766     HT_GHeader                  h;
00767     HT_Polyhedron_Common        common;
00768     HT_Shell                    shell;
00769     HT_Mesh                     mesh;
00770 };
00771 
00772 
00773 struct HT_UV_Point {
00774     float               u, v;
00775 };
00776 
00777 
00778 struct HT_UV_Edge {
00779     HT_UV_Edge      *next;
00780     HT_UV_Edge      *opposing;
00781 
00782     int             index;
00783     float           priority;
00784     HT_UV_Region    *region;
00785     struct {
00786         float   a, b, c;
00787     } line;
00788 };
00789 
00790 
00791 struct HT_UV_Region {
00792     HT_UV_Region *next;
00793     HT_UV_Edge          *edges;
00794 
00795     struct {
00796         HT_UV_Point     min, max;
00797     } bounds;           
00798 
00799     bool                cut;
00800 };
00801 
00802 
00803 struct HT_UV_Region_Set {
00804     HT_UV_Region        *regions;
00805     HT_UV_Point         *points;        
00806     int                 point_count;
00807     int                 points_allocated;
00808 };
00809 
00810 #define UVF_KEEP (char)0x1
00811 struct HT_UV_Trim_Header {
00812     HT_Type             type;
00813     char                flags;
00814     HT_UV_Trim *        next;
00815 };
00816 
00817 struct HT_UV_Trim_Poly {
00818     HT_UV_Trim_Header   h;
00819     HT_UV_Point         *points;        
00820     int                 count;    
00821 };
00822 
00823 struct HT_UV_Trim_Curve {
00824     HT_UV_Trim_Header   h;
00825     int                 degree;
00826     int                 control_point_count;
00827     HT_UV_Point         *control_points;
00828     float               *weights;
00829     float               *knots;
00830 };
00831 
00832 
00833 struct HT_UV_Trim_Collection {
00834     HT_UV_Trim_Header   h;
00835     HT_UV_Trim          *trimlist;
00836 };
00837 
00838 union HT_UV_Trim {
00839     HT_UV_Trim_Header       h;
00840     HT_UV_Trim_Poly         poly;
00841     HT_UV_Trim_Curve        curve;
00842     HT_UV_Trim_Collection   collection;
00843 };
00844 
00845 
00846 #define NSF_HAS_NEGATIVE_WEIGHTS        (HT_NURBS_Surface_Flags)0x01
00847 #define NSF_COPLANAR_CONTROL_POINTS     (HT_NURBS_Surface_Flags)0x02
00848 
00849 struct HT_NURBS_Surface {
00850     HT_GHeader  h;
00851 
00852     HT_NURBS_Surface_Flags surface_flags;
00853     int n_u_vertices, n_v_vertices;
00854     int u_degree, v_degree;
00855     HT_Point *control_points; /* size is (n_u_vertices * n_v_vertices). Varies faster in v */
00856     float *weights; /* size is (n_u_vertices * n_v_vertices) */
00857     float *u_knots; /* size is (u_degree + n_u_vertices + 1) */
00858     float *v_knots; /* size is (v_degree + n_v_vertices + 1) */
00859 
00860     HT_UV_Trim *trimlist;
00861 
00862     /* above data are user-specified, below are derived */
00863     HT_Polyhedron *polyhedron;
00864     int checksum;  /* determines if any of the settings has changed since polyhedron generation */
00865 };
00866 
00867 
00868 #define MAX_EDGES_PER_POLYEDGE_CHUNK    128 /* the only independent variable here */
00869 #define MAX_POINTS_PER_POLYEDGE_CHUNK   (MAX_EDGES_PER_POLYEDGE_CHUNK + 1)
00870 #define MAX_INTS_PER_POLYEDGE_CHUNK     (MAX_POINTS_PER_POLYEDGE_CHUNK + \
00871                                          MAX_EDGES_PER_POLYEDGE_CHUNK)
00872 
00873 #define MAX_TRIANGLE_PAIRS_PER_TRISTRIP_CHUNK   64 /* the only independent variable here */
00874 #define MAX_TRIANGLES_PER_TRISTRIP_CHUNK        (2 * MAX_TRIANGLE_PAIRS_PER_TRISTRIP_CHUNK)
00875 #define MAX_POINTS_PER_TRISTRIP_CHUNK           (MAX_TRIANGLES_PER_TRISTRIP_CHUNK + 2)
00876 #define MAX_INTS_PER_TRISTRIP_CHUNK             (MAX_POINTS_PER_TRISTRIP_CHUNK + \
00877                                                  MAX_TRIANGLES_PER_TRISTRIP_CHUNK)
00878 
00879 #define PHEDRON_DEFINED TRUE
00880 #endif /* PHEDRON_DEFINED */
Main Index
HOOPS/3dGS I.M. Interface

     << Back      Full Index      Forward >>