13 #include <liblas/liblas.hpp> 14 #include <liblas/reader.hpp> 15 #include <liblas/writer.hpp> 64 template <
class POINTSMAP>
66 const POINTSMAP& ptmap,
const std::string& filename,
70 ofs.open(filename.c_str(), std::ios::out | std::ios::binary);
74 std::cerr <<
"[saveLASFile] Couldn't write to file: " << filename
82 const size_t nPts = ptmap.size();
84 header.SetPointRecordsCount(nPts);
88 liblas::Writer writer(ofs,
header);
90 const bool has_color = ptmap.hasColorPoints();
91 const float col_fract = 255.0f;
95 for (
size_t i = 0; i < nPts; i++)
97 float x,
y,
z,
R,
G, B;
98 ptmap.getPoint(i,
x,
y,
z,
R,
G, B);
106 col.SetRed(static_cast<uint16_t>(
R * col_fract));
107 col.SetGreen(static_cast<uint16_t>(
G * col_fract));
108 col.SetBlue(static_cast<uint16_t>(B * col_fract));
112 if (!writer.WritePoint(pt))
114 std::cerr <<
"[saveLASFile] liblas returned error writing point #" 115 << i <<
" to file.\n";
127 template <
class POINTSMAP>
137 ifs.open(filename.c_str(),
std::ios::in | std::ios::binary);
141 std::cerr <<
"[loadLASFile] Couldn't open file: " << filename
148 liblas::Reader reader(ifs);
152 liblas::Header
const&
header = reader.GetHeader();
153 const size_t nPts =
header.GetPointRecordsCount();
159 #if LIBLAS_VERSION_NUM < 1800 171 const bool has_color = ptmap.hasColorPoints();
172 const float col_fract = 1.0f / 255.0f;
173 while (reader.ReadNextPoint())
175 liblas::Point
const&
p = reader.GetPoint();
179 liblas::Color
const& col =
p.GetColor();
180 ptmap.insertPointRGB(
181 p.GetX(),
p.GetY(),
p.GetZ(), col.GetRed() * col_fract,
182 col.GetGreen() * col_fract, col.GetBlue() * col_fract);
186 ptmap.insertPoint(
p.GetX(),
p.GetY(),
p.GetZ());
190 if (ptmap.size() != nPts)
191 cerr <<
"[loadLASFile] Header says point count is " << nPts
192 <<
" but only " << ptmap.size() <<
" were really parsed in.\n";
194 ptmap.mark_as_modified();
unsigned __int16 uint16_t
Optional settings for loadLASFile()
bool saveLASFile(const POINTSMAP &ptmap, const std::string &filename, const LAS_WriteParams ¶ms=LAS_WriteParams())
Save the point cloud as an ASPRS LAS binary file (requires MRPT built against liblas).
nv_oem6_header_t header
Novatel frame: NV_OEM6_BESTPOS.
bool loadLASFile(POINTSMAP &ptmap, const std::string &filename, LAS_HeaderInfo &out_headerInfo, const LAS_LoadParams ¶ms=LAS_LoadParams())
Load the point cloud from an ASPRS LAS binary file (requires MRPT built against liblas).
GLsizei const GLchar ** string
Optional settings for saveLASFile()
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLenum const GLfloat * params