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. * bin.c++ - $Revision: 1.1 $
  14. * Derrick Burns - 1991
  15. */
  16. #include "glimport.h"
  17. #include "mystdio.h"
  18. #include "myassert.h"
  19. #include "bin.h"
  20. /*----------------------------------------------------------------------------
  21. * Constructor and destructor
  22. *----------------------------------------------------------------------------
  23. */
  24. Bin::Bin()
  25. {
  26. head = NULL;
  27. }
  28. Bin::~Bin()
  29. {
  30. assert( head == NULL);
  31. }
  32. /*----------------------------------------------------------------------------
  33. * remove_this_arc - remove given Arc_ptr from bin
  34. *----------------------------------------------------------------------------
  35. */
  36. void
  37. Bin::remove_this_arc( Arc_ptr arc )
  38. {
  39. for( Arc_ptr *j = &(head); (*j != 0) && (*j != arc); j = &((*j)->link) );
  40. if( *j != 0 ) {
  41. if( *j == current )
  42. current = (*j)->link;
  43. *j = (*j)->link;
  44. }
  45. }
  46. /*----------------------------------------------------------------------------
  47. * numarcs - count number of arcs in bin
  48. *----------------------------------------------------------------------------
  49. */
  50. int
  51. Bin::numarcs()
  52. {
  53. long count = 0;
  54. for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
  55. count++;
  56. return count;
  57. }
  58. /*----------------------------------------------------------------------------
  59. * adopt - place an orphaned arcs into their new parents bin
  60. *----------------------------------------------------------------------------
  61. */
  62. void
  63. Bin::adopt()
  64. {
  65. markall();
  66. Arc_ptr orphan;
  67. while( orphan = removearc() ) {
  68. for( Arc_ptr parent = orphan->next; parent != orphan; parent = parent->next ) {
  69. if (! parent->ismarked() ) {
  70. orphan->link = parent->link;
  71. parent->link = orphan;
  72. orphan->clearmark();
  73. break;
  74. }
  75. }
  76. }
  77. }
  78. /*----------------------------------------------------------------------------
  79. * show - print out descriptions of the arcs in the bin
  80. *----------------------------------------------------------------------------
  81. */
  82. void
  83. Bin::show( char *name )
  84. {
  85. #ifndef NDEBUG
  86. dprintf( "%s\n", name );
  87. for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
  88. jarc->show( );
  89. #endif
  90. }
  91. /*----------------------------------------------------------------------------
  92. * markall - mark all arcs with an identifying tag
  93. *----------------------------------------------------------------------------
  94. */
  95. void
  96. Bin::markall()
  97. {
  98. for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() )
  99. jarc->setmark();
  100. }
  101. /*----------------------------------------------------------------------------
  102. * listBezier - print out all arcs that are untessellated border arcs
  103. *----------------------------------------------------------------------------
  104. */
  105. void
  106. Bin::listBezier( void )
  107. {
  108. for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() ) {
  109. if( jarc->isbezier( ) ) {
  110. assert( jarc->pwlArc->npts == 2 );
  111. TrimVertex *pts = jarc->pwlArc->pts;
  112. REAL s1 = pts[0].param[0];
  113. REAL t1 = pts[0].param[1];
  114. REAL s2 = pts[1].param[0];
  115. REAL t2 = pts[1].param[1];
  116. #ifndef NDEBUG
  117. dprintf( "arc (%g,%g) (%g,%g)\n", s1, t1, s2, t2 );
  118. #endif
  119. }
  120. }
  121. }