ImFusion SDK 4.3
ImFusion::MeshIO Namespace Reference

Mesh input/output to standard mesh formats. More...

Detailed Description

Mesh input/output to standard mesh formats.

Please note that a mesh is loaded as is, i.e. duplicate vertices are not removed. A user might need to remove duplicate vertices to be able to use some mesh processing functionality

Functions

Meshload (const char *buffer, size_t bufferLength, const std::string &sourceFilename="", Progress *progressBar=nullptr, bool log=false)
 Loads a mesh from a memory buffer.
 
Meshload (const std::string &filename, Progress *progressBar=nullptr, bool log=false, bool allowVertexOnlyMesh=false, bool forceNoChecks=false, bool abortOnFaceAddFailure=false)
 Generic method to load a mesh from a file Supports the following file extensions: stl, off, vtk, ply, obj, surf, grid, 3mf.
 
MeshloadFromSTL (const std::string &filename, bool mergeVertices=true)
 Loads a mesh from a STL file, automatically determining text or binary format.
 
MeshloadFromSTL (std::istream &binaryStream, bool mergeVertices=true)
 
MeshloadFromOFF (const std::string &filename, bool allowVertexOnlyMesh)
 Loads a mesh from an OFF file.
 
MeshloadFromOFF (std::istream &binaryStream, bool allowVertexOnlyMesh)
 
MeshloadFromVTK (const std::string &filename)
 Loads a mesh from a VTK file.
 
MeshloadFromVTK (std::istream &binaryStream)
 
MeshloadFromSURF (const std::string &filename)
 
MeshloadFromSURF (std::istream &binaryStream)
 
MeshloadFromGRID (const std::string &filename)
 
MeshloadFromGRID (std::istream &binaryStream)
 
MeshloadFrom3MF (const std::string &filename)
 
MeshloadFrom3MF (std::istream &binaryStream)
 
MeshloadFromOBJ (const std::string &filename, Progress *progressBar=nullptr, bool allowVertexOnlyMesh=false, bool enforceCLocale=true)
 Loads a mesh from an OBJ file If enforceCLocale is true, the global locale is modified to make sure that the obj file is properly parsed.
 
MeshloadFromOBJ (std::istream &in, const std::string &sourceFilename, Progress *progressBar=nullptr, bool allowVertexOnlyMesh=false, bool enforceCLocale=true)
 Loads a mesh from an OBJ generic stream.
 
MeshloadFromPLY (const std::string &filename, Progress *progress=nullptr, bool allowVertexOnlyMesh=false, bool forceNoChecks=false, bool abortOnFaceAddFailure=false, bool enforceCLocale=true)
 Loads a mesh from an PLY file.
 
MeshloadFromPLY (std::istream &in, std::string &texFile, Progress *progress=nullptr, bool allowVertexOnlyMesh=false, bool forceNoChecks=false, bool abortOnFaceAddFailure=false, bool enforceCLocale=true)
 
bool saveToOBJ (const Mesh &mesh, const std::string &filename, Progress *progress=0, bool saveWithTexture=false, bool optimizeStorage=false, bool allowVertexOnlyMesh=false)
 Save as file in OBJ format, returns true if successful.
 
bool saveToOBJ (const Mesh &mesh, std::ostream &out, Progress *progress=0, bool saveWithTexture=false, bool optimizeStorage=false, bool allowVertexOnlyMesh=false)
 Save into an output stream in OBJ format, returns true if successful.
 
bool saveToPLY (const Mesh &mesh, const std::string &filename, bool saveWithTexture=false, bool allowVertexOnlyMesh=false)
 Save as file in PLY format, returns true if successful.
 
bool saveToPLY (const Mesh &mesh, std::ostream &out, const std::string &textureFilename="", bool allowVertexOnlyMesh=false)
 Save into an output stream in PLY format, returns true if successful.
 
bool saveToSTL (const Mesh &mesh, const std::string &filename)
 Save as file in STL format, returns true if successful.
 
bool saveToWRL (const Mesh &mesh, const std::string &filename, Progress *progress=0)
 Save as file in VRML format, returns true if successful.
 
bool saveToOFF (const Mesh &mesh, const std::string &filename, Progress *progress=0)
 Save as file in OFF format, returns true if successful.
 
bool saveTo3MF (const Mesh &mesh, const std::string &filename)
 Save as file in OFF format, returns true if successful.
 
std::string getMeshNameFromPath (const std::string &path)
 
MeshloadASCIISTLFile (std::istream &binaryStream)
 
MeshloadBinarySTLFile (std::istream &binaryStream)
 

Function Documentation

◆ load() [1/2]

Mesh * load ( const char * buffer,
size_t bufferLength,
const std::string & sourceFilename = "",
Progress * progressBar = nullptr,
bool log = false )

Loads a mesh from a memory buffer.

The optional sourceFilename is used to determine the mesh type and used to load additional files (e.g. materials).

Examples
ExampleMeshAlgorithm.cpp.

◆ load() [2/2]

Mesh * load ( const std::string & filename,
Progress * progressBar = nullptr,
bool log = false,
bool allowVertexOnlyMesh = false,
bool forceNoChecks = false,
bool abortOnFaceAddFailure = false )

Generic method to load a mesh from a file Supports the following file extensions: stl, off, vtk, ply, obj, surf, grid, 3mf.

Parameters
logunused, does not do anything
allowVertexOnlyMeshAllows meshes without triangle data (off, ply and obj only)
forceNoChecksDisables detecting and working around topology problems (ply only)
abortOnFaceAddFailureDiscards the mesh when topology prevents adding a face (ply only) Note that working around topology problems may result in new vertices being added, while ignoring them will either result in faces being lost or the mesh being discarded, depending on whether abortOnFaceAddFailure is set.

◆ loadFromOBJ() [1/2]

Mesh * loadFromOBJ ( const std::string & filename,
Progress * progressBar = nullptr,
bool allowVertexOnlyMesh = false,
bool enforceCLocale = true )

Loads a mesh from an OBJ file If enforceCLocale is true, the global locale is modified to make sure that the obj file is properly parsed.

If this is the case, the function should not be used in parallel with other code that relies on the locale, such as any other number parsing code. If enforceCLocale is false, the function assumes that a C-locale is set such that the decimal separator is '.' If this precondition is not fulfilled (for example, if the current locale uses ',' as decimal separator) an empty mesh is returned Modifying the global locale while the function is running is unspecified behavior and may produce an invalid mesh.

◆ loadFromOBJ() [2/2]

Mesh * loadFromOBJ ( std::istream & in,
const std::string & sourceFilename,
Progress * progressBar = nullptr,
bool allowVertexOnlyMesh = false,
bool enforceCLocale = true )

Loads a mesh from an OBJ generic stream.

The optional sourceFilename is used to load materials files. Not safe to run in parallel. See the function above for a description of the common parameters

Search Tab / S to search, Esc to close