xyz_writing_points_processor.cc
Go to the documentation of this file.
2 
3 #include <iomanip>
4 
6 #include "glog/logging.h"
7 
8 namespace cartographer {
9 namespace io {
10 
11 namespace {
12 
13 void WriteXyzPoint(const Eigen::Vector3f& point,
14  FileWriter* const file_writer) {
15  std::ostringstream stream;
16  stream << std::setprecision(6);
17  stream << point.x() << " " << point.y() << " " << point.z() << "\n";
18  const string out = stream.str();
19  CHECK(file_writer->Write(out.data(), out.size()));
20 }
21 
22 } // namespace
23 
25  std::unique_ptr<FileWriter> file_writer, PointsProcessor* const next)
26  : next_(next), file_writer_(std::move(file_writer)) {}
27 
28 std::unique_ptr<XyzWriterPointsProcessor>
30  FileWriterFactory file_writer_factory,
31  common::LuaParameterDictionary* const dictionary,
32  PointsProcessor* const next) {
33  return common::make_unique<XyzWriterPointsProcessor>(
34  file_writer_factory(dictionary->GetString("filename")), next);
35 }
36 
38  CHECK(file_writer_->Close()) << "Closing XYZ file failed.";
39  switch (next_->Flush()) {
42 
44  LOG(FATAL) << "XYZ generation must be configured to occur after any "
45  "stages that require multiple passes.";
46  }
47  LOG(FATAL);
48 }
49 
50 void XyzWriterPointsProcessor::Process(std::unique_ptr<PointsBatch> batch) {
51  for (const Eigen::Vector3f& point : batch->points) {
52  WriteXyzPoint(point, file_writer_.get());
53  }
54  next_->Process(std::move(batch));
55 }
56 
57 } // namespace io
58 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
void Process(std::unique_ptr< PointsBatch > batch) override
std::function< std::unique_ptr< FileWriter >(const string &filename)> FileWriterFactory
Definition: file_writer.h:63
XyzWriterPointsProcessor(std::unique_ptr< FileWriter >, PointsProcessor *next)
virtual FlushResult Flush()=0
static std::unique_ptr< XyzWriterPointsProcessor > FromDictionary(FileWriterFactory file_writer_factory, common::LuaParameterDictionary *dictionary, PointsProcessor *next)


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:59