Пример #1
0
Terrain::Terrain(int maxX, int maxY, int fequencyDivisor) {
    this->frequencyDivisor = fequencyDivisor;
    srand(time(NULL));
    for (int i = 0; i < maxX / fequencyDivisor; i++) {
        for (int j = 0; j < maxY / fequencyDivisor; j++) {
            createSeed(i, j);
        }
    }
    this->bounds = makeBounds(0, 0, maxY / frequencyDivisor, maxY / frequencyDivisor);
}
Пример #2
0
static void newProposal( MEX_ARGS ) {
    if( nlhs == 0 ) {
        mexErrMsgTxt("newProposal expected one return argument");
        return;
    }
    // Create an empty unary
    ProposalSettings prop_settings;
    prop_settings.unaries.clear();
    
    // Add all settings
    for ( int i=0; i<nrhs; i++ ) {
        std::string c = toString( prhs[i] );
        
        // Process the command
        if (c == "max_iou") {
            if( i+1>=nrhs || !mxIsNumeric(prhs[i+1]) )
                mexErrMsgTxt("max_iou numeric argument required");
            prop_settings.max_iou = mxGetScalar(prhs[i+1]);
            i++;
        }
        else if (c == "seed") {
            if( i+1>=nrhs || !mxIsChar(prhs[i+1]) )
                mexErrMsgTxt("seed string argument required");
            prop_settings.foreground_seeds = createSeed( toString( prhs[i+1] ) );
            i++;
        }
        else if (c == "unary") {
            if( i+4 >= nrhs || !mxIsNumeric(prhs[i+1]) || !mxIsNumeric(prhs[i+2]) || !mxIsChar(prhs[i+3]) || !mxIsChar(prhs[i+4]) )
                mexErrMsgTxt("unary N_S:int N_T:int fg_unary:string bg_unary:string [min_size:float max_side:float]");
            const int N_S = mxGetScalar(prhs[i+1]), N_T = mxGetScalar(prhs[i+2]);
            std::string fg_unary = toString( prhs[i+3] ), bg_unary = toString( prhs[i+4] );
            float min_size = 0.0, max_size=0.75;
            if( i+6 <= nrhs && mxIsNumeric(prhs[i+5]) && mxIsNumeric(prhs[i+5]) ) {
                min_size = mxGetScalar( prhs[i+5] );
                max_size = mxGetScalar( prhs[i+6] );
                i += 2;
            }
            prop_settings.unaries.push_back( ProposalSettings::UnarySettings( N_S, N_T, createUnaryFromString( fg_unary ), createUnaryFromString( bg_unary ), min_size, max_size ) );
            i+=4;
        }
        else {
            mexErrMsgTxt(("Setting '"+c+"' not found").c_str());
        }
    }
    plhs[0] = ptr2Mat( std::make_shared<Proposal>( prop_settings ) );
}
Пример #3
0
/*
 * Use this function to create new terrain and destroy old terrain that is outside of the max range.
 * For example, we can shift +x/+y and dealloc the old blocks that were part of the original terrain
 * but not within the new range.
 *
 * (-x, +y)     (+x, +y)
 *        ______
 *        |    |
 *        |    |
 *        |____|
 *
 * (-x, -y)     (+x, -y)
 *
 */
void Terrain::shift(int idx, int idy) {
    int dx = idx / frequencyDivisor;
    int dy = idy / frequencyDivisor;

    // move bounds and create new seeds
    shiftBounds(this->bounds, dx, dy);

    for (int i = bounds.xmin; i <= bounds.xmax; i++) {
        for (int j = bounds.ymin; j <= bounds.ymax; j++) {
            createSeed(i, j, true);
        }
    }

    // clean up the heightmap cache
    //    for (Point p : heightmap.keys()) {
    //        if (p.x > bounds.xmax || p.x < bounds.xmin || p.y > bounds.ymax || p.y < bounds.ymin) {
    //            heightmap.remove(p);
    //        }
    //    }
}
Пример #4
0
    Allocator2Test(TestCase tc)
	  : testCase_(tc)
	  , LOOPS(testTable[testCase_].loop_)
	{
	  createSeed(1, srcData_);
	}