MCPcopy Create free account
hub / github.com/SpectacularAI/sdk / serializePointCloud

Function serializePointCloud

cpp/common/visualization/serialization.cpp:78–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void serializePointCloud(const std::string &filename, std::shared_ptr<spectacularAI::mapping::PointCloud> pointCloud) {
79 std::ofstream outputStream(filename.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
80 if (!outputStream.is_open()) {
81 throw std::runtime_error("Failed to create temporary file <" + filename + "> for pointcloud serialization.");
82 }
83
84 std::size_t points = pointCloud->size();
85 if (points > 0) {
86 outputStream.write(
87 reinterpret_cast<const char*>(pointCloud->getPositionData()),
88 sizeof(spectacularAI::Vector3f) * points);
89
90 if (pointCloud->hasNormals()) {
91 outputStream.write(
92 reinterpret_cast<const char*>(pointCloud->getNormalData()),
93 sizeof(spectacularAI::Vector3f) * points);
94 }
95
96 if (pointCloud->hasColors()) {
97 outputStream.write(
98 reinterpret_cast<const char*>(pointCloud->getRGB24Data()),
99 sizeof(std::uint8_t) * 3 * points);
100 }
101 }
102
103 outputStream.close();
104}
105
106} // anonymous namespace
107

Callers 1

Calls 6

getPositionDataMethod · 0.80
hasNormalsMethod · 0.80
getNormalDataMethod · 0.80
hasColorsMethod · 0.80
getRGB24DataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected