Template Class LazyMesh

Nested Relationships

Nested Types

Class Documentation

template<typename BaseVecT>
class LazyMesh

A Mesh that is only loaded into memory when needed.

Public Functions

LazyMesh(PMPMesh<BaseVecT> &&src, std::shared_ptr<HighFive::File> file, bool keepLoaded = false)

Construct a new Lazy Mesh object from the given mesh. The mesh is stored in the file in the group specified by LAZY_MESH_TEMP_DIR.

setting keepLoaded to true defeats the purpose of a LazyMesh, and should only be used if you a) Need a consistent interface between several LazyMeshes and “Lazy”Meshes b) Want to manually decide when to load and unload the mesh by using the keepLoaded() and allowUnload() methods

file may be a nullptr if keepLoaded is true and stays true. Calling allowUnload() will cause an exception to be thrown the next time the mesh is loaded.

Parameters:
  • src – The mesh to store.

  • file – The file to store the mesh in whenever it is not needed.

  • keepLoaded – Whether to keep the mesh loaded in memory.

LazyMesh(LazyMesh&&)

move constructor

LazyMesh &operator=(LazyMesh&&)

move assignment operator

virtual ~LazyMesh()
std::shared_ptr<const PMPMesh<BaseVecT>> get()

Gain read-only access to the mesh, loading it if necessary.

The instance returned by this is shared with any previous calls to get() or modify(), provided that their shared_ptr are still alive.

Returns:

A shared_ptr around the mesh. The mesh is unloaded again when the last shared_ptr instance is destroyed (unless keepLoaded is set).

std::shared_ptr<PMPMesh<BaseVecT>> modify()

Same as get(), but the underlying file is updated when the mesh is unloaded.

The instance returned by this is shared with those returned by get(). This allows calling get() first and modify() only once you want to make changes to the mesh, without having to load the mesh again.

Returns:

A shared_ptr around the mesh. The mesh is saved to file and unloaded as soon as the last reference is destroyed.

inline bool isLoaded() const

Returns true if the mesh is currently loaded in memory.

inline void keepLoaded()

Keeps the mesh loaded until the entire LazyMesh is destroyed or allowUnload() is called.

inline bool isKeptLoaded() const

Returns true if the mesh is permanently loaded.

inline void allowUnload()

Inverse of keepLoaded(). Allows unloading the mesh if it is not needed anymore.

Note: If you call this after creating an instance with a nullptr file, the mesh will be permanently deleted on unload and cannot be loaded again.

inline size_t numFaces() const

Get the number of faces without loading the mesh.

inline size_t numVertices() const

Get the number of vertices without loading the mesh.

inline size_t numEdges() const

Get the number of edges without loading the mesh.

inline std::shared_ptr<HighFive::File> getFile() const

Returns the file this mesh is stored in (if any). Useful for creating a new LazyMesh in the same file.

Public Static Functions

static inline void removeTempDir(std::shared_ptr<HighFive::File> file)

Remove the temp dir from the file. Make sure to only call this after any remaining LazyMesh instances in the file have been destroyed.

Parameters:

file – The file to remove the temp dir from.