diff --git a/LibCarla/source/carla/pointcloud/PointCloudIO.cpp b/LibCarla/source/carla/pointcloud/PointCloudIO.cpp deleted file mode 100644 index 4a5cf78d3..000000000 --- a/LibCarla/source/carla/pointcloud/PointCloudIO.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma -// de Barcelona (UAB). -// -// This work is licensed under the terms of the MIT license. -// For a copy, see . - -#include "carla/pointcloud/PointCloudIO.h" - -#include - -namespace carla { -namespace pointcloud { - - void PointCloudIO::WriteHeader(std::ostream &out, size_t number_of_points) { - out << "ply\n" - "format ascii 1.0\n" - "element vertex " << std::to_string(number_of_points) << "\n" - "property float32 x\n" - "property float32 y\n" - "property float32 z\n" - "property float32 I\n" - // "property uchar diffuse_red\n" - // "property uchar diffuse_green\n" - // "property uchar diffuse_blue\n" - "end_header\n"; - out << std::fixed << std::setprecision(4u); - } - -} // namespace pointcloud -} // namespace carla diff --git a/LibCarla/source/carla/pointcloud/PointCloudIO.h b/LibCarla/source/carla/pointcloud/PointCloudIO.h index 76f19395c..165c5cad7 100644 --- a/LibCarla/source/carla/pointcloud/PointCloudIO.h +++ b/LibCarla/source/carla/pointcloud/PointCloudIO.h @@ -10,19 +10,20 @@ #include #include +#include namespace carla { namespace pointcloud { class PointCloudIO { - public: + public: template static void Dump(std::ostream &out, PointIt begin, PointIt end) { - DEBUG_ASSERT(std::distance(begin, end) >= 0); - WriteHeader(out, static_cast(std::distance(begin, end))); + WriteHeader(out, begin, end); for (; begin != end; ++begin) { - out << begin->point.x << ' ' << begin->point.y << ' ' << begin->point.z << ' ' << begin->intensity << '\n'; + begin->WriteDetection(out); + out << '\n'; } } @@ -35,8 +36,15 @@ namespace pointcloud { } private: - - static void WriteHeader(std::ostream &out, size_t number_of_points); + template static void WriteHeader(std::ostream &out, PointIt begin, PointIt end) { + DEBUG_ASSERT(std::distance(begin, end) >= 0); + out << "ply\n" + "format ascii 1.0\n" + "element vertex " << std::to_string(static_cast(std::distance(begin, end))) << "\n"; + begin->WritePlyHeaderInfo(out); + out << "end_header\n"; + out << std::fixed << std::setprecision(4u); + } }; } // namespace pointcloud