Wildmeshing Toolkit
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
wmtk::io::TriVTUWriter Class Reference

Public Member Functions

 TriVTUWriter (const TriMesh &mesh)
 Construct a VTU writer for the given mesh.
 
void add_vertex_positions (const std::function< VectorXd(const size_t)> &f)
 Add vertex positions.
 
void add_vertex_attribute (const std::string &name, const std::function< VectorXd(const size_t)> &f)
 Add vertex attribute.
 
void add_vertex_attribute (const std::string &name, const std::function< double(const size_t)> &f)
 
void add_edge_attribute (const std::string &name, const std::function< VectorXd(const size_t)> &f)
 Add edge attribute.
 
void add_edge_attribute (const std::string &name, const std::function< double(const size_t)> &f)
 
void add_triangle_attribute (const std::string &name, const std::function< VectorXd(const size_t)> &f)
 Add triangle attribute.
 
void add_triangle_attribute (const std::string &name, const std::function< double(const size_t)> &f)
 
bool write_triangles (const std::filesystem::path &filename)
 Write the triangle mesh with triangle and vertex attributes.
 
bool write_edges (const std::filesystem::path &filename)
 Write the edge mesh with edge and vertex attributes.
 

Private Types

using Tuple = typename TriMesh::Tuple
 

Private Attributes

const TriMeshm_mesh
 
MatrixXd m_V
 
MatrixXi m_E
 
MatrixXi m_F
 
std::map< std::string, MatrixXd > m_V_attributes
 
std::map< std::string, MatrixXd > m_E_attributes
 
std::map< std::string, MatrixXd > m_F_attributes
 

Constructor & Destructor Documentation

◆ TriVTUWriter()

wmtk::io::TriVTUWriter::TriVTUWriter ( const TriMesh mesh)

Construct a VTU writer for the given mesh.

The IDs in the written mesh might not be the same as in inside the code. If you want these two to match, you must consolidate before writing. Additionally, edge IDs will never match.

If you want to know the IDs in your code, you can add an attribute like:

writer.add_edge_attribute("eid", [&m](int i) { return VectorXd::Constant(1, i); });
Definition TriMesh.h:28

Member Function Documentation

◆ add_edge_attribute()

void wmtk::io::TriVTUWriter::add_edge_attribute ( const std::string &  name,
const std::function< VectorXd(const size_t)> &  f 
)

Add edge attribute.

See add_vertex_attribute for details.

◆ add_triangle_attribute()

void wmtk::io::TriVTUWriter::add_triangle_attribute ( const std::string &  name,
const std::function< VectorXd(const size_t)> &  f 
)

Add triangle attribute.

See add_vertex_attribute for details.

◆ add_vertex_attribute()

void wmtk::io::TriVTUWriter::add_vertex_attribute ( const std::string &  name,
const std::function< VectorXd(const size_t)> &  f 
)

Add vertex attribute.

Examples:

writer.add_vertex_attribute("abc", [&m](int i) { return m.vertex_attrs[i].pos; });
writer.add_vertex_attribute("vid", [&m](int i) { return VectorXd::Constant(1, i); });
Parameters
fA function that takes the vertex ID as input and returns the attribute value for that vertex.

◆ add_vertex_positions()

void wmtk::io::TriVTUWriter::add_vertex_positions ( const std::function< VectorXd(const size_t)> &  f)

Add vertex positions.

If no positions are provided, all vertices will be placed at (0,0,0).

Parameters
fA function that takes the vertex ID as input and returns the position.

◆ write_edges()

bool wmtk::io::TriVTUWriter::write_edges ( const std::filesystem::path &  filename)

Write the edge mesh with edge and vertex attributes.

Parameters
filenameThe file the mesh is written to. Should have the extension .VTU.

◆ write_triangles()

bool wmtk::io::TriVTUWriter::write_triangles ( const std::filesystem::path &  filename)

Write the triangle mesh with triangle and vertex attributes.

Parameters
filenameThe file the mesh is written to. Should have the extension .VTU.

The documentation for this class was generated from the following files: