Debian Codegraph @

lib/database/src/so/nodes/nurbs/libnurbs/trimregion.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 * trimregion.c++ - $Revision: 1.2 $
39 * Derrick Burns - 1991
40 */
41
42 #include "glimports.h"
43 #include "myassert.h"
44 #include "mystdio.h"
45 #include "trimregion.h"
46 #include "backend.h"
47
48 TrimRegion::TrimRegion( void )
49 {
50 }
51
52 void
53 TrimRegion::setDu( REAL du )
54 {
55 oneOverDu = 1.0/du;
56 }
57
58 void
59 TrimRegion::init( long npts, Arc_ptr extrema )
60 {
61 left.init( npts, extrema, extrema->pwlArc->npts - 1 );
62 left.getNextPt();
63
64 right.init( npts, extrema, 0 );
65 right.getPrevPt();
66 }
67
68 void
69 TrimRegion::getPts( Arc_ptr extrema )
70 {
71 left.getNextPts( extrema );
72 right.getPrevPts( extrema );
73 }
74
75 void
76 TrimRegion::getPts( Backend &backend )
77 {
78 left.getNextPts( bot.vval, backend );
79 right.getPrevPts( bot.vval, backend );
80 }
81
82 void
83 TrimRegion::getGridExtent( void )
84 {
85 getGridExtent( left.last(), right.last() );
86 }
87
88 void
89 TrimRegion::getGridExtent( TrimVertex *l, TrimVertex *r )
90 {
91 bot.ustart = (long) ((l->param[0] - uarray.uarray[0])*oneOverDu);
92 if( l->param[0] >= uarray.uarray[bot.ustart] ) bot.ustart++;
93 // if( l->param[0] > uarray.uarray[bot.ustart] ) bot.ustart++;
94 assert( l->param[0] <= uarray.uarray[bot.ustart] );
95 assert( l->param[0] >= uarray.uarray[bot.ustart-1] );
96
97 bot.uend = (long) ((r->param[0] - uarray.uarray[0])*oneOverDu);
98 if( uarray.uarray[bot.uend] >= r->param[0] ) bot.uend--;
99 // if( uarray.uarray[bot.uend] > r->param[0] ) bot.uend--;
100 assert( r->param[0] >= uarray.uarray[bot.uend] );
101 assert( r->param[0] <= uarray.uarray[bot.uend+1] );
102 }
103
104 int
105 TrimRegion::canTile( void )
106 {
107 TrimVertex *lf = left.first();
108 TrimVertex *ll = left.last();
109 TrimVertex *l = ( ll->param[0] > lf->param[0] ) ? ll : lf;
110
111 TrimVertex *rf = right.first();
112 TrimVertex *rl = right.last();
113 TrimVertex *r = ( rl->param[0] < rf->param[0] ) ? rl : rf;
114 return (l->param[0] <= r->param[0]) ? 1 : 0;
115 }
116