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