| 1 | /* $Id: bin.cpp,v 1.1 2000-02-09 08:50:21 jeroen Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | ** License Applicability. Except to the extent portions of this file are
|
|---|
| 4 | ** made subject to an alternative license as permitted in the SGI Free
|
|---|
| 5 | ** Software License B, Version 1.0 (the "License"), the contents of this
|
|---|
| 6 | ** file are subject only to the provisions of the License. You may not use
|
|---|
| 7 | ** this file except in compliance with the License. You may obtain a copy
|
|---|
| 8 | ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
|---|
| 9 | ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
|---|
| 10 | **
|
|---|
| 11 | ** http://oss.sgi.com/projects/FreeB
|
|---|
| 12 | **
|
|---|
| 13 | ** Note that, as provided in the License, the Software is distributed on an
|
|---|
| 14 | ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
|---|
| 15 | ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
|---|
| 16 | ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
|---|
| 17 | ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|---|
| 18 | **
|
|---|
| 19 | ** Original Code. The Original Code is: OpenGL Sample Implementation,
|
|---|
| 20 | ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
|---|
| 21 | ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
|---|
| 22 | ** Copyright in any portions created by third parties is as indicated
|
|---|
| 23 | ** elsewhere herein. All Rights Reserved.
|
|---|
| 24 | **
|
|---|
| 25 | ** Additional Notice Provisions: The application programming interfaces
|
|---|
| 26 | ** established by SGI in conjunction with the Original Code are The
|
|---|
| 27 | ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
|---|
| 28 | ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
|---|
| 29 | ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
|---|
| 30 | ** Window System(R) (Version 1.3), released October 19, 1998. This software
|
|---|
| 31 | ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
|---|
| 32 | ** published by SGI, but has not been independently verified as being
|
|---|
| 33 | ** compliant with the OpenGL(R) version 1.2.1 Specification.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | * bin.c++
|
|---|
| 38 | *
|
|---|
| 39 | * $Date: 2000-02-09 08:50:21 $ $Revision: 1.1 $
|
|---|
| 40 | * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glu/nurbs/internals/bin.cpp,v 1.1 2000-02-09 08:50:21 jeroen Exp $
|
|---|
| 41 | */
|
|---|
| 42 |
|
|---|
| 43 | #include <stdlib.h>
|
|---|
| 44 | #include "glimports.h"
|
|---|
| 45 | #include "mystdio.h"
|
|---|
| 46 | #include "myassert.h"
|
|---|
| 47 | #include "bin.h"
|
|---|
| 48 |
|
|---|
| 49 | /*----------------------------------------------------------------------------
|
|---|
| 50 | * Constructor and destructor
|
|---|
| 51 | *----------------------------------------------------------------------------
|
|---|
| 52 | */
|
|---|
| 53 | Bin::Bin()
|
|---|
| 54 | {
|
|---|
| 55 | head = NULL;
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | Bin::~Bin()
|
|---|
| 59 | {
|
|---|
| 60 | assert( head == NULL);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | /*----------------------------------------------------------------------------
|
|---|
| 64 | * remove_this_arc - remove given Arc_ptr from bin
|
|---|
| 65 | *----------------------------------------------------------------------------
|
|---|
| 66 | */
|
|---|
| 67 |
|
|---|
| 68 | void
|
|---|
| 69 | Bin::remove_this_arc( Arc_ptr arc )
|
|---|
| 70 | {
|
|---|
| 71 | Arc_ptr *j;
|
|---|
| 72 | for( j = &(head); (*j != 0) && (*j != arc); j = &((*j)->link) );
|
|---|
| 73 |
|
|---|
| 74 | if( *j != 0 ) {
|
|---|
| 75 | if( *j == current )
|
|---|
| 76 | current = (*j)->link;
|
|---|
| 77 | *j = (*j)->link;
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | /*----------------------------------------------------------------------------
|
|---|
| 82 | * numarcs - count number of arcs in bin
|
|---|
| 83 | *----------------------------------------------------------------------------
|
|---|
| 84 | */
|
|---|
| 85 |
|
|---|
| 86 | int
|
|---|
| 87 | Bin::numarcs()
|
|---|
| 88 | {
|
|---|
| 89 | long count = 0;
|
|---|
| 90 | for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
|---|
| 91 | count++;
|
|---|
| 92 | return count;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | /*----------------------------------------------------------------------------
|
|---|
| 96 | * adopt - place an orphaned arcs into their new parents bin
|
|---|
| 97 | *----------------------------------------------------------------------------
|
|---|
| 98 | */
|
|---|
| 99 |
|
|---|
| 100 | void
|
|---|
| 101 | Bin::adopt()
|
|---|
| 102 | {
|
|---|
| 103 | markall();
|
|---|
| 104 |
|
|---|
| 105 | Arc_ptr orphan;
|
|---|
| 106 | while( orphan = removearc() ) {
|
|---|
| 107 | for( Arc_ptr parent = orphan->next; parent != orphan; parent = parent->next ) {
|
|---|
| 108 | if (! parent->ismarked() ) {
|
|---|
| 109 | orphan->link = parent->link;
|
|---|
| 110 | parent->link = orphan;
|
|---|
| 111 | orphan->clearmark();
|
|---|
| 112 | break;
|
|---|
| 113 | }
|
|---|
| 114 | }
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | /*----------------------------------------------------------------------------
|
|---|
| 120 | * show - print out descriptions of the arcs in the bin
|
|---|
| 121 | *----------------------------------------------------------------------------
|
|---|
| 122 | */
|
|---|
| 123 |
|
|---|
| 124 | void
|
|---|
| 125 | Bin::show( char *name )
|
|---|
| 126 | {
|
|---|
| 127 | #ifndef NDEBUG
|
|---|
| 128 | dprintf( "%s\n", name );
|
|---|
| 129 | for( Arc_ptr jarc = firstarc(); jarc; jarc = nextarc() )
|
|---|
| 130 | jarc->show( );
|
|---|
| 131 | #endif
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | /*----------------------------------------------------------------------------
|
|---|
| 137 | * markall - mark all arcs with an identifying tag
|
|---|
| 138 | *----------------------------------------------------------------------------
|
|---|
| 139 | */
|
|---|
| 140 |
|
|---|
| 141 | void
|
|---|
| 142 | Bin::markall()
|
|---|
| 143 | {
|
|---|
| 144 | for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() )
|
|---|
| 145 | jarc->setmark();
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | /*----------------------------------------------------------------------------
|
|---|
| 149 | * listBezier - print out all arcs that are untessellated border arcs
|
|---|
| 150 | *----------------------------------------------------------------------------
|
|---|
| 151 | */
|
|---|
| 152 |
|
|---|
| 153 | void
|
|---|
| 154 | Bin::listBezier( void )
|
|---|
| 155 | {
|
|---|
| 156 | for( Arc_ptr jarc=firstarc(); jarc; jarc=nextarc() ) {
|
|---|
| 157 | if( jarc->isbezier( ) ) {
|
|---|
| 158 | assert( jarc->pwlArc->npts == 2 );
|
|---|
| 159 | TrimVertex *pts = jarc->pwlArc->pts;
|
|---|
| 160 | REAL s1 = pts[0].param[0];
|
|---|
| 161 | REAL t1 = pts[0].param[1];
|
|---|
| 162 | REAL s2 = pts[1].param[0];
|
|---|
| 163 | REAL t2 = pts[1].param[1];
|
|---|
| 164 | #ifndef NDEBUG
|
|---|
| 165 | dprintf( "arc (%g,%g) (%g,%g)\n", s1, t1, s2, t2 );
|
|---|
| 166 | #endif
|
|---|
| 167 | }
|
|---|
| 168 | }
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|