Exemplo n.º 1
0
void show_tile (void)
{
  set_grid(current_tile[5]);
  set_next(next_tile[5]);   

  show_grid();

  set_grid(0);
  set_next(0);
}
Exemplo n.º 2
0
void set_preference_display_settings()
{
	set_grid(grid());
	set_turbo(turbo());
	set_turbo_speed(turbo_speed());
	set_color_cursors(preferences::get("color_cursors", true));
}
AdaptiveRegularRefiner_MultiGrid::
AdaptiveRegularRefiner_MultiGrid(MultiGrid& mg,
								 IRefinementCallback* refCallback) :
	HangingNodeRefiner_MultiGrid(refCallback)
{
	set_grid(&mg);
}
Exemplo n.º 4
0
/******************************************************************************
   main --- main routine
******************************************************************************/
int main()
{ 
  int imax, jmax, kmax;
  
  para.geom = &geom;
  para.outp = &outp1;
  para.prob = &prob;
  para.mytime = &mytime;
  para.bc     = &bc;
  para.solv   = &solv;

  initial(&para);

  imax = geom.imax, jmax = geom.jmax, kmax = geom.kmax;

  if(!allocate_data( ))
    exit ( 1 );
   
   clear_data(&para, var);	
   set_grid(&para, var); 
   set_bnd_vel(&para, var, VY, v);

   write_data1(&para, var, "grid");

   FFD_solver(&para, var);


   free_data(var);

   getchar();
  
	exit ( 0 );
} // End of main( )
Exemplo n.º 5
0
/*
void ISelector::registered_at_grid(Grid* grid)
{
//	if we're already registered at this grid then return
	if(m_pGrid == grid)
		return;

//	if we're already registered at a grid, then unregister first
	if(m_pGrid)
		m_pGrid->unregister_observer(this);

//	assign grid
	m_pGrid = grid;

//	initialise attachments and accessors.
//	do this whith a little trick:
//	set the supported-element-options to SE_NONE,
//	then call enable for all element-types that should be supported.
	uint tmpOpts = m_supportedElements;
	m_supportedElements = SE_NONE;
	enable_element_support(tmpOpts);
}

void ISelector::unregistered_from_grid(Grid* grid)
{
	assert(m_pGrid == grid && "grids do not match!");

	if(m_pGrid == grid){
	//	disable all currently supported elements (this will remove any attachments)
		disable_element_support(m_supportedElements);
		m_pGrid = NULL;
	}
}
*/
void ISelector::grid_to_be_destroyed(Grid* grid)
{
	assert(m_pGrid == grid && "grids do not match!");

	if(m_pGrid == grid){
		set_grid(NULL);
	}
}
HangingNodeRefiner_Grid::
HangingNodeRefiner_Grid(Grid& grid,
						IRefinementCallback* refCallback) :
	BaseClass(refCallback),
	m_pGrid(NULL),
	m_aVertex(false)
{
	set_grid(&grid);
}
Exemplo n.º 7
0
void Dock_Grid::unset_grid(Snapping_Grid *grid)
{
    if ( target == grid )
    {
        grid->disconnect(this);
        disconnect(grid);
        check_enable->disconnect(grid);
        grid->disconnect(check_enable);
        spin_size->disconnect(grid);
        set_grid( nullptr );
    }
}
Exemplo n.º 8
0
display_manager::display_manager(display* d)
{
	disp = d;

	load_hotkeys();

	set_grid(grid());
	set_turbo(turbo());
	set_turbo_speed(turbo_speed());
	set_scroll_to_action(scroll_to_action());
	set_color_cursors(preferences::get("color_cursors", false));
}
Exemplo n.º 9
0
static int dotbot_stream_callback(struct libwebsocket_context *context,
        struct libwebsocket *wsi,
        enum libwebsocket_callback_reasons reason,
        void *user, void *in, size_t len) {

    int n = 0, m;
    const char *in_buf = (const char *)in;
    unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 + LWS_SEND_BUFFER_POST_PADDING];
    unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
    struct per_session_data *data = (struct per_session_data*)user;

    switch (reason) {
        /* New connection; initialize a game for them. */
        case LWS_CALLBACK_ESTABLISHED:
            lwsl_info("dotbot_stream_callback: LWS_CALLBACK_ESTABLISHED\n");
            init_session_data(data);
            break;
        /* Calculate a move, update the board, and send back the results. */
        case LWS_CALLBACK_SERVER_WRITEABLE:
            tick(&n, (char *)p, data);
            if (n) {
                m = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
                if (m < n) {
                    lwsl_info("client disconnected\n");
                    return -1;
                }
            }
            break;
        case LWS_CALLBACK_RECEIVE:
            if (len == 4 && strncmp(in_buf, "next", len) == 0) {
                libwebsocket_callback_on_writable(context, wsi);
            }
            if (strncmp(in_buf, "setGrid:", 8) == 0) {
                set_grid(data, in_buf + 8);
            }
            break;
        default:
            break;
    }

    return 0;
}
Exemplo n.º 10
0
wrl::constraint::constraint() : mode(0), axis(1), grid(3)
{
    pool = ::glob->new_pool();

    for (int i = 0; i < 10; ++i)
    {
        pool->add_node(rot[i] = new ogl::node());
        pool->add_node(pos[i] = new ogl::node());
    }

    rot[0]->add_unit(new ogl::unit("wire/constraint_rot_0.obj"));
    rot[0]->add_unit(new ogl::unit("wire/constraint_rot_0.obj"));
    rot[1]->add_unit(new ogl::unit("wire/constraint_rot_1.obj"));
    rot[2]->add_unit(new ogl::unit("wire/constraint_rot_2.obj"));
    rot[3]->add_unit(new ogl::unit("wire/constraint_rot_3.obj"));
    rot[4]->add_unit(new ogl::unit("wire/constraint_rot_4.obj"));
    rot[5]->add_unit(new ogl::unit("wire/constraint_rot_5.obj"));
    rot[6]->add_unit(new ogl::unit("wire/constraint_rot_6.obj"));
    rot[7]->add_unit(new ogl::unit("wire/constraint_rot_7.obj"));
    rot[8]->add_unit(new ogl::unit("wire/constraint_rot_8.obj"));
    rot[9]->add_unit(new ogl::unit("wire/constraint_rot_9.obj"));

    pos[0]->add_unit(new ogl::unit("wire/constraint_pos_0.obj"));
    pos[1]->add_unit(new ogl::unit("wire/constraint_pos_1.obj"));
    pos[2]->add_unit(new ogl::unit("wire/constraint_pos_2.obj"));
    pos[3]->add_unit(new ogl::unit("wire/constraint_pos_3.obj"));
    pos[4]->add_unit(new ogl::unit("wire/constraint_pos_4.obj"));
    pos[5]->add_unit(new ogl::unit("wire/constraint_pos_5.obj"));
    pos[6]->add_unit(new ogl::unit("wire/constraint_pos_6.obj"));
    pos[7]->add_unit(new ogl::unit("wire/constraint_pos_7.obj"));
    pos[8]->add_unit(new ogl::unit("wire/constraint_pos_8.obj"));
    pos[9]->add_unit(new ogl::unit("wire/constraint_pos_9.obj"));

    set_grid(3);

    orient();
}
Exemplo n.º 11
0
HangingNodeRefiner_Grid::
~HangingNodeRefiner_Grid()
{
	set_grid(NULL);
}
Exemplo n.º 12
0
static void tst_tweak_n(CuTest* tc, int run, int GX, int GY) {
    double origxy[GX*GY*2];
    double xy[GX*GY*2];
    double noisyxy[GX*GY*2];
    double radec[GX*GY*2];
    double gridx[GX];
    double gridy[GY];
    sip_t thesip;
    sip_t* sip = &thesip;
    tan_t* tan = &(sip->wcstan);
    int i,j;
    sip_t* outsip;

    printf("\ntest_tweak_%i\n\n", run);

    log_init(LOG_VERB);

    memset(sip, 0, sizeof(sip_t));

    tan->imagew = 2000;
    tan->imageh = 2000;
    tan->crval[0] = 150;
    tan->crval[1] = -30;
    tan->crpix[0] = 1000.5;
    tan->crpix[1] = 1000.5;
    tan->cd[0][0] = 1./1000.;
    tan->cd[0][1] = 0;
    tan->cd[1][1] = 1./1000.;
    tan->cd[1][0] = 0;

    sip->a_order = sip->b_order = 2;
    sip->a[2][0] = 10.*1e-6;
    sip->b[0][2] = -10.*1e-6;
    sip->ap_order = sip->bp_order = 4;

    sip_compute_inverse_polynomials(sip, 0, 0, 0, 0, 0, 0);

    set_grid(GX, GY, tan, sip, origxy, radec, xy, gridx, gridy);

    // add noise to observed xy positions.
    srand(42);
    for (i=0; i<(GX*GY*2); i++) {
        noisyxy[i] = xy[i] + gaussian_sample(0.0, 1.0);
    }

    fprintf(stderr, "from numpy import array\n");
    fprintf(stderr, "x0,y0 = %g,%g\n", tan->crpix[0], tan->crpix[1]);
    fprintf(stderr, "gridx_%i=array([", run);
    for (i=0; i<GX; i++)
        fprintf(stderr, "%g, ", gridx[i]);
    fprintf(stderr, "])\n");
    fprintf(stderr, "gridy_%i=array([", run);
    for (i=0; i<GY; i++)
        fprintf(stderr, "%g, ", gridy[i]);
    fprintf(stderr, "])\n");
    fprintf(stderr, "origxy_%i = array([", run);
    for (i=0; i<(GX*GY); i++)
        fprintf(stderr, "[%g,%g],", origxy[2*i+0], origxy[2*i+1]);
    fprintf(stderr, "])\n");
    fprintf(stderr, "xy_%i = array([", run);
    for (i=0; i<(GX*GY); i++)
        fprintf(stderr, "[%g,%g],", xy[2*i+0], xy[2*i+1]);
    fprintf(stderr, "])\n");

    fprintf(stderr, "noisyxy_%i = array([", run);
    for (i=0; i<(GX*GY); i++)
        fprintf(stderr, "[%g,%g],", noisyxy[2*i+0], noisyxy[2*i+1]);
    fprintf(stderr, "])\n");

    fprintf(stderr, "truesip_a_%i = array([", run);
    for (i=0; i<=sip->a_order; i++)
        for (j=0; j<=sip->a_order; j++)
            if (sip->a[i][j] != 0)
                fprintf(stderr, "[%i,%i,%g],", i, j, sip->a[i][j]);
    fprintf(stderr, "])\n");

    fprintf(stderr, "truesip_b_%i = array([", run);
    for (i=0; i<=sip->a_order; i++)
        for (j=0; j<=sip->a_order; j++)
            if (sip->b[i][j] != 0)
                fprintf(stderr, "[%i,%i,%g],", i, j, sip->b[i][j]);
    fprintf(stderr, "])\n");

    fprintf(stderr, "sip_a_%i = {}\n", run);
    fprintf(stderr, "sip_b_%i = {}\n", run);

    int o;
    for (o=2; o<6; o++) {
        sip->a_order = o;
        outsip = run_test(tc, sip, GX*GY, noisyxy, radec);

        fprintf(stderr, "sip_a_%i[%i] = array([", run, o);
        for (i=0; i<=outsip->a_order; i++)
            for (j=0; j<=outsip->a_order; j++)
                if (outsip->a[i][j] != 0)
                    fprintf(stderr, "[%i,%i,%g],", i, j, outsip->a[i][j]);
        fprintf(stderr, "])\n");

        fprintf(stderr, "sip_b_%i[%i] = array([", run, o);
        for (i=0; i<=outsip->a_order; i++)
            for (j=0; j<=outsip->a_order; j++)
                if (outsip->b[i][j] != 0)
                    fprintf(stderr, "[%i,%i,%g],", i, j, outsip->b[i][j]);
        fprintf(stderr, "])\n");
    }

    sip->a_order = 2;
    outsip = run_test(tc, sip, GX*GY, noisyxy, radec);

    CuAssertDblEquals(tc, tan->crval[0], outsip->wcstan.crval[0], 1e-3);
    CuAssertDblEquals(tc, tan->crval[1], outsip->wcstan.crval[1], 1e-3);

    CuAssertDblEquals(tc, tan->cd[0][0], outsip->wcstan.cd[0][0], 1e-6);
    CuAssertDblEquals(tc, tan->cd[0][1], outsip->wcstan.cd[0][1], 1e-6);
    CuAssertDblEquals(tc, tan->cd[1][0], outsip->wcstan.cd[1][0], 1e-6);
    CuAssertDblEquals(tc, tan->cd[1][1], outsip->wcstan.cd[1][1], 1e-6);

    if (run == 2) {
        double *d1, *d2;
        d1 = (double*)outsip->a;
        d2 = (double*)&(sip->a);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
            // rather large error, no?
            CuAssertDblEquals(tc, d2[i], d1[i], 6e-7);
        d1 = (double*)outsip->b;
        d2 = (double*)&(sip->b);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++) {
            printf("test_tweak_2, run 2: Expecting %.18g, got %.18g\n", d2[i], d1[i]);
            fflush(NULL);
            CuAssertDblEquals(tc, d2[i], d1[i], 3e-7);
        }
        d1 = (double*)outsip->ap;
        d2 = (double*)&(sip->ap);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
            CuAssertDblEquals(tc, d2[i], d1[i], 1e-6);
        d1 = (double*)outsip->bp;
        d2 = (double*)&(sip->bp);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
            CuAssertDblEquals(tc, d2[i], d1[i], 1e-6);
        CuAssertIntEquals(tc, sip->a_order, outsip->a_order);
        CuAssertIntEquals(tc, sip->b_order, outsip->b_order);
        CuAssertIntEquals(tc, sip->ap_order, outsip->ap_order);
        CuAssertIntEquals(tc, sip->bp_order, outsip->bp_order);
    } else if (run == 3) {
        double *d1, *d2;
        d1 = (double*)outsip->a;
        d2 = (double*)&(sip->a);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++) {
            // rather large error, no?
            printf("test_tweak_2, run 3: Expecting %.18g, got %.18g\n", d2[i], d1[i]);
            fflush(NULL);
            CuAssertDblEquals(tc, d2[i], d1[i], 7e-7);
        }
        d1 = (double*)outsip->b;
        d2 = (double*)&(sip->b);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++) {
            printf("test_tweak_2, run 3b: Expecting %.18g, got %.18g\n", d2[i], d1[i]);
            fflush(NULL);
            CuAssertDblEquals(tc, d2[i], d1[i], 2e-6);
        }
        d1 = (double*)outsip->ap;
        d2 = (double*)&(sip->ap);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
            CuAssertDblEquals(tc, d2[i], d1[i], 1e-6);
        d1 = (double*)outsip->bp;
        d2 = (double*)&(sip->bp);
        for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++) {
            printf("test_tweak_2, run 3c: Expecting %.18g, got %.18g\n", d2[i], d1[i]);
            fflush(NULL);
            CuAssertDblEquals(tc, d2[i], d1[i], 2e-6);
        }
        CuAssertIntEquals(tc, sip->a_order, outsip->a_order);
        CuAssertIntEquals(tc, sip->b_order, outsip->b_order);
        CuAssertIntEquals(tc, sip->ap_order, outsip->ap_order);
        CuAssertIntEquals(tc, sip->bp_order, outsip->bp_order);
    }
}
Exemplo n.º 13
0
void test_tweak_1(CuTest* tc) {
    int GX = 5;
    int GY = 5;
    double origxy[GX*GY*2];
    double xy[GX*GY*2];
    double radec[GX*GY*2];
    double gridx[GX];
    double gridy[GY];
    sip_t thesip;
    sip_t* sip = &thesip;
    tan_t* tan = &(sip->wcstan);
    int i;
    sip_t* outsip;

    printf("\ntest_tweak_1\n\n");

    log_init(LOG_VERB);

    memset(sip, 0, sizeof(sip_t));

    tan->imagew = 2000;
    tan->imageh = 2000;
    tan->crval[0] = 150;
    tan->crval[1] = -30;
    tan->crpix[0] = 1000.5;
    tan->crpix[1] = 1000.5;
    tan->cd[0][0] = 1./1000.;
    tan->cd[0][1] = 0;
    tan->cd[1][1] = 1./1000.;
    tan->cd[1][0] = 0;

    sip->a_order = sip->b_order = 2;
    sip->a[2][0] = 10.*1e-6;
    sip->ap_order = sip->bp_order = 4;

    sip_compute_inverse_polynomials(sip, 0, 0, 0, 0, 0, 0);

    /*
     printf("After compute_inverse_polynomials:\n");
     sip_print_to(sip, stdout);
     fflush(NULL);
     */

    set_grid(GX, GY, tan, sip, origxy, radec, xy, gridx, gridy);

    /*{
     int i,j;
     printf("RA,Dec\n");
     for (i=0; i<GY; i++) {
     for (j=0; j<GX; j++) {
     fflush(NULL);
     printf("gy %i gyx %i: %g %g\n", i, j, radec[2*(i*GX+j)],
     radec[2*(i*GX+j) + 1]);
     fflush(NULL);
     }
     }
     }*/

    outsip = run_test(tc, sip, GX*GY, xy, radec);

    CuAssertDblEquals(tc, tan->crval[0], outsip->wcstan.crval[0], 1e-6);
    CuAssertDblEquals(tc, tan->crval[1], outsip->wcstan.crval[1], 1e-6);

    CuAssertDblEquals(tc, tan->cd[0][0], outsip->wcstan.cd[0][0], 1e-10);
    CuAssertDblEquals(tc, tan->cd[0][1], outsip->wcstan.cd[0][1], 1e-14);
    CuAssertDblEquals(tc, tan->cd[1][0], outsip->wcstan.cd[1][0], 1e-14);
    CuAssertDblEquals(tc, tan->cd[1][1], outsip->wcstan.cd[1][1], 1e-10);

    double *d1, *d2;
    d1 = (double*)outsip->a;
    d2 = (double*)&(sip->a);
    for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
        CuAssertDblEquals(tc, d2[i], d1[i], 1e-13);
    d1 = (double*)outsip->b;
    d2 = (double*)&(sip->b);
    for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++) {
        printf("test_tweak_1: Expecting %.18g, got %.18g\n", d2[i], d1[i]);
        fflush(NULL);
        CuAssertDblEquals(tc, d2[i], d1[i], 3e-18);
    }
    d1 = (double*)outsip->ap;
    d2 = (double*)&(sip->ap);
    for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
        CuAssertDblEquals(tc, d2[i], d1[i], 1e-10);
    d1 = (double*)outsip->bp;
    d2 = (double*)&(sip->bp);
    for (i=0; i<(SIP_MAXORDER * SIP_MAXORDER); i++)
        CuAssertDblEquals(tc, d2[i], d1[i], 1e-10);
    CuAssertIntEquals(tc, sip->a_order, outsip->a_order);
    CuAssertIntEquals(tc, sip->b_order, outsip->b_order);
    CuAssertIntEquals(tc, sip->ap_order, outsip->ap_order);
    CuAssertIntEquals(tc, sip->bp_order, outsip->bp_order);
}
Exemplo n.º 14
0
void MultiGridRefiner::grid_to_be_destroyed(Grid* grid)
{
	if(m_pMG)
		set_grid(NULL);
}
Exemplo n.º 15
0
void HangingNodeRefiner_Grid::
grid_to_be_destroyed(Grid* grid)
{
	set_grid(NULL);
}
void AdaptiveRegularRefiner_MultiGrid::
assign_grid(MultiGrid& mg)
{
	set_grid(&mg);
}
Exemplo n.º 17
0
void MultiGridRefiner::assign_grid(MultiGrid& mg)
{
	set_grid(&mg);
}
Exemplo n.º 18
0
void HangingNodeRefiner_Grid::
assign_grid(Grid& grid)
{
	set_grid(&grid);
}
Exemplo n.º 19
0
static int set_arf_grid (Isis_Rmf_t *rmf, double *lo, double *hi, unsigned int n) /*{{{*/
{
   Client_Data_t *cl = (Client_Data_t *)rmf->client_data;

   return set_grid (&cl->arf, lo, hi, n);
}