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 // Stage calls this when the model starts up
14 extern "C" int Init(Model *mod)
15 {
16  const unsigned int dw = 40, dh = 20;
17 
18  uint8_t *data = new uint8_t[dw * dh * 2];
19  memset(data, 0, sizeof(uint8_t) * dw * dh);
20 
21  printf("\n[Rasterize] Raster of model \"%s\":\n", mod->Token());
22 
23  Stg::Size modsz(mod->GetGeom().size);
24 
25  mod->Rasterize(data, dw, dh, modsz.x / (float)dw, modsz.y / (float)dh);
26 
27  for (unsigned int y = 0; y < dh; y++) {
28  printf("[Rasterize] ");
29  for (unsigned int x = 0; x < dw; x++)
30  putchar(data[x + ((dh - y - 1) * dw)] ? 'O' : '.');
31  putchar('\n');
32  }
33  delete[] data;
34  puts("[Rasterize] Done");
35 
36  return 0; // ok
37 }
Model class
Definition: stage.hh:1651
The Stage library uses its own namespace.
Definition: canvas.hh:8
void Init(int *argc, char **argv[])
Definition: stage.cc:17
Size size
extent
Definition: stage.hh:379
void Rasterize(uint8_t *data, unsigned int width, unsigned int height, meters_t cellwidth, meters_t cellheight)
Definition: model.cc:849
Geom GetGeom() const
Definition: stage.hh:2247
const char * Token() const
Definition: stage.hh:689


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 Feb 28 2022 23:48:56