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 <tbb/concurrent_priority_queue.h>
10#include <tbb/concurrent_vector.h>
11#include <tbb/enumerable_thread_specific.h>
12#include <tbb/parallel_for.h>
13#include <fastenvelope/FastEnvelope.h>
14#include <wmtk/utils/EnableWarnings.hpp>
15// clang-format on
16
17#include <Eigen/Core>
18#include <Eigen/Geometry>
19
20#include <atomic>
21#include <memory>
22#include <queue>
23
24#include <wmtk/envelope/Envelope.hpp>
25
26namespace wmtk::components::shortest_edge_collapse {
27
29{
30 Eigen::Vector3d pos;
31 size_t partition_id = 0;
32 bool freeze = false;
33};
34
36{
37public:
38 wmtk::SampleEnvelope m_envelope;
39 bool m_has_envelope = false;
41
42 int retry_limit = 10;
44 std::vector<Eigen::Vector3d> _m_vertex_positions,
45 int num_threads = 1,
46 bool use_exact_envelope = true);
47
48 void freeze_boundary();
49
50 void create_mesh(
51 size_t n_vertices,
52 const std::vector<std::array<size_t, 3>>& tris,
53 const std::vector<size_t>& frozen_verts = {},
54 double eps = 0);
55
57
58 void partition_mesh();
59
60 size_t get_partition_id(const Tuple& loc) const
61 {
62 return vertex_attrs[loc.vid(*this)].partition_id;
63 }
64
65 void write_vtu(const std::string& path);
66
67public:
68 bool collapse_edge_before(const Tuple& t) override;
69 bool collapse_edge_after(const Tuple& t) override;
70 bool collapse_shortest(int target_vertex_count);
71 bool write_triangle_mesh(std::string path);
72 bool invariants(const std::vector<Tuple>& new_tris) override;
73
74private:
76 {
77 Eigen::Vector3d v1p;
78 Eigen::Vector3d v2p;
79 };
80 tbb::enumerable_thread_specific<PositionInfoCache> position_cache;
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:51
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:73
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:138
bool collapse_edge_after(const Tuple &t) override
User specified modifications and desideratas after an edge collapse.
Definition ShortestEdgeCollapse.cpp:149
Definition AttributeCollection.hpp:37