Exemple #1
0
QList<RVector> RShape::getIntersectionPointsCX(const RCircle& circle1,
        const RExplodable& explodable2, bool limited) {
    Q_UNUSED(limited)
    QList<RVector> res;

    QList<QSharedPointer<RShape> > sub = explodable2.getExploded();
    QList<QSharedPointer<RShape> >::iterator it;
    for (it=sub.begin(); it!=sub.end(); ++it) {
        QSharedPointer<RLine> pLine2 = (*it).dynamicCast<RLine>();
        if (!pLine2.isNull()) {
            RLine line2 = *pLine2.data();
            res.append(RShape::getIntersectionPointsLC(line2, circle1));
            continue;
        }

        QSharedPointer<RArc> pArc2 = (*it).dynamicCast<RArc>();
        if (!pArc2.isNull()) {
            RArc arc2 = *pArc2.data();
            res.append(RShape::getIntersectionPointsAC(arc2, circle1));
            continue;
        }
    }

    return res;
}
Exemple #2
0
QList<RVector> RShape::getIntersectionPointsLX(const RLine& line1,
        const RExplodable& explodable2, bool limited) {
    Q_UNUSED(limited)

    QList<RVector> res;

    QList<QSharedPointer<RShape> > sub = explodable2.getExploded();
    QList<QSharedPointer<RShape> >::iterator it;
    for (it=sub.begin(); it!=sub.end(); ++it) {
        // TODO: limited true for line1, not for line2:
        QSharedPointer<RLine> pLine2 = (*it).dynamicCast<RLine>();
        if (!pLine2.isNull()) {
            RLine line2 = *pLine2.data();
            res.append(RShape::getIntersectionPointsLL(line1, line2, limited, true));
            continue;
        }

        QSharedPointer<RArc> pArc2 = (*it).dynamicCast<RArc>();
        if (!pArc2.isNull()) {
            RArc arc2 = *pArc2.data();
            res.append(RShape::getIntersectionPointsLA(line1, arc2, limited, true));
            continue;
        }
    }

    return res;
}
Exemple #3
0
/**
 * \param same True if the two shapes are identical, from the same interpolated
 *      shape (e.g. spline).
 */
QList<RVector> RShape::getIntersectionPointsXX(const RExplodable& explodable1,
        const RExplodable& explodable2, bool limited, bool same) {

    Q_UNUSED(limited)
    QList<RVector> res;

    QList<QSharedPointer<RShape> > sub1 = explodable1.getExploded();
    QList<QSharedPointer<RShape> > sub2;

    if (same) {
        sub2 = sub1;
    }
    else {
        sub2 = explodable2.getExploded();
    }

    QList<QSharedPointer<RShape> >::iterator it1;
    QList<QSharedPointer<RShape> >::iterator it2;

    int c1, c2;
    for (it1=sub1.begin(), c1=0; it1!=sub1.end(); ++it1, ++c1) {
        for (it2=sub2.begin(), c2=0; it2!=sub2.end(); ++it2, ++c2) {
            // sub shapes of same, interpolated shape (e.g. spline):
            if (same) {
                /*
                QSharedPointer<RDirected> directed1 = *it1->dynamicCast<RDirected>();
                QSharedPointer<RDirected> directed2 = *it2->dynamicCast<RDirected>();
                if (!directed1.isNull() && !directed2.isNull()) {
                    if (directed1->connectsTo(*directed2)) {
                        // spline internal connection point is not an intersection:
                        continue;
                    }
                }
                */
                // segments are connected and therefore don't intersect for a spline:
                if (qAbs(c1-c2)<=1) {
                    continue;
                }
            }

            res.append(RShape::getIntersectionPoints(*it1->data(), *it2->data()));
        }
    }

    return res;
}
Exemple #4
0
void RExporter::exportExplodable(const RExplodable& explodable, double offset) {
    QList<QSharedPointer<RShape> > sub = explodable.getExploded();

    RLinetypePattern p = getLinetypePattern();
    if (!p.isValid() || p.getNumDashes() <= 1 || draftMode || screenBasedLinetypes || twoColorSelectedMode) {
        for (int i=0; i<sub.length(); i++) {
            QSharedPointer<RLine> lineP = sub[i].dynamicCast<RLine>();
            if (!lineP.isNull()) {
                exportLine(*lineP.data());
                continue;
            }

            QSharedPointer<RArc> arc = sub[i].dynamicCast<RArc>();
            if (!arc.isNull()) {
                exportArc(*arc.data());
                continue;
            }
        }
        return;
    }

    if (getEntity()!=NULL && (getEntity()->getType()!=RS::EntitySpline || RSpline::hasProxy())) {
        // all explodable entities including splines if we have a spline proxy:
        RShapesExporter(*this, sub, offset);
        return;
    }

    // use alternative algorithm for splines if we don't have a spline proxy:
    double dist;

    for (int i=0; i<sub.length(); i++) {
        QSharedPointer<RLine> lineP = sub[i].dynamicCast<RLine>();
        if (!lineP.isNull()) {
            RLine line = *lineP.data();
            dist = exportLine(line, offset);
            offset -= lineP->getLength();
            continue;
        }

        QSharedPointer<RArc> arc = sub[i].dynamicCast<RArc>();
        if (!arc.isNull()) {
            exportArc(*arc.data(), offset);
            offset -= arc->getLength();
            continue;
        }
    }
}
Exemple #5
0
void RExporter::exportExplodable(const RExplodable& explodable, double offset) {
    QList<QSharedPointer<RShape> > sub = explodable.getExploded();
    QList<QSharedPointer<RShape> >::iterator it;
    for (it=sub.begin(); it!=sub.end(); ++it) {
        QSharedPointer<RLine> line = (*it).dynamicCast<RLine>();
        if (!line.isNull()) {
            exportLine(*line.data(), offset);
            offset -= line->getLength();
            continue;
        }

        QSharedPointer<RArc> arc = (*it).dynamicCast<RArc>();
        if (!arc.isNull()) {
            exportArc(*arc.data(), offset);
            offset -= arc->getLength();
            continue;
        }
    }
}
Exemple #6
0
    // public methods:
     QScriptValue
        REcmaExplodable::getExploded
        (QScriptContext* context, QScriptEngine* engine) 
        
        {
            //REcmaHelper::functionStart("REcmaExplodable::getExploded", context, engine);
            //qDebug() << "ECMAScript WRAPPER: REcmaExplodable::getExploded";
            //QCoreApplication::processEvents();

            QScriptValue result = engine->undefinedValue();
            
                    // public function: can be called from ECMA wrapper of ECMA shell:
                    RExplodable* self = 
                        getSelf("getExploded", context);
                  

                //Q_ASSERT(self!=NULL);
                if (self==NULL) {
                    return REcmaHelper::throwError("self is NULL", context);
                }
                
    
    if( context->argumentCount() ==
    0
    ){
    // prepare arguments:
    
    // end of arguments

    // call C++ function:
    // return type 'QList < QSharedPointer < RShape > >'
    QList < QSharedPointer < RShape > > cppResult =
        
               self->getExploded();
        // return type: QList < QSharedPointer < RShape > >
                // List of ...:
                result = REcmaHelper::listToScriptValue(engine, cppResult);
            
    } else


        
    
    if( context->argumentCount() ==
    1 && (
            context->argument(0).isNumber()
        ) /* type: int */
    
    ){
    // prepare arguments:
    
                    // argument isStandardType
                    int
                    a0 =
                    (int)
                    
                    context->argument( 0 ).
                    toNumber();
                
    // end of arguments

    // call C++ function:
    // return type 'QList < QSharedPointer < RShape > >'
    QList < QSharedPointer < RShape > > cppResult =
        
               self->getExploded(a0);
        // return type: QList < QSharedPointer < RShape > >
                // List of ...:
                result = REcmaHelper::listToScriptValue(engine, cppResult);
            
    } else


        
            {
               return REcmaHelper::throwError("Wrong number/types of arguments for RExplodable.getExploded().",
                   context);
            }
            //REcmaHelper::functionEnd("REcmaExplodable::getExploded", context, engine);
            return result;
        }