Debian Codegraph @

lib/database/src/so/nodes/nurbs/libnurbs/curvelist.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * curvelist.c++ - $Revision: 1.1.1.1 $
39 * Derrick Burns - 1991
40 */
41
42 #include "glimports.h"
43 #include "myassert.h"
44 #include "mystdio.h"
45 #include "quilt.h"
46 #include "curvelist.h"
47 #include "curve.h"
48 #include "nurbsconsts.h"
49 #include "types.h"
50
51 Curvelist::Curvelist( Quilt *quilts, REAL pta, REAL ptb )
52 {
53 curve = 0;
54 for( Quilt *q = quilts; q; q = q->next )
55 curve = new Curve( q, pta, ptb, curve );
56 range[0] = pta;
57 range[1] = ptb;
58 range[2] = ptb - pta;
59 }
60
61 Curvelist::Curvelist( Curvelist &upper, REAL value )
62 {
63 Curvelist &lower = *this;
64 curve = 0;
65 for( Curve *c = upper.curve; c; c = c->next )
66 curve = new Curve( *c, value, curve );
67
68 lower.range[0] = upper.range[0];
69 lower.range[1] = value;
70 lower.range[2] = value - upper.range[0];
71 upper.range[0] = value;
72 upper.range[2] = upper.range[1] - value;
73 }
74
75 Curvelist::~Curvelist()
76 {
77 while( curve ) {
78 Curve *c = curve;
79 curve = curve->next;
80 delete c;
81 }
82 }
83
84 int
85 Curvelist::cullCheck( void )
86 {
87 for( Curve *c = curve; c; c = c->next )
88 if( c->cullCheck() == CULL_TRIVIAL_REJECT )
89 return CULL_TRIVIAL_REJECT;
90 return CULL_ACCEPT;
91 }
92
93 void
94 Curvelist::getstepsize( void )
95 {
96 Curve *c;
97 stepsize = range[2];
98 for( c = curve; c; c = c->next ) {
99 c->getstepsize();
100 c->clamp();
101 stepsize = ((c->stepsize < stepsize) ? c->stepsize : stepsize);
102 if( c->needsSamplingSubdivision() ) break;
103 }
104 needsSubdivision = ( c ) ? 1 : 0;
105 }
106
107 int
108 Curvelist::needsSamplingSubdivision( void )
109 {
110 return needsSubdivision;
111 }
112