9 #ifndef CPOINTSMAP_LIBLAS_H 10 #define CPOINTSMAP_LIBLAS_H 14 #include <liblas/liblas.hpp> 15 #include <liblas/reader.hpp> 16 #include <liblas/writer.hpp> 65 template <
class POINTSMAP>
67 const POINTSMAP& ptmap,
const std::string& filename,
71 ofs.open(filename.c_str(), std::ios::out | std::ios::binary);
75 std::cerr <<
"[saveLASFile] Couldn't write to file: " << filename
83 const size_t nPts = ptmap.size();
85 header.SetPointRecordsCount(nPts);
89 liblas::Writer writer(ofs,
header);
91 const bool has_color = ptmap.hasColorPoints();
92 const float col_fract = 255.0f;
96 for (
size_t i = 0; i < nPts; i++)
98 float x,
y,
z,
R, G, B;
99 ptmap.getPoint(i,
x,
y,
z,
R, G, B);
107 col.SetRed(static_cast<uint16_t>(
R * col_fract));
108 col.SetGreen(static_cast<uint16_t>(G * col_fract));
109 col.SetBlue(static_cast<uint16_t>(B * col_fract));
113 if (!writer.WritePoint(pt))
115 std::cerr <<
"[saveLASFile] liblas returned error writing point #" 116 << i <<
" to file.\n";
128 template <
class POINTSMAP>
138 ifs.open(filename.c_str(),
std::ios::in | std::ios::binary);
142 std::cerr <<
"[loadLASFile] Couldn't open file: " << filename
149 liblas::Reader reader(ifs);
153 liblas::Header
const&
header = reader.GetHeader();
154 const size_t nPts =
header.GetPointRecordsCount();
160 #if LIBLAS_VERSION_NUM < 1800 172 const bool has_color = ptmap.hasColorPoints();
173 const float col_fract = 1.0f / 255.0f;
174 while (reader.ReadNextPoint())
176 liblas::Point
const&
p = reader.GetPoint();
180 liblas::Color
const& col =
p.GetColor();
182 p.GetX(),
p.GetY(),
p.GetZ(), col.GetRed() * col_fract,
183 col.GetGreen() * col_fract, col.GetBlue() * col_fract);
187 ptmap.insertPoint(
p.GetX(),
p.GetY(),
p.GetZ());
191 if (ptmap.size() != nPts)
192 cerr <<
"[loadLASFile] Header says point count is " << nPts
193 <<
" but only " << ptmap.size() <<
" were really parsed in.\n";
195 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