Open RiskyRob opened 10 months ago
I've spent some time looking into this and it seems like it's a bit of an overall design problem.
Whoever initially wrote this code added checks against the ranges in the node constructors (which throw exceptions). Add to that a bunch of default arguments to constructors and that the XML generation is entwined with the nodes and it's a bit of a mess.
Not yet sure how to solve it nicely.
Agreed the original creators could have considered using specific templating functionality or something! For my purposes I've set the default argument as the minimum value for the prototypes where 0 could cause problems but this is certainly not the ideal solution, it is just a quick work around unfortunately.
The work that you have done has been incredible btw, nicely done!
I've set the default argument as the minimum value for the prototypes
This was my initial "fix" as well, but it then means that (in the colour case) the colorLimits must be specified and that's actually an optional field. Its meaning in the standard is such that it can't be computed from the data:
The limits for the value of red, green, and blue color that the sensor is capable of producing.
(It also looks like leaving the defaults for IntegerNode
min and max leads to UB.)
I'm still trying to work out if I can fix this without breaking the API...
A similar issue to #246 but different.
In file src/WriterImpl.cpp in method NewData3D we are creating prototypes, e.g.
proto.set( "colorGreen", IntegerNode( imf_, 0, (int64_t)data3DHeader.colorLimits.colorGreenMinimum, (int64_t)data3DHeader.colorLimits.colorGreenMaximum ) );
The problem is that the minimum bounds has to be 0 or this code will fail because the default value being passed in for this prototype is 0. This makes the minimum bounds property effectively an unusable property for many data fields as it always has to be 0. When the minimum bounds is greater than 0 the software will crash with an E57_ERROR_VALUE_OUT_OF_BOUNDS exception.
As stated in #246 for prototypes (E57 Standard 8.3.9.3 (1)):
And in the header of the IntegerNode class: