E57SimpleWriter: Pass file guid as constructor argument
In testing we noticed that E57 files are not completely deterministic. Turns out to be due to random GUIDs generated at the file and Data3D scope. This change is necesssary for using a user-specified GUID rather than a randomly generated one at the file scope.
Perhaps a better solution would be to set the RNG seed instead? Then it captures all calls to generateRandomGUID().
Maybe something like:
static std::random_device rd;
static std::mt19937 mte( rd() );
void seedRandom( uint32_t inRand )
{
mte.seed( inRand );
}
And then use mte in generateRandomGUID() in place of gen.
Instead of passing a GUID in your changes, pass a seed and call seedRandom() in Writer::Writer(). Then you don't need the changes to WriterImpl either.
That's an option. I think it has some downsides, though.
Technical: making the RNG static has implications for multi-threading and determinism.
Design: I think the intention of the GUID is that they're application-specified, rather than randomised.

If we wish to avoid a possibly breaking API change, we could extend the simpler writer API to allow for setting a specific GUID, along similar lines to what we can already do for Data3D?
e57::Data3D header;
header.guid = guid;
header.pointsSize = size;
Thanks Nigel.
So maybe something like this?
struct E57_DLL WriterOptions
{
ustring guid; //!< A globally unique identification string for the current version of the Image2D object
ustring coordinateMetadata; //!< Information describing the Coordinate Reference System to be used for the file
};
// ...
Writer( const ustring &filePath, const WriterOptions &options );
// ... and
WriterImpl( const ustring &filePath, const WriterOptions &options );
We can leave the old constructors for compatibility and mark them as deprecated.
Yes, agreed.
Reworked as discussed.
Awesome - thanks Nigel!