Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 1395 of file sampleMonoPoly.cc.
Referenced by sampleMonoPoly(), and sampleMonoPolyRec().
{ /*find the first connected component, and the four corners. */ Int index1, index2; /*the first and last grid line of the first connected component*/ if(topVertex[1] <= botVertex[1]) return; /*find i so that the grid line is below the top vertex*/ Int i=gridStartIndex; while (i < leftGridChain->get_nVlines()) { if(leftGridChain->get_v_value(i) < topVertex[1]) break; i++; } /*find the first connected component starting with i*/ /*find index1 so that left_uline_index <= right_uline_index, that is, this *grid line contains at least one inner grid point */ index1=i; int num_skipped_grid_lines=0; while(index1 < leftGridChain->get_nVlines()) { if(leftGridChain->getUlineIndex(index1) <= rightGridChain->getUlineIndex(index1)) break; num_skipped_grid_lines++; index1++; } if(index1 >= leftGridChain->get_nVlines()) /*no grid line exists which has inner point*/ { /*stop recursion, ...*/ /*monotone triangulate it...*/ // printf("no grid line exists\n"); /* monoTriangulationRecOpt(topVertex, botVertex, leftChain, leftStartIndex, rightChain, rightStartIndex, pStream); */ if(num_skipped_grid_lines <2) { monoTriangulationRecGenOpt(topVertex, botVertex, leftChain, leftStartIndex, leftChain->getNumElements()-1, rightChain, rightStartIndex, rightChain->getNumElements()-1, pStream); } else { //the optimum way to triangulate is top-down since this polygon //is narrow-long. monoTriangulationRec(topVertex, botVertex, leftChain, leftStartIndex, rightChain, rightStartIndex, pStream); } /* monoTriangulationRec(topVertex, botVertex, leftChain, leftStartIndex, rightChain, rightStartIndex, pStream); */ /* monoTriangulationRecGenTBOpt(topVertex, botVertex, leftChain, leftStartIndex, leftChain->getNumElements()-1, rightChain, rightStartIndex, rightChain->getNumElements()-1, pStream);*/ } else { /*find index2 so that left_inner_index <= right_inner_index holds until index2*/ index2=index1+1; if(index2 < leftGridChain->get_nVlines()) while(leftGridChain->getInnerIndex(index2) <= rightGridChain->getInnerIndex(index2)) { index2++; if(index2 >= leftGridChain->get_nVlines()) break; } index2--; /*the neck*/ Int neckLeftIndex; Int neckRightIndex; /*the four corners*/ Int up_leftCornerWhere; Int up_leftCornerIndex; Int up_rightCornerWhere; Int up_rightCornerIndex; Int down_leftCornerWhere; Int down_leftCornerIndex; Int down_rightCornerWhere; Int down_rightCornerIndex; Real* tempBotVertex; /*the bottom vertex for this component*/ Real* nextTopVertex=NULL; /*for the recursion*/ Int nextLeftStartIndex=0; Int nextRightStartIndex=0; /*find the points below the grid line index2 on both chains*/ Int botLeftIndex = leftChain->findIndexStrictBelowGen( leftGridChain->get_v_value(index2), leftStartIndex, leftChain->getNumElements()-1); Int botRightIndex = rightChain->findIndexStrictBelowGen( rightGridChain->get_v_value(index2), rightStartIndex, rightChain->getNumElements()-1); /*if either botLeftIndex>= numelements, * or botRightIndex >= numelemnet, *then there is no neck exists. the bottom vertex is botVertex, */ if(! findNeckF(leftChain, botLeftIndex, rightChain, botRightIndex, leftGridChain, rightGridChain, index2, neckLeftIndex, neckRightIndex)) /* if(botLeftIndex == leftChain->getNumElements() || botRightIndex == rightChain->getNumElements()) */ { #ifdef MYDEBUG printf("neck NOT exists, botRightIndex=%i\n", botRightIndex); #endif tempBotVertex = botVertex; nextTopVertex = botVertex; botLeftIndex = leftChain->getNumElements()-1; botRightIndex = rightChain->getNumElements()-1; } else /*neck exists*/ { #ifdef MYDEBUG printf("neck exists\n"); #endif /* findNeck(leftChain, botLeftIndex, rightChain, botRightIndex, neckLeftIndex, neckRightIndex); */ #ifdef MYDEBUG printf("neck is found, neckLeftIndex=%i, neckRightIndex=%i\n", neckLeftIndex, neckRightIndex); glBegin(GL_LINES); glVertex2fv(leftChain->getVertex(neckLeftIndex)); glVertex2fv(rightChain->getVertex(neckRightIndex)); glEnd(); #endif if(leftChain->getVertex(neckLeftIndex)[1] <= rightChain->getVertex(neckRightIndex)[1]) { tempBotVertex = leftChain->getVertex(neckLeftIndex); botLeftIndex = neckLeftIndex-1; botRightIndex = neckRightIndex; nextTopVertex = rightChain->getVertex(neckRightIndex); nextLeftStartIndex = neckLeftIndex; nextRightStartIndex = neckRightIndex+1; } else { tempBotVertex = rightChain->getVertex(neckRightIndex); botLeftIndex = neckLeftIndex; botRightIndex = neckRightIndex-1; nextTopVertex = leftChain->getVertex(neckLeftIndex); nextLeftStartIndex = neckLeftIndex+1; nextRightStartIndex = neckRightIndex; } } findUpCorners(topVertex, leftChain, leftStartIndex, botLeftIndex, rightChain, rightStartIndex, botRightIndex, leftGridChain->get_v_value(index1), leftGridChain->get_u_value(index1), rightGridChain->get_u_value(index1), up_leftCornerWhere, up_leftCornerIndex, up_rightCornerWhere, up_rightCornerIndex); findDownCorners(tempBotVertex, leftChain, leftStartIndex, botLeftIndex, rightChain, rightStartIndex, botRightIndex, leftGridChain->get_v_value(index2), leftGridChain->get_u_value(index2), rightGridChain->get_u_value(index2), down_leftCornerWhere, down_leftCornerIndex, down_rightCornerWhere, down_rightCornerIndex); #ifdef MYDEBUG printf("find corners done, down_leftwhere=%i, down_righwhere=%i,\n",down_leftCornerWhere, down_rightCornerWhere ); printf("find corners done, up_leftwhere=%i, up_righwhere=%i,\n",up_leftCornerWhere, up_rightCornerWhere ); printf("find corners done, up_leftindex=%i, up_righindex=%i,\n",up_leftCornerIndex, up_rightCornerIndex ); printf("find corners done, down_leftindex=%i, down_righindex=%i,\n",down_leftCornerIndex, down_rightCornerIndex ); #endif /* drawCorners(topVertex, tempBotVertex, leftChain, rightChain, leftGridChain, rightGridChain, index1, index2, up_leftCornerWhere, up_leftCornerIndex, up_rightCornerWhere, up_rightCornerIndex, down_leftCornerWhere, down_leftCornerIndex, down_rightCornerWhere, down_rightCornerIndex); */ sampleConnectedComp(topVertex, tempBotVertex, leftChain, leftStartIndex, botLeftIndex, rightChain, rightStartIndex, botRightIndex, leftGridChain, rightGridChain, index1, index2, up_leftCornerWhere, up_leftCornerIndex, up_rightCornerWhere, up_rightCornerIndex, down_leftCornerWhere, down_leftCornerIndex, down_rightCornerWhere, down_rightCornerIndex, pStream, rbArray ); /*recursion*/ sampleMonoPolyRec( nextTopVertex, botVertex, leftChain, nextLeftStartIndex, rightChain, nextRightStartIndex, leftGridChain, rightGridChain, index2+1, pStream, rbArray); } }