Wildmeshing Toolkit
Loading...
Searching...
No Matches
ShortestEdgeCollapse.h
1#pragma once
2#include <wmtk/utils/PartitionMesh.h>
3#include <wmtk/utils/VectorUtils.h>
4#include <wmtk/AttributeCollection.hpp>
5
6// clang-format off
7#include <wmtk/utils/DisableWarnings.hpp>
8#include <igl/write_triangle_mesh.h>
9#include <wmtk/threading/enumerable_thread_specific.hpp>
10#include <fastenvelope/FastEnvelope.h>
11#include <wmtk/utils/EnableWarnings.hpp>
12// clang-format on
13
14#include <Eigen/Core>
15#include <Eigen/Geometry>
16
17#include <atomic>
18#include <memory>
19#include <queue>
20
21#include <wmtk/envelope/Envelope.hpp>
22
23namespace wmtk::components::shortest_edge_collapse {
24
26{
27 Eigen::Vector3d pos;
28 size_t partition_id = 0;
29 bool freeze = false;
30};
31
33{
34public:
35 wmtk::SampleEnvelope m_envelope;
36 bool m_has_envelope = false;
38
39 int retry_limit = 10;
41 std::vector<Eigen::Vector3d> _m_vertex_positions,
42 int num_threads = 1,
43 bool use_exact_envelope = true);
44
45 void freeze_boundary();
46
47 void create_mesh(
48 size_t n_vertices,
49 const std::vector<std::array<size_t, 3>>& tris,
50 const std::vector<size_t>& frozen_verts = {},
51 double eps = 0);
52
54
55 void partition_mesh();
56
57 size_t get_partition_id(const Tuple& loc) const
58 {
59 return vertex_attrs[loc.vid(*this)].partition_id;
60 }
61
62 void write_vtu(const std::string& path);
63
64public:
65 bool collapse_edge_before(const Tuple& t) override;
66 bool collapse_edge_after(const Tuple& t) override;
67 bool collapse_shortest(int target_vertex_count);
68 bool write_triangle_mesh(std::string path);
69 bool invariants(const std::vector<Tuple>& new_tris) override;
70
71private:
73 {
74 Eigen::Vector3d v1p;
75 Eigen::Vector3d v2p;
76 // v1 is the endpoint the collapse removes, v2 the one it keeps.
77 bool v1_frozen = false;
78 bool v2_frozen = false;
79 };
81
82 std::vector<TriMesh::Tuple> new_edges_after(const std::vector<TriMesh::Tuple>& t) const;
83};
84
85} // namespace wmtk::components::shortest_edge_collapse
Definition Envelope.hpp:52
Definition TriMesh.h:32
Definition TriMesh.h:28
bool invariants(const std::vector< Tuple > &new_tris) override
User specified invariants that can't be violated.
Definition ShortestEdgeCollapse.cpp:75
bool collapse_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge collapse including the link check as collapse...
Definition ShortestEdgeCollapse.cpp:140
bool collapse_edge_after(const Tuple &t) override
User specified modifications and desideratas after an edge collapse.
Definition ShortestEdgeCollapse.cpp:177
Definition enumerable_thread_specific.hpp:26
Definition AttributeCollection.hpp:36