Exemple #1
0
/**
 * \return Points on entity which are intersection points with the
 *     given other entity. If \c same is true, the two datas originate
 *     from the same entity.
 */
QList<RVector> REntityData::getIntersectionPoints(
        const REntityData& other, bool limited, bool same, const RBox& queryBox, bool ignoreComplex) const {

    QList<RVector> ret;
    QList<QSharedPointer<RShape> > shapes1 = getShapes(queryBox, ignoreComplex, true);

    if (RMouseEvent::hasMouseMoved()) {
        return QList<RVector>();
    }

    QList<QSharedPointer<RShape> > shapes2 = other.getShapes(queryBox, ignoreComplex, true);

    for (int i=0; i<shapes1.size(); i++) {
        for (int k=0; k<shapes2.size(); k++) {
            if (RMouseEvent::hasMouseMoved()) {
                return QList<RVector>();
            }
//            if (same) {
//                if (abs(i-k)<=1) {
//                    // same or connecting segment of same entity
//                    continue;
//                }
//            }

            ret.append(
                shapes1.at(i)->getIntersectionPoints(*shapes2.at(k), limited, same)
            );
        }
    }

    return ret;
}
Exemple #2
0
/**
 * \return Points on entity which are intersection points with the
 *     given other entity. If \c same is true, the two datas originate
 *     from the same entity.
 */
QList<RVector> REntityData::getIntersectionPoints(
        const REntityData& other, bool limited, bool same, const RBox& queryBox) const {

    QList<RVector> ret;
    QList<QSharedPointer<RShape> > shapes1 = getShapes(queryBox);
    QList<QSharedPointer<RShape> > shapes2 = other.getShapes(queryBox);

    for (int i=0; i<shapes1.size(); i++) {
        for (int k=0; k<shapes2.size(); k++) {
            ret.append(
                shapes1.at(i)->getIntersectionPoints(*shapes2.at(k), limited, same)
            );
        }
    }

    return ret;
}
Exemple #3
0
/**
 * \return Points on entity which are intersection points with the
 *     given other entity. If \c same is true, the two datas originate
 *     from the same entity.
 */
QList<RVector> RPolylineData::getIntersectionPoints(
        const REntityData& other, bool limited, bool same,
        const RBox& queryBox, bool ignoreComplex) const {

    Q_UNUSED(ignoreComplex)

    QList<RVector> ret;

    QList<QSharedPointer<RShape> > shapes1 = getShapes(queryBox, true); //getExploded();
    QList<QSharedPointer<RShape> > shapes2;
    if (same) {
        shapes2 = shapes1;
    }
    else {
        const RPolylineData* otherPl = dynamic_cast<const RPolylineData*>(&other);
        if (otherPl!=NULL) {
            //shapes2All = otherPl->getExploded();
            shapes2 = other.getShapes(queryBox, true);
        }
        else {
            shapes2 = other.getShapes(queryBox);
        }
    }

    for (int i1=0; i1<shapes1.size(); i1++) {
        int i2Start = 0;
        if (same) {
            i2Start = i1+1;
        }
        for (int i2=i2Start; i2<shapes2.size(); i2++) {
            // very same polyline segments can't intersect:
            if (same && i1==i2) {
                continue;
            }

            QSharedPointer<RShape> shape1 = shapes1.at(i1);
            QSharedPointer<RShape> shape2 = shapes2.at(i2);
            QList<RVector> candidates = shape1->getIntersectionPoints(*shape2, limited, false);
            if (same) {
                // polyline internal intersections:
                if (shape1->isDirected() && shape2->isDirected()) {
                    // ignore polyline nodes:
                    for (int c=0; c<candidates.size(); c++) {
                        if (candidates[c].equalsFuzzy(shape1->getStartPoint())) {
                            continue;
                        }
                        if (candidates[c].equalsFuzzy(shape1->getEndPoint())) {
                            continue;
                        }
                        if (candidates[c].equalsFuzzy(shape2->getStartPoint())) {
                            continue;
                        }
                        if (candidates[c].equalsFuzzy(shape2->getEndPoint())) {
                            continue;
                        }
                        ret.append(candidates[c]);
                    }
                }
            }
            else {
                ret.append(candidates);
            }
        }
    }

    return ret;
}