Wildmeshing Toolkit
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
wmtk::components::simwild::EmbedSurface Class Reference

#include <EmbedSurface.hpp>

Public Member Functions

 EmbedSurface (const std::vector< std::string > &img_filenames, const std::vector< Matrix4d > &img_transform={}, const double tol_rel=-1, const double tol_abs=-1)
 Input from meshes.
 
void simplify_surface (const double eps, const int num_threads=0)
 Simplify the input surface while staying within the eps envelope.
 
void remove_duplicates (const double eps)
 Merge vertices that are closer than eps.
 
bool embed_surface (const bool flood_fill=false, const bool tag_from_winding_number=true)
 Run the arrangement and tag the resulting cells.
 
void consolidate ()
 Remove unreferenced vertices.
 
const MatrixXd & V_emb () const
 
const MatrixXr & V_emb_r () const
 
const MatrixXd & V_surface () const
 
const MatrixXi & T_emb () const
 
const MatrixSi & T_tags () const
 
const MatrixXi & F_on_surface () const
 
const MatrixXi & F_surface () const
 
void write_surf_off (const std::string &filename) const
 Write surface as read from image.
 
void write_emb_surf_off (const std::string &filename) const
 Write embedded surface.
 
void write_emb_msh (const std::string &filename) const
 
void write_emb_vtu (const std::string &filename) const
 
std::pair< Vector3d, Vector3d > bbox_minmax () const
 
std::pair< Vector3d, Vector3d > bbox_surf_minmax () const
 
std::vector< Eigen::Vector3d > V_surf_to_vector () const
 
std::vector< std::array< size_t, 3 > > F_surf_to_vector () const
 

Public Attributes

bool m_smooth_surface = false
 
bool m_perform_sanity_checks = false
 
int m_num_threads = 0
 

Private Member Functions

void V_surf_from_vector (const std::vector< Eigen::Vector3d > &verts)
 
void F_surf_from_vector (const std::vector< std::array< size_t, 3 > > &tris)
 
void tag_from_winding_number ()
 
void tag_from_provenance ()
 Decide the cell tags from the arrangement's surface provenance.
 
void check_tag_surface_invariant (const std::string &how) const
 Count where the tagging and the arrangement's surface disagree.
 

Private Attributes

std::vector< std::string > m_img_filenames
 
std::vector< ImageData > m_img_datas
 
MatrixXd m_V_surface
 
MatrixXi m_F_surface
 
std::vector< size_t > m_F_input
 
std::vector< std::vector< size_t > > m_F_tags_surface
 
std::vector< size_t > modified_nonmanifold_v
 
MatrixXd m_V_emb
 
MatrixXr m_V_emb_r
 
MatrixXi m_T_emb
 
MatrixXi m_F_on_surface
 
MatrixSi m_T_tags
 
std::vector< std::set< int64_t > > m_tags
 
std::vector< MatrixXd > Vs
 
std::vector< MatrixXi > Fs
 

Detailed Description

A class for reading an image and converting it into a tet mesh.

Member Function Documentation

◆ check_tag_surface_invariant()

void wmtk::components::simwild::EmbedSurface::check_tag_surface_invariant ( const std::string &  how) const
private

Count where the tagging and the arrangement's surface disagree.

Everything downstream reads the surface off the tags – SimWildMesh marks a face as surface exactly when its two tets' tags differ – so a tagging is only right if it reproduces the surface the arrangement computed. Diagnostic, under DEBUG_sanity_checks.

◆ embed_surface()

bool wmtk::components::simwild::EmbedSurface::embed_surface ( const bool  flood_fill = false,
const bool  tag_from_winding_number = true 
)

Run the arrangement and tag the resulting cells.

Parameters
flood_fillUnify the tags of each region bounded by the surface.
tag_from_winding_numberDecide each cell's tags by evaluating the winding number of every input at its centroid (the default), rather than by propagating them across the arrangement's own surface provenance. See tag_from_provenance.

Only do a trivial rounding here. The more complex rounding is performed later on.

Cluster tags by flood-filling regions that are bounded by the surface. All tags within one region are unified by taking the tag with most occurances.

This is for several reasons not the best way to do this.

  1. The tags should be volume-weighted so that the tag that represents the most volume should be picked.
  2. We should not rely on geometric look-up at all, but use the information stored in m_F_tags_surface. This is more work so I took a shortcut here.

◆ simplify_surface()

void wmtk::components::simwild::EmbedSurface::simplify_surface ( const double  eps,
const int  num_threads = 0 
)

Simplify the input surface while staying within the eps envelope.

Parameters
epsThe absolute envelope thickness.

◆ tag_from_provenance()

void wmtk::components::simwild::EmbedSurface::tag_from_provenance ( )
private

Decide the cell tags from the arrangement's surface provenance.

The exact alternative to tag_from_winding_number. m_F_tags_surface says which inputs each surface face belongs to, so tags propagate combinatorially: start from a cell of the padded box, which is outside everything, and walk the tet adjacency graph toggling membership of input i whenever a face belonging to input i is crossed. Every input surface is closed, so the parity along any two paths to the same cell agrees; if it does not, the input was not closed and this throws rather than returning a tagging that depends on the traversal order.

◆ write_emb_surf_off()

void wmtk::components::simwild::EmbedSurface::write_emb_surf_off ( const std::string &  filename) const

Write embedded surface.

This writes all the vertices that exist in the volume and all triangles that are representing the embedded surface.

◆ write_surf_off()

void wmtk::components::simwild::EmbedSurface::write_surf_off ( const std::string &  filename) const

Write surface as read from image.

The surface is all the contours in the image, i.e., the surface in between voxels with different value.


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