Possibly get min/max from the colour node itself instead of the colorLimits.
| 152 | |
| 153 | /// Possibly get min/max from the colour node itself instead of the colorLimits. |
| 154 | void _readColourRanges( const std::string &protoName, const StructureNode &proto, |
| 155 | double &colourMin, double &colourMax ) |
| 156 | { |
| 157 | // IF the colorLimits are not set |
| 158 | // AND our colour node is |
| 159 | // THEN get our min/max from the colour node itself. |
| 160 | if ( ( colourMax == 0.0 ) && proto.isDefined( protoName ) ) |
| 161 | { |
| 162 | const auto colourProto = proto.get( protoName ); |
| 163 | |
| 164 | if ( colourProto.type() == TypeInteger ) |
| 165 | { |
| 166 | const IntegerNode integerColour( colourProto ); |
| 167 | |
| 168 | colourMin = static_cast<uint16_t>( integerColour.minimum() ); |
| 169 | colourMax = static_cast<uint16_t>( integerColour.maximum() ); |
| 170 | } |
| 171 | else if ( colourProto.type() == TypeScaledInteger ) |
| 172 | { |
| 173 | const ScaledIntegerNode scaledColour( colourProto ); |
| 174 | const double scale = scaledColour.scale(); |
| 175 | const double offset = scaledColour.offset(); |
| 176 | const int64_t minimum = scaledColour.minimum(); |
| 177 | const int64_t maximum = scaledColour.maximum(); |
| 178 | |
| 179 | colourMin = static_cast<uint16_t>( minimum ) * scale + offset; |
| 180 | colourMax = static_cast<uint16_t>( maximum ) * scale + offset; |
| 181 | } |
| 182 | else if ( colourProto.type() == TypeFloat ) |
| 183 | { |
| 184 | const FloatNode floatColour( colourProto ); |
| 185 | |
| 186 | colourMin = static_cast<uint16_t>( floatColour.minimum() ); |
| 187 | colourMax = static_cast<uint16_t>( floatColour.maximum() ); |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | ReaderImpl::ReaderImpl( const ustring &filePath, const ReaderOptions &options ) : |
| 193 | imf_( filePath, "r", options.checksumPolicy ), root_( imf_.root() ), |