Lagrange
Loading...
Searching...
No Matches
lagrange::io Namespace Reference

Mesh input/output. More...

Classes

struct  LoadOptions
 Options used when loading a mesh or a scene. More...
 
struct  SaveOptions
 Options used when saving a mesh or a scene. More...
 

Enumerations

enum class  FileEncoding { Binary , Ascii }
 
enum class  FileFormat {
  Obj , Ply , Gltf , Msh ,
  Fbx , Stl , Unknown
}
 

Functions

template<typename MeshType, std::enable_if_t<!lagrange::MeshTraitHelper::is_mesh< MeshType >::value > * = nullptr>
MeshType load_mesh (std::istream &input_stream, const LoadOptions &options={})
 Load a mesh from a stream.
 
template<typename MeshType, std::enable_if_t<!lagrange::MeshTraitHelper::is_mesh< MeshType >::value > * = nullptr>
MeshType load_mesh (const fs::path &filename, const LoadOptions &={})
 Load a mesh from a file.
 
template<typename MeshType>
MeshType load_mesh_fbx (std::istream &input_stream, const LoadOptions &options={})
 Loads a mesh from an input stream in fbx format.
 
template<typename MeshType>
MeshType load_mesh_fbx (const fs::path &filename, const LoadOptions &options={})
 Loads a mesh from a file in fbx format.
 
template<typename MeshType>
MeshType load_mesh_gltf (std::istream &input_stream, const LoadOptions &options={})
 Loads a mesh from an input stream in glTF or GLB format.
 
template<typename MeshType>
MeshType load_mesh_gltf (const fs::path &filename, const LoadOptions &options={})
 Loads a mesh from a file in glTF or GLB format.
 
template<typename MeshType>
MeshType load_mesh_msh (std::istream &input_stream, const LoadOptions &options={})
 Loads a mesh from a stream in MSH format.
 
template<typename MeshType>
MeshType load_mesh_msh (const fs::path &filename, const LoadOptions &options={})
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a mesh from a file in MSH format.
 
template<typename MeshType>
MeshType load_mesh_obj (std::istream &input_stream_obj, const LoadOptions &options={})
 Loads a mesh from a file in MSH format.
 
template<typename MeshType>
MeshType load_mesh_obj (const fs::path &filename, const LoadOptions &options={})
 Loads a mesh from a file in MSH format.
 
template<typename MeshType>
MeshType load_mesh_ply (std::istream &input_stream, const LoadOptions &options={})
 Loads a mesh from a stream in PLY format.
 
template<typename MeshType>
MeshType load_mesh_ply (const fs::path &filename, const LoadOptions &options={})
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a mesh from a file in PLY format.
 
template<typename MeshType>
MeshType load_mesh_stl (std::istream &input_stream, const LoadOptions &options={})
 Loads a mesh from a stream in STL format.
 
template<typename MeshType>
MeshType load_mesh_stl (const fs::path &filename, const LoadOptions &options={})
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a mesh from a file in STL format.
 
template<typename SceneType>
SceneType load_scene (const fs::path &filename, const LoadOptions &options={})
 Load a scene.
 
template<typename SceneType>
SceneType load_scene (std::istream &input_stream, const LoadOptions &options={})
 Load a scene from a stream.
 
template<typename SceneType>
SceneType load_scene_fbx (const fs::path &filename, const LoadOptions &options={})
 Load an fbx scene.
 
template<typename SceneType>
SceneType load_scene_fbx (std::istream &input_stream, const LoadOptions &options={})
 Load an fbx scene.
 
template<typename SceneType>
SceneType load_scene_gltf (const fs::path &filename, const LoadOptions &options={})
 Load a scene using gltf.
 
template<typename SceneType>
SceneType load_scene_gltf (std::istream &input_stream, const LoadOptions &options={})
 Load a scene using gltf.
 
template<typename SceneType>
SceneType load_scene_obj (const fs::path &filename, const LoadOptions &options={})
 Load an obj into a scene.
 
template<typename SceneType>
SceneType load_scene_obj (std::istream &input_stream_obj, std::istream &input_stream_mtl, const LoadOptions &options={})
 Loadn obj into a scene.
 
template<typename SceneType>
SceneType load_simple_scene (const fs::path &filename, const LoadOptions &options={})
 Load a simple scene.
 
template<typename SceneType>
SceneType load_simple_scene (std::istream &input_stream, const LoadOptions &options={})
 Load a simple scene from a stream.
 
template<typename SceneType>
SceneType load_simple_scene_fbx (std::istream &input_stream, const LoadOptions &options={})
 Load a simple scene from fbx.
 
template<typename SceneType>
SceneType load_simple_scene_fbx (const fs::path &filename, const LoadOptions &options={})
 Load a simple scene from fbx.
 
template<typename SceneType>
SceneType load_simple_scene_gltf (std::istream &input_stream, const LoadOptions &options={})
 Load a simple scene with gltf.
 
template<typename SceneType>
SceneType load_simple_scene_gltf (const fs::path &filename, const LoadOptions &options={})
 Load a simple scene with gltf.
 
template<typename Scalar, typename Index>
void save_mesh (std::ostream &output_stream, const SurfaceMesh< Scalar, Index > &mesh, FileFormat format, const SaveOptions &options={})
 Save a mesh to a stream.
 
template<typename Scalar, typename Index>
void save_mesh (const fs::path &filename, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 Save a mesh to a file.
 
template<typename Scalar, typename Index>
void save_mesh_gltf (std::ostream &output_stream, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 Saves a mesh to an output stream in glTF or GLB format.
 
template<typename Scalar, typename Index>
void save_mesh_gltf (const fs::path &filename, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 Saves a mesh to a file in glTF or GLB format.
 
template<typename Scalar, typename Index>
void save_mesh_msh (std::ostream &output_stream, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 Saves a mesh to a stream in MSH format.
 
template<typename Scalar, typename Index>
void save_mesh_msh (const fs::path &filename, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Saves a mesh to a stream in MSH format.
 
template<typename Scalar, typename Index>
void save_mesh_obj (std::ostream &output_stream, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 Saves a mesh to a stream in OBJ format.
 
template<typename Scalar, typename Index>
void save_mesh_obj (const fs::path &filename, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Saves a mesh to a file in OBJ format.
 
template<typename Scalar, typename Index>
void save_mesh_ply (std::ostream &output_stream, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 Saves a mesh to a stream in PLY format.
 
template<typename Scalar, typename Index>
void save_mesh_ply (const fs::path &filename, const SurfaceMesh< Scalar, Index > &mesh, const SaveOptions &options={})
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Saves a mesh to a file in PLY format.
 
template<typename Scalar, typename Index>
void save_scene (const fs::path &filename, const scene::Scene< Scalar, Index > &scene, const SaveOptions &options={})
 Save a scene to a file.
 
template<typename Scalar, typename Index>
void save_scene (std::ostream &output_stream, const scene::Scene< Scalar, Index > &scene, FileFormat format, const SaveOptions &options={})
 Save a scene to a stream.
 
template<typename Scalar, typename Index>
void save_scene_gltf (std::ostream &output_stream, const scene::Scene< Scalar, Index > &scene, const SaveOptions &options={})
 Save a scene to a gltf or glb file.
 
template<typename Scalar, typename Index>
void save_scene_gltf (const fs::path &filename, const scene::Scene< Scalar, Index > &scene, const SaveOptions &options={})
 Save a scene to a gltf or glb file.
 
template<typename Scalar, typename Index>
void save_scene_obj (std::ostream &output_stream, const scene::Scene< Scalar, Index > &scene, const SaveOptions &options={})
 Save a scene to an obj file.
 
template<typename Scalar, typename Index>
void save_scene_obj (const fs::path &filename, const scene::Scene< Scalar, Index > &scene, const SaveOptions &options={})
 Save a scene to an obj file.
 
template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene (const fs::path &filename, const scene::SimpleScene< Scalar, Index, Dimension > &scene, const SaveOptions &options={})
 Save a mesh to a file.
 
template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene (std::ostream &output_stream, const scene::SimpleScene< Scalar, Index, Dimension > &scene, FileFormat format, const SaveOptions &options={})
 Save a simple scene to a stream.
 
template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_gltf (std::ostream &output_stream, const scene::SimpleScene< Scalar, Index, Dimension > &scene, const SaveOptions &options={})
 Save a simple scene to a gltf or glb file.
 
template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_gltf (const fs::path &filename, const scene::SimpleScene< Scalar, Index, Dimension > &scene, const SaveOptions &options={})
 Save a simple scene to a gltf or glb file.
 
template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_obj (std::ostream &output_stream, const scene::SimpleScene< Scalar, Index, Dimension > &scene, const SaveOptions &options={})
 Save a simple scene to an obj file.
 
template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_obj (const fs::path &filename, const scene::SimpleScene< Scalar, Index, Dimension > &scene, const SaveOptions &options={})
 Save a simple scene to an obj file.
 
template<typename Scalar, typename Index>
bool involve_indexed_attribute (const SurfaceMesh< Scalar, Index > &mesh, span< const AttributeId > attr_ids)
 
template<typename Scalar, typename Index>
std::tuple< SurfaceMesh< Scalar, Index >, std::vector< AttributeId > > remap_indexed_attributes (const SurfaceMesh< Scalar, Index > &in_mesh, span< const AttributeId > in_attr_ids)
 
 LA_SURFACE_MESH_X (load_mesh_fbx, 0)
 
 LA_SIMPLE_SCENE_X (load_simple_scene_fbx, 0)
 
 LA_SCENE_X (load_scene_fbx, 0)
 
 LA_SURFACE_MESH_X (load_mesh_gltf, 0)
 
 LA_SIMPLE_SCENE_X (load_simple_scene_gltf, 0)
 
 LA_SCENE_X (load_scene_gltf, 0)
 
 LA_SURFACE_MESH_X (load_mesh, 0)
 
std::string_view get_suffix (std::string_view name)
 
template<typename Scalar, typename Index, typename ValueType, AttributeElement element>
void extract_normal (happly::Element &ply_element, const std::string_view name, SurfaceMesh< Scalar, Index > &mesh)
 
template<typename Scalar, typename Index, typename ValueType>
void extract_vertex_uv (happly::Element &vertex_element, const std::string_view name, SurfaceMesh< Scalar, Index > &mesh)
 
template<typename Scalar, typename Index, typename ValueType, AttributeElement element>
void extract_color (happly::Element &ply_element, const std::string_view name, SurfaceMesh< Scalar, Index > &mesh)
 
template<AttributeElement element, typename Scalar, typename Index>
void extract_property (happly::Element &ply_element, const std::string &name, SurfaceMesh< Scalar, Index > &mesh)
 
template<typename Scalar, typename Index>
void extract_vertex_properties (happly::Element &vertex_element, SurfaceMesh< Scalar, Index > &mesh, const LoadOptions &options)
 
template<typename Scalar, typename Index>
void extract_facet_properties (happly::Element &facet_element, SurfaceMesh< Scalar, Index > &mesh, const LoadOptions &options)
 
 LA_SCENE_X (load_scene_obj, 0)
 
 LA_SCENE_X (load_scene, 0)
 
 LA_SIMPLE_SCENE_X (load_simple_scene, 0)
 
template<typename Scalar, typename Index, size_t Dimension>
tinygltf::Model lagrange_simple_scene_to_gltf_model (const scene::SimpleScene< Scalar, Index, Dimension > &lscene, const SaveOptions &options)
 
 LA_SIMPLE_SCENE_X (save_simple_scene_gltf, 0)
 
template<typename Scalar, typename Index>
tinygltf::Model lagrange_scene_to_gltf_model (const scene::Scene< Scalar, Index > &lscene, const SaveOptions &options)
 
 LA_SCENE_X (save_scene_gltf, 0)
 
 LA_SURFACE_MESH_X (save_mesh, 0)
 
 LA_SIMPLE_SCENE_X (save_simple_scene_obj, 0)
 
 LA_SCENE_X (save_scene_obj, 0)
 
 LA_SCENE_X (save_scene, 0)
 
 LA_SIMPLE_SCENE_X (save_simple_scene, 0)
 
template<typename Scalar, typename Index>
void stitch_mesh (SurfaceMesh< Scalar, Index > &mesh)
 

Detailed Description

Mesh input/output.

Function Documentation

◆ load_mesh() [1/2]

template<typename MeshType, std::enable_if_t<!lagrange::MeshTraitHelper::is_mesh< MeshType >::value > * = nullptr>
MeshType load_mesh ( std::istream & input_stream,
const LoadOptions & options = {} )

Load a mesh from a stream.

A mesh loader will automatically be selected based on the contents of the stream.

Template Parameters
MeshTypeThe mesh type to load.
Parameters
[in]input_streamThe input stream.
[in]optionsExtra options related to loading.
Returns
A SurfaceMesh object loaded from the input stream.

◆ load_mesh() [2/2]

template<typename MeshType, std::enable_if_t<!lagrange::MeshTraitHelper::is_mesh< MeshType >::value > * = nullptr>
MeshType load_mesh ( const fs::path & filename,
const LoadOptions & options = {} )

Load a mesh from a file.

The loader will be chosen depending on the file extension.

Parameters
[in]filenameInput file name.
[in]optionsExtra options related to loading.
Returns
A SurfaceMesh object loaded from the input file.

◆ load_mesh_fbx() [1/2]

template<typename MeshType>
MeshType load_mesh_fbx ( std::istream & input_stream,
const LoadOptions & options = {} )

Loads a mesh from an input stream in fbx format.

If the scene contains multiple meshes, they will be merged into one.

Parameters
input_streamInput data stream.
optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_fbx() [2/2]

template<typename MeshType>
MeshType load_mesh_fbx ( const fs::path & filename,
const LoadOptions & options = {} )

Loads a mesh from a file in fbx format.

If the scene contains multiple meshes, they will be merged into one.

Parameters
[in]filenameInput filename.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_gltf() [1/2]

template<typename MeshType>
MeshType load_mesh_gltf ( std::istream & input_stream,
const LoadOptions & options = {} )

Loads a mesh from an input stream in glTF or GLB format.

If the scene contains multiple meshes, they will be merged into one.

Parameters
input_streamInput data stream.
optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_gltf() [2/2]

template<typename MeshType>
MeshType load_mesh_gltf ( const fs::path & filename,
const LoadOptions & options = {} )

Loads a mesh from a file in glTF or GLB format.

If the scene contains multiple meshes, they will be merged into one.

Parameters
[in]filenameInput filename.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_msh() [1/2]

template<typename MeshType>
MeshType load_mesh_msh ( std::istream & input_stream,
const LoadOptions & options = {} )

Loads a mesh from a stream in MSH format.

Parameters
[in]input_streamInput stream.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_msh() [2/2]

template<typename MeshType>
MeshType load_mesh_msh ( const fs::path & filename,
const LoadOptions & options = {} )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a mesh from a file in MSH format.

Parameters
[in]filenameInput filename.
[in]optionsLoad options.
See also
load_mesh_msh
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_obj() [1/2]

template<typename MeshType>
MeshType load_mesh_obj ( std::istream & input_stream_obj,
const LoadOptions & options = {} )

Loads a mesh from a file in MSH format.

Parameters
[in]input_stream_objInput stream.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_obj() [2/2]

template<typename MeshType>
MeshType load_mesh_obj ( const fs::path & filename,
const LoadOptions & options = {} )

Loads a mesh from a file in MSH format.

Parameters
[in]filenameInput filename.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_ply() [1/2]

template<typename MeshType>
MeshType load_mesh_ply ( std::istream & input_stream,
const LoadOptions & options = {} )

Loads a mesh from a stream in PLY format.

Parameters
[in,out]input_streamInput stream.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_ply() [2/2]

template<typename MeshType>
MeshType load_mesh_ply ( const fs::path & filename,
const LoadOptions & options = {} )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a mesh from a file in PLY format.

Parameters
[in]filenameInput filename.
[in]optionsLoad options.
Template Parameters
MeshTypeMesh type to load.
Returns
Loaded mesh.

◆ load_mesh_stl() [1/2]

template<typename MeshType>
MeshType load_mesh_stl ( std::istream & input_stream,
const LoadOptions & options = {} )

Loads a mesh from a stream in STL format.

Parameters
[in]input_streamInput stream.
[in]optionsLoad options.
Returns
Loaded mesh.

◆ load_mesh_stl() [2/2]

template<typename MeshType>
MeshType load_mesh_stl ( const fs::path & filename,
const LoadOptions & options = {} )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a mesh from a file in STL format.

Parameters
[in]filenameInput filename.
[in]optionsLoad options.
See also
load_mesh_stl
Returns
Loaded mesh.

◆ load_scene() [1/2]

template<typename SceneType>
SceneType load_scene ( const fs::path & filename,
const LoadOptions & options = {} )

Load a scene.

Parameters
[in]filenameInput scene file.
[in]optionsExtra options related to loading.
Returns
A Scene object created from the input scene file.

◆ load_scene() [2/2]

template<typename SceneType>
SceneType load_scene ( std::istream & input_stream,
const LoadOptions & options = {} )

Load a scene from a stream.

Parameters
[in]input_streamThe input stream.
[in]optionsExtra options related to loading.
Returns
A Scene object loaded from the input stream.

◆ load_scene_fbx() [1/2]

template<typename SceneType>
SceneType load_scene_fbx ( const fs::path & filename,
const LoadOptions & options = {} )

Load an fbx scene.

Parameters
[in]filenameinput file name
[in]options
Returns
loaded scene

◆ load_scene_fbx() [2/2]

template<typename SceneType>
SceneType load_scene_fbx ( std::istream & input_stream,
const LoadOptions & options = {} )

Load an fbx scene.

Parameters
[in]input_streamInput stream containing the scene data
[in]options
Returns
loaded scene

◆ load_scene_gltf() [1/2]

template<typename SceneType>
SceneType load_scene_gltf ( const fs::path & filename,
const LoadOptions & options = {} )

Load a scene using gltf.

Parameters
[in]filenameinput file name
[in]options
Returns
loaded scene

◆ load_scene_gltf() [2/2]

template<typename SceneType>
SceneType load_scene_gltf ( std::istream & input_stream,
const LoadOptions & options = {} )

Load a scene using gltf.

Parameters
[in]input_streamInput stream containing the scene data
[in]options
Returns
loaded scene

◆ load_scene_obj() [1/2]

template<typename SceneType>
SceneType load_scene_obj ( const fs::path & filename,
const LoadOptions & options = {} )

Load an obj into a scene.

Parameters
[in]filenameinput file name
[in]options
Returns
loaded scene

◆ load_scene_obj() [2/2]

template<typename SceneType>
SceneType load_scene_obj ( std::istream & input_stream_obj,
std::istream & input_stream_mtl,
const LoadOptions & options = {} )

Loadn obj into a scene.

Parameters
[in]input_stream_objInput stream containing the obj file data
[in]input_stream_mtlInput stream containing the mtl file data
[in]options
Returns
loaded scene

◆ load_simple_scene() [1/2]

template<typename SceneType>
SceneType load_simple_scene ( const fs::path & filename,
const LoadOptions & options = {} )

Load a simple scene.

Parameters
[in]filenameInput scene file.
[in]optionsExtra options related to loading.
Returns
A SimpleScene object created from the input scene file.

◆ load_simple_scene() [2/2]

template<typename SceneType>
SceneType load_simple_scene ( std::istream & input_stream,
const LoadOptions & options = {} )

Load a simple scene from a stream.

Parameters
[in]input_streamThe input stream.
[in]optionsExtra options related to loading.
Returns
A SimpleScene object loaded from the input stream.

◆ load_simple_scene_fbx() [1/2]

template<typename SceneType>
SceneType load_simple_scene_fbx ( std::istream & input_stream,
const LoadOptions & options = {} )

Load a simple scene from fbx.

Parameters
[in]filenameinput file
[in]options
Returns
scene

◆ load_simple_scene_fbx() [2/2]

template<typename SceneType>
SceneType load_simple_scene_fbx ( const fs::path & filename,
const LoadOptions & options = {} )

Load a simple scene from fbx.

Parameters
[in]filenameinput file
[in]options
Returns
scene

◆ load_simple_scene_gltf() [1/2]

template<typename SceneType>
SceneType load_simple_scene_gltf ( std::istream & input_stream,
const LoadOptions & options = {} )

Load a simple scene with gltf.

Parameters
[in]input_streaminput stream data
[in]options
Returns
scene

◆ load_simple_scene_gltf() [2/2]

template<typename SceneType>
SceneType load_simple_scene_gltf ( const fs::path & filename,
const LoadOptions & options = {} )

Load a simple scene with gltf.

Parameters
[in]filenameinput file
[in]options
Returns
scene

◆ save_mesh() [1/2]

template<typename Scalar, typename Index>
void save_mesh ( std::ostream & output_stream,
const SurfaceMesh< Scalar, Index > & mesh,
FileFormat format,
const SaveOptions & options = {} )

Save a mesh to a stream.

Parameters
[in]output_streamStream to output
[in]meshMesh to save
[in]formatMesh format to use.
[in]optionsExtra options related to saving.

◆ save_mesh() [2/2]

template<typename Scalar, typename Index>
void save_mesh ( const fs::path & filename,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

Save a mesh to a file.

Parameters
[in]filenamepath to output
[in]meshmesh to save
[in]optionsExtra options related to saving.

◆ save_mesh_gltf() [1/2]

template<typename Scalar, typename Index>
void save_mesh_gltf ( std::ostream & output_stream,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

Saves a mesh to an output stream in glTF or GLB format.

Parameters
[in]output_streamOutput data stream.
[in]meshMesh to write.
[in]optionsSave options.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_gltf() [2/2]

template<typename Scalar, typename Index>
void save_mesh_gltf ( const fs::path & filename,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

Saves a mesh to a file in glTF or GLB format.

Parameters
[in]filenameOutput filename.
[in]meshMesh to write.
[in]optionsSave options.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_msh() [1/2]

template<typename Scalar, typename Index>
void save_mesh_msh ( std::ostream & output_stream,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

Saves a mesh to a stream in MSH format.

If the mesh cannot be saved, an exception is raised (e.g., invalid output stream, incorrect mesh dimension, or facet size < 3).

Parameters
[in,out]output_streamOutput stream.
[in]meshInput mesh.
[in]optionsOption settings.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_msh() [2/2]

template<typename Scalar, typename Index>
void save_mesh_msh ( const fs::path & filename,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Saves a mesh to a stream in MSH format.

If the mesh cannot be saved, an exception is raised (e.g., incorrect mesh dimension, or facet size < 3).

Parameters
[in]filenameOutput filename.
[in]meshMesh to write.
[in]optionsSave options.
See also
save_mesh_msh
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_obj() [1/2]

template<typename Scalar, typename Index>
void save_mesh_obj ( std::ostream & output_stream,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

Saves a mesh to a stream in OBJ format.

If the mesh cannot be saved, an exception is raised (e.g., invalid output stream, incorrect mesh dimension, or facet size < 3).

Parameters
[in,out]output_streamOutput stream.
[in]meshMesh to write.
[in]optionsSave options.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_obj() [2/2]

template<typename Scalar, typename Index>
void save_mesh_obj ( const fs::path & filename,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Saves a mesh to a file in OBJ format.

If the mesh cannot be saved, an exception is raised (e.g., incorrect mesh dimension, or facet size < 3).

Parameters
[in]filenameOutput filename.
[in]meshMesh to write.
[in]optionsSave options.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_ply() [1/2]

template<typename Scalar, typename Index>
void save_mesh_ply ( std::ostream & output_stream,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

Saves a mesh to a stream in PLY format.

Parameters
[in,out]output_streamOutput stream.
[in]meshMesh to write.
[in]optionsSave options.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_mesh_ply() [2/2]

template<typename Scalar, typename Index>
void save_mesh_ply ( const fs::path & filename,
const SurfaceMesh< Scalar, Index > & mesh,
const SaveOptions & options = {} )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Saves a mesh to a file in PLY format.

Parameters
[in]filenameOutput filename.
[in]meshMesh to write.
[in]optionsSave options.
Template Parameters
ScalarMesh scalar type.
IndexMesh index type.

◆ save_scene() [1/2]

template<typename Scalar, typename Index>
void save_scene ( const fs::path & filename,
const scene::Scene< Scalar, Index > & scene,
const SaveOptions & options = {} )

Save a scene to a file.

Parameters
[in]filenamepath to output
[in]scenescene to save
[in]optionsSaveOptions, check the struct for more details.

◆ save_scene() [2/2]

template<typename Scalar, typename Index>
void save_scene ( std::ostream & output_stream,
const scene::Scene< Scalar, Index > & scene,
FileFormat format,
const SaveOptions & options = {} )

Save a scene to a stream.

Parameters
[in]output_streamStream to output
[in]sceneScene to save
[in]formatFileFormat to use.
[in]optionsSaveOptions, check the struct for more details.

◆ save_scene_gltf() [1/2]

template<typename Scalar, typename Index>
void save_scene_gltf ( std::ostream & output_stream,
const scene::Scene< Scalar, Index > & scene,
const SaveOptions & options = {} )

Save a scene to a gltf or glb file.

Parameters
output_streamStream to output data
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_scene_gltf() [2/2]

template<typename Scalar, typename Index>
void save_scene_gltf ( const fs::path & filename,
const scene::Scene< Scalar, Index > & scene,
const SaveOptions & options = {} )

Save a scene to a gltf or glb file.

Parameters
filenamepath to output file
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_scene_obj() [1/2]

template<typename Scalar, typename Index>
void save_scene_obj ( std::ostream & output_stream,
const scene::Scene< Scalar, Index > & scene,
const SaveOptions & options = {} )

Save a scene to an obj file.

The following information will be saved:

  • Geometry (vertices, faces)
  • UV coordinates (if present)
  • Normals (if present)
  • Material assignments (if present)
  • Object and group names

Notes:

  • Some scene features such as hierarchical transforms, cameras, lights, and custom attributes are not supported by the OBJ format and will be lost.
  • Stream-based save_scene_obj does not support writing an .mtl file or texture images. Consider using file-based save_scene_obj instead.
Parameters
output_streamStream to output data
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_scene_obj() [2/2]

template<typename Scalar, typename Index>
void save_scene_obj ( const fs::path & filename,
const scene::Scene< Scalar, Index > & scene,
const SaveOptions & options = {} )

Save a scene to an obj file.

The following information will be saved:

  • Geometry (vertices, faces)
  • UV coordinates (if present)
  • Normals (if present)
  • Material assignments (if present)
  • Object and group names
  • Materials will be saved to a separate .mtl file, but will be (poorly) converted from PBR to phong.
  • Base color and normal textures (if present) will be saved to separate files in the same directory.

Notes:

  • Some scene features such as hierarchical transforms, cameras, lights, and custom attributes are not supported by the OBJ format and will be lost.
Parameters
filenamepath to output file
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_simple_scene() [1/2]

template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene ( const fs::path & filename,
const scene::SimpleScene< Scalar, Index, Dimension > & scene,
const SaveOptions & options = {} )

Save a mesh to a file.

Parameters
[in]filenamepath to output
[in]scenemesh to save
[in]optionsSaveOptions, check the struct for more details.

◆ save_simple_scene() [2/2]

template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene ( std::ostream & output_stream,
const scene::SimpleScene< Scalar, Index, Dimension > & scene,
FileFormat format,
const SaveOptions & options = {} )

Save a simple scene to a stream.

Parameters
[in]output_streamoutput stream
[in]scenescene to save
[in]formatfile format to use
[in]optionsSaveOptions, check the struct for more details.

◆ save_simple_scene_gltf() [1/2]

template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_gltf ( std::ostream & output_stream,
const scene::SimpleScene< Scalar, Index, Dimension > & scene,
const SaveOptions & options = {} )

Save a simple scene to a gltf or glb file.

Parameters
output_streamStream to output data
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_simple_scene_gltf() [2/2]

template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_gltf ( const fs::path & filename,
const scene::SimpleScene< Scalar, Index, Dimension > & scene,
const SaveOptions & options = {} )

Save a simple scene to a gltf or glb file.

Parameters
filenamepath to output file
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_simple_scene_obj() [1/2]

template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_obj ( std::ostream & output_stream,
const scene::SimpleScene< Scalar, Index, Dimension > & scene,
const SaveOptions & options = {} )

Save a simple scene to an obj file.

Some information about the scene will be lost, as the obj format does not support all scene features.

Parameters
output_streamStream to output data
sceneScene to save
optionsSaveOptions, check the struct for more details.

◆ save_simple_scene_obj() [2/2]

template<typename Scalar, typename Index, size_t Dimension = 3>
void save_simple_scene_obj ( const fs::path & filename,
const scene::SimpleScene< Scalar, Index, Dimension > & scene,
const SaveOptions & options = {} )

Save a simple scene to an obj file.

Some information about the scene will be lost, as the obj format does not support all scene features.

Parameters
filenamepath to output file
sceneScene to save
optionsSaveOptions, check the struct for more details.