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.

144 lines
3.3 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. * slicer.c++ - $Revision: 1.4 $
  14. * Derrick Burns - 1991
  15. */
  16. #include "glimport.h"
  17. #include "mystdio.h"
  18. #include "myassert.h"
  19. #include "bufpool.h"
  20. #include "slicer.h"
  21. #include "backend.h"
  22. #include "arc.h"
  23. #include "gridtrim.h"
  24. #include "trimvert.h"
  25. #include "varray.h"
  26. Slicer::Slicer( Backend &b )
  27. : CoveAndTiler( b ), Mesher( b ), backend( b )
  28. {
  29. }
  30. Slicer::~Slicer()
  31. {
  32. }
  33. void
  34. Slicer::setisolines( int x )
  35. {
  36. isolines = x;
  37. }
  38. void
  39. Slicer::setstriptessellation( REAL x, REAL y )
  40. {
  41. assert(x > 0 && y > 0);
  42. du = x;
  43. dv = y;
  44. setDu( du );
  45. }
  46. void
  47. Slicer::slice( Arc_ptr loop )
  48. {
  49. loop->markverts();
  50. Arc_ptr extrema[4];
  51. loop->getextrema( extrema );
  52. unsigned int npts = loop->numpts();
  53. TrimRegion::init( npts, extrema[0] );
  54. Mesher::init( npts );
  55. long ulines = uarray.init( du, extrema[1], extrema[3] );
  56. Varray varray;
  57. long vlines = varray.init( dv, extrema[0], extrema[2] );
  58. long botv = 0;
  59. long topv;
  60. TrimRegion::init( varray.varray[botv] );
  61. getGridExtent( &extrema[0]->pwlArc->pts[0], &extrema[0]->pwlArc->pts[0] );
  62. for( long quad=0; quad<varray.numquads; quad++ ) {
  63. backend.surfgrid( uarray.uarray[0],
  64. uarray.uarray[ulines-1],
  65. ulines-1,
  66. varray.vval[quad],
  67. varray.vval[quad+1],
  68. varray.voffset[quad+1] - varray.voffset[quad] );
  69. for( long i=varray.voffset[quad]+1; i <= varray.voffset[quad+1]; i++ ) {
  70. topv = botv++;
  71. advance( topv - varray.voffset[quad],
  72. botv - varray.voffset[quad],
  73. varray.varray[botv] );
  74. if( i == vlines )
  75. getPts( extrema[2] );
  76. else
  77. getPts( backend );
  78. getGridExtent();
  79. if( isolines ) {
  80. outline();
  81. } else {
  82. if( canTile() )
  83. coveAndTile();
  84. else
  85. mesh();
  86. }
  87. }
  88. }
  89. }
  90. void
  91. Slicer::outline( void )
  92. {
  93. GridTrimVertex upper, lower;
  94. Hull::init( );
  95. backend.bgnoutline();
  96. while( (nextupper( &upper )) ) {
  97. if( upper.isGridVert() )
  98. backend.linevert( upper.g );
  99. else
  100. backend.linevert( upper.t );
  101. }
  102. backend.endoutline();
  103. backend.bgnoutline();
  104. while( (nextlower( &lower )) ) {
  105. if( lower.isGridVert() )
  106. backend.linevert( lower.g );
  107. else
  108. backend.linevert( lower.t );
  109. }
  110. backend.endoutline();
  111. }
  112. void
  113. Slicer::outline( Arc_ptr jarc )
  114. {
  115. jarc->markverts();
  116. if( jarc->pwlArc->npts >= 2 ) {
  117. backend.bgnoutline();
  118. for( int j = jarc->pwlArc->npts-1; j >= 0; j-- )
  119. backend.linevert( &(jarc->pwlArc->pts[j]) );
  120. backend.endoutline();
  121. }
  122. }