Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/StringRepresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ using namespace std;

namespace libforefire {

// static variables initialization
size_t StringRepresentation::currentLevel = 0;
ostringstream StringRepresentation::outputstr("");
// The output buffer, the nesting level and the GeoJSON aggregation state used
// to be statics and file globals here, so two simulations printing at the same
// time wrote into one buffer. They are members now.
//
// For GEOJSON mode we aggregate rings per top-level front. Each top-level
// feature (currentLevel==1) is a vector of rings, where each ring is a vector
// of coordinate strings.
//
// writedOnce is deliberately left shared for now. Unlike the rest, making it
// per-instance is an observable change: output() skips a representation whose
// domain has no front once anything has been written, so a second
// representation in the same session would gain a first output file it does
// not produce today. That is a behaviour question for the coupled runs, not a
// mechanical one, and it belongs with the state work in #175.
bool writedOnce = false;
string outPattern;
FireDomain* domain = 0;

// --- GEOJSON Aggregation Variables ---
// For GEOJSON mode we aggregate rings per top-level front.
// Each top-level feature (currentLevel==1) will be represented as a vector of rings,
// where each ring is a vector of coordinate strings.
static bool firstGeoFeature = true; // used when outputting the feature list
static std::vector< std::vector<std::string> > geojson_current_feature;

StringRepresentation::StringRepresentation(FireDomain* fdom) : Visitor() {
lastLevel = -1;
Expand Down
13 changes: 11 additions & 2 deletions src/StringRepresentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ namespace libforefire {
class StringRepresentation: public Visitor {

FireDomain* domain;
static size_t currentLevel;

/* These were statics, shared by every simulation in the process: two
* concurrent print[] calls interleaved into one buffer. */
size_t currentLevel = 0;
bool firstGeoFeature = true; /*!< first feature of the GeoJSON list */
std::vector< std::vector<std::string> > geojson_current_feature;

double updateStep;

public:

static ostringstream outputstr;
/*! \brief buffer the representation is built into
*
* Was static, so two simulations printing at once interleaved into one
* buffer. Command::dumpString reads it, hence public. */
ostringstream outputstr;

/* StringRepresentation();*/
StringRepresentation(FireDomain*);
Expand Down
Loading