Update to SGI FreeB 2.0.
[mesa.git] / src / glu / sgi / libnurbs / internals / arc.h
1 /*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30
31 /*
32 * arc.h
33 *
34 * $Date: 2001/08/07 17:34:11 $ $Revision: 1.2 $
35 * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arc.h,v 1.2 2001/08/07 17:34:11 brianp Exp $
36 */
37
38 #ifndef __gluarc_h_
39 #define __gluarc_h_
40
41 #include "myassert.h"
42 #include "bufpool.h"
43 #include "mystdio.h"
44 #include "types.h"
45 #include "pwlarc.h"
46 #include "trimvertex.h"
47
48 class Bin;
49 class Arc;
50 struct BezierArc;
51
52 typedef class Arc *Arc_ptr;
53
54 enum arc_side { arc_none = 0, arc_right, arc_top, arc_left, arc_bottom };
55
56
57 class Arc: public PooledObj { /* an arc, in two list, the trim list and bin */
58
59 public:
60 static const int bezier_tag;
61 static const int arc_tag;
62 static const int tail_tag;
63 Arc_ptr prev; /* trim list pointer */
64 Arc_ptr next; /* trim list pointer */
65 Arc_ptr link; /* bin pointers */
66 BezierArc * bezierArc; /* associated bezier arc */
67 PwlArc * pwlArc; /* associated pwl arc */
68 long type; /* curve type */
69 long nuid;
70
71 inline Arc( Arc *, PwlArc * );
72 inline Arc( arc_side, long );
73
74 Arc_ptr append( Arc_ptr );
75 int check( void );
76 int isMonotone( void );
77 int isDisconnected( void );
78 int numpts( void );
79 void markverts( void );
80 void getextrema( Arc_ptr[4] );
81 void print( void );
82 void show( void );
83 void makeSide( PwlArc *, arc_side );
84 inline int isTessellated() { return pwlArc ? 1 : 0; }
85 inline long isbezier() { return type & bezier_tag; }
86 inline void setbezier() { type |= bezier_tag; }
87 inline void clearbezier() { type &= ~bezier_tag; }
88 inline long npts() { return pwlArc->npts; }
89 inline TrimVertex * pts() { return pwlArc->pts; }
90 inline REAL * tail() { return pwlArc->pts[0].param; }
91 inline REAL * head() { return next->pwlArc->pts[0].param; }
92 inline REAL * rhead() { return pwlArc->pts[pwlArc->npts-1].param; }
93 inline long ismarked() { return type & arc_tag; }
94 inline void setmark() { type |= arc_tag; }
95 inline void clearmark() { type &= (~arc_tag); }
96 inline void clearside() { type &= ~(0x7 << 8); }
97 inline void setside( arc_side s ) { clearside(); type |= (((long)s)<<8); }
98 inline arc_side getside() { return (arc_side) ((type>>8) & 0x7); }
99 inline int getitail() { return type & tail_tag; }
100 inline void setitail() { type |= tail_tag; }
101 inline void clearitail() { type &= (~tail_tag); }
102 };
103
104 /*--------------------------------------------------------------------------
105 * Arc - initialize a new Arc with the same type and uid of
106 * a given Arc and a given pwl arc
107 *--------------------------------------------------------------------------
108 */
109
110 inline
111 Arc::Arc( Arc *j, PwlArc *p )
112 {
113 bezierArc = NULL;
114 pwlArc = p;
115 type = j->type;
116 nuid = j->nuid;
117 }
118
119 /*--------------------------------------------------------------------------
120 * Arc - initialize a new Arc with the same type and uid of
121 * a given Arc and a given pwl arc
122 *--------------------------------------------------------------------------
123 */
124
125 inline
126 Arc::Arc( arc_side side, long _nuid )
127 {
128 bezierArc = NULL;
129 pwlArc = NULL;
130 type = 0;
131 setside( side );
132 nuid = _nuid;
133 }
134
135 #endif /* __gluarc_h_ */