Wildmeshing Toolkit
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
wmtk::components::topological_offset::TopoOffsetTetMesh Class Reference
Inheritance diagram for wmtk::components::topological_offset::TopoOffsetTetMesh:
wmtk::TetMesh

Classes

struct  EdgeSplitCache
 
struct  FaceSplitCache
 
struct  TetSplitCache
 

Public Types

enum class  EdgeSplitMode { Midpoint = 0 , BinarySearch = 1 , Initial = 2 }
 
using VertAttCol = wmtk::AttributeCollection< VertexAttributes >
 
using EdgeAttCol = wmtk::AttributeCollection< EdgeAttributes >
 
using FaceAttCol = wmtk::AttributeCollection< FaceAttributes >
 
using TetAttCol = wmtk::AttributeCollection< TetAttributes >
 
- Public Types inherited from wmtk::TetMesh
template<typename T >
using vector = tbb::concurrent_vector< T >
 

Public Member Functions

 TopoOffsetTetMesh (Parameters &_m_params, int _num_threads=0)
 
void init_from_image (const MatrixXd &V, const MatrixXi &T, const MatrixSi &T_tags, const MatrixXd &V_env, const MatrixXi F_env, const std::vector< std::string > &tag_names)
 initialize TetMesh from vertex, tet, and tag data
 
void label_input_complex ()
 label input simplicial complex simplices, as defined in m_params.offset_selection
 
bool empty_input_complex ()
 check if the input complex is empty. Only valid after calling init_from_image(...). Checks if any vertices (therefore any simplices) are labelled 1, if not returns true
 
void init_input_complex_bvh ()
 initialize BVH for input complex. Must be called after init_from_image(...)
 
void edge_split_binary_search (const size_t v1, const size_t v2, Vector3d &p_new) const
 split edge at point by minimizing m_params.target_distance - d() (where d() is distance to input complex via BVH) along the edge. Uses binary search, so implicitly assumes distance field is monotonic along edge. May give weird results if not monotonic
 
size_t flood_fill ()
 label connected simplicial complex components (simplices labelled 1 or 2)
 
bool split_edge_before (const Tuple &t) override
 User specified preparations and desideratas for an edge split before changing the connectivity.
 
bool split_edge_after (const Tuple &t) override
 This function computes the attributes for the added simplices. User specified modifications and desideratas for after an edge split.
 
bool split_face_before (const Tuple &t) override
 User specified preparations and desideratas for a face split before changing the connectivity.
 
bool split_face_after (const Tuple &t) override
 Compute the attributes for the added simplices.
 
bool split_tet_before (const Tuple &t) override
 User specified preparations and desideratas for a tet split before changing the connectivity.
 
bool split_tet_after (const Tuple &t) override
 Compute the attributes for the added simplices.
 
bool invariants (const std::vector< Tuple > &tets) override
 
void marching_tets ()
 execute simplistic marching tets. All edges with one vertex labelled 0 and the other 1/2 are split. If m_edge_split_mode=BinarySearch, edges are split according to BVH distance field and the offset target distance (m_params.target_distance). If m_edge_split_mode=Midpoint, edges are split at the midpoint
 
bool is_simplicially_embedded () const
 check if the input complex (simplices labelled 1) are simplicially embedded w.r.t. the entire mesh
 
bool tet_is_simp_emb (const Tuple &t) const
 check if a tet satisfies simpicial embedding criteria w.r.t. input complex (simplices labelled 1)
 
void simplicial_embedding ()
 make mesh a simplicial embedding of the input complex (simplices labelled 1)
 
bool tag_tet_consistent_topology (size_t t_id, int64_t tag) const
 check if removing the tet would change the topology of any label
 
bool offset_tet_consistent_topology (const size_t t_id) const
 check if adding a tet to the offset region does not change the topology of the offset. Returns true if topology would not be changed
 
bool tet_is_in_offset_conservative (const size_t t_id, const double threshold_r) const
 check if a tet is inside the offset (implicitly defined via BVH distance field to input complex) via conservative sphere subdivision estimation
 
void grow_offset_conservative ()
 grow offset region conservatively using conservative checks while ensuring consistent topology
 
void set_offset_tet_tags ()
 update 'tags' data for tets in the offset region (tets labelled 2) based on the given offset tag values in m_params.offset_tag_value
 
bool offset_is_manifold ()
 verify that the closed offset region (simplices labelled 1 or 2) form a manifold region. This should be true for any offset. This function is for verification.
 
void write_input_complex (const std::string &path)
 
void write_vtu (const std::string &path)
 
void write_msh_groups (const std::string &file)
 
std::vector< Tupleget_face_adjacent_tets (const Tuple &t) const
 get tets (as Tuples) that are face-adjacent to the given tet (as Tuple)
 
std::vector< size_t > connected_components_helper (const size_t &v_id)
 get all one-ring vertices through input simplices (labelled 1)
 
void reset_connected_components ()
 reset connected component assignments.
 
- Public Member Functions inherited from wmtk::TetMesh
size_t vert_capacity () const
 get the current largest global vid
 
size_t tet_capacity () const
 get the current largest global tid
 
size_t vertex_size () const
 get the number of unremoved verticies
 
size_t tet_size () const
 get the number of unremoved tets
 
void init (size_t n_vertices, const std::vector< std::array< size_t, 4 > > &tets)
 
void init_with_isolated_vertices (size_t n_vertices, const std::vector< std::array< size_t, 4 > > &tets)
 
void init (const MatrixXi &T)
 Generate the connectivity of the mesh from an IGL-style T matrix.
 
bool split_edge (const Tuple &t, std::vector< Tuple > &new_tets)
 
virtual bool collapse_edge (const Tuple &t, std::vector< Tuple > &new_tets)
 
bool link_condition (const Tuple &t)
 
bool collapse_edge_conn (const Tuple &loc0, std::vector< Tuple > &new_edges, size_t &v1_id, Tuple &new_loc, std::map< size_t, wmtk::TetMesh::VertexConnectivity > &rollback_vert_conn, std::vector< size_t > &n1_t_ids_copy, std::vector< size_t > &new_tet_id, std::vector< TetrahedronConnectivity > &old_tets)
 
bool collapse_edge_check_topology (const std::vector< size_t > &new_tet_id)
 Check topology after collapse connectivity change. This is a sanity check and should not be necessary.
 
void collapse_edge_rollback (size_t &v1_id, std::map< size_t, wmtk::TetMesh::VertexConnectivity > &rollback_vert_conn, std::vector< size_t > &n1_t_ids, std::vector< size_t > &new_tet_id, std::vector< TetrahedronConnectivity > &old_tets)
 
bool swap_edge_56 (const Tuple &t, std::vector< Tuple > &new_tets)
 
bool swap_edge_44 (const Tuple &t, std::vector< Tuple > &new_tets)
 
bool swap_edge (const Tuple &t, std::vector< Tuple > &new_tets)
 3-2 edge swap
 
bool swap_face (const Tuple &t, std::vector< Tuple > &new_tets)
 2-3 face swap
 
bool smooth_vertex (const Tuple &t)
 
bool split_tet (const Tuple &t, std::vector< Tuple > &new_tets)
 Split a tet in 4 tets.
 
bool split_face (const Tuple &t, std::vector< Tuple > &new_tets)
 Split a face in 3 faces.
 
void triangle_insertion (const std::vector< Tuple > &intersected_tets, const std::vector< Tuple > &intersected_edges, std::vector< size_t > &new_edge_vids, std::vector< size_t > &new_center_vids, std::vector< std::array< size_t, 4 > > &center_split_tets)
 Insert a triangle into a tetmesh, with known intersection information.
 
bool insert_point (const Tuple &t, std::vector< Tuple > &new_tets)
 Insert a point into a tetmesh inside a tet. In general position, this split a tet into 4. In face position, split two tets. In edge position, In point position, do nothing.
 
virtual bool insert_point_before (const Tuple &t)
 
virtual bool insert_point_after (std::vector< Tuple > &new_tets)
 
void consolidate_mesh ()
 cleans up the deleted vertices or tetrahedra, fixes the corresponding indices, and reset the version number. WARNING: it invalidates all tuples!
 
std::vector< Tupleget_edges () const
 
std::vector< Tupleget_faces () const
 
std::vector< Tupleget_vertices () const
 
std::vector< Tupleget_tets () const
 
virtual void for_each_face (const std::function< void(const TetMesh::Tuple &)> &)
 looping through all the unique edges and perform the given function
 
Tuple tuple_from_edge (size_t tid, int local_eid) const
 get a Tuple from global tetra index and local edge index (from 0-5).
 
Tuple tuple_from_edge (const std::array< size_t, 2 > &vids) const
 get a Tuple from global vids of the 2 end of an edge
 
Tuple tuple_from_face (size_t tid, int local_fid) const
 get a Tuple from global tetra index and local face index (from 0-3).
 
std::tuple< Tuple, size_t > tuple_from_face (const std::array< size_t, 3 > &vids) const
 get a Tuple and the global face index from global vertex index of the face.
 
std::tuple< Tuple, size_t > tuple_from_face (const simplex::Face &f) const
 
Tuple tuple_from_vertex (size_t vid) const
 get a Tuple from global vertex index
 
Tuple tuple_from_tet (size_t tid) const
 get a Tuple from global tetra index
 
Tuple tuple_from_vids (size_t vid0, size_t vid1, size_t vid2, size_t vid3) const
 Get a Tuple from global vertex IDs.
 
simplex::Tet simplex_from_tet (const Tuple &t) const
 
simplex::Tet simplex_from_tet (const size_t tid) const
 
simplex::Edge simplex_from_edge (const Tuple &t) const
 
Tuple switch_vertex (const Tuple &t) const
 wrapper function from Tuple::switch_vertex
 
Tuple switch_edge (const Tuple &t) const
 wrapper function from Tuple::switch_edge
 
Tuple switch_face (const Tuple &t) const
 wrapper function from Tuple::switch_face
 
std::optional< Tupleswitch_tetrahedron (const Tuple &t) const
 wrapper function from Tuple::switch_tetrahedron
 
std::vector< Tupleget_one_ring_tets_for_vertex (const Tuple &t) const
 Get the one ring tets for a vertex.
 
std::vector< size_t > get_one_ring_tids_for_vertex (const Tuple &t) const
 Get the one ring tids for vertex.
 
std::vector< size_t > get_one_ring_tids_for_vertex (const size_t vid) const
 
std::vector< Tupleget_one_ring_vertices_for_vertex (const Tuple &t) const
 Get the one ring vertices for a vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex (size_t vid, std::vector< size_t > &cache)
 Get the one ring vids for vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex (size_t vid) const
 Get the one ring vids for vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex_adj (size_t vid) const
 Duplicate of the function TetMesh::get_one_ring_vids_for_vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex_adj (size_t vid, std::vector< size_t > &cache)
 Duplicate of the function TetMesh::get_one_ring_vids_for_vertex.
 
std::vector< Tupleget_incident_tets_for_edge (const Tuple &t) const
 Get the incident tets for edge.
 
std::vector< Tupleget_incident_tets_for_edge (const size_t vid0, const size_t vid1) const
 
std::vector< size_t > get_incident_tids_for_edge (const Tuple &t) const
 
std::vector< size_t > get_incident_tids_for_edge (const size_t vid0, const size_t vid1) const
 
std::vector< Tupleget_one_ring_tets_for_edge (const Tuple &t) const
 Get the one ring tets for edge.
 
std::vector< std::array< size_t, 3 > > vertex_adjacent_boundary_faces (const Tuple &t) const
 
std::array< Tuple, 4 > oriented_tet_vertices (const Tuple &t) const
 
std::array< size_t, 4 > oriented_tet_vids (const Tuple &t) const
 
std::array< size_t, 4 > oriented_tet_vids (const size_t tid) const
 
std::array< Tuple, 3 > get_face_vertices (const Tuple &t) const
 Get the 3 vertices of a face represented by Tuple.
 
std::array< size_t, 3 > get_face_vids (const Tuple &t) const
 
std::array< Tuple, 6 > tet_edges (const Tuple &t) const
 get the 6 edges of a tet represented by Tuples
 
void check_tuple_validity (const Tuple &t) const
 
bool check_mesh_connectivity_validity () const
 checks the validity of the connectivity of the mesh. Including the validity of each Tuple
 
void remove_tets_by_ids (const std::vector< size_t > &tids)
 remove the tetrahedrons in the mesh that have given tet ids
 
void start_protect_attributes ()
 
void release_protect_attributes ()
 
void rollback_protected_attributes ()
 
int release_vertex_mutex_in_stack ()
 
bool try_set_vertex_mutex_two_ring (const Tuple &v, int threadid)
 try lock the two-ring neighboring traingles' incident vertices
 
bool try_set_vertex_mutex_two_ring_vid (const Tuple &v, int threadid)
 try lock the two-ring neighboring traingles' incident vertices using vids
 
bool try_set_vertex_mutex_two_ring_vid (size_t v, int threadid)
 a duplicate of ConcurrentTetMesh::try_set_vertex_mutex_two_ring_vid that gets vids using the vid of the input Tuple
 
bool try_set_edge_mutex_two_ring (const Tuple &e, int threadid=0)
 try lock the two-ring neighboring triangles' incident vertices for the two ends of an edge
 
bool try_set_face_mutex_two_ring (const Tuple &f, int threadid=0)
 try lock the two-ring neighboring triangles' incident vertices for the 3 vertices of a face
 
bool try_set_face_mutex_two_ring (const Tuple &v1, const Tuple &v2, const Tuple &v3, int threadid=0)
 locking the two-ring neighboring triangles' incident vertices given the 3 vertex Tuples of the face
 
bool try_set_face_mutex_two_ring (size_t v1, size_t v2, size_t v3, int threadid=0)
 a duplicate of ConcurrentTetMesh::try_set_face_mutex_two_ring usign the vids of the 3 vertices of a face
 
bool try_set_vertex_mutex_one_ring (const Tuple &v, int threadid=0)
 try lock the one-ring neighboring traingles' incident vertices
 
void for_each_edge (const std::function< void(const TetMesh::Tuple &)> &)
 perform the given function for each edge
 
void for_each_vertex (const std::function< void(const TetMesh::Tuple &)> &)
 perform the given function for each vertex
 
void for_each_tetra (const std::function< void(const TetMesh::Tuple &)> &)
 perform the given function for each tet
 
virtual bool vertex_is_on_surface (const size_t vid) const
 Is a vertex part of the substructure.
 
virtual bool face_is_on_surface (const size_t fid) const
 Is a face part of the substructure.
 
simplex::SimplexCollection get_surface_faces_for_vertex (const size_t vid) const
 Get all faces on the surface that are incident to vid.
 
simplex::SimplexCollection get_surface_faces_for_edge (const std::array< size_t, 2 > &vids) const
 Get all faces on the surface that are incident to the edge.
 
size_t get_num_surface_faces_for_edge (const std::array< size_t, 2 > &vids) const
 Get the number of surface faces incident to the edge.
 
size_t compute_vertex_order (const size_t vid) const
 Compute the vertex order for a single vertex.
 
virtual size_t get_order_of_vertex (const size_t vid) const
 Get the order of a vertex.
 
size_t get_order_of_edge (const std::array< size_t, 2 > &vids) const
 Compute the order of an edge.
 
bool substructure_link_condition (const Tuple &e_tuple) const
 Link condition that also considers substructures.
 

Public Attributes

int m_vtu_counter = 0
 
std::array< size_t, 4 > m_init_counts = {{0, 0, 0, 0}}
 
size_t m_tags_count
 
SimplicialComplexBVH m_input_complex_bvh
 
EdgeSplitMode m_edge_split_mode = EdgeSplitMode::Midpoint
 
std::map< std::string, int64_t > m_tag_name_to_id
 
std::map< int64_t, std::string > m_tag_id_to_name
 
CellTag m_offset_output_tag_ids
 
bool m_singlebody = false
 
int64_t m_single_tag
 
bool m_has_envelope
 
MatrixXd m_V_envelope
 
MatrixXi m_F_envelope
 
Parametersm_params
 
VertAttCol m_vertex_attribute
 
EdgeAttCol m_edge_attribute
 
FaceAttCol m_face_attribute
 
TetAttCol m_tet_attribute
 
- Public Attributes inherited from wmtk::TetMesh
AbstractAttributeContainerp_vertex_attrs = nullptr
 
AbstractAttributeContainerp_edge_attrs = nullptr
 
AbstractAttributeContainerp_face_attrs = nullptr
 
AbstractAttributeContainerp_tet_attrs = nullptr
 
bool m_collapse_check_link_condition = true
 
bool m_collapse_check_topology = false
 
bool m_collapse_check_manifold = true
 
tbb::enumerable_thread_specific< std::vector< size_t > > mutex_release_stack
 
tbb::enumerable_thread_specific< std::vector< size_t > > get_one_ring_cache
 
int NUM_THREADS = 0
 

Private Member Functions

bool any_tag_present (const CellTag &tag1, const CellTag &tag2)
 determine if any tag from tag1 is also present in tag2.
 
void sort_edges_by_length (std::vector< simplex::Edge > &edges)
 sort edge simplices in place by decreasing edge length
 

Private Attributes

tbb::enumerable_thread_specific< EdgeSplitCacheedge_split_cache
 
tbb::enumerable_thread_specific< FaceSplitCacheface_split_cache
 
tbb::enumerable_thread_specific< TetSplitCachetet_split_cache
 

Additional Inherited Members

- Protected Member Functions inherited from wmtk::TetMesh
virtual bool triangle_insertion_before (const std::vector< Tuple > &faces)
 
virtual bool triangle_insertion_after (const std::vector< std::vector< Tuple > > &)
 
virtual bool collapse_edge_before (const Tuple &t)
 User specified preparations and desideratas for an edge collapse before changing the connectivity.
 
virtual bool collapse_edge_after (const Tuple &t)
 User specified modifications and desideratas for after an edge collapse.
 
virtual bool swap_edge_44_before (const Tuple &t)
 User specified preparations and desideratas for an 4-4 edge swap before changing the connectivity.
 
virtual double swap_edge_44_energy (const std::vector< std::array< size_t, 4 > > &tets, const int op_case)
 User specified energy to decide which of the 4 possible orientations should be chosen.
 
virtual bool swap_edge_44_after (const Tuple &t)
 User specified modifications and desideratas for after a 4-4 edge swap.
 
virtual bool swap_edge_56_before (const Tuple &t)
 User specified preparations and desideratas for a 5-6 edge swap before changing the connectivity.
 
virtual double swap_edge_56_energy (const std::vector< std::array< size_t, 4 > > &tets, const int op_case)
 User specified energy to decide which of the 5 possible orientations should be chosen.
 
virtual bool swap_edge_56_after (const Tuple &t)
 User specified modifications and desideratas for after a 5-6 edge swap.
 
virtual bool swap_edge_before (const Tuple &t)
 User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.
 
virtual bool swap_edge_after (const Tuple &t)
 User specified modifications and desideratas for after a 3-2 edge swap.
 
virtual bool swap_face_before (const Tuple &t)
 User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.
 
virtual bool swap_face_after (const Tuple &t)
 User specified modifications and desideratas for after a 2-3 face swap.
 
virtual bool smooth_before (const Tuple &t)
 User specified preparations and desideratas for smoothing a vertex.
 
virtual bool smooth_after (const Tuple &t)
 User specified modifications and desideratas for after smoothing a vertex.
 
void resize_vertex_mutex (size_t v)
 

Member Function Documentation

◆ any_tag_present()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::any_tag_present ( const CellTag &  tag1,
const CellTag &  tag2 
)
inlineprivate

determine if any tag from tag1 is also present in tag2.

Note
if tag2 is empty (ambient), return true if tag1 is empty, otherwise false (tag2 is ambient, so only 'element' is ambient)

◆ init_from_image()

void wmtk::components::topological_offset::TopoOffsetTetMesh::init_from_image ( const MatrixXd &  V,
const MatrixXi &  T,
const MatrixSi &  T_tags,
const MatrixXd &  V_env,
const MatrixXi  F_env,
const std::vector< std::string > &  tag_names 
)

initialize TetMesh from vertex, tet, and tag data

Parameters
V#V by 3 vertex matrix
T#T by 4 tet matrix
T_tags#T by #tags tag matrix
V_envV_env by 3 EnvelopeSurface vertices
F_envF_env by 3 EnvelopeSurface faces

◆ invariants()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::invariants ( const std::vector< Tuple > &  tets)
overridevirtual

Reimplemented from wmtk::TetMesh.

◆ offset_is_manifold()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::offset_is_manifold ( )

verify that the closed offset region (simplices labelled 1 or 2) form a manifold region. This should be true for any offset. This function is for verification.

Note
We first collect the tets labelled 1 or 2, then extract the boundary of this region and check if it is manifold.

◆ split_edge_after()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::split_edge_after ( const Tuple t)
overridevirtual

This function computes the attributes for the added simplices. User specified modifications and desideratas for after an edge split.

Parameters
theedge Tuple to be split
Returns
true if the modification succeed

Reimplemented from wmtk::TetMesh.

◆ split_edge_before()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::split_edge_before ( const Tuple t)
overridevirtual

User specified preparations and desideratas for an edge split before changing the connectivity.

Parameters
theedge Tuple to be split
Returns
true if the preparation succeed

Reimplemented from wmtk::TetMesh.

◆ split_face_after()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::split_face_after ( const Tuple t)
overridevirtual

Compute the attributes for the added simplices.

User specified modifications and desideratas for after a face split

Parameters
tThe face tuple to be split.
Returns
true if the modification succeed

Reimplemented from wmtk::TetMesh.

◆ split_face_before()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::split_face_before ( const Tuple t)
overridevirtual

User specified preparations and desideratas for a face split before changing the connectivity.

Parameters
tThe face tuple to be split.
Returns
true if the preparation succeed.

Reimplemented from wmtk::TetMesh.

◆ split_tet_after()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::split_tet_after ( const Tuple t)
overridevirtual

Compute the attributes for the added simplices.

User specified modifications and desideratas for after a tet split

Parameters
tThe tet tuple to be split.
Returns
true if the modification succeed

Reimplemented from wmtk::TetMesh.

◆ split_tet_before()

bool wmtk::components::topological_offset::TopoOffsetTetMesh::split_tet_before ( const Tuple t)
overridevirtual

User specified preparations and desideratas for a tet split before changing the connectivity.

Parameters
tThe tet tuple to be split.
Returns
true if the preparation succeed.

Reimplemented from wmtk::TetMesh.


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