| 305 | } |
| 306 | |
| 307 | CachedFileRcPtr |
| 308 | LocalFileFormat::read(std::istream & istream, |
| 309 | const std::string & /* fileName unused */, |
| 310 | Interpolation interp) const |
| 311 | { |
| 312 | |
| 313 | // this shouldn't happen |
| 314 | if (!istream) |
| 315 | throw Exception ("file stream empty when trying to read Houdini LUT"); |
| 316 | |
| 317 | // |
| 318 | CachedFileHDLRcPtr cachedFile = CachedFileHDLRcPtr (new CachedFileHDL ()); |
| 319 | |
| 320 | Lut3DOpDataRcPtr lut3d_ptr; |
| 321 | |
| 322 | // Parse headers into key-value pairs |
| 323 | StringToStringVecMap header_chunks; |
| 324 | StringToStringVecMap::iterator iter; |
| 325 | |
| 326 | // Read headers, ending after the "LUT:" line |
| 327 | readHeaders(header_chunks, istream); |
| 328 | |
| 329 | // Grab useful values from headers |
| 330 | StringUtils::StringVec value; |
| 331 | |
| 332 | // "Version 3" - format version (currently one version |
| 333 | // number per LUT type) |
| 334 | value = findHeaderItem(header_chunks, "version", 1); |
| 335 | cachedFile->hdlversion = value[0]; |
| 336 | |
| 337 | // "Format any" - bit depth of image the LUT should be |
| 338 | // applied to (this is basically ignored) |
| 339 | value = findHeaderItem(header_chunks, "format", 1); |
| 340 | cachedFile->hdlformat = value[0]; |
| 341 | |
| 342 | // "Type 3d" - type of LUT |
| 343 | { |
| 344 | value = findHeaderItem(header_chunks, "type", 1); |
| 345 | |
| 346 | cachedFile->hdltype = value[0]; |
| 347 | } |
| 348 | |
| 349 | // "From 0.0 1.0" - range of input values |
| 350 | { |
| 351 | float from_min = 0.0f; |
| 352 | float from_max = 1.0f; |
| 353 | value = findHeaderItem(header_chunks, "from", 2); |
| 354 | |
| 355 | if(!StringToFloat(&from_min, value[0].c_str()) || |
| 356 | !StringToFloat(&from_max, value[1].c_str())) |
| 357 | { |
| 358 | std::ostringstream os; |
| 359 | os << "Invalid float value(s) on 'From' line, '"; |
| 360 | os << value[0] << "' and '" << value[1] << "'"; |
| 361 | throw Exception(os.str().c_str()); |
| 362 | } |
| 363 | cachedFile->from_min = from_min; |
| 364 | cachedFile->from_max = from_max; |
nothing calls this directly
no test coverage detected