Wildmeshing Toolkit
Loading...
Searching...
No Matches
IsotropicRemeshing.h
1#pragma once
2
3#include <wmtk/utils/PartitionMesh.h>
4#include <wmtk/utils/VectorUtils.h>
5#include <wmtk/envelope/Envelope.hpp>
6#include "wmtk/AttributeCollection.hpp"
7
8// clang-format off
9#include <wmtk/utils/DisableWarnings.hpp>
10#include <igl/write_triangle_mesh.h>
11#include <wmtk/threading/enumerable_thread_specific.hpp>
12#include <fastenvelope/FastEnvelope.h>
13#include <wmtk/utils/EnableWarnings.hpp>
14// clang-format on
15
16#include <Eigen/Core>
17#include <Eigen/Geometry>
18#include <atomic>
19#include <memory>
20#include <queue>
21
22namespace wmtk::components::isotropic_remeshing {
23
25{
26 Eigen::Vector3d pos;
27 // TODO: in fact, partition id should not be vertex attribute, it is a fixed marker to distinguish tuple/operations.
28 size_t partition_id;
29 bool freeze = false;
30};
31
33{
34public:
35 wmtk::SampleEnvelope m_envelope;
36 bool m_has_envelope = false;
37
39 VertAttCol vertex_attrs;
40
41 int retry_limit = 10;
43 std::vector<Eigen::Vector3d> _m_vertex_positions,
44 int num_threads = 1,
45 bool use_exact = true);
46
48
49 void create_mesh(
50 size_t n_vertices,
51 const std::vector<std::array<size_t, 3>>& tris,
52 const std::vector<size_t>& frozen_verts = std::vector<size_t>(),
53 bool m_freeze = true,
54 double eps = 0);
55
57 {
58 Eigen::Vector3d v1p;
59 Eigen::Vector3d v2p;
60 size_t partition_id;
61 };
63
64 void cache_edge_positions(const Tuple& t);
65
66 bool invariants(const std::vector<Tuple>& new_tris) override;
67
68 // TODO: this should not be here
69 void partition_mesh();
70
71 // TODO: morton should not be here, but inside wmtk
72 void partition_mesh_morton();
73
74 size_t get_partition_id(const Tuple& loc) const
75 {
76 return vertex_attrs[loc.vid(*this)].partition_id;
77 }
78
79 bool smooth_all_vertices();
80
81 Eigen::Vector3d smooth(const Tuple& t);
82
83
84 Eigen::Vector3d tangential_smooth(const Tuple& t);
85
86 bool collapse_edge_before(const Tuple& t) override;
87 bool collapse_edge_after(const Tuple& t) override;
88
89 bool swap_edge_before(const Tuple& t) override;
90 bool swap_edge_after(const Tuple& t) override;
91
92 std::vector<TriMesh::Tuple> new_edges_after(const std::vector<TriMesh::Tuple>& tris) const;
93 std::vector<TriMesh::Tuple> new_edges_after_swap(const TriMesh::Tuple& t) const;
94 std::vector<TriMesh::Tuple> replace_edges_after_split(
95 const std::vector<TriMesh::Tuple>& tris,
96 const size_t vid_threshold) const;
97 std::vector<TriMesh::Tuple> new_sub_edges_after_split(
98 const std::vector<TriMesh::Tuple>& tris) const;
99
100
101 bool split_edge_before(const Tuple& t) override;
102 bool split_edge_after(const Tuple& t) override;
103
104 bool smooth_before(const Tuple& t) override;
105 bool smooth_after(const Tuple& t) override;
106
107 double compute_edge_cost_collapse(const TriMesh::Tuple& t, double L) const;
108 double compute_edge_cost_split(const TriMesh::Tuple& t, double L) const;
109 double compute_vertex_valence(const TriMesh::Tuple& t) const;
121 std::vector<double> average_len_valen();
122 bool split_remeshing(double L);
123 bool collapse_remeshing(double L);
124 bool swap_remeshing();
125 bool uniform_remeshing(double L, int interations);
126 bool write_triangle_mesh(std::string path);
127};
128
129} // namespace wmtk::components::isotropic_remeshing
Definition Envelope.hpp:52
Definition TriMesh.h:31
Definition TriMesh.h:27
bool collapse_edge_after(const Tuple &t) override
User specified modifications and desideratas after an edge collapse.
Definition IsotropicRemeshing.cpp:210
bool invariants(const std::vector< Tuple > &new_tris) override
User specified invariants that can't be violated.
Definition IsotropicRemeshing.cpp:92
bool split_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge split.
Definition IsotropicRemeshing.cpp:220
bool collapse_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge collapse including the link check as collapse...
Definition IsotropicRemeshing.cpp:200
bool swap_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge swap including 1.can't swap on boundary edge....
Definition IsotropicRemeshing.cpp:149
std::vector< double > average_len_valen()
Report statistics.
Definition IsotropicRemeshing.cpp:313
bool smooth_after(const Tuple &t) override
User specified modifications and desideras after an edge smooth.
Definition IsotropicRemeshing.cpp:243
bool smooth_before(const Tuple &t) override
User specified preparations and desideratas for an edge smooth.
Definition IsotropicRemeshing.cpp:237
bool swap_edge_after(const Tuple &t) override
User specified modifications and desideras after an edge swap.
Definition IsotropicRemeshing.cpp:158
bool split_edge_after(const Tuple &t) override
User specified modifications and desideratas after an edge split.
Definition IsotropicRemeshing.cpp:228
Definition enumerable_thread_specific.hpp:26