dev:data_output
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| dev:data_output [2014/10/17 03:20] – created csymonds | dev:data_output [2014/10/17 03:55] (current) – [AbstractDriver.h] csymonds | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| 2. / | 2. / | ||
| - | ===main.cpp=== | + | ====main.cpp==== |
| - | To edit the main.cpp file, paste the following code into the Private section of the file: | + | To edit the main.cpp file, paste the following code into the **Private** section of the file: |
| <code cpp> | <code cpp> | ||
| - | | + | const char* GetSimDirPathTemporary(const char* format, ...) const |
| + | { | ||
| + | static OverflowableCharBufferByteSink< | ||
| + | buf.Reset(); | ||
| + | buf.Printf(" | ||
| + | va_list ap; | ||
| + | va_start(ap, | ||
| + | buf.Vprintf(format, | ||
| + | if (buf.HasOverflowed()) | ||
| + | { | ||
| + | | ||
| + | } | ||
| + | return buf.GetZString(); | ||
| + | } | ||
| + | </ | ||
| + | and | ||
| + | <code cpp> | ||
| + | typedef typename CC:: | ||
| + | typedef typename CC:: | ||
| + | </ | ||
| + | |||
| + | Then paste the following in the **public** section of main.cpp: | ||
| + | <code cpp> | ||
| + | virtual void DoEpochEvents(Grid< | ||
| + | { | ||
| + | u32 H = Grid< | ||
| + | u32 W = Grid< | ||
| + | |||
| + | u32 emptyCount = 0; | ||
| + | for (u32 y = 0; y < H; ++y) | ||
| + | { | ||
| + | for (u32 x = 0; x < W; ++x) | ||
| { | { | ||
| - | | + | |
| - | buf.Reset(); | + | for (u32 x = 0; x < P:: |
| - | buf.Printf(" | + | |
| - | | + | |
| - | va_start(ap, format); | + | |
| - | buf.Vprintf(format, | + | |
| - | if (buf.HasOverflowed()) | + | |
| { | { | ||
| - | | + | |
| + | { | ||
| + | const SPoint pt(x, y); | ||
| + | if(Tile< | ||
| + | { | ||
| + | continue; | ||
| + | } | ||
| + | const T * atom = tile.GetAtom(x, | ||
| + | |||
| + | //<<< | ||
| + | if (atom-> | ||
| + | ++emptyCount; | ||
| + | } | ||
| } | } | ||
| - | return buf.GetZString(); | ||
| } | } | ||
| - | </code cpp> | + | } |
| + | |||
| + | //<<< | ||
| + | const char* path = GetSimDirPathTemporary(" | ||
| + | FILE* fp = fopen(path, " | ||
| + | |||
| + | //<<< | ||
| + | fprintf(fp, "%d %d %d\n", | ||
| + | fclose(fp); | ||
| + | // Remember to let the parent run too! | ||
| + | Super:: | ||
| + | } | ||
| + | </code> | ||
| + | |||
| + | Please note: There are 3 TODO tags in the above snippet. These are where you'll need to modify the code to suit your needs. | ||
| + | |||
| + | ====AbstractDriver.h==== | ||
| + | Now we need to do a small modifcation to the AbstractDriver.h file. Paste the following code into the **public** section: | ||
| + | <code cpp> | ||
| + | const char * GetSimulationBasePath() const | ||
| + | { | ||
| + | return & | ||
| + | } | ||
| + | </code> | ||
| + | And that's it! Happy scienceing. | ||
dev/data_output.1413516020.txt.gz · Last modified: 2014/10/17 03:20 by csymonds
