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.

138 lines
4.2 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. * patchlist.c++ - $Revision: 1.1 $
  14. * Derrick Burns - 1991
  15. */
  16. #include "glimport.h"
  17. #include "myassert.h"
  18. #include "mystdio.h"
  19. #include "quilt.h"
  20. #include "patchlis.h"
  21. #include "patch.h"
  22. #include "nurbscon.h"
  23. Patchlist::Patchlist( Quilt *quilts, REAL *pta, REAL *ptb )
  24. {
  25. patch = 0;
  26. for( Quilt *q = quilts; q; q = q->next )
  27. patch = new Patch( q, pta, ptb, patch );
  28. pspec[0].range[0] = pta[0];
  29. pspec[0].range[1] = ptb[0];
  30. pspec[0].range[2] = ptb[0] - pta[0];
  31. pspec[1].range[0] = pta[1];
  32. pspec[1].range[1] = ptb[1];
  33. pspec[1].range[2] = ptb[1] - pta[1];
  34. }
  35. Patchlist::Patchlist( Patchlist &upper, int param, REAL value)
  36. {
  37. Patchlist &lower = *this;
  38. patch = 0;
  39. for( Patch *p = upper.patch; p; p = p->next )
  40. patch = new Patch( *p, param, value, patch );
  41. if( param == 0 ) {
  42. lower.pspec[0].range[0] = upper.pspec[0].range[0];
  43. lower.pspec[0].range[1] = value;
  44. lower.pspec[0].range[2] = value - upper.pspec[0].range[0];
  45. upper.pspec[0].range[0] = value;
  46. upper.pspec[0].range[2] = upper.pspec[0].range[1] - value;
  47. lower.pspec[1] = upper.pspec[1];
  48. } else {
  49. lower.pspec[0] = upper.pspec[0];
  50. lower.pspec[1].range[0] = upper.pspec[1].range[0];
  51. lower.pspec[1].range[1] = value;
  52. lower.pspec[1].range[2] = value - upper.pspec[1].range[0];
  53. upper.pspec[1].range[0] = value;
  54. upper.pspec[1].range[2] = upper.pspec[1].range[1] - value;
  55. }
  56. }
  57. Patchlist::~Patchlist()
  58. {
  59. while( patch ) {
  60. Patch *p = patch;
  61. patch = patch->next;
  62. delete p;
  63. }
  64. }
  65. int
  66. Patchlist::cullCheck( void )
  67. {
  68. for( Patch *p = patch; p; p = p->next )
  69. if( p->cullCheck() == CULL_TRIVIAL_REJECT )
  70. return CULL_TRIVIAL_REJECT;
  71. return CULL_ACCEPT;
  72. }
  73. void
  74. Patchlist::getstepsize( void )
  75. {
  76. pspec[0].stepsize = pspec[0].range[2];
  77. pspec[0].sidestep[0] = pspec[0].range[2];
  78. pspec[0].sidestep[1] = pspec[0].range[2];
  79. pspec[1].stepsize = pspec[1].range[2];
  80. pspec[1].sidestep[0] = pspec[1].range[2];
  81. pspec[1].sidestep[1] = pspec[1].range[2];
  82. for( Patch *p = patch; p; p = p->next ) {
  83. p->getstepsize();
  84. p->clamp();
  85. pspec[0].stepsize = ((p->pspec[0].stepsize < pspec[0].stepsize) ? p->pspec[0].stepsize : pspec[0].stepsize);
  86. pspec[0].sidestep[0] = ((p->pspec[0].sidestep[0] < pspec[0].sidestep[0]) ? p->pspec[0].sidestep[0] : pspec[0].sidestep[0]);
  87. pspec[0].sidestep[1] = ((p->pspec[0].sidestep[1] < pspec[0].sidestep[1]) ? p->pspec[0].sidestep[1] : pspec[0].sidestep[1]);
  88. pspec[1].stepsize = ((p->pspec[1].stepsize < pspec[1].stepsize) ? p->pspec[1].stepsize : pspec[1].stepsize);
  89. pspec[1].sidestep[0] = ((p->pspec[1].sidestep[0] < pspec[1].sidestep[0]) ? p->pspec[1].sidestep[0] : pspec[1].sidestep[0]);
  90. pspec[1].sidestep[1] = ((p->pspec[1].sidestep[1] < pspec[1].sidestep[1]) ? p->pspec[1].sidestep[1] : pspec[1].sidestep[1]);
  91. }
  92. }
  93. void
  94. Patchlist::bbox( void )
  95. {
  96. for( Patch *p = patch; p; p = p->next )
  97. p->bbox();
  98. }
  99. int
  100. Patchlist::needsNonSamplingSubdivision( void )
  101. {
  102. notInBbox = 0;
  103. for( Patch *p = patch; p; p = p->next )
  104. notInBbox |= p->needsNonSamplingSubdivision();
  105. return notInBbox;
  106. }
  107. int
  108. Patchlist::needsSamplingSubdivision( void )
  109. {
  110. pspec[0].needsSubdivision = 0;
  111. pspec[1].needsSubdivision = 0;
  112. for( Patch *p = patch; p; p = p->next ) {
  113. pspec[0].needsSubdivision |= p->pspec[0].needsSubdivision;
  114. pspec[1].needsSubdivision |= p->pspec[0].needsSubdivision;
  115. }
  116. return (pspec[0].needsSubdivision || pspec[1].needsSubdivision) ? 1 : 0;
  117. }
  118. int
  119. Patchlist::needsSubdivision( int param )
  120. {
  121. return pspec[param].needsSubdivision;
  122. }