Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentrimline.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 * trimline.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/trimline.cc,v 1.1 2004/02/02 16:39:13 navaraf Exp $ 00040 */ 00041 00042 #include "glimports.h" 00043 #include "myassert.h" 00044 #include "mystdio.h" 00045 #include "trimline.h" 00046 #include "backend.h" 00047 00048 Trimline::Trimline() 00049 { 00050 size = 0; pts = 0; numverts = 0; 00051 tinterp = &t; binterp = &b; 00052 } 00053 00054 Trimline::~Trimline() 00055 { 00056 if( pts ) delete[] pts; 00057 } 00058 00059 void 00060 Trimline::init( TrimVertex *v ) 00061 { 00062 reset(); 00063 grow(1); 00064 append(v); 00065 } 00066 00067 inline void 00068 Trimline::grow( long npts ) 00069 { 00070 if( size < npts ) { 00071 size = 2 * npts; 00072 if( pts ) delete[] pts; 00073 pts = new TrimVertex_p[size]; 00074 } 00075 } 00076 00077 inline void 00078 Trimline::append( TrimVertex *v ) 00079 { 00080 assert( numverts != size ); 00081 pts[numverts++] = v; 00082 } 00083 00084 void 00085 Trimline::init( long npts, Arc_ptr jarc, long last ) 00086 { 00087 jarcl.init( jarc, 0, last ); 00088 grow( npts + 2 ); 00089 } 00090 00091 inline void 00092 Trimline::swap() 00093 { 00094 TrimVertex *tmp=tinterp; 00095 tinterp=binterp; 00096 binterp=tmp; 00097 } 00098 00099 void 00100 Trimline::getNextPt() 00101 { 00102 *binterp = *jarcl.getnextpt(); 00103 } 00104 00105 void 00106 Trimline::getPrevPt() 00107 { 00108 *binterp = *jarcl.getprevpt(); 00109 } 00110 00111 /*---------------------------------------------------------------------- 00112 * getNextPts - make arrays of pointers to trim points on left and right 00113 * hulls of trim strip. 00114 *---------------------------------------------------------------------- 00115 */ 00116 void 00117 Trimline::getNextPts( REAL vval, Backend& backend ) 00118 { 00119 reset(); swap(); append( tinterp ); 00120 assert( tinterp->param[1] >= vval ); 00121 00122 register TrimVertex *p; 00123 for( p=jarcl.getnextpt() ; p->param[1] >= vval; p=jarcl.getnextpt() ) { 00124 append( p ); 00125 } 00126 00127 /* compute and copy pointer to final point on left hull */ 00128 if( interpvert( last(), p, binterp, vval ) ) { 00129 binterp->nuid = p->nuid; 00130 backend.triangle( p, binterp, last() ); 00131 append( binterp ); 00132 } 00133 jarcl.reverse(); 00134 (void) jarcl.getprevpt(); /* reset jarcl to proper position */ 00135 jarcl.reverse(); 00136 } 00137 00138 void 00139 Trimline::getPrevPts( REAL vval, Backend& backend ) 00140 { 00141 reset(); swap(); append( tinterp ); 00142 assert( tinterp->param[1] >= vval ); 00143 00144 register TrimVertex *q; 00145 for( q=jarcl.getprevpt(); q->param[1] >= vval; q=jarcl.getprevpt() ) { 00146 append( q ); 00147 } 00148 00149 /* compute and copy pointer to final point on right hull */ 00150 if( interpvert( q, last(), binterp, vval ) ) { 00151 binterp->nuid = q->nuid; 00152 backend.triangle( last(), binterp, q ); 00153 append( binterp ); 00154 } 00155 jarcl.reverse(); 00156 (void) jarcl.getnextpt(); /* reset jarcl to proper position */ 00157 jarcl.reverse(); 00158 } 00159 00160 void 00161 Trimline::getNextPts( Arc_ptr botarc ) 00162 { 00163 reset(); swap(); append( tinterp ); 00164 00165 PwlArc *lastpwl = botarc->prev->pwlArc; 00166 TrimVertex *lastpt1 = &lastpwl->pts[lastpwl->npts-1]; 00167 TrimVertex *lastpt2 = botarc->pwlArc->pts; 00168 00169 register TrimVertex *p = jarcl.getnextpt(); 00170 for( append( p ); p != lastpt2; append( p ) ) { 00171 assert( p != lastpt1 ); 00172 p = jarcl.getnextpt(); 00173 } 00174 } 00175 00176 void 00177 Trimline::getPrevPts( Arc_ptr botarc ) 00178 { 00179 reset(); swap(); append( tinterp ); 00180 00181 PwlArc *lastpwl = botarc->prev->pwlArc; 00182 TrimVertex *lastpt1 = &lastpwl->pts[lastpwl->npts-1]; 00183 TrimVertex *lastpt2 = botarc->pwlArc->pts; 00184 00185 register TrimVertex *q = jarcl.getprevpt(); 00186 for( append( q ); q != lastpt1; append( q ) ) { 00187 assert( q != lastpt2 ); 00188 q = jarcl.getprevpt(); 00189 } 00190 } 00191 00192 00193 long 00194 Trimline::interpvert( TrimVertex *a, TrimVertex *b, TrimVertex *c, REAL vval ) 00195 { 00196 REAL denom = a->param[1] - b->param[1]; 00197 00198 if(denom != 0) { 00199 if( vval == a->param[1] ) { 00200 c->param[0] = a->param[0]; 00201 c->param[1] = a->param[1]; 00202 c->nuid = a->nuid; 00203 return 0; 00204 } else if( vval == b->param[1] ) { 00205 c->param[0] = b->param[0]; 00206 c->param[1] = b->param[1]; 00207 c->nuid = b->nuid; 00208 return 0; 00209 } else { 00210 REAL r = (a->param[1] - vval)/denom; 00211 c->param[0] = a->param[0] - r * (a->param[0] - b->param[0]); 00212 c->param[1] = vval; 00213 return 1; 00214 } 00215 } else { 00216 c->param[0] = a->param[0]; 00217 c->param[1] = a->param[1]; 00218 c->nuid = a->nuid; 00219 return 0; 00220 } 00221 } 00222 Generated on Mon May 28 2012 04:23:35 for ReactOS by
1.7.6.1
|