Ejemplo n.º 1
0
float MgComposite::_hitTest(const Point2d& pt, float tol, MgHitResult& res) const
{
    void* it;
    MgHitResult tmpRes;
    Box2d limits(pt, 2 * tol, 0);

    res.segment = 0;
    res.dist = _FLT_MAX;

    for (MgShape* sp = _shapes->getFirstShape(it); sp;
        sp = _shapes->getNextShape(it))
    {
        if (limits.isIntersect(sp->shapec()->getExtent())) {
            float d = sp->shapec()->hitTest(pt, tol, tmpRes);
            if (res.dist > d - _MGZERO)
            {
                res = tmpRes;
                res.dist = d;
                res.segment = sp->getID();
            }
        }
    }
    _shapes->freeIterator(it);

    return res.segment != 0;
}
Ejemplo n.º 2
0
float MgComposite::_hitTest(const Point2d& pt, float tol, Point2d& nearpt,
                            int& segment, bool& inside) const
{
    void* it;
    float mindist = 1e10f;
    Point2d tmpNear;
    int tmpseg;
    bool tmpIn;
    Box2d limits(pt, 2 * tol, 0);

    segment = 0;
    for (MgShape* sp = _shapes->getFirstShape(it); sp;
        sp = _shapes->getNextShape(it))
    {
        if (limits.isIntersect(sp->shapec()->getExtent())) {
            float d = sp->shapec()->hitTest(pt, tol, tmpNear, tmpseg, tmpIn);

            if (mindist > d - _MGZERO) {
                mindist = d;
                nearpt = tmpNear;
                segment = sp->getID();
                inside = tmpIn;
            }
        }
    }
    _shapes->freeIterator(it);

    return mindist;
}
Ejemplo n.º 3
0
void MgComposite::_update()
{
    void* it;
    _extent.empty();

    for (MgShape* sp = _shapes->getFirstShape(it); sp;
        sp = _shapes->getNextShape(it)) {
        sp->shape()->update();
        _extent.unionWith(sp->shapec()->getExtent());
    }
    _shapes->freeIterator(it);
}
Ejemplo n.º 4
0
Point2d MgComposite::_getPoint(int index) const
{
    MgShape* sp = _shapes->getHeadShape();
    return sp ? sp->shapec()->getPoint(index) : Point2d();
}
Ejemplo n.º 5
0
int MgComposite::_getPointCount() const
{
    MgShape* sp = _shapes->getHeadShape();
    return sp ? sp->shapec()->getPointCount() : 0;
}
Ejemplo n.º 6
0
int MgComposite::_getHandleType(int index) const
{
    MgShape* sp = _shapes->getHeadShape();
    return sp ? sp->shapec()->getHandleType(index) : kMgHandleOutside;
}