41 #include "glimports.h"
45 #include "patchlist.h"
47 #include "nurbsconsts.h"
49 Patchlist::Patchlist(
Quilt *quilts, REAL *pta, REAL *ptb )
52 for(
Quilt *q = quilts; q; q = q->next )
53 patch =
new Patch( q, pta, ptb, patch );
54 pspec[0].range[0] = pta[0];
55 pspec[0].range[1] = ptb[0];
56 pspec[0].range[2] = ptb[0] - pta[0];
58 pspec[1].range[0] = pta[1];
59 pspec[1].range[1] = ptb[1];
60 pspec[1].range[2] = ptb[1] - pta[1];
63 Patchlist::Patchlist(
Patchlist &upper,
int param, REAL value)
67 for(
Patch *p = upper.patch; p; p = p->next )
68 patch =
new Patch( *p, param, value, patch );
71 lower.pspec[0].range[0] = upper.pspec[0].range[0];
72 lower.pspec[0].range[1] = value;
73 lower.pspec[0].range[2] = value - upper.pspec[0].range[0];
74 upper.pspec[0].range[0] = value;
75 upper.pspec[0].range[2] = upper.pspec[0].range[1] - value;
76 lower.pspec[1] = upper.pspec[1];
78 lower.pspec[0] = upper.pspec[0];
79 lower.pspec[1].range[0] = upper.pspec[1].range[0];
80 lower.pspec[1].range[1] = value;
81 lower.pspec[1].range[2] = value - upper.pspec[1].range[0];
82 upper.pspec[1].range[0] = value;
83 upper.pspec[1].range[2] = upper.pspec[1].range[1] - value;
87 Patchlist::~Patchlist()
97 Patchlist::cullCheck(
void )
99 for(
Patch *p = patch; p; p = p->next )
100 if( p->cullCheck() == CULL_TRIVIAL_REJECT )
101 return CULL_TRIVIAL_REJECT;
106 Patchlist::getRanges(REAL ranges[4])
108 ranges[0] = pspec[0].range[0];
109 ranges[1] = pspec[0].range[1];
110 ranges[2] = pspec[1].range[0];
111 ranges[3] = pspec[1].range[1];
115 Patchlist::getstepsize(
void )
117 pspec[0].stepsize = pspec[0].range[2];
118 pspec[0].sidestep[0] = pspec[0].range[2];
119 pspec[0].sidestep[1] = pspec[0].range[2];
121 pspec[1].stepsize = pspec[1].range[2];
122 pspec[1].sidestep[0] = pspec[1].range[2];
123 pspec[1].sidestep[1] = pspec[1].range[2];
125 for(
Patch *p = patch; p; p = p->next ) {
128 pspec[0].stepsize = ((p->pspec[0].stepsize < pspec[0].stepsize) ? p->pspec[0].stepsize : pspec[0].stepsize);
129 pspec[0].sidestep[0] = ((p->pspec[0].sidestep[0] < pspec[0].sidestep[0]) ? p->pspec[0].sidestep[0] : pspec[0].sidestep[0]);
130 pspec[0].sidestep[1] = ((p->pspec[0].sidestep[1] < pspec[0].sidestep[1]) ? p->pspec[0].sidestep[1] : pspec[0].sidestep[1]);
131 pspec[1].stepsize = ((p->pspec[1].stepsize < pspec[1].stepsize) ? p->pspec[1].stepsize : pspec[1].stepsize);
132 pspec[1].sidestep[0] = ((p->pspec[1].sidestep[0] < pspec[1].sidestep[0]) ? p->pspec[1].sidestep[0] : pspec[1].sidestep[0]);
133 pspec[1].sidestep[1] = ((p->pspec[1].sidestep[1] < pspec[1].sidestep[1]) ? p->pspec[1].sidestep[1] : pspec[1].sidestep[1]);
138 Patchlist::bbox(
void )
140 for(
Patch *p = patch; p; p = p->next )
145 Patchlist::needsNonSamplingSubdivision(
void )
148 for(
Patch *p = patch; p; p = p->next )
149 notInBbox |= p->needsNonSamplingSubdivision();
154 Patchlist::needsSamplingSubdivision(
void )
156 pspec[0].needsSubdivision = 0;
157 pspec[1].needsSubdivision = 0;
159 for(
Patch *p = patch; p; p = p->next ) {
160 pspec[0].needsSubdivision |= p->pspec[0].needsSubdivision;
161 pspec[1].needsSubdivision |= p->pspec[0].needsSubdivision;
163 return (pspec[0].needsSubdivision || pspec[1].needsSubdivision) ? 1 : 0;
167 Patchlist::needsSubdivision(
int param )
169 return pspec[param].needsSubdivision;