コード例 #1
0
ファイル: qfileselector.cpp プロジェクト: RSATom/Qt
QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors, const QChar &indicator)
{
    /* selectionHelper does a depth-first search of possible selected files. Because there is strict
       selector ordering in the API, we can stop checking as soon as we find the file in a directory
       which does not contain any other valid selector directories.
    */
    Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));

    for (const QString &s : selectors) {
        QString prospectiveBase = path;
        if (!indicator.isNull())
            prospectiveBase += indicator;
        prospectiveBase += s + QLatin1Char('/');
        QStringList remainingSelectors = selectors;
        remainingSelectors.removeAll(s);
        if (!QDir(prospectiveBase).exists())
            continue;
        QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors, indicator);
        if (!prospectiveFile.isEmpty())
            return prospectiveFile;
    }

    // If we reach here there were no successful files found at a lower level in this branch, so we
    // should check this level as a potential result.
    if (!QFile::exists(path + fileName))
        return QString();
    return path + fileName;
}
コード例 #2
0
void HxCPDSpatialGraphWarp::preparePoints(McDArray<McVec3f>& p1,
                                          McDArray<McVec3f>& p2,
                                          SpatialGraphSelection& slice2,
                                          const HxSpatialGraph* spatialGraph) {
    ma::SliceSelector selectionHelper(spatialGraph, "TransformInfo");

    ma::EndPointParams params;
    params.endPointRegion = 30;
    params.projectionPlane = selectionHelper.computeMidPlane(0, 1);
    params.projectionType = ma::P_ORTHOGONAL;
    params.refSliceNum = 0;
    params.transSliceNum = 1;
    params.useAbsoluteValueForEndPointRegion = false;
    params.maxDistForAngle = 2000;
    params.angleToPlaneFilter = 0.01;
    SpatialGraphSelection slice1;
    ma::FacingPointSets pr =
        ma::projectEndPoints(spatialGraph, slice1, slice2, params);
    McDArray<McVec3f> refCoords = pr.ref.positions;
    McDArray<McVec3f> transCoords = pr.trans.positions;
    mcassert(refCoords.size() == slice1.getNumSelectedVertices());
    mcassert(transCoords.size() == slice2.getNumSelectedVertices());

    p1.resize(refCoords.size());
    for (int i = 0; i < refCoords.size(); i++) {
        McVec3f coord = refCoords[i];
        p1[i] = McVec3f(coord.x, coord.y, 0);
    }
    p2.resize(transCoords.size());
    for (int i = 0; i < transCoords.size(); i++) {
        McVec3f coord = transCoords[i];
        p2[i] = McVec3f(coord.x, coord.y, 0);
    }
    mcassert(p2.size() == slice2.getNumSelectedVertices());
}
コード例 #3
0
ファイル: qfileselector.cpp プロジェクト: RSATom/Qt
QString QFileSelectorPrivate::select(const QString &filePath) const
{
    Q_Q(const QFileSelector);
    QFileInfo fi(filePath);

    QString ret = selectionHelper(fi.path().isEmpty() ? QString() : fi.path() + QLatin1Char('/'),
            fi.fileName(), q->allSelectors());

    if (!ret.isEmpty())
        return ret;
    return filePath;
}
コード例 #4
0
void HxCPDSpatialGraphWarp::computeRigidVanMises() {
    const HxSpatialGraph* inputSG = (HxSpatialGraph*)portData.getSource();

    ma::SliceSelector selectionHelper(inputSG, "TransformInfo");

    HxSpatialGraph* resultSG = createOutputDataSet();
    resultSG->copyFrom(inputSG);
    McDArray<McVec3f> points1, points2;
    McDArray<McVec3f> dirs1, dirs2;
    SpatialGraphSelection slice2;
    preparePointsAndDirectionsRigid(points1, points2, dirs1, dirs2, slice2,
                                    resultSG);
    mcassert(slice2.getNumSelectedVertices() == points2.size());
    ma::CPDLinearAligner cpd;
    cpd.params.w = portW.getValue();
    cpd.params.withScaling = portWithScale.getValue();
    cpd.params.maxIterations = portEMParams.getValue(0);
    cpd.params.sigmaSquareStop = portEMParams.getValue(1);
    cpd.params.eDiffRelStop = portEMParams.getValue(2);
    cpd.params.useDirections = portUseDirection.getValue();
    cpd.params.usePositions = portUseCoords.getValue();

    if (!portUseDirection.getValue()) {
        dirs1.fill(McVec3f(0, 0, 1));
        dirs2.fill(McVec3f(0, 0, 1));
    }

    ma::FacingPointSets points;
    points.ref.positions = points1;
    points.ref.directions = dirs1;
    points.trans.positions = points2;
    points.trans.directions = dirs2;
    cpd.setPoints(points);

    McDMatrix<double> Rc, Rd;
    McDVector<double> t;
    double s;
    const mtalign::AlignInfo info = cpd.align(Rc, s, t, Rd);

    applyRigidDeformationToSliceVanMises(slice2, resultSG, cpd, Rc, s, t);
    portCPDResults.setValue(0, info.sigmaSquare);
    portCPDResults.setValue(1, info.kappa);
    portCPDResults.setValue(2, s);
    double rho = mtalign::rotationAngle2d(Rc);

    portCPDResults.setValue(3, rho);
    portCPDResults.setValue(4, t[0]);
    portCPDResults.setValue(5, t[1]);
    portCPDResults.setValue(6, info.numIterations);

    resultSG->touch();
    resultSG->fire();
}
コード例 #5
0
ファイル: qfileselector.cpp プロジェクト: CodeDJ/qt5-hidpi
static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
{
    /* selectionHelper does a depth-first search of possible selected files. Because there is strict
       selector ordering in the API, we can stop checking as soon as we find the file in a directory
       which does not contain any other valid selector directories.
    */
    Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));

    foreach (const QString &s, selectors) {
        QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');
        QStringList remainingSelectors = selectors;
        remainingSelectors.removeAll(s);
        if (!QDir(prospectiveBase).exists())
            continue;
        QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
        if (!prospectiveFile.isEmpty())
            return prospectiveFile;
    }
コード例 #6
0
void HxCPDSpatialGraphWarp::computeNL() {
    const HxSpatialGraph* inputSG = (HxSpatialGraph*)portData.getSource();

    ma::SliceSelector selectionHelper(inputSG, "TransformInfo");

    HxSpatialGraph* resultSG = createOutputDataSet();
    resultSG->copyFrom(inputSG);
    ma::FacingPointSets points;
    SpatialGraphSelection slice2;
    preparePointsAndDirectionsRigid(
        points.ref.positions, points.trans.positions, points.ref.directions,
        points.trans.directions, slice2, resultSG);
    mcassert(slice2.getNumSelectedVertices() == points.trans.positions.size());

    mtalign::CPDElasticAligner cpd;
    cpd.params.beta = portBeta.getValue();
    cpd.params.lambda = portLambda.getValue();
    cpd.params.w = portW.getValue();
    cpd.params.eDiffRelStop = portEMParams.getValue(2);
    cpd.params.sigmaSquareStop = portEMParams.getValue(1);
    cpd.params.maxIterations = portEMParams.getValue(0);
    cpd.params.useDirections = portUseDirection.getValue();
    cpd.setPoints(points);

    ma::AlignInfo info;
    McDArray<McVec3f> shiftedCoords = cpd.align(info);

    McDArray<McVec3f> origCoords = points.trans.positions;
    resamplePairs(origCoords, shiftedCoords);

    applyNLDeformationToSlice(slice2, resultSG, origCoords, shiftedCoords);
    portCPDResults.setValue(0, info.sigmaSquare);
    portCPDResults.setValue(1, info.kappa);
    portCPDResults.setValue(6, info.numIterations);

    resultSG->touch();
    resultSG->fire();
}