ReactOS 0.4.15-dev-8131-g4988de4
trimline.cc
Go to the documentation of this file.
1/*
2** License Applicability. Except to the extent portions of this file are
3** made subject to an alternative license as permitted in the SGI Free
4** Software License B, Version 1.1 (the "License"), the contents of this
5** file are subject only to the provisions of the License. You may not use
6** this file except in compliance with the License. You may obtain a copy
7** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
9**
10** http://oss.sgi.com/projects/FreeB
11**
12** Note that, as provided in the License, the Software is distributed on an
13** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17**
18** Original Code. The Original Code is: OpenGL Sample Implementation,
19** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21** Copyright in any portions created by third parties is as indicated
22** elsewhere herein. All Rights Reserved.
23**
24** Additional Notice Provisions: The application programming interfaces
25** established by SGI in conjunction with the Original Code are The
26** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29** Window System(R) (Version 1.3), released October 19, 1998. This software
30** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31** published by SGI, but has not been independently verified as being
32** compliant with the OpenGL(R) version 1.2.1 Specification.
33*/
34
35/*
36 * trimline.c++
37 *
38 */
39
40//#include "glimports.h"
41//#include "myassert.h"
42//#include "mystdio.h"
43#include "trimline.h"
44#include "backend.h"
45
47{
48 size = 0; pts = 0; numverts = 0;
49 tinterp = &t; binterp = &b;
50}
51
53{
54 if( pts ) delete[] pts;
55}
56
57void
59{
60 reset();
61 grow(1);
62 append(v);
63}
64
65inline void
66Trimline::grow( long npts )
67{
68 if( size < npts ) {
69 size = 2 * npts;
70 if( pts ) delete[] pts;
71 pts = new TrimVertex_p[size];
72 }
73}
74
75inline void
77{
78 assert( numverts != size );
79 pts[numverts++] = v;
80}
81
82void
83Trimline::init( long npts, Arc_ptr jarc, long last )
84{
85 jarcl.init( jarc, 0, last );
86 grow( npts + 2 );
87}
88
89inline void
91{
92 TrimVertex *tmp=tinterp;
94 binterp=tmp;
95}
96
97void
99{
100 *binterp = *jarcl.getnextpt();
101}
102
103void
105{
106 *binterp = *jarcl.getprevpt();
107}
108
109/*----------------------------------------------------------------------
110 * getNextPts - make arrays of pointers to trim points on left and right
111 * hulls of trim strip.
112 *----------------------------------------------------------------------
113 */
114void
116{
117 reset(); swap(); append( tinterp );
118 assert( tinterp->param[1] >= vval );
119
120 TrimVertex *p;
121 for( p=jarcl.getnextpt() ; p->param[1] >= vval; p=jarcl.getnextpt() ) {
122 append( p );
123 }
124
125 /* compute and copy pointer to final point on left hull */
126 if( interpvert( last(), p, binterp, vval ) ) {
127 binterp->nuid = p->nuid;
128 backend.triangle( p, binterp, last() );
129 append( binterp );
130 }
131 jarcl.reverse();
132 (void) jarcl.getprevpt(); /* reset jarcl to proper position */
133 jarcl.reverse();
134}
135
136void
138{
139 reset(); swap(); append( tinterp );
140 assert( tinterp->param[1] >= vval );
141
142 TrimVertex *q;
143 for( q=jarcl.getprevpt(); q->param[1] >= vval; q=jarcl.getprevpt() ) {
144 append( q );
145 }
146
147 /* compute and copy pointer to final point on right hull */
148 if( interpvert( q, last(), binterp, vval ) ) {
149 binterp->nuid = q->nuid;
150 backend.triangle( last(), binterp, q );
151 append( binterp );
152 }
153 jarcl.reverse();
154 (void) jarcl.getnextpt(); /* reset jarcl to proper position */
155 jarcl.reverse();
156}
157
158void
160{
161 reset(); swap(); append( tinterp );
162
163#ifndef NDEBUG
164 PwlArc *lastpwl = botarc->prev->pwlArc;
165 TrimVertex *lastpt1 = &lastpwl->pts[lastpwl->npts-1];
166#endif
167 TrimVertex *lastpt2 = botarc->pwlArc->pts;
169 for( append( p ); p != lastpt2; append( p ) ) {
170 assert( p != lastpt1 );
171 p = jarcl.getnextpt();
172 }
173}
174
175void
177{
178 reset(); swap(); append( tinterp );
179
180 PwlArc *lastpwl = botarc->prev->pwlArc;
181 TrimVertex *lastpt1 = &lastpwl->pts[lastpwl->npts-1];
182#ifndef NDEBUG
183 TrimVertex *lastpt2 = botarc->pwlArc->pts;
184#endif
185
187 for( append( q ); q != lastpt1; append( q ) ) {
188 assert( q != lastpt2 );
189 q = jarcl.getprevpt();
190 }
191}
192
193
194long
196{
197 REAL denom = a->param[1] - b->param[1];
198
199 if(denom != 0) {
200 if( vval == a->param[1] ) {
201 c->param[0] = a->param[0];
202 c->param[1] = a->param[1];
203 c->nuid = a->nuid;
204 return 0;
205 } else if( vval == b->param[1] ) {
206 c->param[0] = b->param[0];
207 c->param[1] = b->param[1];
208 c->nuid = b->nuid;
209 return 0;
210 } else {
211 REAL r = (a->param[1] - vval)/denom;
212 c->param[0] = a->param[0] - r * (a->param[0] - b->param[0]);
213 c->param[1] = vval;
214 return 1;
215 }
216 } else {
217 c->param[0] = a->param[0];
218 c->param[1] = a->param[1];
219 c->nuid = a->nuid;
220 return 0;
221 }
222}
223
void triangle(TrimVertex *, TrimVertex *, TrimVertex *)
Definition: backend.cc:517
void init(Arc_ptr a, long first, long last)
Definition: jarcloc.h:47
void reverse()
Definition: jarcloc.h:54
TrimVertex * getprevpt(void)
Definition: jarcloc.h:76
TrimVertex * getnextpt(void)
Definition: jarcloc.h:63
Definition: pwlarc.h:44
int npts
Definition: pwlarc.h:47
TrimVertex * pts
Definition: pwlarc.h:46
REAL param[2]
Definition: trimvertex.h:45
long nuid
Definition: trimvertex.h:50
void append(TrimVertex *)
Definition: trimline.cc:76
TrimVertex b
Definition: trimline.h:53
Jarcloc jarcl
Definition: trimline.h:52
void reset(void)
Definition: trimline.h:55
TrimVertex * binterp
Definition: trimline.h:54
TrimVertex t
Definition: trimline.h:53
TrimVertex * tinterp
Definition: trimline.h:54
void getNextPts(REAL, Backend &)
Definition: trimline.cc:115
~Trimline()
Definition: trimline.cc:52
void grow(long)
Definition: trimline.cc:66
static long interpvert(TrimVertex *, TrimVertex *, TrimVertex *, REAL)
Definition: trimline.cc:195
TrimVertex ** pts
Definition: trimline.h:48
void getNextPt(void)
Definition: trimline.cc:98
Trimline()
Definition: trimline.cc:46
long numverts
Definition: trimline.h:49
void getPrevPt(void)
Definition: trimline.cc:104
void init(TrimVertex *)
Definition: trimline.cc:58
long size
Definition: trimline.h:51
void swap(void)
Definition: trimline.cc:90
void getPrevPts(REAL, Backend &)
Definition: trimline.cc:137
TrimVertex * last(void)
Definition: trimline.h:99
class Arc * Arc_ptr
Definition: arc.h:50
float REAL
Definition: types.h:41
#define assert(x)
Definition: debug.h:53
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static UINT UINT last
Definition: font.c:45
class TrimVertex * TrimVertex_p
Definition: trimvertex.h:53