Ejemplo n.º 1
0
void MainWindow::setFilterTab()
{
    FilterOptions filterOptions = settings->filterOptions();

    // Global
    minUedit->setText(QString("%1").arg(filterOptions.umin()));
    maxUedit->setText(QString("%1").arg(filterOptions.umax()));
    minVedit->setText(QString("%1").arg(filterOptions.vmin()));
    maxVedit->setText(QString("%1").arg(filterOptions.vmax()));

    minUedit->setEnabled(filterOptions.globalRange());
    maxUedit->setEnabled(filterOptions.globalRange());
    minVedit->setEnabled(filterOptions.globalRange());
    maxVedit->setEnabled(filterOptions.globalRange());

    nStdDevSpin->setValue(filterOptions.nStd());
    nStdDevSpin->setEnabled(filterOptions.globalStd());

    // Local
    localMethodCombo->setEnabled(filterOptions.local());
    localMethodCombo->setCurrentIndex(filterOptions.localMethod());
    localNxNCombo->setEnabled(filterOptions.local());
    localNxNCombo->setCurrentIndex((filterOptions.localNxN()-1)/2-1);
    localUedit->setEnabled(filterOptions.local());
    localVedit->setEnabled(filterOptions.local());
    localUedit->setText(QString("%1").arg(filterOptions.uTol()));
    localVedit->setText(QString("%1").arg(filterOptions.vTol()));

    // Interpolate
    interpolateMethodCombo->setEnabled(filterOptions.interpolate());
    interpolateMethodCombo->setCurrentIndex(filterOptions.intMethod());
    interpolateNxNCombo->setEnabled(filterOptions.interpolate());
    interpolateNxNCombo->setCurrentIndex((filterOptions.intNxN()-1)/2-1);

    // Smoothing
    smoothNxNCombo->setEnabled(filterOptions.smoothing());
    smoothNxNCombo->setCurrentIndex((filterOptions.smoothNxN()-1)/2-1);
    smoothRadiusEdit->setEnabled(filterOptions.smoothing());
    smoothRadiusEdit->setText(QString("%1").arg(filterOptions.smoothRadius()));
}
Ejemplo n.º 2
0
/*---------Interpolate---------------*/
void meanInterpolate(PivData *pivData, FilterOptions filterOptions)
{
    int width = pivData->width();
    int height = pivData->height();

    double *uTemp, *vTemp;
    uTemp = new double [width*height + 1];
    vTemp = new double [width*height + 1];

    int N = filterOptions.intNxN();
    int halfN = floor(double(N - 1) / 2.0);

    int i, j, m, n;
    double mxU, mxV;
    int count;
    PivPointData pointData;

    // Creating temporary velocity field from original PivData object
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            uTemp[i*width+j] = pivData->data(i,j).u;
            vTemp[i*width+j] = pivData->data(i,j).v;
        }
    }

    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            // If the current vector is flagged as erroneous
            if (pivData->filtered(i,j))
            {
                count = 0; mxU = 0.0; mxV = 0.0;
                for (m = -halfN; m <= halfN; m++)
                {
                    for (n = -halfN; n <= halfN; n++)
                    {
                        // Calculate the local average from valid points
                        if (!pivData->filtered(i+m,j+n) && pivData->isValid(i+m,j+n))
                        {
                            mxU += pivData->data(i+m,j+n).u;
                            mxV += pivData->data(i+m,j+n).v;
                            count++;
                        }
                    }
                }
                // Assign the current vector the value of the local mean
                if (count > 0)
                {
                    uTemp[i*width + j] = mxU / double(count);
                    vTemp[i*width + j] = mxV / double(count);
                }
            }
        }
    }


    // Reassign the temporary (new) data to the original object
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            pointData = pivData->data(i,j);
            pointData.u = uTemp[i*width+j];
            pointData.v = vTemp[i*width+j];
            pivData->setData(i,j,pointData);
        }
    }

    // Cleaning up
    delete [] uTemp;
    delete [] vTemp;
}