Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmapdescv.cc
Go to the documentation of this file.
00001 /* 00002 ** License Applicability. Except to the extent portions of this file are 00003 ** made subject to an alternative license as permitted in the SGI Free 00004 ** Software License B, Version 1.1 (the "License"), the contents of this 00005 ** file are subject only to the provisions of the License. You may not use 00006 ** this file except in compliance with the License. You may obtain a copy 00007 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 00008 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: 00009 ** 00010 ** http://oss.sgi.com/projects/FreeB 00011 ** 00012 ** Note that, as provided in the License, the Software is distributed on an 00013 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS 00014 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND 00015 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A 00016 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 00017 ** 00018 ** Original Code. The Original Code is: OpenGL Sample Implementation, 00019 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, 00020 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. 00021 ** Copyright in any portions created by third parties is as indicated 00022 ** elsewhere herein. All Rights Reserved. 00023 ** 00024 ** Additional Notice Provisions: The application programming interfaces 00025 ** established by SGI in conjunction with the Original Code are The 00026 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released 00027 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version 00028 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X 00029 ** Window System(R) (Version 1.3), released October 19, 1998. This software 00030 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation 00031 ** published by SGI, but has not been independently verified as being 00032 ** compliant with the OpenGL(R) version 1.2.1 Specification. 00033 */ 00034 00035 /* 00036 * mapdescv.c++ 00037 * 00038 * $Date: 2006-03-12 00:07:02 +0000 (Sun, 12 Mar 2006) $ $Revision: 1.1 $ 00039 * $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/internals/mapdescv.cc,v 1.1 2004/02/02 16:39:11 navaraf Exp $ 00040 */ 00041 00042 #include "glimports.h" 00043 #include "mystdio.h" 00044 #include "myassert.h" 00045 #include "mystring.h" 00046 #include "mymath.h" 00047 #include "nurbsconsts.h" 00048 #include "mapdesc.h" 00049 00050 /*-------------------------------------------------------------------------- 00051 * calcPartialVelocity - calculate maximum magnitude of a given partial 00052 * derivative 00053 *-------------------------------------------------------------------------- 00054 */ 00055 REAL 00056 Mapdesc::calcPartialVelocity ( 00057 REAL *p, 00058 int stride, 00059 int ncols, 00060 int partial, 00061 REAL range ) 00062 { 00063 REAL tmp[MAXORDER][MAXCOORDS]; 00064 REAL mag[MAXORDER]; 00065 00066 assert( ncols <= MAXORDER ); 00067 00068 int j, k, t; 00069 // copy inhomogeneous control points into temporary array 00070 for( j=0; j != ncols; j++ ) 00071 for( k=0; k != inhcoords; k++ ) 00072 tmp[j][k] = p[j*stride + k]; 00073 00074 for( t=0; t != partial; t++ ) 00075 for( j=0; j != ncols-t-1; j++ ) 00076 for( k=0; k != inhcoords; k++ ) 00077 tmp[j][k] = tmp[j+1][k] - tmp[j][k]; 00078 00079 // compute magnitude and store in mag array 00080 for( j=0; j != ncols-partial; j++ ) { 00081 mag[j] = 0.0; 00082 for( k=0; k != inhcoords; k++ ) 00083 mag[j] += tmp[j][k] * tmp[j][k]; 00084 } 00085 00086 // compute scale factor 00087 REAL fac = 1; 00088 REAL invt = 1.0 / range; 00089 for( t = ncols-1; t != ncols-1-partial; t-- ) 00090 fac *= t * invt; 00091 00092 // compute max magnitude of all entries in array 00093 REAL max = 0.0; 00094 for( j=0; j != ncols-partial; j++ ) 00095 if( mag[j] > max ) max = mag[j]; 00096 max = fac * sqrtf( (float) max ); 00097 00098 return max; 00099 } 00100 00101 /*-------------------------------------------------------------------------- 00102 * calcPartialVelocity - calculate maximum magnitude of a given partial 00103 * derivative 00104 *-------------------------------------------------------------------------- 00105 */ 00106 REAL 00107 Mapdesc::calcPartialVelocity ( 00108 REAL *dist, 00109 REAL *p, 00110 int rstride, 00111 int cstride, 00112 int nrows, 00113 int ncols, 00114 int spartial, 00115 int tpartial, 00116 REAL srange, 00117 REAL trange, 00118 int side ) 00119 { 00120 REAL tmp[MAXORDER][MAXORDER][MAXCOORDS]; 00121 REAL mag[MAXORDER][MAXORDER]; 00122 00123 assert( nrows <= MAXORDER ); 00124 assert( ncols <= MAXORDER ); 00125 00126 REAL *tp = &tmp[0][0][0]; 00127 REAL *mp = &mag[0][0]; 00128 const int istride = sizeof( tmp[0]) / sizeof( tmp[0][0][0] ); 00129 const int jstride = sizeof( tmp[0][0]) / sizeof( tmp[0][0][0] ); 00130 const int mistride = sizeof( mag[0]) / sizeof( mag[0][0] ); 00131 const int mjstride = sizeof( mag[0][0]) / sizeof( mag[0][0] ); 00132 const int idist = nrows * istride; 00133 const int jdist = ncols * jstride; 00134 const int id = idist - spartial * istride; 00135 const int jd = jdist - tpartial * jstride; 00136 00137 { 00138 // copy control points 00139 REAL *ti = tp; 00140 REAL *qi = p; 00141 REAL *til = tp + idist; 00142 for( ; ti != til; ) { 00143 REAL *tj = ti; 00144 REAL *qj = qi; 00145 REAL *tjl = ti + jdist; 00146 for( ; tj != tjl; ) { 00147 for( int k=0; k != inhcoords; k++ ) { 00148 tj[k] = qj[k]; 00149 } 00150 tj += jstride; 00151 qj += cstride; 00152 } 00153 ti += istride; 00154 qi += rstride; 00155 } 00156 } 00157 00158 { 00159 // compute (s)-partial derivative control points 00160 REAL *til = tp + idist - istride; 00161 const REAL *till = til - ( spartial * istride ); 00162 for( ; til != till; til -= istride ) 00163 for( REAL *ti = tp; ti != til; ti += istride ) 00164 for( REAL *tj = ti, *tjl = tj + jdist; tj != tjl; tj += jstride ) 00165 for( int k=0; k != inhcoords; k++ ) 00166 tj[k] = tj[k+istride] - tj[k]; 00167 } 00168 00169 { 00170 // compute (s,t)-partial derivative control points 00171 REAL *tjl = tp + jdist - jstride; 00172 const REAL *tjll = tjl - ( tpartial * jstride ); 00173 for( ; tjl != tjll; tjl -= jstride ) 00174 for( REAL *tj = tp; tj != tjl; tj += jstride ) 00175 for( REAL *ti = tj, *til = ti + id; ti != til; ti += istride ) 00176 for( int k=0; k != inhcoords; k++ ) 00177 ti[k] = ti[k+jstride] - ti[k]; 00178 00179 } 00180 00181 REAL max = 0.0; 00182 { 00183 // compute magnitude and store in mag array 00184 memset( (void *) mp, 0, sizeof( mag ) ); 00185 for( REAL *ti = tp, *mi = mp, *til = tp + id; ti != til; ti += istride, mi += mistride ) 00186 for( REAL *tj = ti, *mj = mi, *tjl = ti + jd; tj != tjl; tj += jstride, mj += mjstride ) { 00187 for( int k=0; k != inhcoords; k++ ) 00188 *mj += tj[k] * tj[k]; 00189 if( *mj > max ) max = *mj; 00190 } 00191 00192 } 00193 00194 int i, j; 00195 00196 // compute scale factor 00197 REAL fac = 1.0; 00198 { 00199 REAL invs = 1.0 / srange; 00200 REAL invt = 1.0 / trange; 00201 for( int s = nrows-1, slast = s-spartial; s != slast; s-- ) 00202 fac *= s * invs; 00203 for( int t = ncols-1, tlast = t-tpartial; t != tlast; t-- ) 00204 fac *= t * invt; 00205 } 00206 00207 if( side == 0 ) { 00208 // compute max magnitude of first and last column 00209 dist[0] = 0.0; 00210 dist[1] = 0.0; 00211 for( i=0; i != nrows-spartial; i++ ) { 00212 j = 0; 00213 if( mag[i][j] > dist[0] ) dist[0] = mag[i][j]; 00214 00215 j = ncols-tpartial-1; 00216 if( mag[i][j] > dist[1] ) dist[1] = mag[i][j]; 00217 } 00218 dist[0] = fac * sqrtf( dist[0] ); 00219 dist[1] = fac * sqrtf( dist[1] ); 00220 } else if( side == 1 ) { 00221 // compute max magnitude of first and last row 00222 dist[0] = 0.0; 00223 dist[1] = 0.0; 00224 for( j=0; j != ncols-tpartial; j++ ) { 00225 i = 0; 00226 if( mag[i][j] > dist[0] ) dist[0] = mag[i][j]; 00227 00228 i = nrows-spartial-1; 00229 if( mag[i][j] > dist[1] ) dist[1] = mag[i][j]; 00230 } 00231 dist[0] = fac * sqrtf( dist[0] ); 00232 dist[1] = fac * sqrtf( dist[1] ); 00233 } 00234 00235 max = fac * sqrtf( (float) max ); 00236 00237 return max; 00238 } 00239 Generated on Sun May 27 2012 04:23:40 for ReactOS by
1.7.6.1
|