Beispiel #1
0
bool RayIntersectorKDTreeNode::FindBestSplit(const Vector<UINT> &TriangleIndices, const RayIntersectorKDTree &Root, UINT &Axis, float &SplitValue) const
{
    Rectangle3f BBox = ComputeBBox(TriangleIndices, Root);
    int BestAxis = -1;
    UINT BestChildImprovement = 8;
    for(UINT CurAxis = 0; CurAxis < 3; CurAxis++)
    {
        UINT LeftCount, RightCount;
        TestSplit(TriangleIndices, Root, CurAxis, BBox, LeftCount, RightCount);
        
        /*const UINT BestChildCost = TriangleIndices.Length();
        const UINT WorstChildCost = TriangleIndices.Length() * 2;
        const UINT ActualChildCost = LeftCount + RightCount;
        const float CurAxisValue = float(ActualChildCost) / float(WorstChildCost);*/
        const UINT CurChildImprovement = Math::Min(TriangleIndices.Length() - LeftCount, TriangleIndices.Length() - RightCount);
        if(CurChildImprovement > BestChildImprovement && LeftCount > 0 && RightCount > 0)
        {
            BestAxis = CurAxis;
            BestChildImprovement = CurChildImprovement;
        }
    }
    if(BestAxis == -1)
    {
        return false;
    }
    else
    {
        Axis = BestAxis;
        SplitValue = BBox.Center()[Axis];
        return true;
    }
}
Beispiel #2
0
    return;

    set<char> trainChars, testChars;
    for (char c = '0'; c <= '9'; c++)
    {
        trainChars.insert(c);
    }

    trainChars.insert('a');
    trainChars.insert('b');

    testChars.insert('c');
    testChars.insert('d');
    testChars.insert('e');
    testChars.insert('f');

    ImageDatabase database;
    database.initSynthNet();
    database.saveLevelDB(constants::synthDatabaseDir + "trainSynthDatabase", TestSplit(trainChars), 200000);
    database.saveLevelDB(constants::synthDatabaseDir + "testSynthDatabase", TestSplit(testChars), 10000);
}

void main()
{
    goB();
    //goA();
    
    cout << "done!" << endl;
    cin.get();
}