bool Picture::intersects (BoxObj& userb, Graphic* gs) { if (!IsEmpty()) { Iterator i; FullGraphic gstemp; Transformer ttemp; BoxObj b; getBox(b, gs); if (b.Intersects(userb)) { gstemp.SetTransformer(&ttemp); for (First(i); !Done(i); Next(i)) { Graphic* gr = GetGraphic(i); concatGraphic(gr, gr, gs, &gstemp); if (intersectsGraphic(gr, userb, &gstemp)) { gstemp.SetTransformer(nil); return true; } } gstemp.SetTransformer(nil); /* to avoid deleting ttemp explicitly*/ } } return false; }
boolean FillPolygonObj::Intersects (BoxObj& ub) { BoxObj b; GetBox(b); if (!b.Intersects(ub)) { return false; } if (b.Within(ub)) { return true; } LineObj bottom(ub._left, ub._bottom, ub._right, ub._bottom); if (Intersects(bottom)) { return true; } LineObj right(ub._right, ub._bottom, ub._right, ub._top); if (Intersects(right)) { return true; } LineObj top(ub._right, ub._top, ub._left, ub._top); if (Intersects(top)) { return true; } LineObj left(ub._left, ub._top, ub._left, ub._bottom); return Intersects(left); }
boolean MultiLineObj::Intersects (BoxObj& userb) { register int i; BoxObj b; GetBox(b); if (b.Intersects(userb)) { for (i = 1; i < _count; ++i) { LineObj test(_x[i-1], _y[i-1], _x[i], _y[i]); if (userb.Intersects(test)) { return true; } } } return false; }
boolean BSplineSelection::intersects (BoxObj& userb, Graphic* gs) { BoxObj b; getBox(b, gs); if (b.Intersects(userb)) { if (intersectsGraphic(ifillbspline, userb, gs)) { return true; } else if (intersectsGraphic(bspline, userb, gs)) { return true; } else if (LeftAints(lx0, ly0, lx1, ly1, userb, gs)) { return true; } else if (RightAints(rx0, ry0, rx1, ry1, userb, gs)) { return true; } } return false; }
void Damage::Merge (BoxObj& newb) { BoxObj* a1, *a2; int newArea, area1, area2, diff1, diff2, diff3, maximum; Iterator i; FirstArea(i); a1 = GetArea(i); Next(i); a2 = GetArea(i); BoxObj merge1(*a1 + newb); BoxObj merge2(*a2 + newb); BoxObj merge3(*a1 + *a2); newArea = Area(newb); area1 = Area(*a1); area2 = Area(*a2); diff1 = area1 + newArea - Area(merge1); diff2 = area2 + newArea - Area(merge2); diff3 = area1 + area2 - Area(merge3); maximum = max(max(diff1, diff2), diff3); if (maximum == diff1) { if (a2->Intersects(merge1)) { *a1 = merge1 + *a2; DeleteArea(a2); } else { *a1 = merge1; } } else if (maximum == diff2) { if (a1->Intersects(merge2)) { *a2 = merge2 + *a1; DeleteArea(a1); } else { *a2 = merge2; } } else { if (newb.Intersects(merge3)) { *a1 = merge3 + newb; DeleteArea(a2); } else { *a1 = merge3; *a2 = newb; } } }
boolean FillPolygonObj::Intersects (LineObj& l) { BoxObj b; boolean intersects = false; if (_normCount == 0) { Normalize(); } GetBox(b); if (b.Intersects(l)) { MultiLineObj ml (_normx, _normy, _normCount - 1); intersects = ml.Intersects(l) || Contains(l._p1) || Contains(l._p2); } return intersects; }
boolean MultiLine::f_intersects (BoxObj& userb, Graphic* gs) { Coord* convx, *convy; BoxObj b; boolean result = false; getBox(b, gs); if (b.Intersects(userb)) { convx = new Coord[count()+1]; convy = new Coord[count()+1]; transformList(x(), y(), count(), convx, convy, gs); FillPolygonObj fp (convx, convy, count()); result = fp.Intersects(userb); delete convx; delete convy; } return result; }
bool OpenBSpline::s_intersects (BoxObj& userb, Graphic* gs) { Coord* convx, *convy; BoxObj b; bool result = false; getBox(b, gs); if (b.Intersects(userb)) { convx = new Coord[_count]; convy = new Coord[_count]; transformList(_x, _y, _count, convx, convy, gs); MultiLineObj ml; ml.SplineToMultiLine(convx, convy, _count); result = ml.Intersects(userb); delete convx; delete convy; } return result; }
bool ClosedBSpline::f_intersects (BoxObj& userb, Graphic* gs) { Coord* convx, *convy; BoxObj b; bool result = false; getBox(b, gs); if (b.Intersects(userb)) { convx = new Coord[_count]; convy = new Coord[_count]; transformList(_x, _y, _count, convx, convy, gs); FillPolygonObj fp; fp.ClosedSplineToPolygon(convx, convy, _count); result = fp.Intersects(userb); delete convx; delete convy; } return result; }
void Damage::Incur (BoxObj& newb) { BoxObj* b; Iterator i; if (_areas->IsEmpty()) { _areas->Prepend(new UList(new BoxObj(&newb))); } else if (_areas->First() == _areas->Last()) { FirstArea(i); b = GetArea(i); if (newb.Intersects(*b)) { if (!newb.Within(*b)) { *b = *b + newb; } } else { _areas->Prepend(new UList(new BoxObj(&newb))); } } else { Merge(newb); } }
boolean Graphic::intersects (BoxObj& userb, Graphic* gs) { BoxObj b; getBox(b, gs); return b.Intersects(userb); }
boolean Line::intersects (BoxObj& b, Graphic* gs) { LineObj l (_x0, _y0, _x1, _y1); transform(l._p1._x, l._p1._y, gs); transform(l._p2._x, l._p2._y, gs); return b.Intersects(l); }