コード例 #1
0
void FiberSelector::boxTest( QVector<bool>& workfield, int left, int right, int axis )
{
    // abort condition
    if ( left > right )
        return;

    int root = left + ( ( right - left ) / 2 );
    int axis1 = ( axis + 1 ) % 3;
    int pointIndex = m_kdTree->m_tree[root] * 3;

    if ( m_kdVerts[pointIndex + axis] < m_boxMin[axis] )
    {
        boxTest( workfield, root + 1, right, axis1 );
    }
    else if ( m_kdVerts[pointIndex + axis] > m_boxMax[axis] )
    {
        boxTest( workfield, left, root - 1, axis1 );
    }
    else
    {
        int axis2 = ( axis + 2 ) % 3;
        if ( m_kdVerts[pointIndex + axis1] <= m_boxMax[axis1] && m_kdVerts[pointIndex + axis1]
                >= m_boxMin[axis1] && m_kdVerts[pointIndex + axis2] <= m_boxMax[axis2]
                && m_kdVerts[pointIndex + axis2] >= m_boxMin[axis2] )
        {
            workfield[m_reverseIndexes[ m_kdTree->m_tree[root] ]] = true;
        }
        boxTest( workfield, left, root - 1, axis1 );
        boxTest( workfield, root + 1, right, axis1 );
    }
}
コード例 #2
0
int main()
{
    int grid = 0;
    int runtime = 0;
    int ar[9][9];
    int row = 0;
    int column = 0;
    int c = 2;
    int d = 2;
    int e = 2;
	//input how many puzzle will be check
    scanf("%d",&grid);
    //input files from provided input files
    while(runtime != grid) // check and see if the program used every game given
    {
        //nested for loop to fill in the sudokode array
        for (row = 0; row<9;row++)
            {
                for(column = 0; column< 9;column++)
                {
                	//input the number to a 2D array
                    scanf("%d",&(ar[row][column]));
                }

            }

    //increase run time by one after run through the loop once
    runtime++;
    // set c,d ,e to the return value each test give
    c = rowTest(ar);
    d = columnTest(ar);
    e = boxTest(ar);
    // check if the puzzle had pass the row, column and box test
    if( (c==1) && (d==1) && (e==1) )
    {
        printf("YES\n");
    }
    else
        printf("NO\n");

    }//end of while loop
    return 0;
    }
コード例 #3
0
void FiberSelector::updateBox( int branch, int pos )
{
    if ( Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::ACTIVE ), Qt::DisplayRole ).toBool() )
    {
        m_x = Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::X ), Qt::DisplayRole ).toFloat();
        m_y = Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::Y ), Qt::DisplayRole ).toFloat();
        m_z = Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::Z ), Qt::DisplayRole ).toFloat();
        m_dx = Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::DX ), Qt::DisplayRole ).toFloat() / 2;
        m_dy = Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::DY ), Qt::DisplayRole ).toFloat() / 2;
        m_dz = Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::DZ ), Qt::DisplayRole ).toFloat() / 2;
        m_boxMin[0] = m_x - m_dx;
        m_boxMax[0] = m_x + m_dx;
        m_boxMin[1] = m_y - m_dy;
        m_boxMax[1] = m_y + m_dy;
        m_boxMin[2] = m_z - m_dz;
        m_boxMax[2] = m_z + m_dz;

        for ( int i = 0; i < m_numLines; ++i )
        {
            m_bitfields[branch][pos][i] = false;
        }
        boxTest( m_bitfields[branch][pos], 0, m_numPoints - 1, 0 );

        if ( Models::r()->data( createIndex( branch, pos, (int)Fn::ROI::SHAPE ), Qt::DisplayRole ).toInt() == 0 )
        {
            sphereTest( m_bitfields[branch][pos] );
        }
    }
    else
    {
        for ( int i = 0; i < m_numLines; ++i )
        {
            m_bitfields[branch][pos][i] = true;
        }
    }

    updateBranch( branch );
    if ( m_isInitialized )
    {
        Models::r()->setData( createIndex( branch, pos, (int)Fn::ROI::UPDATED ), true, Qt::DisplayRole );
    }
}