CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
pointcloud
PointCloudIO.h
Go to the documentation of this file.
1
// Copyright (c) 2026 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
15
namespace
carla
{
16
namespace
pointcloud
{
17
18
class
PointCloudIO
{
19
20
public
:
21
template
<
typename
Po
int
It>
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
Po
int
It>
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
Po
int
It>
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
DEBUG_ASSERT
#define DEBUG_ASSERT(predicate)
Definition
Debug.h:66
FileSystem.h
carla::FileSystem::ValidateFilePath
static void ValidateFilePath(std::string &filepath, const std::string &default_extension="")
Convenient function to validate a path before creating a file.
Definition
FileSystem.cpp:18
carla::pointcloud::PointCloudIO
Definition
PointCloudIO.h:18
carla::pointcloud::PointCloudIO::WriteHeader
static void WriteHeader(std::ostream &out, PointIt begin, PointIt end)
Definition
PointCloudIO.h:39
carla::pointcloud::PointCloudIO::SaveToDisk
static std::string SaveToDisk(std::string path, PointIt begin, PointIt end)
Definition
PointCloudIO.h:31
carla::pointcloud::PointCloudIO::Dump
static void Dump(std::ostream &out, PointIt begin, PointIt end)
Definition
PointCloudIO.h:22
carla::pointcloud
Definition
PointCloudIO.h:16
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Generated by
1.18.0