|
Wildmeshing Toolkit
|
#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, const bool split_connected_components=false, const io::ComponentIO *component_io=nullptr, const bool record_history=false) | |
| Input from meshes. | |
| const history::SurfaceHistory & | input_history () const |
| With record_history: the files as read, concatenated, then what became of them on the way to the arrangement – the weld, the transform, the split into components and the concatenation as one relabel, and the simplification's own edits. | |
| FacetSources & | facet_sources () |
| With record_history, once embedded: the input triangles each surface facet lies on. | |
| void | simplify_surface (const double eps, const bool use_exact, const int num_threads=0, const double boundary_eps=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, const bool provenance=false) |
| 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 std::vector< std::vector< size_t > > & | F_tags_surface () const |
| Per row of F_on_surface(): the inputs tiling it. Empty unless embed_surface recorded it. | |
| const std::vector< std::vector< int > > & | F_tags_surface_orientation () const |
| const MatrixXi & | F_surface () const |
| const std::vector< size_t > & | F_input () const |
| Per row of F_surface(): the input it came from, SIZE_MAX for none. | |
| 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 () |
| One binary tag column per input, set where that input's winding number at a tet barycenter is at least 0.5. Auto-corrects an inside-out input and warns when an input claims nothing, as the 2D EmbedCurves::tag_from_winding_number does. | |
| 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 | |
| bool | m_record_history = false |
| history::SurfaceHistory | m_input_history |
| FacetSources | m_facet_sources |
| 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< std::vector< int > > | m_F_tags_surface_orientation |
| 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 |
A class for reading an image and converting it into a tet mesh.
| wmtk::components::simwild::EmbedSurface::EmbedSurface | ( | const std::vector< std::string > & | img_filenames, |
| const std::vector< Matrix4d > & | img_transform = {}, |
||
| const double | tol_rel = -1, |
||
| const double | tol_abs = -1, |
||
| const bool | split_connected_components = false, |
||
| const io::ComponentIO * | component_io = nullptr, |
||
| const bool | record_history = false |
||
| ) |
Input from meshes.
| split_connected_components | Treat each connected component of an input file as an input in its own right, rather than the file as a whole. What counts as "an input" is what gets its own tag column and its own winding-number evaluation, so a file holding several disjoint closed surfaces is tagged as one region with this off, and as one region per component with it on. Off by default. |
Note that the inputs then outnumber the files, so input_names – which is applied by position – no longer lines up with the filenames; components past the end of that list fall back to the generic tag_N names.
|
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.
| bool wmtk::components::simwild::EmbedSurface::embed_surface | ( | const bool | flood_fill = false, |
| const bool | tag_from_winding_number = true, |
||
| const bool | provenance = false |
||
| ) |
Run the arrangement and tag the resulting cells.
| flood_fill | Unify the tags of each region bounded by the surface. |
| tag_from_winding_number | Decide 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. |
| provenance | Also record which inputs tile each surface face (F_tags_surface()), which the provenance tagging records anyway. |
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.
|
inline |
Parallel to F_tags_surface(): each input's direction on the row, +1 along its vertex order, -1 against, 0 where its triangles face both ways.
| void wmtk::components::simwild::EmbedSurface::simplify_surface | ( | const double | eps, |
| const bool | use_exact, | ||
| const int | num_threads = 0, |
||
| const double | boundary_eps = 0 |
||
| ) |
Simplify the input surface while staying within the eps envelope.
| eps | The absolute envelope thickness. |
| use_exact | Whether the envelope uses the exact predicate rather than the sampled one. The simwild application passes !simplify_use_sample_envelope. |
| boundary_eps | How the open boundary is held: 0 freezes it; positive lets it move within a tube of this radius around the input's boundary edges. See ShortestEdgeCollapse::create_mesh. |
|
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.
| 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.
| 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.