reshuffling of dlls
[reactos.git] / reactos / dll / glu32 / libnurbs / internals / subdivider.h
1 /*
2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
9 **
10 ** http://oss.sgi.com/projects/FreeB
11 **
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17 **
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
23 **
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
33 */
34
35 /*
36 * subdivider.h
37 *
38 * $Date$ $Revision: 1.1 $
39 * $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/internals/subdivider.h,v 1.1 2004/02/02 16:39:12 navaraf Exp $
40 */
41
42 #ifndef __glusubdivider_h_
43 #define __glusubdivider_h_
44
45 #include "mysetjmp.h"
46 #include "bin.h"
47 #include "flist.h"
48 #include "slicer.h"
49 #include "arctess.h"
50 #include "trimvertex.h"
51 #include "trimvertpool.h"
52
53 class Arc;
54 class Pool;
55 class Renderhints;
56 class Quilt;
57 class Patchlist;
58 class Curvelist;
59 struct JumpBuffer;
60
61 class Subdivider {
62 public:
63 Subdivider( Renderhints&, Backend& );
64 ~Subdivider( void );
65 void clear( void );
66
67 void beginTrims( void ) {}
68 void beginLoop( void );
69 void addArc( REAL *, Quilt *, long );
70 void addArc( int, TrimVertex *, long );
71 void endLoop( void ) {}
72 void endTrims( void ) {}
73
74 void beginQuilts( void );
75 void addQuilt( Quilt * );
76 void endQuilts( void ) {}
77
78 void drawCurves( void );
79 void drawSurfaces( long );
80
81 int ccwTurn_sl( Arc_ptr, Arc_ptr );
82 int ccwTurn_sr( Arc_ptr , Arc_ptr );
83 int ccwTurn_tl( Arc_ptr , Arc_ptr );
84 int ccwTurn_tr( Arc_ptr , Arc_ptr );
85
86 void setJumpbuffer( JumpBuffer * );
87
88 void set_domain_distance_u_rate(REAL u_rate)
89 {
90 domain_distance_u_rate = u_rate;
91 }
92 void set_domain_distance_v_rate(REAL v_rate)
93 {
94 domain_distance_v_rate = v_rate;
95 }
96 void set_is_domain_distance_sampling(int flag)
97 {
98 is_domain_distance_sampling = flag;
99 }
100
101 private:
102 void classify_headonleft_s( Bin &, Bin &, Bin &, REAL );
103 void classify_tailonleft_s( Bin &, Bin &, Bin &, REAL );
104 void classify_headonright_s( Bin &, Bin &, Bin &, REAL );
105 void classify_tailonright_s( Bin &, Bin &, Bin &, REAL );
106 void classify_headonleft_t( Bin &, Bin &, Bin &, REAL );
107 void classify_tailonleft_t( Bin &, Bin &, Bin &, REAL );
108 void classify_headonright_t( Bin &, Bin &, Bin &, REAL );
109 void classify_tailonright_t( Bin &, Bin &, Bin &, REAL );
110
111 enum dir { down, same, up, none };
112 void tessellate( Arc_ptr, REAL );
113 void monotonize( Arc_ptr , Bin & );
114 int isMonotone( Arc_ptr );
115 int decompose( Bin &, REAL );
116
117
118 Slicer slicer;
119 ArcTessellator arctessellator;
120 Pool arcpool;
121 Pool bezierarcpool;
122 Pool pwlarcpool;
123 TrimVertexPool trimvertexpool;
124
125 JumpBuffer* jumpbuffer;
126 Renderhints& renderhints;
127 Backend& backend;
128
129 Bin initialbin;
130 Arc_ptr pjarc;
131 int s_index;
132 int t_index;
133 Quilt * qlist;
134 Flist spbrkpts;
135 Flist tpbrkpts;
136 Flist smbrkpts;
137 Flist tmbrkpts;
138 REAL stepsizes[4];
139 int showDegenerate;
140 int isArcTypeBezier;
141
142 void samplingSplit( Curvelist&, int );
143
144 void subdivideInS( Bin& );
145 void splitInS( Bin&, int, int );
146 void splitInT( Bin&, int, int );
147 void samplingSplit( Bin&, Patchlist&, int, int );
148 void nonSamplingSplit( Bin&, Patchlist&, int, int );
149 void tessellation( Bin&, Patchlist& );
150 void monosplitInS( Bin&, int, int );
151 void monosplitInT( Bin&, int, int );
152
153 void outline( Bin & );
154 void freejarcs( Bin & );
155 void render( Bin & );
156 void split( Bin &, Bin &, Bin &, int, REAL );
157 void tessellate( Bin &, REAL, REAL, REAL, REAL );
158
159 inline void setDegenerate( void ) { showDegenerate = 1; }
160 inline void setNonDegenerate( void ) { showDegenerate = 0; }
161 inline int showingDegenerate( void ) { return showDegenerate; }
162 inline void setArcTypeBezier( void ) { isArcTypeBezier = 1; }
163 inline void setArcTypePwl( void ) { isArcTypeBezier = 0; }
164 inline int isBezierArcType( void ) { return isArcTypeBezier; }
165
166 void makeBorderTrim( const REAL *, const REAL * );
167 void split( Bin &, int, const REAL *, int, int );
168 void partition( Bin &, Bin &, Bin &, Bin &, Bin &, int, REAL );
169 void findIrregularS( Bin & );
170 void findIrregularT( Bin & );
171
172
173 inline int bbox( TrimVertex *, TrimVertex *, TrimVertex *, int );
174 static int bbox( REAL, REAL, REAL, REAL, REAL, REAL );
175 static int ccw( TrimVertex *, TrimVertex *, TrimVertex * );
176 void join_s( Bin &, Bin &, Arc_ptr, Arc_ptr );
177 void join_t( Bin &, Bin &, Arc_ptr , Arc_ptr );
178 int arc_split( Arc_ptr , int, REAL, int );
179 void check_s( Arc_ptr , Arc_ptr );
180 void check_t( Arc_ptr , Arc_ptr );
181 inline void link( Arc_ptr , Arc_ptr , Arc_ptr , Arc_ptr );
182 inline void simple_link( Arc_ptr , Arc_ptr );
183
184 Bin* makePatchBoundary( const REAL *from, const REAL *to );
185
186 /*in domain distance method, the tessellation is controled by two numbers:
187 *GLU_U_STEP: number of u-segments per unit u length of domain
188 *GLU_V_STEP: number of v-segments per unit v length of domain
189 *These two numbers are normally stored in mapdesc->maxs(t)rate.
190 *I (ZL) put these two numbers here so that I can optimize the untrimmed
191 *case in the case of domain distance sampling.
192 *These two numbers are set by set_domain_distance_u_rate() and ..._v_..().
193 */
194 REAL domain_distance_u_rate;
195 REAL domain_distance_v_rate;
196 int is_domain_distance_sampling;
197 };
198
199 inline void
200 Subdivider::beginLoop( void )
201 {
202 pjarc = 0;
203 }
204
205
206 #endif /* __glusubdivider_h_ */