if (f1<= 0 && f2 <= 0 ) res = -1;
else
if (f1 >= 0 && f2 >= 0 ) res = 1;
else {
fl = s2 -> f ( s1 -> x1, s1 -> invZ1 ); f2 = s2 -> f ( s1 -> x2, s1 -> invZ2 );
if (f 1<= 0 && f2 <= 0 ) res = 1;
else
res = -1;
}
return res;
}
///////////////// SBuffer methods ////////////////
void SBuffer:: addSpan (int line, Span * newSpan ) {
newSpan -> precompute ();
Span * prevSpan = head [line]; Span * curSpan = prevSpan -> next;

Компьютерная графика. Полигональные модели

for (; curSpan != NULL; ) {
if ( curSpan -> x2 < newSpan -> x1 ) {
prevSpan = curSpan; curSpan = curSpan -> next;
continue;
}
if ( newSpan -> x1 < curSpan -> x1 ) // cases 1, 2 or 4
{
if ( newSpan -> x2 <= curSpan -> x1 ) // case 1 {
newSpan -> insertBefore ( curSpan ); return;
}
if ( newSpan -> x2 < curSpan -> x2 ) // case 2 {
if ( compareSpans ( curSpan, newSpan ) < 0 )
curSpan -> clipAtXI ( newSpan -> x2 ); else
newSpan -> clipAtX2 ( curSpan -> x1 );
if (InewSpan -> isEmpty ())
newSpan -> insertBefore ( curSpan );
return;
}
else // case 4
{
if ( compareSpans ( curSpan, newSpan ) < 0 ) {
Span * tempSpan = curSpan -> next;
curSpan -> remove (); // remove from chain
pool -> freeSpan ( curSpan ); curSpan = tempSpan;
continue;
}
else
{
Span * tempSpan = pool -> allocSpan ( newSpan );
tempSpan -> insertBefore ( curSpan ); tempSpan -> clipAtX2 ( curSpan -> x1 ); newSpan -> clipAtXI ( curSpan -> x2 );
}
}
}
else // curSpan -> x1 <= newSpan -> x1
{
if ( newSpan -> x2 > curSpan -> x2 ) // case 5 {
10. YnaneHHe HeBUflUMbix dhhum m noBepxHocre
if ( compareSpans ( curSpan, newSpan ) < 0 ) {
curSpan -> clipAtX2 ( newSpan ;> x1 );
if ( curSpan -> isEmpty ()) {
Span * tempSpan = curSpan -> next;
curSpan -> remove ();
pool -> freeSpan ( curSpan );
curSpan - tempSpan;
continue;
}
else
newSpan -> clipAtXI (curSpan -> x2 );
}
else // case 3
{
if ( compareSpans ( curSpan, newSpan ) < 0 ) {

⇐ Предыдущая| |Следующая ⇒