Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.8 KiB

  1. /**************************************************************************
  2. * *
  3. * Copyright (C) 1992, Silicon Graphics, Inc. *
  4. * *
  5. * These coded instructions, statements, and computer programs contain *
  6. * unpublished proprietary information of Silicon Graphics, Inc., and *
  7. * are protected by Federal copyright law. They may not be disclosed *
  8. * to third parties or copied or duplicated in any form, in whole or *
  9. * in part, without the prior written consent of Silicon Graphics, Inc. *
  10. * *
  11. **************************************************************************/
  12. /*
  13. * hull.c++ - $Revision: 1.1 $
  14. * Derrick Burns - 1991
  15. */
  16. #include "glimport.h"
  17. #include "myassert.h"
  18. #include "mystdio.h"
  19. #include "hull.h"
  20. #include "gridvert.h"
  21. #include "gridtrim.h"
  22. #include "gridline.h"
  23. #include "trimline.h"
  24. #include "uarray.h"
  25. #include "trimregi.h"
  26. Hull::Hull( void )
  27. {}
  28. Hull::~Hull( void )
  29. {}
  30. /*----------------------------------------------------------------------
  31. * Hull:init - this routine does the initialization needed before any
  32. * calls to nextupper or nextlower can be made.
  33. *----------------------------------------------------------------------
  34. */
  35. void
  36. Hull::init( void )
  37. {
  38. TrimVertex *lfirst = left.first();
  39. TrimVertex *llast = left.last();
  40. if( lfirst->param[0] <= llast->param[0] ) {
  41. fakeleft.init( left.first() );
  42. upper.left = &fakeleft;
  43. lower.left = &left;
  44. } else {
  45. fakeleft.init( left.last() );
  46. lower.left = &fakeleft;
  47. upper.left = &left;
  48. }
  49. upper.left->last();
  50. lower.left->first();
  51. if( top.ustart <= top.uend ) {
  52. upper.line = &top;
  53. upper.index = top.ustart;
  54. } else
  55. upper.line = 0;
  56. if( bot.ustart <= bot.uend ) {
  57. lower.line = &bot;
  58. lower.index = bot.ustart;
  59. } else
  60. lower.line = 0;
  61. TrimVertex *rfirst = right.first();
  62. TrimVertex *rlast = right.last();
  63. if( rfirst->param[0] <= rlast->param[0] ) {
  64. fakeright.init( right.last() );
  65. lower.right = &fakeright;
  66. upper.right = &right;
  67. } else {
  68. fakeright.init( right.first() );
  69. upper.right = &fakeright;
  70. lower.right = &right;
  71. }
  72. upper.right->first();
  73. lower.right->last();
  74. }
  75. /*----------------------------------------------------------------------
  76. * nextupper - find next vertex on upper hull of trim region.
  77. * - if vertex is on trim curve, set vtop point to
  78. * that vertex. if vertex is on grid, set vtop to
  79. * point to temporary area and stuff coordinants into
  80. * temporary vertex. Also, place grid coords in temporary
  81. * grid vertex.
  82. *----------------------------------------------------------------------
  83. */
  84. GridTrimVertex *
  85. Hull::nextupper( GridTrimVertex *gv )
  86. {
  87. if( upper.left ) {
  88. gv->set( upper.left->prev() );
  89. if( gv->isTrimVert() ) return gv;
  90. upper.left = 0;
  91. }
  92. if( upper.line ) {
  93. assert( upper.index <= upper.line->uend );
  94. gv->set( uarray.uarray[upper.index], upper.line->vval );
  95. gv->set( upper.index, upper.line->vindex );
  96. if( upper.index++ == upper.line->uend ) upper.line = 0;
  97. return gv;
  98. }
  99. if( upper.right ) {
  100. gv->set( upper.right->next() );
  101. if( gv->isTrimVert() ) return gv;
  102. upper.right = 0;
  103. }
  104. return 0;
  105. }
  106. GridTrimVertex *
  107. Hull::nextlower( register GridTrimVertex *gv )
  108. {
  109. if( lower.left ) {
  110. gv->set( lower.left->next() );
  111. if( gv->isTrimVert() ) return gv;
  112. lower.left = 0;
  113. }
  114. if( lower.line ) {
  115. gv->set( uarray.uarray[lower.index], lower.line->vval );
  116. gv->set( lower.index, lower.line->vindex );
  117. if( lower.index++ == lower.line->uend ) lower.line = 0;
  118. return gv;
  119. }
  120. if( lower.right ) {
  121. gv->set( lower.right->prev() );
  122. if( gv->isTrimVert() ) return gv;
  123. lower.right = 0;
  124. }
  125. return 0;
  126. }