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.

92 lines
2.5 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. * trimregion.c++ - $Revision: 1.2 $
  14. * Derrick Burns - 1991
  15. */
  16. #include "glimport.h"
  17. #include "myassert.h"
  18. #include "mystdio.h"
  19. #include "trimregi.h"
  20. #include "backend.h"
  21. TrimRegion::TrimRegion( void )
  22. {
  23. }
  24. void
  25. TrimRegion::setDu( REAL du )
  26. {
  27. oneOverDu = 1.0/du;
  28. }
  29. void
  30. TrimRegion::init( long npts, Arc_ptr extrema )
  31. {
  32. left.init( npts, extrema, extrema->pwlArc->npts - 1 );
  33. left.getNextPt();
  34. right.init( npts, extrema, 0 );
  35. right.getPrevPt();
  36. }
  37. void
  38. TrimRegion::getPts( Arc_ptr extrema )
  39. {
  40. left.getNextPts( extrema );
  41. right.getPrevPts( extrema );
  42. }
  43. void
  44. TrimRegion::getPts( Backend &backend )
  45. {
  46. left.getNextPts( bot.vval, backend );
  47. right.getPrevPts( bot.vval, backend );
  48. }
  49. void
  50. TrimRegion::getGridExtent( void )
  51. {
  52. getGridExtent( left.last(), right.last() );
  53. }
  54. void
  55. TrimRegion::getGridExtent( TrimVertex *l, TrimVertex *r )
  56. {
  57. bot.ustart = (long) ((l->param[0] - uarray.uarray[0])*oneOverDu);
  58. if( l->param[0] >= uarray.uarray[bot.ustart] ) bot.ustart++;
  59. // if( l->param[0] > uarray.uarray[bot.ustart] ) bot.ustart++;
  60. assert( l->param[0] <= uarray.uarray[bot.ustart] );
  61. assert( l->param[0] >= uarray.uarray[bot.ustart-1] );
  62. bot.uend = (long) ((r->param[0] - uarray.uarray[0])*oneOverDu);
  63. if( uarray.uarray[bot.uend] >= r->param[0] ) bot.uend--;
  64. // if( uarray.uarray[bot.uend] > r->param[0] ) bot.uend--;
  65. assert( r->param[0] >= uarray.uarray[bot.uend] );
  66. assert( r->param[0] <= uarray.uarray[bot.uend+1] );
  67. }
  68. int
  69. TrimRegion::canTile( void )
  70. {
  71. TrimVertex *lf = left.first();
  72. TrimVertex *ll = left.last();
  73. TrimVertex *l = ( ll->param[0] > lf->param[0] ) ? ll : lf;
  74. TrimVertex *rf = right.first();
  75. TrimVertex *rl = right.last();
  76. TrimVertex *r = ( rl->param[0] < rf->param[0] ) ? rl : rf;
  77. return (l->param[0] <= r->param[0]) ? 1 : 0;
  78. }