source: trunk/src/opengl/glu/nurbs/internals/hull.cpp

Last change on this file was 2689, checked in by jeroen, 26 years ago

* empty log message *

File size: 5.0 KB
Line 
1/* $Id: hull.cpp,v 1.1 2000-02-09 08:50:23 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 * hull.c++
38 *
39 * $Date: 2000-02-09 08:50:23 $ $Revision: 1.1 $
40 * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glu/nurbs/internals/hull.cpp,v 1.1 2000-02-09 08:50:23 jeroen Exp $
41 */
42
43#include "glimports.h"
44#include "myassert.h"
45#include "mystdio.h"
46#include "hull.h"
47#include "gridvertex.h"
48#include "gridtrimvertex.h"
49#include "gridline.h"
50#include "trimline.h"
51#include "uarray.h"
52#include "trimregion.h"
53
54Hull::Hull( void )
55{}
56
57Hull::~Hull( void )
58{}
59
60/*----------------------------------------------------------------------
61 * Hull:init - this routine does the initialization needed before any
62 * calls to nextupper or nextlower can be made.
63 *----------------------------------------------------------------------
64 */
65void
66Hull::init( void )
67{
68 TrimVertex *lfirst = left.first();
69 TrimVertex *llast = left.last();
70 if( lfirst->param[0] <= llast->param[0] ) {
71 fakeleft.init( left.first() );
72 upper.left = &fakeleft;
73 lower.left = &left;
74 } else {
75 fakeleft.init( left.last() );
76 lower.left = &fakeleft;
77 upper.left = &left;
78 }
79 upper.left->last();
80 lower.left->first();
81
82 if( top.ustart <= top.uend ) {
83 upper.line = &top;
84 upper.index = top.ustart;
85 } else
86 upper.line = 0;
87
88 if( bot.ustart <= bot.uend ) {
89 lower.line = &bot;
90 lower.index = bot.ustart;
91 } else
92 lower.line = 0;
93
94 TrimVertex *rfirst = right.first();
95 TrimVertex *rlast = right.last();
96 if( rfirst->param[0] <= rlast->param[0] ) {
97 fakeright.init( right.last() );
98 lower.right = &fakeright;
99 upper.right = &right;
100 } else {
101 fakeright.init( right.first() );
102 upper.right = &fakeright;
103 lower.right = &right;
104 }
105 upper.right->first();
106 lower.right->last();
107}
108
109/*----------------------------------------------------------------------
110 * nextupper - find next vertex on upper hull of trim region.
111 * - if vertex is on trim curve, set vtop point to
112 * that vertex. if vertex is on grid, set vtop to
113 * point to temporary area and stuff coordinants into
114 * temporary vertex. Also, place grid coords in temporary
115 * grid vertex.
116 *----------------------------------------------------------------------
117 */
118GridTrimVertex *
119Hull::nextupper( GridTrimVertex *gv )
120{
121 if( upper.left ) {
122 gv->set( upper.left->prev() );
123 if( gv->isTrimVert() ) return gv;
124 upper.left = 0;
125 }
126
127 if( upper.line ) {
128 assert( upper.index <= upper.line->uend );
129 gv->set( uarray.uarray[upper.index], upper.line->vval );
130 gv->set( upper.index, upper.line->vindex );
131 if( upper.index++ == upper.line->uend ) upper.line = 0;
132 return gv;
133 }
134
135 if( upper.right ) {
136 gv->set( upper.right->next() );
137 if( gv->isTrimVert() ) return gv;
138 upper.right = 0;
139 }
140
141 return 0;
142}
143
144GridTrimVertex *
145Hull::nextlower( register GridTrimVertex *gv )
146{
147 if( lower.left ) {
148 gv->set( lower.left->next() );
149 if( gv->isTrimVert() ) return gv;
150 lower.left = 0;
151 }
152
153 if( lower.line ) {
154 gv->set( uarray.uarray[lower.index], lower.line->vval );
155 gv->set( lower.index, lower.line->vindex );
156 if( lower.index++ == lower.line->uend ) lower.line = 0;
157 return gv;
158 }
159
160 if( lower.right ) {
161 gv->set( lower.right->prev() );
162 if( gv->isTrimVert() ) return gv;
163 lower.right = 0;
164 }
165
166 return 0;
167}
168
Note: See TracBrowser for help on using the repository browser.