diff --git a/voxblox/include/voxblox/io/mesh_ply.h b/voxblox/include/voxblox/io/mesh_ply.h index 13b3e1b27..bfac19153 100644 --- a/voxblox/include/voxblox/io/mesh_ply.h +++ b/voxblox/include/voxblox/io/mesh_ply.h @@ -46,7 +46,7 @@ bool outputMeshLayerAsPly(const std::string& filename, const MeshLayer& mesh_layer); /** - * @param connected_mesh if true veracities will be shared between triangles + * @param connected_mesh if true vertices will be shared between triangles */ bool outputMeshLayerAsPly(const std::string& filename, const bool connected_mesh, diff --git a/voxblox/include/voxblox/mesh/mesh.h b/voxblox/include/voxblox/mesh/mesh.h index b275ddd4f..1b5cee24a 100644 --- a/voxblox/include/voxblox/mesh/mesh.h +++ b/voxblox/include/voxblox/mesh/mesh.h @@ -59,6 +59,19 @@ struct Mesh { inline bool hasTriangles() const { return !indices.empty(); } inline size_t size() const { return vertices.size(); } + inline size_t getMemorySize() const { + size_t size_bytes = 0u; + size_bytes += sizeof(Pointcloud) + vertices.size() * sizeof(Point); + size_bytes += sizeof(Pointcloud) + normals.size() * sizeof(Point); + size_bytes += sizeof(Colors) + vertices.size() * sizeof(Color); + size_bytes += + sizeof(VertexIndexList) + indices.size() * sizeof(VertexIndex); + + size_bytes += sizeof(block_size); + size_bytes += sizeof(origin); + size_bytes += sizeof(updated); + return size_bytes; + } inline void clear() { vertices.clear(); diff --git a/voxblox/include/voxblox/mesh/mesh_layer.h b/voxblox/include/voxblox/mesh/mesh_layer.h index 89d38e90b..4bcd4db9a 100644 --- a/voxblox/include/voxblox/mesh/mesh_layer.h +++ b/voxblox/include/voxblox/mesh/mesh_layer.h @@ -276,6 +276,21 @@ class MeshLayer { size_t getNumberOfAllocatedMeshes() const { return mesh_map_.size(); } + inline size_t getMemorySize() const { + size_t size_bytes = 0u; + + // Calculate size of members + size_bytes += sizeof(block_size_); + size_bytes += sizeof(block_size_inv_); + + // Calculate size of mesh blocks + for (const auto& idx_mesh_pair : mesh_map_) { + CHECK(idx_mesh_pair.second); + size_bytes += idx_mesh_pair.second->getMemorySize(); + } + return size_bytes; + } + /// Deletes ALL parts of the mesh. void clear() { mesh_map_.clear(); }