2#include <wmtk/TriMesh.h>
6#include "SimplicialComplexBVH.hpp"
8using CellTag = std::set<int64_t>;
11namespace wmtk::components::topological_offset {
14const int64_t TEMP_OFFSET_TRI_TAG = -1;
15const CellTag TEMP_OFFSET_TRI_TAG_SET{TEMP_OFFSET_TRI_TAG};
47 enum class EdgeSplitMode {
58 int m_vtu_counter = 0;
59 std::array<size_t, 3> m_init_counts = {{0, 0, 0}};
62 EdgeSplitMode m_edge_split_mode = EdgeSplitMode::Midpoint;
65 std::map<std::string, int64_t> m_tag_name_to_id;
66 std::map<int64_t, std::string> m_tag_id_to_name;
68 CellTag m_offset_output_tag_ids;
71 bool m_singlebody =
false;
75 bool m_has_envelope =
false;
76 MatrixXd m_V_envelope;
77 MatrixXi m_F_envelope;
91 NUM_THREADS = _num_threads;
92 p_vertex_attrs = &m_vertex_attribute;
93 p_edge_attrs = &m_edge_attribute;
94 p_face_attrs = &m_face_attribute;
110 const MatrixSi& F_tags,
111 const MatrixXd& V_env,
112 const MatrixXi& F_env,
113 const std::vector<std::string>& tag_names);
143 bool invariants(
const std::vector<Tuple>& tris)
override;
214 void write_input_complex(
const std::string& path);
215 void write_vtu(
const std::string& path);
217 void write_msh_groups(
const std::string& file);
234 std::map<simplex::Edge, EdgeAttributes2d> existing_eattr;
237 std::map<size_t, FaceAttributes2d> opp_v_fattr;
239 tbb::enumerable_thread_specific<EdgeSplitCache> edge_split_cache;
248 std::map<simplex::Edge, EdgeAttributes2d> existing_eattr;
251 tbb::enumerable_thread_specific<FaceSplitCache> face_split_cache;
259 for (
const int64_t& i : tag1) {
260 if (tag2.find(i) != tag2.end()) {
290 double len1 = (m_vertex_attribute[e1.vertices()[0]].m_posf -
291 m_vertex_attribute[e1.vertices()[1]].m_posf)
293 double len2 = (m_vertex_attribute[e2.vertices()[0]].m_posf -
294 m_vertex_attribute[e2.vertices()[1]].m_posf)
306 const auto& verts = e.vertices();
307 const auto incident = simplex_incident_triangles(e);
308 const auto& faces = incident.faces();
310 assert(!faces.empty());
312 const size_t f_id = tuple_from_simplex(faces.front()).
fid(*
this);
314 return t_edge.eid(*
this);
322 const auto& v = e.vertices();
323 const auto faces = simplex_incident_triangles(e).faces();
324 assert(!faces.empty());
325 const size_t fid = tuple_from_simplex(faces.front()).
fid(*
this);
334 std::vector<Tuple> adj_tris;
335 auto tri_1 = f.switch_face(*
this);
337 adj_tris.push_back(tri_1.value());
339 auto tri_2 = f.switch_edge(*this).switch_face(*
this);
341 adj_tris.push_back(tri_2.value());
343 auto tri_3 = f.switch_vertex(*this).switch_edge(*this).switch_face(*
this);
345 adj_tris.push_back(tri_3.value());
size_t fid(const TriMesh &) const
Definition TriMesh.h:80
Tuple tuple_from_edge(size_t vid1, size_t vid2, size_t fid) const
Definition TriMesh.cpp:1479
Definition TopoOffsetTriMesh.h:30
Definition TopoOffsetTriMesh.h:37
Definition SimplicialComplexBVH.hpp:12
Definition TopoOffsetTriMesh.h:45
void label_input_complex()
label input complex simplices as per boolean expression (or single body mode)
Definition TopoOffsetTriMesh.cpp:103
void init_from_image(const MatrixXd &V, const MatrixXi &F, const MatrixSi &F_tags, const MatrixXd &V_env, const MatrixXi &F_env, const std::vector< std::string > &tag_names)
initialize TriMesh from vertex, face, tag data
Definition TopoOffsetTriMesh.cpp:19
bool split_face_before(const Tuple &t) override
User specified preparations and desideratas for a face split.
Definition ComponentSplitting.cpp:637
void set_offset_tri_tags()
update 'tags' data for triangles in the offset region (tris labelled 2) based on the given offset tag...
Definition TopoOffsetTriMesh.cpp:713
bool offset_is_manifold()
verify that the closed offset region (simplices labelled 1 or 2) form a manifold region....
Definition TopoOffsetTriMesh.cpp:748
bool tag_tri_consistent_topology(size_t f_id, int64_t tag) const
check if removing the given face from the given tag set would retain its topology
Definition Spatial.cpp:327
void grow_offset_conservative()
grow offset region conservatively using conservative checks while ensuring consistent topology
Definition TopoOffsetTriMesh.cpp:654
bool empty_input_complex()
check if the input complex is empty. Only valid after calling init_from_image(...)....
Definition TopoOffsetTriMesh.cpp:359
void init_input_complex_bvh()
initialize BVH for input complex. Must be called after init_from_image(...)
Definition TopoOffsetTriMesh.cpp:372
size_t edge_id_from_simplex(const simplex::Edge &e) const
get global id of edge from simplex::Edge object
Definition TopoOffsetTriMesh.h:304
Tuple get_tuple_from_edge(const simplex::Edge &e) const
get Tuple simplex::Edge object
Definition TopoOffsetTriMesh.h:320
void marching_tris()
execute simplistic marching tets. All edges with one vertex labelled 0 and the other 1/2 are split....
Definition TopoOffsetTriMesh.cpp:588
void sort_edges_by_length(std::vector< simplex::Edge > &edges)
sort vector of edge simplices in place by decreasing length
Definition TopoOffsetTriMesh.h:284
bool split_edge_after(const Tuple &t) override
User specified modifications and desideratas after an edge split.
Definition ComponentSplitting.cpp:584
bool invariants(const std::vector< Tuple > &tris) override
User specified invariants that can't be violated.
Definition TopoOffsetTriMesh.cpp:796
bool split_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge split.
Definition ComponentSplitting.cpp:497
bool split_face_after(const Tuple &t) override
User specified modifications and desideratas after a face split.
Definition ComponentSplitting.cpp:668
bool any_tag_present(const CellTag &tag1, const CellTag &tag2) const
determine if any tag from tag1 is also present in tag2.
Definition TopoOffsetTriMesh.h:257
bool offset_tri_consistent_topology(const size_t f_id) const
check if adding a triangle to the offset region does not change the topology of the offset....
Definition Spatial.cpp:274
bool tri_is_in_offset_conservative(const size_t f_id, const double threshold_r) const
check if a triangle is inside the offset (implicitly defined via BVH distance field to input complex)...
Definition Spatial.cpp:233
void edge_split_binary_search(const size_t v1, const size_t v2, Vector2d &p_new) const
split edge at point by minimizing m_params.target_distance - d() (where d() is distance to input comp...
Definition ComponentSplitting.cpp:475
void simplicial_embedding()
make mesh a simplicial embedding of the input complex (simplices labelled 1)
Definition TopoOffsetTriMesh.cpp:525
std::vector< Tuple > get_edge_adjacent_faces(const Tuple &f) const
get faces (as Tuples) that are edge-adjacent to the given face (as Tuple)
Definition TopoOffsetTriMesh.h:332
bool is_simplicially_embedded() const
check if the input complex (simplices labelled 1) are simplicially embedded w.r.t....
Definition TopoOffsetTriMesh.cpp:480
bool tri_is_simp_emb(const Tuple &t) const
check if a triangle satisfies simpicial embedding criteria w.r.t. input complex (simplices labelled 1...
Definition TopoOffsetTriMesh.cpp:499
Definition TopoOffsetTriMesh.h:19
Definition Simplex.hpp:46
Definition Parameters.h:9
Definition TopoOffsetTriMesh.h:227
Definition TopoOffsetTriMesh.h:242