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

sampleComp.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 ** $Date: 2006-03-12 00:07:02 +0000 (Sun, 12 Mar 2006) $ $Revision: 1.1 $
00035 */
00036 /*
00037 ** $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/nurbtess/sampleComp.cc,v 1.1 2004/02/02 16:39:13 navaraf Exp $
00038 */
00039 
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042 #include "glimports.h"
00043 #include "sampleComp.h"
00044 #include "sampleCompTop.h"
00045 #include "sampleCompBot.h"
00046 #include "sampleCompRight.h"
00047 
00048 
00049 
00050 #define max(a,b) ((a>b)? a:b)
00051 #define min(a,b) ((a>b)? b:a)
00052 
00053 void sampleConnectedComp(Real* topVertex, Real* botVertex,
00054             vertexArray* leftChain, 
00055             Int leftStartIndex, Int leftEndIndex,
00056             vertexArray* rightChain,
00057             Int rightStartIndex, Int rightEndIndex,
00058             gridBoundaryChain* leftGridChain,
00059             gridBoundaryChain* rightGridChain,
00060             Int gridIndex1, Int gridIndex2,
00061             Int up_leftCornerWhere,
00062             Int up_leftCornerIndex,
00063             Int up_rightCornerWhere,
00064             Int up_rightCornerIndex,
00065             Int down_leftCornerWhere,
00066             Int down_leftCornerIndex,
00067             Int down_rightCornerWhere,
00068             Int down_rightCornerIndex,
00069             primStream* pStream,
00070             rectBlockArray* rbArray
00071             )
00072 {
00073 
00074  sampleCompLeft(topVertex, botVertex,
00075         leftChain,
00076         leftStartIndex, leftEndIndex,
00077         rightChain,
00078         rightStartIndex, rightEndIndex,
00079         leftGridChain,
00080         gridIndex1,
00081         gridIndex2,
00082         up_leftCornerWhere,
00083         up_leftCornerIndex,
00084         down_leftCornerWhere,
00085         down_leftCornerIndex,
00086         pStream);
00087 
00088 
00089  sampleCompRight(topVertex, botVertex,
00090          leftChain,
00091          leftStartIndex, leftEndIndex,
00092          rightChain,
00093          rightStartIndex,
00094          rightEndIndex,
00095          rightGridChain,
00096          gridIndex1, gridIndex2,
00097          up_rightCornerWhere,
00098          up_rightCornerIndex,
00099          down_rightCornerWhere,
00100          down_rightCornerIndex,
00101          pStream);
00102          
00103 
00104  sampleCompTop(topVertex,
00105              leftChain,
00106              leftStartIndex,
00107              rightChain,
00108              rightStartIndex,
00109              leftGridChain,
00110              rightGridChain,
00111              gridIndex1,
00112              up_leftCornerWhere,
00113              up_leftCornerIndex,
00114              up_rightCornerWhere,
00115              up_rightCornerIndex,
00116              pStream);
00117 
00118  sampleCompBot(botVertex,
00119              leftChain,
00120              leftEndIndex,
00121              rightChain,
00122              rightEndIndex,
00123              leftGridChain,
00124              rightGridChain,
00125              gridIndex2,
00126              down_leftCornerWhere,
00127              down_leftCornerIndex,
00128              down_rightCornerWhere,
00129              down_rightCornerIndex,
00130              pStream);
00131 
00132 
00133  //the center
00134 
00135  rbArray->insert(new rectBlock(leftGridChain, rightGridChain, gridIndex1, gridIndex2));
00136 
00137     
00138 }
00139 
00140 /*notice that we need rightChain because the 
00141  *corners could be on the rightChain.
00142  *here comp means component.
00143  */
00144 void sampleCompLeft(Real* topVertex, Real* botVertex,
00145             vertexArray* leftChain,
00146             Int leftStartIndex, Int leftEndIndex,
00147             vertexArray* rightChain,
00148             Int rightStartIndex, Int rightEndIndex,
00149             gridBoundaryChain* leftGridChain,
00150             Int gridIndex1, Int gridIndex2,
00151             Int up_leftCornerWhere,
00152             Int up_leftCornerIndex,
00153             Int down_leftCornerWhere,
00154             Int down_leftCornerIndex,
00155             primStream* pStream)
00156 {
00157   /*find out whether there is a trim vertex which is
00158    *inbetween the top and bot grid lines or not.
00159    */
00160   Int midIndex1 = 0;
00161   Int midIndex2 = 0;
00162   Int gridMidIndex1 = 0, gridMidIndex2 = 0;
00163   //midIndex1: array[i] <= v, array[i-1] > v
00164   //midIndex2: array[i] >= v, array[i+1] < v
00165   // v(gridMidIndex1) >= v(midindex1) > v(gridMidIndex1+1)
00166   // v(gridMidIndex2-1) >= v(midIndex2) > v(gridMidIndex2) ??
00167   midIndex1 = leftChain->findIndexBelowGen(
00168                        leftGridChain->get_v_value(gridIndex1),
00169                        leftStartIndex,
00170                        leftEndIndex);
00171 
00172   midIndex2 = -1; /*initilization*/
00173   if(midIndex1<= leftEndIndex && gridIndex1<gridIndex2)
00174     if(leftChain->getVertex(midIndex1)[1] >= leftGridChain->get_v_value(gridIndex2))
00175       {
00176     midIndex2 = leftChain->findIndexAboveGen(
00177                          leftGridChain->get_v_value(gridIndex2),
00178                          midIndex1, //midIndex1 <= midIndex2.
00179                          leftEndIndex);
00180     gridMidIndex1  = leftGridChain->lookfor(leftChain->getVertex(midIndex1)[1],
00181                         gridIndex1, gridIndex2);
00182     gridMidIndex2 = 1+leftGridChain->lookfor(leftChain->getVertex(midIndex2)[1],
00183                            gridMidIndex1, gridIndex2);  
00184       }
00185 
00186 
00187   /*to interprete the corner information*/
00188   Real* cornerTop;
00189   Real* cornerBot;
00190   Int cornerLeftStart;
00191   Int cornerLeftEnd;
00192   Int cornerRightUpEnd;
00193   Int cornerRightDownStart;
00194   if(up_leftCornerWhere == 0) /*left corner is on left chain*/
00195     {
00196       cornerTop = leftChain->getVertex(up_leftCornerIndex);
00197       cornerLeftStart = up_leftCornerIndex+1;
00198       cornerRightUpEnd = -1; /*no right*/
00199     }
00200   else if(up_leftCornerWhere == 1) /*left corner is on top*/
00201     {
00202       cornerTop = topVertex;
00203       cornerLeftStart = leftStartIndex;
00204       cornerRightUpEnd = -1; /*no right*/
00205     }
00206   else /*left corner is on right chain*/
00207     {
00208       cornerTop = topVertex;
00209       cornerLeftStart = leftStartIndex;
00210       cornerRightUpEnd = up_leftCornerIndex;
00211     }
00212   
00213   if(down_leftCornerWhere == 0) /*left corner is on left chain*/
00214     {
00215       cornerBot = leftChain->getVertex(down_leftCornerIndex);
00216       cornerLeftEnd = down_leftCornerIndex-1;
00217       cornerRightDownStart = rightEndIndex+1; /*no right*/
00218     }
00219   else if(down_leftCornerWhere == 1) /*left corner is on bot*/
00220     {
00221       cornerBot = botVertex;
00222       cornerLeftEnd = leftEndIndex;
00223       cornerRightDownStart = rightEndIndex+1; /*no right*/
00224     }
00225   else /*left corner is on the right chian*/
00226     {
00227       cornerBot = botVertex;
00228       cornerLeftEnd = leftEndIndex;
00229       cornerRightDownStart = down_leftCornerIndex;
00230     }
00231       
00232 
00233 
00234 
00235   /*sample*/
00236   if(midIndex2 >= 0) /*there is a trim point inbewteen grid lines*/
00237     {
00238 
00239       sampleLeftSingleTrimEdgeRegionGen(cornerTop, leftChain->getVertex(midIndex1),
00240                     leftChain,
00241                     cornerLeftStart,
00242                     midIndex1-1,
00243                     leftGridChain,
00244                     gridIndex1,
00245                     gridMidIndex1,
00246                     rightChain,
00247                     rightStartIndex,
00248                     cornerRightUpEnd,
00249                     0, //no right down section
00250                     -1,
00251                     pStream);
00252 
00253       sampleLeftSingleTrimEdgeRegionGen(leftChain->getVertex(midIndex2),
00254                     cornerBot,
00255                     leftChain,
00256                     midIndex2+1,
00257                     cornerLeftEnd,
00258                     leftGridChain,
00259                     gridMidIndex2,
00260                     gridIndex2,
00261                     rightChain,
00262                     0, //no right up section
00263                     -1,
00264                     cornerRightDownStart,
00265                     rightEndIndex,
00266                     pStream);
00267 
00268 
00269       sampleLeftStripRecF(leftChain,
00270               midIndex1,
00271               midIndex2,
00272               leftGridChain,
00273               gridMidIndex1,
00274               gridMidIndex2,
00275               pStream);
00276     }
00277   else
00278     {
00279       sampleLeftSingleTrimEdgeRegionGen(cornerTop, cornerBot,
00280                     leftChain,
00281                     cornerLeftStart,
00282                     cornerLeftEnd,
00283                     leftGridChain,
00284                     gridIndex1,
00285                     gridIndex2,
00286                     rightChain,
00287                     rightStartIndex,
00288                     cornerRightUpEnd,
00289                     cornerRightDownStart,
00290                     rightEndIndex,
00291                     pStream);
00292     }                    
00293 }
00294             
00295 void sampleLeftSingleTrimEdgeRegionGen(Real topVert[2], Real botVert[2],
00296                        vertexArray* leftChain,
00297                        Int leftStart,
00298                        Int leftEnd,
00299                        gridBoundaryChain* gridChain,
00300                        Int gridBeginIndex,
00301                        Int gridEndIndex,
00302                        vertexArray* rightChain,
00303                        Int rightUpBegin,
00304                        Int rightUpEnd,
00305                        Int rightDownBegin,
00306                        Int rightDownEnd,
00307                        primStream* pStream)
00308 {
00309   Int i,j,k;
00310 
00311   /*creat an array to store all the up and down secments of the right chain,
00312    *and the left end grid points
00313    *
00314    *although vertex array is a dynamic array, but to gain efficiency,
00315    *it is better to initiliza the exact array size
00316    */
00317   vertexArray vArray(gridEndIndex-gridBeginIndex+1 +
00318              max(0,rightUpEnd - rightUpBegin+1)+
00319              max(0,rightDownEnd - rightDownBegin+1));
00320   
00321   /*append the vertices on the up section of thr right chain*/
00322   for(i=rightUpBegin; i<= rightUpEnd; i++)
00323     vArray.appendVertex(rightChain->getVertex(i));
00324   
00325   /*append the vertices of the left extremal grid points,
00326    *and at the same time, perform triangulation for the stair cases
00327    */
00328   vArray.appendVertex(gridChain->get_vertex(gridBeginIndex));
00329 
00330   for(k=1, i=gridBeginIndex+1; i<=gridEndIndex; i++, k++)
00331     {
00332       vArray.appendVertex(gridChain->get_vertex(i));
00333 
00334       /*output the fan of the grid points of the (i)th and (i-1)th grid line.
00335        */
00336       if(gridChain->getUlineIndex(i) < gridChain->getUlineIndex(i-1))
00337     {
00338       pStream->begin();   
00339       pStream->insert(gridChain->get_vertex(i-1));
00340       for(j=gridChain->getUlineIndex(i); j<= gridChain->getUlineIndex(i-1); j++)
00341         pStream->insert(gridChain->getGrid()->get_u_value(j), gridChain->get_v_value(i));
00342       pStream->end(PRIMITIVE_STREAM_FAN);
00343     }
00344       else if(gridChain->getUlineIndex(i) > gridChain->getUlineIndex(i-1))
00345     {
00346       pStream->begin();
00347       pStream->insert(gridChain->get_vertex(i));
00348       for(j=gridChain->getUlineIndex(i); j>= gridChain->getUlineIndex(i-1); j--)
00349         pStream->insert(gridChain->getGrid()->get_u_value(j), gridChain->get_v_value(i-1));
00350       pStream->end(PRIMITIVE_STREAM_FAN);
00351     }
00352       /*otherwisem, the two are equal, so there is no fan to outout*/     
00353     }
00354 
00355   /*then append all the vertices on the down section of the right chain*/
00356   for(i=rightDownBegin; i<= rightDownEnd; i++)
00357     vArray.appendVertex(rightChain->getVertex(i));  
00358 
00359   monoTriangulationRecGen(topVert, botVert,
00360               leftChain, leftStart, leftEnd,
00361               &vArray, 0, vArray.getNumElements()-1,
00362               pStream);
00363              
00364 }
00365 
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 

Generated on Sun May 27 2012 04:23:49 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.