rasterize.cc
Go to the documentation of this file.
1 
8 // uncomment the line 'ctrl "rasterize"' in <stage source>/worlds/simple.world to try this example
9 
10 #include "stage.hh"
11 using namespace Stg;
12 
13 
14 // Stage calls this when the model starts up
15 extern "C" int Init( Model* mod )
16 {
17  const unsigned int dw = 40, dh = 20;
18 
19  uint8_t* data = new uint8_t[dw*dh*2];
20  memset( data, 0, sizeof(uint8_t) * dw * dh );
21 
22  printf( "\n[Rasterize] Raster of model \"%s\":\n",
23  mod->Token() );
24 
25  Stg::Size modsz( mod->GetGeom().size );
26 
27  mod->Rasterize( data, dw, dh,
28  modsz.x / (float)dw,
29  modsz.y / (float)dh );
30 
31  for( unsigned int y=0; y<dh; y++ )
32  {
33  printf( "[Rasterize] " );
34  for( unsigned int x=0; x<dw; x++ )
35  putchar( data[x + ((dh-y-1)*dw)] ? 'O' : '.' );
36  putchar( '\n' );
37  }
38  delete data;
39  puts( "[Rasterize] Done" );
40 
41  return 0; //ok
42 }
43 
44 
45 
Model class
Definition: stage.hh:1742
The Stage library uses its own namespace.
Definition: canvas.hh:8
void Init(int *argc, char **argv[])
Definition: stage.cc:18
Size size
extent
Definition: stage.hh:395
void Rasterize(uint8_t *data, unsigned int width, unsigned int height, meters_t cellwidth, meters_t cellheight)
Definition: model.cc:1002
const char * Token() const
Definition: stage.hh:715
Geom GetGeom() const
Definition: stage.hh:2378


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:09