Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/mm2ply/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ void saveToPly(
}

// 4. Data Loop
auto write_val = [&](auto val)
auto write_val = [&](auto val, const char* fmt)
{
if (binary)
{
f.write(reinterpret_cast<const char*>(&val), sizeof(val));
}
else
{
f << +val << " ";
f << mrpt::format(fmt, val) << " ";
}
};

Expand All @@ -296,29 +296,29 @@ void saveToPly(
{
const auto& buf =
*static_cast<const mrpt::aligned_std_vector<float>*>(acc.bufPtr);
write_val(buf[i]);
write_val(buf[i], "%.8e");
break;
}
#if MRPT_VERSION >= 0x020f03 // 2.15.3
case FieldAccessor::DOUBLE:
{
const auto& buf =
*static_cast<const mrpt::aligned_std_vector<double>*>(acc.bufPtr);
write_val(buf[i]);
write_val(buf[i], "%.16le");
break;
}
case FieldAccessor::UINT16:
{
const auto& buf =
*static_cast<const mrpt::aligned_std_vector<uint16_t>*>(acc.bufPtr);
write_val(buf[i]);
write_val(buf[i], "%u");
break;
}
case FieldAccessor::UINT8:
{
const auto& buf =
*static_cast<const mrpt::aligned_std_vector<uint8_t>*>(acc.bufPtr);
write_val(buf[i]);
write_val(buf[i], "%i");
break;
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions apps/mm2txt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,20 @@ bool saveToTxt(
// Check coordinate fields
if (fieldName == "x")
{
mrpt::system::os::fprintf(f, "%f", xs.at(i));
mrpt::system::os::fprintf(f, "%.8f", xs.at(i));
}
else if (fieldName == "y")
{
mrpt::system::os::fprintf(f, "%f", ys.at(i));
mrpt::system::os::fprintf(f, "%.8f", ys.at(i));
}
else if (fieldName == "z")
{
mrpt::system::os::fprintf(f, "%f", zs.at(i));
mrpt::system::os::fprintf(f, "%.8f", zs.at(i));
}
// Check float fields
else if (floatFields.count(fieldName))
{
mrpt::system::os::fprintf(f, "%f", floatFields.at(fieldName).at(i));
mrpt::system::os::fprintf(f, "%.8e", floatFields.at(fieldName).at(i));
}
// Check uint16 fields
else if (uint16Fields.count(fieldName))
Expand All @@ -165,7 +165,7 @@ bool saveToTxt(
// Check double fields
else if (doubleFields.count(fieldName))
{
mrpt::system::os::fprintf(f, "%lf", doubleFields.at(fieldName).at(i));
mrpt::system::os::fprintf(f, "%.16le", doubleFields.at(fieldName).at(i));
}
// Check uint8 fields
else if (uint8Fields.count(fieldName))
Expand Down