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:
10 ** http://oss.sgi.com/projects/FreeB
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.
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.
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.
34 ** $Date$ $Revision: 1.1 $
37 ** $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/interface/incurveeval.cc,v 1.1 2004/02/02 16:39:08 navaraf Exp $
43 #include "glcurveval.h"
47 *compute the Bezier polynomials C[n,j](v) for all j at v with
48 *return values stored in coeff[], where
49 * C[n,j](v) = (n,j) * v^j * (1-v)^(n-j),
53 *coeff : coeff[j]=C[n,j](v), this array store the returned values.
54 *The algorithm is a recursive scheme:
56 * C[n,j](v) = (1-v)*C[n-1,j](v) + v*C[n-1,j-1](v), n>=1
57 *This code is copied from opengl/soft/so_eval.c:PreEvaluate
59 void OpenGLCurveEvaluator::inPreEvaluate(int order
, REAL vprime
, REAL
*coeff
)
67 * Compute orders 1 and 2 outright, and set coeff[0], coeff[1] to
68 * their i==1 loop values to avoid the initialization and the i==1 loop.
75 oneMinusvprime
= 1-vprime
;
76 coeff
[0] = oneMinusvprime
;
78 if (order
== 2) return;
80 for (i
= 2; i
< order
; i
++) {
81 oldval
= coeff
[0] * vprime
;
82 coeff
[0] = oneMinusvprime
* coeff
[0];
83 for (j
= 1; j
< i
; j
++) {
85 oldval
= coeff
[j
] * vprime
;
86 coeff
[j
] = temp
+ oneMinusvprime
* coeff
[j
];
92 void OpenGLCurveEvaluator::inMap1f(int which
, //0: vert, 1: norm, 2: color, 3: tex
101 curveEvalMachine
*temp_em
;
105 temp_em
= &em_vertex
;
109 temp_em
= &em_normal
;
117 temp_em
= &em_texcoord
;
121 REAL
*data
= temp_em
->ctlpoints
;
122 temp_em
->uprime
= -1; //initialized
124 temp_em
->u1
= ulower
;
125 temp_em
->u2
= uupper
;
126 temp_em
->ustride
= ustride
;
127 temp_em
->uorder
= uorder
;
128 /*copy the control points*/
129 for(i
=0; i
<uorder
; i
++){
131 data
[x
] = ctlpoints
[x
];
133 ctlpoints
+= ustride
;
138 void OpenGLCurveEvaluator::inDoDomain1(curveEvalMachine
*em
, REAL u
, REAL
*retPoint
)
146 the_uprime
= (u
-em
->u1
) / (em
->u2
-em
->u1
);
147 /*use already cached values if possible*/
148 if(em
->uprime
!= the_uprime
){
149 inPreEvaluate(em
->uorder
, the_uprime
, em
->ucoeff
);
150 em
->uprime
= the_uprime
;
153 for(j
=0; j
<em
->k
; j
++){
154 data
= em
->ctlpoints
+j
;
156 for(row
=0; row
<em
->uorder
; row
++)
158 retPoint
[j
] += em
->ucoeff
[row
] * (*data
);
164 void OpenGLCurveEvaluator::inDoEvalCoord1(REAL u
)
169 REAL temp_texcoord
[4];
170 if(texcoord_flag
) //there is a texture map
172 inDoDomain1(&em_texcoord
, u
, temp_texcoord
);
173 texcoordCallBack(temp_texcoord
, userData
);
176 printf("color_flag = %i\n", color_flag
);
178 if(color_flag
) //there is a color map
180 inDoDomain1(&em_color
, u
, temp_color
);
181 colorCallBack(temp_color
, userData
);
183 if(normal_flag
) //there is a normal map
185 inDoDomain1(&em_normal
, u
, temp_normal
);
186 normalCallBack(temp_normal
, userData
);
190 inDoDomain1(&em_vertex
, u
, temp_vertex
);
191 vertexCallBack(temp_vertex
, userData
);
195 void OpenGLCurveEvaluator::inMapMesh1f(int umin
, int umax
)
199 if(global_grid_nu
== 0)
200 return; //no points to output
201 du
= (global_grid_u1
- global_grid_u0
) / (REAL
) global_grid_nu
;
203 for(i
=umin
; i
<= umax
; i
++){
204 u
= (i
==global_grid_nu
)? global_grid_u1
: global_grid_u0
+ i
*du
;