Beispiel #1
0
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);
}
Beispiel #2
0
bool Picture::contains (PointObj& po, Graphic* gs) {
    if (!IsEmpty()) {
        Iterator i;
        FullGraphic gstemp;
        Transformer ttemp;
        BoxObj b;

	getBox(b, gs);

	if (b.Contains(po)) {
	    gstemp.SetTransformer(&ttemp);

            for (First(i); !Done(i); Next(i)) {
                Graphic* gr = GetGraphic(i);
		concatGraphic(gr, gr, gs, &gstemp);

		if (containsGraphic(gr, po, &gstemp)) {
		    gstemp.SetTransformer(nil);
		    return true;
		}
	    }
	    gstemp.SetTransformer(nil); /* to avoid deleting ttemp explicitly*/
	}
    }
    return false;
}
Beispiel #3
0
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;
}
Beispiel #4
0
boolean ULabel::contains (PointObj& po, Graphic* gs) {
    PointObj pt (&po);
    PSFont* f = gs->GetFont();

    invTransform(pt._x, pt._y, gs);
    BoxObj b (0, 0, f->Width(_string), f->Height());
    return b.Contains(pt);
}
Beispiel #5
0
boolean UStencil::contains (PointObj& po, Graphic* gs) {
    Bitmap* bitmap = (_mask == nil) ? _image : _mask;
    PointObj pt (&po);

    invTransform(pt._x, pt._y, gs);
    BoxObj b (0, 0, bitmap->Width(), bitmap->Height());
    return b.Contains(pt);
}
Beispiel #6
0
boolean MultiLine::f_contains (PointObj& po, Graphic* gs) {
    BoxObj b;
    PointObj pt (&po);
    getBox(b, gs);

    if (b.Contains(pt)) {
	FillPolygonObj fp (x(), y(), count());
	invTransform(pt._x, pt._y, gs);
	return fp.Contains(pt);
    }
    return false;
}
Beispiel #7
0
boolean MultiLine::s_contains (PointObj& po, Graphic* gs) {
    MultiLineObj &ml = *_pts;
    PointObj pt (&po);
    BoxObj b;
    getBox(b, gs);

    if (b.Contains(po)) {
	invTransform(pt._x, pt._y, gs);
	return ml.Contains(pt);
    }
    return false;
}
Beispiel #8
0
bool OpenBSpline::f_contains (PointObj& po, Graphic* gs) {
    PointObj pt (&po);
    BoxObj b;
    getBox(b, gs);

    if (b.Contains(pt)) {
	invTransform(pt._x, pt._y, gs);
	FillPolygonObj fp;
	fp.ClosedSplineToPolygon(_x, _y, _count);
	return fp.Contains(pt);
    }
    return false;
}
Beispiel #9
0
bool OpenBSpline::s_contains (PointObj& po, Graphic* gs) {
    PointObj pt (&po);
    BoxObj b;
    getBox(b, gs);

    if (b.Contains(pt)) {
	invTransform(pt._x, pt._y, gs);
	MultiLineObj ml;
	ml.SplineToMultiLine(_x, _y, _count);
	return ml.Contains(pt);
    }
    return false;
}
Beispiel #10
0
Graphic* Picture::LastGraphicWithin (BoxObj& userb) {
    Iterator i;
    BoxObj b;

    for (Last(i); !Done(i); Prev(i)) {
	Graphic* subgr = GetGraphic(i);
	subgr->GetBox(b);

	if (b.Within(userb)) {
	    return subgr;
	}
    }
    return nil;
}
Beispiel #11
0
boolean MultiLineObj::Contains (PointObj& p) {
    register int i;
    BoxObj b;
    
    GetBox(b);
    if (b.Contains(p)) {
	for (i = 1; i < _count; ++i) {
	    LineObj l (_x[i-1], _y[i-1], _x[i], _y[i]);
	    if (l.Contains(p)) {
	        return true;
	    }
	}
    }    
    return false;
}
Beispiel #12
0
boolean BSplineSelection::contains (PointObj& po, Graphic* gs) {
    BoxObj b;
    getBox(b, gs);
    if (b.Contains(po)) {
	if (containsGraphic(ifillbspline, po, gs)) {
	    return true;
	} else if (containsGraphic(bspline, po, gs)) {
	    return true;
	} else if (LeftAcont(lx0, ly0, lx1, ly1, po, gs)) {
	    return true;
	} else if (RightAcont(rx0, ry0, rx1, ry1, po, gs)) {
	    return true;
	}
    }
    return false;
}
Beispiel #13
0
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;
}
Beispiel #14
0
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;
}
Beispiel #15
0
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;    
}
Beispiel #16
0
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;
}
Beispiel #17
0
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;
}
Beispiel #18
0
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;
}
Beispiel #19
0
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);
    }
}
Beispiel #20
0
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;
	}
    }
}
Beispiel #21
0
bool SFH_ClosedBSpline::intersects (BoxObj& userb, Graphic* gs) {
    PointObj po;
    const Coord *x, *y;
    int count = GetOriginal(x, y);
    Transformer* t = gs->GetTransformer();

    for (int i = 0; i < count; i++) {
	po._x = x[i];
	po._y = y[i];

        if (t != nil) {
            t->Transform(po._x, po._y);
        }
	if (userb.Contains(po)) {
            return true;
        }
    }
    return SF_ClosedBSpline::intersects(userb, gs);
}
Beispiel #22
0
boolean Graphic::intersects (BoxObj& userb, Graphic* gs) {
    BoxObj b;

    getBox(b, gs);
    return b.Intersects(userb);
}
Beispiel #23
0
boolean Graphic::contains (PointObj& po, Graphic* gs) {
    BoxObj b;

    getBox(b, gs);
    return b.Contains(po);
}
Beispiel #24
0
boolean MultiLineObj::Within (BoxObj& userb) {
    BoxObj b;
    
    GetBox(b);
    return b.Within(userb);
}
Beispiel #25
0
boolean Point::intersects (BoxObj& b, Graphic* gs) {
    PointObj pt (_x, _y);
        
    transform(pt._x, pt._y, gs);
    return b.Contains(pt);
}
Beispiel #26
0
bool RasterRect::contains (PointObj& po, Graphic* gs) {
    PointObj pt (&po);
    invTransform(pt._x, pt._y, gs);
    BoxObj b (0, 0, _raster->Width(), _raster->Height());
    return b.Contains(pt);
}
Beispiel #27
0
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);
}