MCPcopy Create free account
hub / github.com/PDAL/PDAL / write

Method write

io/PcdWriter.cpp:243–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243void PcdWriter::write(const PointViewPtr view)
244{
245 std::unique_ptr<std::ostream> out(Utils::createFile(filename(), false));
246 if (!out)
247 throwError("Couldn't open '" + filename() + "' for output.");
248
249 PcdHeader header;
250
251 header.m_version = PcdVersion::PCD_V7;
252 header.m_height = 1;
253 if (m_compression_string == "ascii")
254 header.m_dataStorage = PcdDataStorage::ASCII;
255 else if (m_compression_string == "binary")
256 header.m_dataStorage = PcdDataStorage::BINARY;
257 else
258 throwError("Unrecognized compression string '" + m_compression_string + "'. "
259 "Expected 'ASCII' or 'BINARY'.");
260
261 for (auto di = m_dims.begin(); di != m_dims.end(); ++di)
262 header.m_fields.push_back(di->m_field);
263
264 header.m_width = view->size();
265 header.m_pointCount = view->size();
266
267 *out << header;
268
269 if (m_compression_string == "ascii")
270 writeAscii(view, *out);
271 else
272 {
273 // Reopen as for binary output, seeking to the end of the header before writing data.
274 out.reset(FileUtils::openExisting(filename(), true));
275 out->seekp(0, std::ios::end);
276 writeBinary(view, *out);
277 }
278}
279
280void PcdWriter::writeAscii(const PointViewPtr view, std::ostream& out)
281{

Callers

nothing calls this directly

Calls 6

openExistingFunction · 0.85
createFileFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected