Exemple #1
0
RS::Ending RSpline::getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
    double tAtClickPoint = getTAtPoint(clickPoint);
    double tAtTrimPoint = getTAtPoint(trimPoint);

    if (tAtTrimPoint < tAtClickPoint) {
        return RS::EndingStart;
    }
    else {
        return RS::EndingEnd;
    }
}
Exemple #2
0
RS::Ending RSpline::getTrimEnd(const RVector& coord, const RVector& trimPoint) {
    double tTrimPoint = getTAtPoint(trimPoint);
    double tCoord = getTAtPoint(coord);

    if (tCoord < tTrimPoint) {
        return RS::EndingEnd;
    }
    else {
        return RS::EndingStart;
    }
}
Exemple #3
0
double RSpline::getAngleAt(double distance, RS::From from) const {
    QList<RVector> points = getPointsWithDistanceToEnd(distance, from);
    if (points.length()!=1) {
        return RNANDOUBLE;
    }
    double t = getTAtPoint(points[0]);
    ON_3dVector v = curve.DerivativeAt(t);
    return RVector(v.x, v.y).getAngle();
}
Exemple #4
0
bool RSpline::isOnShape(const RVector& point, bool limited, double tolerance) const {
    if (hasProxy()) {
        double t = getTAtPoint(point);
        RVector p = getPointAt(t);
        return point.getDistanceTo(p) < tolerance;
    }
    else {
        return RShape::isOnShape(point, limited, tolerance);
    }
}
Exemple #5
0
/**
 * Inserts a git point at the point on the spline closest to the given position.
 */
void RSpline::insertFitPointAt(const RVector& point) {
    RVector p = getClosestPointOnShape(point);

    // find out T at the point closest to point:
    double t = getTAtPoint(p);

    // find out index of fit point before t:
    int index = -1;
    for (int i=0; i<fitPoints.length(); i++) {
        double tc = getTAtPoint(fitPoints[i]);
        if (i==0 && isClosed()) {
            // closed spline: two t's for first fit point:
            tc = 0.0;
        }
        //qWarning() << "tc: " << tc;
        if (tc<t) {
            index = i+1;
        }
        else {
            break;
        }
    }


    // point not on spline:
    if (index<0 || index>=fitPoints.length()) {
        if (isClosed()) {
            index = 0;
        }
        else {
            qWarning() << "no point on spline found. t: " << t;
            return;
        }
    }

    fitPoints.insert(index, p);
    update();
}