Skip to content

Commit

Permalink
Merge pull request #1439 from SergioRAgostinho/ply_parse_nan
Browse files Browse the repository at this point in the history
Fixes #1433
  • Loading branch information
jspricke committed Nov 20, 2015
2 parents 436ac0e + 036653e commit bf51cf4
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions io/include/pcl/io/ply/ply_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,19 @@ inline bool pcl::io::ply::ply_parser::parse_scalar_property (format_type format,
typedef ScalarType scalar_type;
if (format == ascii_format)
{
scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN ();
std::string value_s;
scalar_type value;
char space = ' ';
istream >> value;
istream >> value_s;
try
{
value = boost::lexical_cast<scalar_type> (value_s);
}
catch (boost::bad_lexical_cast &)
{
value = std::numeric_limits<scalar_type>::quiet_NaN ();
}

if (!istream.eof ())
istream >> space >> std::ws;
if (!istream || !isspace (space))
Expand Down Expand Up @@ -625,9 +635,19 @@ inline bool pcl::io::ply::ply_parser::parse_list_property (format_type format, s
}
for (std::size_t index = 0; index < size; ++index)
{
scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN ();
std::string value_s;
scalar_type value;
char space = ' ';
istream >> value;
istream >> value_s;
try
{
value = boost::lexical_cast<scalar_type> (value_s);
}
catch (boost::bad_lexical_cast &)
{
value = std::numeric_limits<scalar_type>::quiet_NaN ();
}

if (!istream.eof ())
{
istream >> space >> std::ws;
Expand Down

0 comments on commit bf51cf4

Please sign in to comment.