ReactOS 0.4.16-dev-112-g52265ae
sampleCompTop.h File Reference
#include "sampleMonoPoly.h"
Include dependency graph for sampleCompTop.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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 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)
 

Function Documentation

◆ sampleCompTop()

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 
)

Definition at line 468 of file sampleCompTop.cc.

481{
482 if(up_leftCornerWhere == 1 && up_rightCornerWhere == 1) //the top is topVertex with possible grid points
483 {
484 leftGridChain->getGrid()->outputFanWithPoint(leftGridChain->getVlineIndex(gridIndex1),
485 leftGridChain->getUlineIndex(gridIndex1),
486 rightGridChain->getUlineIndex(gridIndex1),
487 topVertex,
488 pStream);
489 return;
490 }
491
492 else if(up_leftCornerWhere != 0)
493 {
494 Real* tempTop;
495 Int tempRightStart;
496 if(up_leftCornerWhere == 1){
497 tempRightStart = rightStartIndex;
498 tempTop = topVertex;
499 }
500 else
501 {
502 tempRightStart = up_leftCornerIndex+1;
503 tempTop = rightChain->getVertex(up_leftCornerIndex);
504 }
505 sampleTopRightWithGridLine(tempTop, rightChain, tempRightStart, up_rightCornerIndex,
506 rightGridChain->getGrid(),
507 leftGridChain->getVlineIndex(gridIndex1),
508 leftGridChain->getUlineIndex(gridIndex1),
509 rightGridChain->getUlineIndex(gridIndex1),
510 pStream);
511 }
512 else if(up_rightCornerWhere != 2)
513 {
514 Real* tempTop;
515 Int tempLeftStart;
516 if(up_rightCornerWhere == 1)
517 {
518 tempLeftStart = leftStartIndex;
519 tempTop = topVertex;
520 }
521 else //0
522 {
523 tempLeftStart = up_rightCornerIndex+1;
524 tempTop = leftChain->getVertex(up_rightCornerIndex);
525 }
526/*
527 sampleTopLeftWithGridLine(tempTop, leftChain, tempLeftStart, up_leftCornerIndex,
528 leftGridChain->getGrid(),
529 leftGridChain->getVlineIndex(gridIndex1),
530 leftGridChain->getUlineIndex(gridIndex1),
531 rightGridChain->getUlineIndex(gridIndex1),
532 pStream);
533*/
534 sampleCompTopSimple(topVertex,
535 leftChain,
536 leftStartIndex,
537 rightChain,
538 rightStartIndex,
539 leftGridChain,
540 rightGridChain,
541 gridIndex1,
542 up_leftCornerWhere,
543 up_leftCornerIndex,
544 up_rightCornerWhere,
545 up_rightCornerIndex,
546 pStream);
547 }
548 else //up_leftCornerWhere == 0, up_rightCornerWhere == 2.
549 {
550 sampleCompTopSimple(topVertex,
551 leftChain,
552 leftStartIndex,
553 rightChain,
554 rightStartIndex,
555 leftGridChain,
556 rightGridChain,
557 gridIndex1,
558 up_leftCornerWhere,
559 up_leftCornerIndex,
560 up_rightCornerWhere,
561 up_rightCornerIndex,
562 pStream);
563 return;
564#ifdef NOT_REACHABLE //code is not reachable, for test purpose only
565 //the following code is trying to do some optimization, but not quite working, also see sampleCompBot.C:
566 Int sep_left, sep_right;
567 if(findTopSeparator(leftChain,
568 leftStartIndex,
569 up_leftCornerIndex,
570 rightChain,
571 rightStartIndex,
572 up_rightCornerIndex,
573 sep_left,
574 sep_right)
575 ) //separator exists
576 {
577
578 if( leftChain->getVertex(sep_left)[0] >= leftGridChain->get_u_value(gridIndex1) &&
579 rightChain->getVertex(sep_right)[0] <= rightGridChain->get_u_value(gridIndex1))
580 {
581 Int gridSep;
582 Int segLeftSmall, segLeftLarge, segRightSmall, segRightLarge;
583 Int valid=1; //whether the gridStep is valid or not.
584 findTopLeftSegment(leftChain,
585 sep_left,
586 up_leftCornerIndex,
587 leftGridChain->get_u_value(gridIndex1),
588 segLeftSmall,
589 segLeftLarge);
590 findTopRightSegment(rightChain,
591 sep_right,
592 up_rightCornerIndex,
593 rightGridChain->get_u_value(gridIndex1),
594 segRightSmall,
595 segRightLarge);
596 if(leftChain->getVertex(segLeftSmall)[1] >= rightChain->getVertex(segRightSmall)[1])
597 {
598 gridSep = rightGridChain->getUlineIndex(gridIndex1);
599 while(leftGridChain->getGrid()->get_u_value(gridSep) > leftChain->getVertex(segLeftSmall)[0])
600 gridSep--;
601 if(segLeftSmall<segLeftLarge)
602 if(leftGridChain->getGrid()->get_u_value(gridSep) < leftChain->getVertex(segLeftSmall+1)[0])
603 {
604 valid = 0;
605 }
606 }
607 else
608 {
609 gridSep = leftGridChain->getUlineIndex(gridIndex1);
610 while(leftGridChain->getGrid()->get_u_value(gridSep) < rightChain->getVertex(segRightSmall)[0])
611 gridSep++;
612 if(segRightSmall<segRightLarge)
613 if(leftGridChain->getGrid()->get_u_value(gridSep) > rightChain->getVertex(segRightSmall+1)[0])
614 {
615 valid = 0;
616 }
617 }
618
619 if(! valid)
620 {
621 sampleCompTopSimple(topVertex,
622 leftChain,
623 leftStartIndex,
624 rightChain,
625 rightStartIndex,
626 leftGridChain,
627 rightGridChain,
628 gridIndex1,
629 up_leftCornerWhere,
630 up_leftCornerIndex,
631 up_rightCornerWhere,
632 up_rightCornerIndex,
633 pStream);
634 }
635 else
636 {
637 sampleTopLeftWithGridLinePost(leftChain->getVertex(segLeftSmall),
638 leftChain,
639 segLeftSmall+1,
640 segLeftSmall+1,
641 segLeftLarge,
642 up_leftCornerIndex,
643 leftGridChain->getGrid(),
644 leftGridChain->getVlineIndex(gridIndex1),
645 leftGridChain->getUlineIndex(gridIndex1),
646 gridSep,
647 pStream);
648 sampleTopRightWithGridLinePost(rightChain->getVertex(segRightSmall),
649 rightChain,
650 segRightSmall+1,
651 segRightSmall+1,
652 segRightLarge,
653 up_rightCornerIndex,
654 leftGridChain->getGrid(),
655 leftGridChain->getVlineIndex(gridIndex1),
656 gridSep,
657 rightGridChain->getUlineIndex(gridIndex1),
658 pStream);
659 Real tempBot[2];
660 tempBot[0] = leftGridChain->getGrid()->get_u_value(gridSep);
661 tempBot[1] = leftGridChain->get_v_value(gridIndex1);
662 monoTriangulationRecGen(topVertex, tempBot,
663 leftChain, leftStartIndex, segLeftSmall,
664 rightChain, rightStartIndex, segRightSmall,
665 pStream);
666 }
667 }//end if both sides have vetices inside the gridboundary points
668 else if(leftChain->getVertex(sep_left)[0] >= leftGridChain->get_u_value(gridIndex1)) //left is in, right is nout
669 {
670
671 Int segLeftSmall, segLeftLarge;
672 findTopLeftSegment(leftChain,
673 sep_left,
674 up_leftCornerIndex,
675 leftGridChain->get_u_value(gridIndex1),
676 segLeftSmall,
677 segLeftLarge);
678 assert(segLeftLarge >= sep_left);
679 monoTriangulation2(leftChain->getVertex(segLeftLarge),
680 leftGridChain->get_vertex(gridIndex1),
681 leftChain,
682 segLeftLarge+1,
683 up_leftCornerIndex,
684 1, //a increase chain,
685 pStream);
686
687 stripOfFanLeft(leftChain, segLeftLarge, segLeftSmall,
688 leftGridChain->getGrid(),
689 leftGridChain->getVlineIndex(gridIndex1),
690 leftGridChain->getUlineIndex(gridIndex1),
691 rightGridChain->getUlineIndex(gridIndex1),
692 pStream, 0);
693
694
695 monoTriangulationRecGen(topVertex, rightGridChain->get_vertex(gridIndex1),
696 leftChain, leftStartIndex, segLeftSmall,
697 rightChain, rightStartIndex, up_rightCornerIndex,
698 pStream);
699 }//end left in right out
700 else if(rightChain->getVertex(sep_right)[0] <= rightGridChain->get_u_value(gridIndex1))
701 {
702 Int segRightSmall, segRightLarge;
703 findTopRightSegment(rightChain,
704 sep_right,
705 up_rightCornerIndex,
706 rightGridChain->get_u_value(gridIndex1),
707 segRightSmall,
708 segRightLarge);
709 assert(segRightLarge>=sep_right);
710 monoTriangulation2(rightChain->getVertex(segRightLarge),
711 rightGridChain->get_vertex(gridIndex1),
712 rightChain,
713 segRightLarge+1,
714 up_rightCornerIndex,
715 0, //a decrease chain
716 pStream);
717 stripOfFanRight(rightChain, segRightLarge, segRightSmall,
718 rightGridChain->getGrid(),
719 rightGridChain->getVlineIndex(gridIndex1),
720 leftGridChain->getUlineIndex(gridIndex1),
721 rightGridChain->getUlineIndex(gridIndex1),
722 pStream, 0);
723
724
725 monoTriangulationRecGen(topVertex, leftGridChain->get_vertex(gridIndex1),
726 leftChain, leftStartIndex, up_leftCornerIndex,
727 rightChain, rightStartIndex,segRightSmall,
728 pStream);
729
730 }//end left out rigth in
731 else //left out , right out
732 {
733
734 sampleCompTopSimple(topVertex,
735 leftChain,
736 leftStartIndex,
737 rightChain,
738 rightStartIndex,
739 leftGridChain,
740 rightGridChain,
741 gridIndex1,
742 up_leftCornerWhere,
743 up_leftCornerIndex,
744 up_rightCornerWhere,
745 up_rightCornerIndex,
746 pStream);
747 }//end leftout, right out
748 }//end if separator exixts.
749 else //no separator
750 {
751
752 sampleCompTopSimple(topVertex,
753 leftChain,
754 leftStartIndex,
755 rightChain,
756 rightStartIndex,
757 leftGridChain,
758 rightGridChain,
759 gridIndex1,
760 up_leftCornerWhere,
761 up_leftCornerIndex,
762 up_rightCornerWhere,
763 up_rightCornerIndex,
764 pStream);
765 }
766#endif
767 }//end if 0,2
768}//end if the function
Int getVlineIndex(Int i)
Definition: gridWrap.h:119
Real get_v_value(Int i)
Definition: gridWrap.h:122
Real get_u_value(Int i)
Definition: gridWrap.h:121
Int getUlineIndex(Int i)
Definition: gridWrap.h:120
Real * get_vertex(Int i)
Definition: gridWrap.h:127
gridWrap * getGrid()
Definition: gridWrap.h:128
Real get_u_value(Int i)
Definition: gridWrap.h:78
void outputFanWithPoint(Int v, Int uleft, Int uright, Real vert[2], primStream *pStream)
Definition: gridWrap.cc:137
Real * getVertex(Int i)
int Int
Definition: definitions.h:37
float Real
Definition: definitions.h:36
#define assert(x)
Definition: debug.h:53
BOOLEAN valid
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 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 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)
void findTopRightSegment(vertexArray *rightChain, Int rightStart, Int rightEnd, Real u, Int &ret_index_small, Int &ret_index_large)
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)

Referenced by sampleConnectedComp().

◆ sampleCompTopSimple()

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 
)

Definition at line 904 of file sampleCompTop.cc.

917{
918 //the plan is to use monotriangulation algortihm.
919 Int i,k;
920 Real* ActualTop;
921 Real* ActualBot;
922 Int ActualLeftStart, ActualLeftEnd;
923 Int ActualRightStart, ActualRightEnd;
924
925 //creat an array to store the points on the grid line
926 gridWrap* grid = leftGridChain->getGrid();
927 Int gridV = leftGridChain->getVlineIndex(gridIndex1);
928 Int gridLeftU = leftGridChain->getUlineIndex(gridIndex1);
929 Int gridRightU = rightGridChain->getUlineIndex(gridIndex1);
930
931 Real2* gridPoints = (Real2*) malloc(sizeof(Real2) * (gridRightU - gridLeftU +1));
932 assert(gridPoints);
933
934 for(k=0, i=gridRightU; i>= gridLeftU; i--, k++)
935 {
936 gridPoints[k][0] = grid->get_u_value(i);
937 gridPoints[k][1] = grid->get_v_value(gridV);
938 }
939
940 if(up_leftCornerWhere != 2)
941 ActualRightStart = rightStartIndex;
942 else
943 ActualRightStart = up_leftCornerIndex+1; //up_leftCornerIndex will be the ActualTop
944
945 if(up_rightCornerWhere != 2) //right corner is not on right chain
946 ActualRightEnd = rightStartIndex-1; //meaning that there is no actual rigth section
947 else
948 ActualRightEnd = up_rightCornerIndex;
949
950 vertexArray ActualRightChain(max(0, ActualRightEnd-ActualRightStart+1) + gridRightU-gridLeftU+1);
951
952 for(i=ActualRightStart; i<= ActualRightEnd; i++)
953 ActualRightChain.appendVertex(rightChain->getVertex(i));
954 for(i=0; i<gridRightU-gridLeftU+1; i++)
955 ActualRightChain.appendVertex(gridPoints[i]);
956
957 //determine ActualLeftEnd
958 if(up_leftCornerWhere != 0)
959 ActualLeftEnd = leftStartIndex-1;
960 else
961 ActualLeftEnd = up_leftCornerIndex;
962
963 if(up_rightCornerWhere != 0)
964 ActualLeftStart = leftStartIndex;
965 else
966 ActualLeftStart = up_rightCornerIndex+1; //up_rightCornerIndex will be the actual top
967
968 if(up_leftCornerWhere == 0)
969 {
970 if(up_rightCornerWhere == 0)
971 ActualTop = leftChain->getVertex(up_rightCornerIndex);
972 else
973 ActualTop = topVertex;
974 }
975 else if(up_leftCornerWhere == 1)
976 ActualTop = topVertex;
977 else //up_leftCornerWhere == 2
978 ActualTop = rightChain->getVertex(up_leftCornerIndex);
979
980 ActualBot = gridPoints[gridRightU - gridLeftU];
981
982
983
984
985 if(leftChain->getVertex(ActualLeftEnd)[1] == ActualBot[1])
986 {
987/*
988 monoTriangulationRecGenOpt(ActualTop, leftChain->getVertex(ActualLeftEnd),
989 leftChain,
990 ActualLeftStart, ActualLeftEnd-1,
991 &ActualRightChain,
992 0,
993 ActualRightChain.getNumElements()-1,
994 pStream);
995*/
996
997 sampleCompTopSimpleOpt(grid, gridV,
998 ActualTop, leftChain->getVertex(ActualLeftEnd),
999 leftChain,
1000 ActualLeftStart, ActualLeftEnd-1,
1001 &ActualRightChain,
1002 0,
1003 ActualRightChain.getNumElements()-1,
1004 pStream);
1005
1006 }
1007 else
1008 {
1009/*
1010 monoTriangulationRecGenOpt(ActualTop, ActualBot, leftChain,
1011 ActualLeftStart, ActualLeftEnd,
1012 &ActualRightChain,
1013 0, ActualRightChain.getNumElements()-2, //the last is the bot.
1014 pStream);
1015*/
1016
1017 sampleCompTopSimpleOpt(grid, gridV,
1018 ActualTop, ActualBot, leftChain,
1019 ActualLeftStart, ActualLeftEnd,
1020 &ActualRightChain,
1021 0, ActualRightChain.getNumElements()-2, //the last is the bot.
1022 pStream);
1023
1024
1025 }
1026
1027 free(gridPoints);
1028
1029}
Real get_v_value(Int j)
Definition: gridWrap.h:83
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
Real Real2[2]
Definition: definitions.h:38
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
Definition: glfuncs.h:248
int k
Definition: mpi.c:3369
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)
#define max(a, b)

Referenced by sampleCompTop().