ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

quilt.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  * quilt.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/quilt.cc,v 1.1 2004/02/02 16:39:12 navaraf Exp $
00040  */
00041 
00042 #include "glimports.h"
00043 #include "mystdio.h"
00044 #include "myassert.h"
00045 #include "quilt.h"
00046 #include "backend.h"
00047 #include "mapdesc.h"
00048 #include "flist.h"
00049 #include "knotvector.h"
00050 #include "patchlist.h"
00051 #include "math.h"     //fglu_abs()
00052 #include "simplemath.h" //min()
00053 
00054 /* local preprocessor definitions */
00055 #define DEF_PATCH_STEPSIZE  .4
00056 #define fsizeof(x)      (sizeof(x)/sizeof(REAL))
00057 
00058 
00059 Quilt::Quilt( Mapdesc *_mapdesc )
00060 {
00061     mapdesc = _mapdesc;
00062 }
00063  
00064 void
00065 Quilt::deleteMe( Pool& p )
00066 {
00067     for( Quiltspec *q=qspec; q != eqspec; q++ ) {
00068 #if 1
00069     if( q->breakpoints) delete[] q->breakpoints;  q->breakpoints = 0;
00070 #else
00071     if( q->breakpoints) {
00072        delete[] q->breakpoints;  
00073        q->breakpoints = 0;
00074 printf("in here\n");
00075         }
00076 #endif
00077     }
00078     if( cpts ) delete[] cpts;  
00079     cpts = 0;
00080     PooledObj::deleteMe( p );
00081 }
00082 
00083 void
00084 Quilt::show( void )
00085 {
00086 #ifndef NDEBUG
00087     int nc = mapdesc->getNcoords();
00088     REAL *ps  = cpts; 
00089     ps += qspec[0].offset;
00090     ps += qspec[1].offset;
00091     for( int i=0; i!= qspec[0].order * qspec[0].width; i++ ) {
00092     for( int j = 0; j!= qspec[1].order * qspec[1].width; j++ ) {
00093         for( int k=0; k < nc; k++ )
00094         dprintf(  "%g ", ps[i*qspec[0].stride + j*qspec[1].stride + k] );
00095         dprintf(  "\n" );
00096     }
00097     dprintf(  "\n" );
00098     }
00099     dprintf( "\n" );
00100 #endif
00101 }
00102 
00103 /*--------------------------------------------------------------------------
00104  * Quilt::select - find which map in each quilt contains the points
00105  *          pta and ptb with pta[i] < ptb[i]
00106  *--------------------------------------------------------------------------
00107  */
00108 
00109 void
00110 Quilt::select( REAL *pta, REAL *ptb )
00111 {
00112     int dim = eqspec - qspec; 
00113     int i, j;
00114     for( i=0; i<dim; i++) {
00115     for( j=qspec[i].width-1; j>=0; j-- )
00116         if( (qspec[i].breakpoints[j] <= pta[i]   ) &&
00117             (ptb[i] <= qspec[i].breakpoints[j+1] ) ) 
00118          break;
00119     assert( j != -1 ); 
00120     qspec[i].index = j;
00121     }
00122 }
00123 
00124 void 
00125 Quilt::download( Backend &backend )
00126 {
00127     if( getDimension() == 2 ) {
00128     REAL *ps  = cpts; 
00129     ps += qspec[0].offset;
00130     ps += qspec[1].offset;
00131     ps += qspec[0].index * qspec[0].order * qspec[0].stride;
00132     ps += qspec[1].index * qspec[1].order * qspec[1].stride;
00133     backend.surfpts( mapdesc->getType(), ps, 
00134           qspec[0].stride,
00135           qspec[1].stride,
00136           qspec[0].order,
00137           qspec[1].order,
00138           qspec[0].breakpoints[qspec[0].index],
00139           qspec[0].breakpoints[qspec[0].index+1],
00140           qspec[1].breakpoints[qspec[1].index],
00141           qspec[1].breakpoints[qspec[1].index+1] );
00142     } else {
00143     REAL *ps  = cpts; 
00144     ps += qspec[0].offset;
00145     ps += qspec[0].index * qspec[0].order * qspec[0].stride;
00146     backend.curvpts( mapdesc->getType(), ps, 
00147               qspec[0].stride,
00148               qspec[0].order,
00149               qspec[0].breakpoints[qspec[0].index],
00150               qspec[0].breakpoints[qspec[0].index+1] );
00151     }
00152 }
00153 
00154 /*--------------------------------------------------------------------------
00155  * Quilt::downloadAll - download each map that contains the current patch
00156  *--------------------------------------------------------------------------
00157  */
00158 
00159 void
00160 Quilt::downloadAll( REAL *pta, REAL *ptb, Backend &backend )
00161 {
00162     for( Quilt *m = this; m; m=m->next ) {
00163     m->select( pta, ptb );
00164     m->download( backend );
00165     }
00166 }
00167 
00168 /*--------------------------------------------------------------------------
00169   * Quilt::isCulled - determine if an entire quilt is trivially rejected.
00170  *--------------------------------------------------------------------------
00171  */
00172 
00173 int
00174 Quilt::isCulled( void )
00175 {
00176     if( mapdesc->isCulling() )
00177     return mapdesc->xformAndCullCheck( cpts + qspec[0].offset + qspec[1].offset,
00178             qspec[0].order * qspec[0].width, qspec[0].stride, 
00179             qspec[1].order * qspec[1].width, qspec[1].stride );
00180     else
00181     return CULL_ACCEPT;
00182 }
00183 
00184 /*---------------------------------------------------------------------------
00185  * Quilt::getRange - retrieve the valid paramater range of a set of quilts
00186  *---------------------------------------------------------------------------
00187  */
00188 void
00189 Quilt::getRange( REAL *from, REAL *to, Flist& slist, Flist &tlist )
00190 {
00191     getRange( from, to, 0, slist );
00192     getRange( from, to, 1, tlist );
00193 }
00194 
00195 /*---------------------------------------------------------------------------
00196  * Quilt::getRange - retrieve the valid paramater range of a set of quilts
00197  *---------------------------------------------------------------------------
00198  */
00199 void
00200 Quilt::getRange( REAL *from, REAL *to, int i, Flist &list )
00201 {
00202     Quilt *maps = this;
00203     from[i] = maps->qspec[i].breakpoints[0];
00204     to[i]   = maps->qspec[i].breakpoints[maps->qspec[i].width];
00205     int maxpts = 0;
00206     Quilt_ptr m;    
00207     for( m=maps; m; m=m->next ) {
00208     if( m->qspec[i].breakpoints[0] > from[i] ) 
00209         from[i] = m->qspec[i].breakpoints[0]; 
00210     if( m->qspec[i].breakpoints[m->qspec[i].width] < to[i] ) 
00211         to[i] = m->qspec[i].breakpoints[m->qspec[i].width]; 
00212     maxpts += m->qspec[i].width + 1;
00213     }
00214 
00215     list.grow( maxpts );
00216 
00217     for( m=maps; m; m=m->next )
00218     for( int j=0; j<=m->qspec[i].width; j++ ) {
00219         list.add( m->qspec[i].breakpoints[j] );
00220     }
00221 
00222     list.filter( );
00223     list.taper( from[i], to[i] );
00224 }
00225 
00226 void
00227 Quilt::getRange( REAL *from, REAL *to, Flist& slist )
00228 {
00229     getRange( from, to, 0, slist );
00230 }
00231 
00232 void
00233 Quilt::findRates( Flist& slist, Flist& tlist, REAL rate[2] )
00234 {
00235     findSampleRates( slist, tlist );
00236     rate[0] = qspec[0].step_size;
00237     rate[1] = qspec[1].step_size;
00238 
00239     for( Quilt *q = next; q; q = q->next ) {
00240     q->findSampleRates( slist, tlist );
00241     if( q->qspec[0].step_size < rate[0] ) 
00242         rate[0] = q->qspec[0].step_size;
00243     if( q->qspec[1].step_size < rate[1] ) 
00244         rate[1] = q->qspec[1].step_size;
00245     }
00246 }
00247 
00248 void
00249 Quilt::findSampleRates( Flist& slist, Flist& tlist )
00250 {
00251     qspec[0].step_size = DEF_PATCH_STEPSIZE * 
00252         (qspec[0].breakpoints[qspec[0].width] - qspec[0].breakpoints[0]); 
00253     qspec[1].step_size = DEF_PATCH_STEPSIZE * 
00254         (qspec[1].breakpoints[qspec[1].width] - qspec[1].breakpoints[0]); 
00255  
00256     for( int i = slist.start; i < slist.end-1; i++ ) {
00257     for( int j = tlist.start; j < tlist.end-1; j++ ) {
00258 
00259         REAL pta[2], ptb[2];
00260         pta[0] = slist.pts[i];
00261         ptb[0] = slist.pts[i+1];
00262         pta[1] = tlist.pts[j];
00263         ptb[1] = tlist.pts[j+1];
00264         Patchlist patchlist( this, pta, ptb );
00265         patchlist.getstepsize();
00266         
00267         {
00268         float edge_len_s = min(glu_abs(ptb[0]-pta[0]),1.0);
00269         float edge_len_t = min(glu_abs(ptb[1]-pta[1]),1.0);
00270 
00271         if( patchlist.getStepsize(0)/edge_len_s < qspec[0].step_size ) 
00272            qspec[0].step_size = patchlist.getStepsize(0)/edge_len_s;
00273         if( patchlist.getStepsize(1)/edge_len_t < qspec[1].step_size ) 
00274           qspec[1].step_size = patchlist.getStepsize(1)/edge_len_t;
00275         }
00276     }
00277     }
00278 }

Generated on Wed May 23 2012 04:21:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.