~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/PEX5/ddpex/mi/include/miNurbs.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: miNurbs.h,v 1.4 2001/02/09 02:04:08 xorgcvs Exp $ */
 
2
 
 
3
/*****************************************************************
 
4
 
 
5
Copyright 1989,1990, 1991, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 
 
27
Copyright 1989,1990, 1991 by Sun Microsystems, Inc.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
31
Permission to use, copy, modify, and distribute this software and its 
 
32
documentation for any purpose and without fee is hereby granted, 
 
33
provided that the above copyright notice appear in all copies and that
 
34
both that copyright notice and this permission notice appear in 
 
35
supporting documentation, and that the names of Sun Microsystems,
 
36
and The Open Group, not be used in advertising or publicity 
 
37
pertaining to distribution of the software without specific, written 
 
38
prior permission.  
 
39
 
 
40
SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
 
41
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
 
42
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
 
43
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
44
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
45
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
46
SOFTWARE.
 
47
 
 
48
******************************************************************/
 
49
 
 
50
#ifndef MI_NURB_H
 
51
#define MI_NURB_H 1
 
52
 
 
53
#ifdef NDEBUG
 
54
extern unsigned         nurb_debug_flags;
 
55
#define NURB_DEBUG_FLAG(_b) (nurb_debug_flags & (_b))
 
56
#endif /* NDEBUG */
 
57
 
 
58
/* Nurb Debug Flags:
 
59
 *      0x01 (1)        Surface edge paths
 
60
 *      0x02 (2)        Surface iso curve paths
 
61
 *      0x04 (4)        Trimming data, tessellated and ordered
 
62
 *      0x08 (8)        Surface facet paths for untrimmed surfaces
 
63
 *      0x10 (16)       Trimmed surface polygons
 
64
 *      0x20 (32)       Surface facet paths
 
65
 *      0x40 (64)       Surface polygons before trimming
 
66
 *      0x80 (128)      Surface hollow-edge paths
 
67
 *      0x100 (256)     Surface grids
 
68
 *      0x200 (512)     Initial data
 
69
 */
 
70
 
 
71
#define MAXORD          10
 
72
#define MAXTCORD        6
 
73
 
 
74
#define XX      0
 
75
#define YY      1
 
76
#define ZZ      2
 
77
#define WW      3
 
78
 
 
79
#define MAX(a,b)        ( ((a) > (b)) ? (a) : (b) )
 
80
 
 
81
extern double   mi_nu_ptofd[MAXORD][MAXORD];
 
82
 
 
83
#define NURB_TRIM_DATA_INIT( _t ) \
 
84
  { \
 
85
    (_t).nloops = 0; \
 
86
    (_t).loops = (Nurb_trim_loop_rep *)NULL; \
 
87
    (_t).cur_vertex = 1; \
 
88
    (_t).vertices = (Nurb_param_point *)NULL; \
 
89
    (_t).ep_index = 0; \
 
90
    (_t).ep_list_size = 0; \
 
91
    (_t).ep_list = (Nurb_edge_point *)NULL; \
 
92
  }
 
93
 
 
94
#define NURB_SURF_STATE_INIT( _s ) \
 
95
  { \
 
96
    (_s)->reps.facets = 0; \
 
97
    (_s)->reps.edges = 0; \
 
98
    (_s)->reps.isocrvs = 0; \
 
99
    (_s)->reps.markers = 0; \
 
100
    (_s)->reps.hollow = 0; \
 
101
    (_s)->reps.grids = 0; \
 
102
    (_s)->reps.normals = 0; \
 
103
    (_s)->reps.trim_data = 0; \
 
104
    (_s)->grids.number = 0; \
 
105
    (_s)->grids.flags.normals = 0; \
 
106
    (_s)->grids.grids = (Nurb_grid *)NULL; \
 
107
    (_s)->ruknots = (ddFLOAT *)NULL; \
 
108
    (_s)->rvknots = (ddFLOAT *)NULL; \
 
109
    (_s)->facets = (miListHeader *)NULL; \
 
110
    (_s)->sofas = (miSOFASStruct *)NULL; \
 
111
    (_s)->edges = (miListHeader *)NULL; \
 
112
    (_s)->isocrvs = (miListHeader *)NULL; \
 
113
    (_s)->markers = (miListHeader *)NULL; \
 
114
    (_s)->hollow = (miListHeader *)NULL; \
 
115
    NURB_TRIM_DATA_INIT((_s)->trim_data); \
 
116
  }
 
117
 
 
118
#define NURB_INIT_RANGE_LIST( _r ) \
 
119
    (_r)->size = 0; \
 
120
    (_r)->number = 0; \
 
121
    (_r)->limits = (Nurb_limit *)NULL;
 
122
 
 
123
#define EXTENTS_OVERLAP( _ea, _eb ) \
 
124
  (!((_eb).umin > (_ea).umax || (_eb).umax < (_ea).umin || \
 
125
   (_eb).vmin > (_ea).vmax || (_eb).vmax < (_ea).vmin))
 
126
 
 
127
#define GET_TRIM_CURVE_TOLERANCE( _crv, _tolerance )            \
 
128
        switch ( (_crv)->curveApprox.approxMethod ) {           \
 
129
          case PEXApproxImpDep:                                 \
 
130
          case PEXApproxConstantBetweenKnots:                   \
 
131
                (_tolerance) = (_crv)->curveApprox.tolerance;   \
 
132
                break;                                          \
 
133
          default:                                              \
 
134
                (_tolerance) = 1.0;                             \
 
135
        }
 
136
 
 
137
#define ADD_POINT_TO_LIST( _l, _r, _op, _pt )                           \
 
138
if ((_l)) {                                                             \
 
139
  listofddPoint *pddlist;                                               \
 
140
  if ( (_op) == PT_MOVE ) {                                             \
 
141
    (_l)->numLists++;                                                   \
 
142
    MI_ALLOCLISTHEADER( (_l),                                           \
 
143
                        MI_ROUND_LISTHEADERCOUNT( (_l)->numLists ) );   \
 
144
  }                                                                     \
 
145
  pddlist = &((_l)->ddList[(_l)->numLists-1]);                          \
 
146
  pddlist->numPoints++;                                                 \
 
147
  if ( (_r) ) {                                                         \
 
148
    MI_ALLOCLISTOFDDPOINT( pddlist,                                     \
 
149
                           MI_ROUND_LISTHEADERCOUNT(pddlist->numPoints),\
 
150
                           sizeof(ddCoord4D) );                         \
 
151
    pddlist->pts.p4Dpt[pddlist->numPoints - 1] = *((ddCoord4D *)(_pt)); \
 
152
  } else {                                                              \
 
153
    MI_ALLOCLISTOFDDPOINT( pddlist,                                     \
 
154
                           MI_ROUND_LISTHEADERCOUNT(pddlist->numPoints),\
 
155
                           sizeof(ddCoord3D) );                         \
 
156
    pddlist->pts.p3Dpt[pddlist->numPoints - 1] = *((ddCoord3D *)(_pt)); \
 
157
  }                                                                     \
 
158
}
 
159
 
 
160
typedef enum {
 
161
    PT_NOP,
 
162
    PT_MOVE,
 
163
    PT_LINE,
 
164
    PT_MARKER
 
165
} Nurb_path_op;
 
166
 
 
167
typedef enum {
 
168
    NURB_SAME_CONTOUR = 0,
 
169
    NURB_NEW_CONTOUR = 1,
 
170
    NURB_NEW_FACET = 2
 
171
} Nurb_facet_op;
 
172
 
 
173
typedef struct {
 
174
    unsigned facets:    1;
 
175
    unsigned isocrvs:   1;
 
176
    unsigned edges:     1;
 
177
    unsigned markers:   1;      /* first order in u and v, use markers */
 
178
    unsigned hollow:    1;
 
179
    unsigned grids:     1;
 
180
    unsigned normals:   1;
 
181
    unsigned trim_data: 1;
 
182
} Nurb_rep_flags;
 
183
 
 
184
typedef struct {
 
185
    double      lmin;
 
186
    double      lmax;
 
187
} Nurb_limit;
 
188
 
 
189
typedef struct {
 
190
    int        size;
 
191
    int        number;
 
192
    Nurb_limit  *limits;
 
193
} Nurb_limitlst;
 
194
 
 
195
typedef struct {
 
196
    double      u;
 
197
    double      v;
 
198
} Nurb_param_point;
 
199
 
 
200
typedef struct {
 
201
    double      umin, umax;
 
202
    double      vmin, vmax;
 
203
} Nurb_param_limit;
 
204
 
 
205
typedef struct Nurb_trim_segment {
 
206
    int                         first, last;    /* indices in vertex list */
 
207
    int                         start, end;     /* effective limit of seg */
 
208
    int                         current;
 
209
    unsigned                    dir;
 
210
    ddULONG                     vis;
 
211
    Nurb_param_limit            extent;         /* of segment */
 
212
    struct Nurb_trim_segment    *next;
 
213
} Nurb_trim_segment;
 
214
 
 
215
typedef struct {
 
216
    Nurb_param_limit    extent; /* of loop */
 
217
    Nurb_trim_segment   *segs;  /* linked list of segments, NULL terminated */
 
218
} Nurb_trim_loop_rep;
 
219
 
 
220
typedef struct {
 
221
    int         flags;
 
222
    int         count;  /* of rectangles this point is part of */
 
223
    double      u, v;
 
224
    ddCoord4D   pt;
 
225
    ddVector3D  normal;
 
226
    int         next, prev, branch;
 
227
} Nurb_edge_point;
 
228
 
 
229
typedef struct {
 
230
    Nurb_param_point            *vertices;      /* of tessellated curves */
 
231
    int                         cur_vertex;     /* index of current vertex */
 
232
    int                         nloops;
 
233
    Nurb_trim_loop_rep          *loops;         /* array of representations */
 
234
    Nurb_edge_point             *ep_list;       /* polygon edge points */
 
235
    int                         ep_index;       /* index of current one */
 
236
    int                         ep_list_size;   /* # allocated entries */
 
237
} Nurb_trim_data;
 
238
 
 
239
typedef struct {
 
240
    Nurb_edge_point     *pts;
 
241
    int                 nu, nv;
 
242
    Nurb_param_limit    extent;
 
243
} Nurb_grid;
 
244
 
 
245
typedef struct {
 
246
    int         number;
 
247
    struct {
 
248
        unsigned        normals;
 
249
    }           flags;
 
250
    Nurb_grid           *grids;
 
251
} Nurb_gridlst;
 
252
 
 
253
typedef struct {
 
254
    int                 gitype;
 
255
    int                 isocount[2];
 
256
    int                 approx_type;
 
257
    ddFLOAT             approx_value[2];
 
258
    Nurb_param_limit    range;
 
259
    Nurb_param_limit    param_limits;
 
260
    Nurb_rep_flags      reps;
 
261
    ddFLOAT             *ruknots;
 
262
    ddFLOAT             *rvknots;
 
263
    Nurb_gridlst        grids;
 
264
    Nurb_trim_data      trim_data;
 
265
    Nurb_param_point    corners[5];
 
266
    Nurb_trim_segment   edge_segs[4];
 
267
    miListHeader        *facets;
 
268
    miSOFASStruct       *sofas;
 
269
    miListHeader        *edges;
 
270
    miListHeader        *isocrvs;
 
271
    miListHeader        *markers;
 
272
    miListHeader        *hollow;
 
273
} Nurb_surf_state;
 
274
 
 
275
#endif /* MI_NURB_H */