45#define max(a,b) ((a>b)? a:b)
62 assert(leftStart <= leftEnd);
63 for(
i=leftEnd;
i>= leftStart;
i--)
69 if(ret_index_large >= leftStart)
71 for(
i=ret_index_large;
i>leftStart;
i--)
88 assert(rightStart<=rightEnd);
89 for(
i=rightEnd;
i>=rightStart;
i--)
95 if(ret_index_large >= rightStart)
97 for(
i=ret_index_large;
i>rightStart;
i--)
120 if(segIndexLarge < rightEnd)
123 if(segIndexLarge >= rightStart)
124 tempTop = rightChain->
getVertex(segIndexLarge);
132 rightChain, segIndexLarge+1, rightEnd,
146 if(segIndexLarge >= rightStart)
148 stripOfFanRight(rightChain, segIndexLarge, segIndexSmall, grid, gridV, leftU, rightU, pStream, 0);
152 monoTriangulation2(topVertex, tempBot, rightChain, rightStart, segIndexSmall, 0, pStream);
170 if(rightEnd < rightStart){
175 Int segIndexSmall = 0, segIndexLarge;
210 if(segIndexLarge < leftEnd)
213 if(segIndexLarge >= leftStart)
214 tempTop = leftChain->
getVertex(segIndexLarge);
230 if(segIndexLarge >= leftStart)
243 for(
i=leftStart;
i<=segIndexSmall;
i++)
244 if(leftChain->
getVertex(
i)[0] >= topVertex[0])
265 stripOfFanLeft(leftChain, segIndexLarge, segIndexSmall, grid, gridV, leftU, midU, pStream, 0);
269 monoTriangulation2(topVertex, tempBot, leftChain, leftStart, segIndexSmall, 1, pStream);
274 stripOfFanLeft(leftChain, segIndexLarge, segIndexSmall, grid, gridV, leftU, rightU, pStream, 0);
278 monoTriangulation2(topVertex, tempBot, leftChain, leftStart, segIndexSmall, 1, pStream);
297 Int segIndexSmall = 0, segIndexLarge;
300 if(leftEnd < leftStart) {
336 Int oldLeftI, oldRightI, newLeftI, newRightI;
342 oldLeftI = leftEndIndex+1;
343 oldRightI = rightEndIndex;
345 rightMin = rightChain->
getVertex(rightEndIndex)[0];
349 oldLeftI = leftEndIndex;
350 oldRightI = rightEndIndex+1;
351 leftMax = leftChain->
getVertex(leftEndIndex)[0];
352 rightMin = rightChain->
getVertex(rightEndIndex)[0] +
Real(1.0);
364 newRightI = oldRightI;
368 for(
k=
j-1;
k>= rightStartIndex;
k--)
384 else if(
j<rightStartIndex)
386 for(
k=
i-1;
k>= leftStartIndex;
k--)
409 for(
k=
j-1;
k>= rightStartIndex;
k--)
420 if(leftMax >= rightMin)
425 oldRightI = newRightI;
435 for(
k=
i-1;
k>= leftStartIndex;
k--)
447 if(leftMax >= rightMin)
452 oldRightI = newRightI;
457 if(oldLeftI > leftEndIndex || oldRightI > rightEndIndex)
461 ret_sep_left = oldLeftI;
462 ret_sep_right = oldRightI;
476 Int up_leftCornerWhere,
477 Int up_leftCornerIndex,
478 Int up_rightCornerWhere,
479 Int up_rightCornerIndex,
482 if(up_leftCornerWhere == 1 && up_rightCornerWhere == 1)
492 else if(up_leftCornerWhere != 0)
496 if(up_leftCornerWhere == 1){
497 tempRightStart = rightStartIndex;
502 tempRightStart = up_leftCornerIndex+1;
503 tempTop = rightChain->
getVertex(up_leftCornerIndex);
512 else if(up_rightCornerWhere != 2)
516 if(up_rightCornerWhere == 1)
518 tempLeftStart = leftStartIndex;
523 tempLeftStart = up_rightCornerIndex+1;
524 tempTop = leftChain->
getVertex(up_rightCornerIndex);
566 Int sep_left, sep_right;
582 Int segLeftSmall, segLeftLarge, segRightSmall, segRightLarge;
601 if(segLeftSmall<segLeftLarge)
612 if(segRightSmall<segRightLarge)
661 tempBot[1] = leftGridChain->
get_v_value(gridIndex1);
663 leftChain, leftStartIndex, segLeftSmall,
664 rightChain, rightStartIndex, segRightSmall,
671 Int segLeftSmall, segLeftLarge;
678 assert(segLeftLarge >= sep_left);
696 leftChain, leftStartIndex, segLeftSmall,
697 rightChain, rightStartIndex, up_rightCornerIndex,
702 Int segRightSmall, segRightLarge;
709 assert(segRightLarge>=sep_right);
726 leftChain, leftStartIndex, up_leftCornerIndex,
727 rightChain, rightStartIndex,segRightSmall,
778 if(gridV <= 0 || dec_end<dec_current || inc_end <inc_current)
781 inc_chain, inc_current, inc_end,
782 dec_chain, dec_current, dec_end,
789 inc_chain, inc_current, inc_end,
790 dec_chain, dec_current, dec_end,
796 if(inc_chain->
getVertex(inc_end)[1] <= currentV &&
797 dec_chain->
getVertex(dec_end)[1] < currentV)
801 for(
i=inc_end;
i >= inc_current;
i--)
807 for(
j=dec_end;
j >= dec_current;
j--)
816 for(
k=
j;
k<=dec_end;
k++)
829 for(
l=
j+1;
l<=
k-1;
l++)
841 inc_chain,
i, inc_end,
842 dec_chain, (
int)(tempI+1), dec_end,
848 inc_chain, inc_current,
i-1,
849 dec_chain, dec_current, (
int)tempI,
855 for(
k=
i;
k<=inc_end;
k++)
868 for(
l=
i+1;
l<=
k-1;
l++)
881 inc_chain, tempI+1, inc_end,
882 dec_chain,
j, dec_end,
888 inc_chain, inc_current, tempI,
889 dec_chain, dec_current,
j-1,
897 topVertex, botVertex,
898 inc_chain, inc_current, inc_end,
899 dec_chain, dec_current, dec_end,
912 Int up_leftCornerWhere,
913 Int up_leftCornerIndex,
914 Int up_rightCornerWhere,
915 Int up_rightCornerIndex,
922 Int ActualLeftStart, ActualLeftEnd;
923 Int ActualRightStart, ActualRightEnd;
934 for(
k=0,
i=gridRightU;
i>= gridLeftU;
i--,
k++)
940 if(up_leftCornerWhere != 2)
941 ActualRightStart = rightStartIndex;
943 ActualRightStart = up_leftCornerIndex+1;
945 if(up_rightCornerWhere != 2)
946 ActualRightEnd = rightStartIndex-1;
948 ActualRightEnd = up_rightCornerIndex;
950 vertexArray ActualRightChain(
max(0, ActualRightEnd-ActualRightStart+1) + gridRightU-gridLeftU+1);
952 for(
i=ActualRightStart;
i<= ActualRightEnd;
i++)
954 for(
i=0;
i<gridRightU-gridLeftU+1;
i++)
958 if(up_leftCornerWhere != 0)
959 ActualLeftEnd = leftStartIndex-1;
961 ActualLeftEnd = up_leftCornerIndex;
963 if(up_rightCornerWhere != 0)
964 ActualLeftStart = leftStartIndex;
966 ActualLeftStart = up_rightCornerIndex+1;
968 if(up_leftCornerWhere == 0)
970 if(up_rightCornerWhere == 0)
971 ActualTop = leftChain->
getVertex(up_rightCornerIndex);
973 ActualTop = topVertex;
975 else if(up_leftCornerWhere == 1)
976 ActualTop = topVertex;
978 ActualTop = rightChain->
getVertex(up_leftCornerIndex);
980 ActualBot = gridPoints[gridRightU - gridLeftU];
985 if(leftChain->
getVertex(ActualLeftEnd)[1] == ActualBot[1])
998 ActualTop, leftChain->
getVertex(ActualLeftEnd),
1000 ActualLeftStart, ActualLeftEnd-1,
1018 ActualTop, ActualBot, leftChain,
1019 ActualLeftStart, ActualLeftEnd,
void outputFanWithPoint(Int v, Int uleft, Int uright, Real vert[2], primStream *pStream)
void appendVertex(Real *ptr)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
void monoTriangulationRecGen(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, Int inc_end, vertexArray *dec_chain, Int dec_current, Int dec_end, primStream *pStream)
void monoTriangulation2(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_smallIndex, Int inc_largeIndex, Int is_increase_chain, primStream *pStream)
void monoTriangulationRecGenOpt(Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, Int inc_end, vertexArray *dec_chain, Int dec_current, Int dec_end, primStream *pStream)
void stripOfFanRight(vertexArray *rightChain, Int largeIndex, Int smallIndex, gridWrap *grid, Int vlineIndex, Int ulineSmallIndex, Int ulineLargeIndex, primStream *pStream, Int gridLineUp)
void sampleCompTopSimple(Real *topVertex, vertexArray *leftChain, Int leftStartIndex, vertexArray *rightChain, Int rightStartIndex, gridBoundaryChain *leftGridChain, gridBoundaryChain *rightGridChain, Int gridIndex1, Int up_leftCornerWhere, Int up_leftCornerIndex, Int up_rightCornerWhere, Int up_rightCornerIndex, primStream *pStream)
Int findTopSeparator(vertexArray *leftChain, Int leftStartIndex, Int leftEndIndex, vertexArray *rightChain, Int rightStartIndex, Int rightEndIndex, Int &ret_sep_left, Int &ret_sep_right)
void sampleTopLeftWithGridLine(Real *topVertex, vertexArray *leftChain, Int leftStart, Int leftEnd, gridWrap *grid, Int gridV, Int leftU, Int rightU, primStream *pStream)
void sampleTopRightWithGridLinePost(Real *topVertex, vertexArray *rightChain, Int rightStart, Int segIndexSmall, Int segIndexLarge, Int rightEnd, gridWrap *grid, Int gridV, Int leftU, Int rightU, primStream *pStream)
void sampleTopLeftWithGridLinePost(Real *topVertex, vertexArray *leftChain, Int leftStart, Int segIndexSmall, Int segIndexLarge, Int leftEnd, gridWrap *grid, Int gridV, Int leftU, Int rightU, primStream *pStream)
void findTopLeftSegment(vertexArray *leftChain, Int leftStart, Int leftEnd, Real u, Int &ret_index_small, Int &ret_index_large)
static void sampleCompTopSimpleOpt(gridWrap *grid, Int gridV, Real *topVertex, Real *botVertex, vertexArray *inc_chain, Int inc_current, Int inc_end, vertexArray *dec_chain, Int dec_current, Int dec_end, primStream *pStream)
void findTopRightSegment(vertexArray *rightChain, Int rightStart, Int rightEnd, Real u, Int &ret_index_small, Int &ret_index_large)
void sampleCompTop(Real *topVertex, vertexArray *leftChain, Int leftStartIndex, vertexArray *rightChain, Int rightStartIndex, gridBoundaryChain *leftGridChain, gridBoundaryChain *rightGridChain, Int gridIndex1, Int up_leftCornerWhere, Int up_leftCornerIndex, Int up_rightCornerWhere, Int up_rightCornerIndex, primStream *pStream)
void sampleTopRightWithGridLine(Real *topVertex, vertexArray *rightChain, Int rightStart, Int rightEnd, gridWrap *grid, Int gridV, Int leftU, Int rightU, primStream *pStream)
void stripOfFanLeft(vertexArray *leftChain, Int largeIndex, Int smallIndex, gridWrap *grid, Int vlineIndex, Int ulineSmallIndex, Int ulineLargeIndex, primStream *pStream, Int gridLineUp)