Avoid out of range casts from float to int when computing dense dethmaps. (#747)
Avoid out of range casts from float to int when computing dense dethmaps. (#747)

Summary:
Pull Request resolved: https://github.com/mapillary/OpenSfM/pull/747

Running PatchMatch ran into problems with invalid numbers that then failed the cast due to an out of range exception when enabling the sanitizers. Using 64bit ints and then checking if the result is valid overcomes this problem. Also, changed from c-style casts to c++'s static cast (added compile time checks).

Reviewed By: YanNoun

Differential Revision: D28147291

fbshipit-source-id: e30ee80ea4a7d42729f9732fe8937d9ac257d249

mapillary/OpenSfM,mapillary/OpenSfM,mapillary/OpenSfM,mapillary/OpenSfM,mapillary/OpenSfM