Skip to content

Commit

Permalink
add function to compute memory size of mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
mfehr committed Mar 8, 2019
1 parent 16feae0 commit eaa6ddc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion voxblox/include/voxblox/io/mesh_ply.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions voxblox/include/voxblox/mesh/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 15 additions & 0 deletions voxblox/include/voxblox/mesh/mesh_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down

0 comments on commit eaa6ddc

Please sign in to comment.