CARLA
 
载入中...
搜索中...
未找到
PointCloudIO.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include "carla/FileSystem.h"
10
11#include <fstream>
12#include <iterator>
13#include <iomanip>
14
15namespace carla {
16namespace pointcloud {
17
19
20 public:
21 template <typename PointIt>
22 static void Dump(std::ostream &out, PointIt begin, PointIt end) {
23 WriteHeader(out, begin, end);
24 for (; begin != end; ++begin) {
25 begin->WriteDetection(out);
26 out << '\n';
27 }
28 }
29
30 template <typename PointIt>
31 static std::string SaveToDisk(std::string path, PointIt begin, PointIt end) {
32 FileSystem::ValidateFilePath(path, ".ply");
33 std::ofstream out(path);
34 Dump(out, begin, end);
35 return path;
36 }
37
38 private:
39 template <typename PointIt> static void WriteHeader(std::ostream &out, PointIt begin, PointIt end) {
40 DEBUG_ASSERT(std::distance(begin, end) >= 0);
41 out << "ply\n"
42 "format ascii 1.0\n"
43 "element vertex " << std::to_string(static_cast<size_t>(std::distance(begin, end))) << "\n";
44 begin->WritePlyHeaderInfo(out);
45 out << "\nend_header\n";
46 out << std::fixed << std::setprecision(4u);
47 }
48 };
49
50} // namespace pointcloud
51} // namespace carla
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
static void ValidateFilePath(std::string &filepath, const std::string &default_extension="")
Convenient function to validate a path before creating a file.
static void WriteHeader(std::ostream &out, PointIt begin, PointIt end)
static std::string SaveToDisk(std::string path, PointIt begin, PointIt end)
static void Dump(std::ostream &out, PointIt begin, PointIt end)
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133