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

Public Member Functions

 TetVTUWriter (const TetMesh &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_edge_attribute (const std::string &name, const std::function< VectorXd(const size_t)> &f)
 Add edge attribute.
 
void add_triangle_attribute (const std::string &name, const std::function< VectorXd(const size_t)> &f)
 Add triangle attribute.
 
void add_tet_attribute (const std::string &name, const std::function< VectorXd(const size_t)> &f)
 Add tet attribute.
 
bool write_tets (const std::filesystem::path &filename)
 Write the tet mesh with tet and vertex attributes.
 
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 TetMesh::Tuple
 

Private Attributes

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

Constructor & Destructor Documentation

◆ TetVTUWriter()

wmtk::io::TetVTUWriter::TetVTUWriter ( const TetMesh 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 TetMesh.h:24

Member Function Documentation

◆ add_edge_attribute()

void wmtk::io::TetVTUWriter::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_tet_attribute()

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

Add tet attribute.

See add_vertex_attribute for details.

◆ add_triangle_attribute()

void wmtk::io::TetVTUWriter::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::TetVTUWriter::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::TetVTUWriter::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::TetVTUWriter::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_tets()

bool wmtk::io::TetVTUWriter::write_tets ( const std::filesystem::path &  filename)

Write the tet mesh with tet and vertex attributes.

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

◆ write_triangles()

bool wmtk::io::TetVTUWriter::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: