3#include <wmtk/OptimizerParameters.h>
4#include <wmtk/RationalPositions.h>
5#include <wmtk/SurfaceTagAttributes.h>
6#include <wmtk/TetMesh.h>
7#include <wmtk/ExactPosition.hpp>
8#include <wmtk/Types.hpp>
9#include <wmtk/envelope/Envelope.hpp>
10#include <wmtk/history/History.hpp>
11#include <wmtk/history/VolumeHistory.hpp>
12#include <wmtk/optimization/SmoothVertex.hpp>
13#include <wmtk/optimization/solver.hpp>
14#include <wmtk/simplex/Simplex.hpp>
15#include <wmtk/threading/enumerable_thread_specific.hpp>
16#include <wmtk/utils/SurfaceTopology.hpp>
63 bool m_is_on_surface =
false;
72 std::vector<int> on_bbox_faces;
74 double m_sizing_scalar = 1;
88 Vector3r pos()
const {
return m_exact.
value(m_posf); }
89 bool pos_coord_equals(
int k,
const Rational& r)
const
93 void set_pos(
const Vector3r& p) { m_exact.
store(p); }
94 void set_pos_to_posf() { m_exact.
clear(); }
95 ExactPosition<Vector3r, Vector3d> m_exact;
99 VertexAttributes(
const Vector3r& p);
104 using VertAttCol = AttributeCollection<VertexAttributes>;
105 using FaceAttCol = AttributeCollection<FaceAttributes>;
107 VertAttCol m_vertex_attribute;
108 FaceAttCol m_face_attribute;
218 "{}() called while an operation pass runs; call it before or after the pass.",
240 c->resize(6 * tet_storage_capacity());
257 bool m_is_feature_edge =
false;
259 using EdgeAttCol = AttributeCollection<FeatureEdgeAttributes>;
311 size_t substructure_order_of_vertex(
size_t vid)
const override;
401 std::pair<size_t, size_t>
feature_retention(
double* worst_ratio =
nullptr)
const;
433 double m_s_envelope = -1.;
435 double time_env = 0.0;
436 igl::Timer isout_timer;
460 bool is_force_split_edge(
const size_t v1,
const size_t v2)
const
467 size_t m_high_valence_claim_size = 0;
468 std::atomic<size_t> m_high_valence_rejects = 0;
482 const size_t n = std::max(
vert_capacity(), m_vertex_attribute.size());
483 if (n <= m_high_valence_claim_size)
return;
484 auto grown = std::make_unique<std::atomic<int>[]>(n);
485 for (
size_t i = 0; i < m_high_valence_claim_size; ++i) {
489 m_high_valence_claim_size = n;
498 size_t m_split_order_wait_defects = 0;
520 virtual void set_cell_quality(
const size_t tid,
const double q) = 0;
544 void compute_vertex_partition();
545 void compute_vertex_partition_morton();
547 size_t get_partition_id(
const Tuple& loc)
const
549 return m_vertex_attribute[loc.vid(*
this)].partition_id;
552 double get_length2(
const Tuple& l)
const;
554 bool is_inverted(
const std::array<size_t, 4>& vs)
const;
555 bool is_inverted(
const Tuple& loc)
const;
559 double get_quality(
const std::array<size_t, 4>& vs)
const;
560 double get_quality(
const Tuple& loc)
const;
561 std::tuple<double, double> get_max_avg_energy();
598 const std::map<int64_t, std::string>& tag_names = {});
602 static PositionKey position_key(
const Vector3d& a,
const Vector3d& b,
const Vector3d& c);
611 uint64_t m_surface_edit_offset = 0;
612 std::optional<history::SurfaceKey> m_finished_surface;
620 const std::array<size_t, 3>& f,
621 const std::vector<size_t>& tets)
const override;
627 void tracked_surface_before(
const std::vector<size_t>& vs,
bool all)
override;
628 bool tracked_surface_after(
const std::vector<size_t>& vs,
bool all)
override;
634 std::shared_ptr<history::TrackedSurfaceRecorder> m_recorded_surface;
641 Eigen::Vector3d normal = Eigen::Vector3d::Zero();
643 size_t star_folds = 0;
648 Eigen::Vector3d
tracked_area_normal(
const std::vector<std::array<size_t, 3>>& faces)
const;
649 size_t tracked_not_facing(
650 const std::vector<std::array<size_t, 3>>& faces,
651 const Eigen::Vector3d& n)
const;
652 size_t tracked_star_folds(
const std::vector<std::array<size_t, 3>>& faces)
const;
655 int m_debug_print_counter = 0;
662 void mesh_improvement(
int max_its = 80);
663 std::tuple<double, double> local_operations(
664 const std::array<int, 4>& ops,
665 bool collapse_limit_length =
true);
679 return m_vertex_attribute.at(vid).m_is_rounded;
687 bool is_edge_on_surface(
const Tuple& loc);
688 bool is_edge_on_bbox(
const Tuple& loc);
730 const std::array<size_t, 3>& vids,
746 if (!env)
return false;
747 const auto& VA = m_vertex_attribute;
748 return env->is_outside({{VA[a].m_posf, VA[b].m_posf, VA[c].m_posf}});
755 std::vector<std::array<size_t, 3>> get_faces_by_condition(
758 void output_faces(std::string file, std::function<
bool(
const FaceAttributes&)> cond);
783 void split_all_edges();
788 void collapse_all_edges(
bool is_limit_length =
true);
816 size_t cells_before = 0;
817 size_t cells_after = 0;
818 double max_energy_before = 0.;
819 double max_energy_after = 0.;
825 size_t swap_all_edges_32();
829 size_t swap_all_edges_44();
834 size_t swap_all_edges_56();
839 size_t swap_all_faces();
842 size_t swap_all_edges_all();
844 bool prepare_surface_flip(
const Tuple& t,
const std::vector<size_t>& incident_tets);
849 return wmtk::utils::surface_topology_signature(*
this, [
this](
size_t fid) {
850 return m_face_attribute[fid].m_is_surface_fs;
853 void warn_if_surface_topology_changed(
const SurfaceTopoSignature& before,
const char* where)
856 wmtk::utils::warn_if_surface_topology_changed(before, surface_topology_signature(), where);
860 std::atomic<int> cnt_swap = 0;
861 std::atomic<int> cnt_surface_swap = 0;
862 std::atomic<int> cnt_surface_swap_32 = 0, cnt_surface_swap_44 = 0, cnt_surface_swap_56 = 0;
864 double swap_edge_44_energy(
const std::vector<std::array<size_t, 4>>& tets,
const int op_case)
866 double swap_edge_56_energy(
const std::vector<std::array<size_t, 4>>& tets,
const int op_case)
885 const std::array<size_t, 3>& face,
954 for (
const Tuple& loc : ring) {
955 const size_t tid = loc.tid(*
this);
977 void smooth_all_vertices(
const size_t n_iters = 1);
991 bool invariants(
const std::vector<Tuple>& t)
override;
997 virtual double optimization_stop_metric()
const {
return m_params.stop_energy; }
998 virtual size_t refine_sizing_around_worst(
double max_metric) = 0;
1026 virtual void write_optimization_debug_output(
const std::string& path) = 0;
1027 virtual void optimization_sanity_checks_extra() {}
1034 virtual bool optimization_stop_at_float()
const {
return false; }
1052 return (prev - cur) <=
m_params.stuck_refine_stall_eps * (cur - optimization_stop_metric());
1058 virtual bool collapse_quality_allowed(
size_t v1,
double quality,
double ring_max)
const
1060 return !m_vertex_attribute.at(v1).m_is_rounded || quality <= ring_max;
1062 virtual bool collapse_is_order_2_edge(
const std::array<size_t, 2>&) {
return false; }
1064 collapse_after_connectivity(
size_t,
size_t,
const std::vector<std::array<size_t, 2>>&)
1068 virtual void collapse_after_vertex(
size_t,
size_t) {}
1086 virtual bool allow_surface_swap()
const = 0;
1087 virtual bool check_surface_topology()
const = 0;
1091 virtual bool swap_before_surface(
const std::vector<size_t>&,
size_t,
size_t,
size_t,
size_t)
1112 enum class SwapReject :
int {
1117 surface_not_allowed,
1123 flip_nonmanifold_edge,
1124 flip_cd_nonmanifold,
1125 flip_new_face_surface,
1138 app_after_side_conflict,
1141 face_tracked_surface,
1164 static const char* swap_reject_name(SwapReject r);
1165 static const char* swap_stage_name(
SwapStage s);
1166 bool swap_reject(SwapReject r)
const
1168 m_swap_reject[size_t(r)].fetch_add(1, std::memory_order_relaxed);
1175 m_swap_reject_by_kind[size_t(
current_op_kind())][size_t(r)].fetch_add(
1177 std::memory_order_relaxed);
1182 m_swap_stage[size_t(s)].fetch_add(1, std::memory_order_relaxed);
1184 void swap_counters_reset();
1188 mutable std::array<std::atomic<long>, size_t(SwapReject::COUNT)> m_swap_reject{};
1189 mutable std::array<std::atomic<long>, size_t(SwapStage::COUNT)> m_swap_stage{};
1198 enum class CollapseReject :
int {
1201 surface_leaves_envelope,
1205 feature_leaves_tube,
1208 app_front_unlimited,
1213 app_substructure_link,
1218 after_face_attribute,
1221 after_coarsen_region,
1224 static const char* collapse_reject_name(CollapseReject r);
1225 bool collapse_reject(CollapseReject r)
const
1227 m_collapse_reject[size_t(r)].fetch_add(1, std::memory_order_relaxed);
1230 mutable std::array<std::atomic<long>, size_t(CollapseReject::COUNT)> m_collapse_reject{};
1237 void op_event(OpKind k, OpEvent e)
const override
1240 m_op_events[size_t(k)][size_t(e)].fetch_add(1, std::memory_order_relaxed);
1242 if (e == OpEvent::screened &&
1243 (k == OpKind::swap_32 || k == OpKind::swap_44 || k == OpKind::swap_56)) {
1244 swap_stage(SwapStage::screened);
1252 static thread_local OpKind k = OpKind::COUNT;
1260 void op_accounting_reset();
1261 static const char* op_kind_name(OpKind k);
1262 static const char* op_event_name(OpEvent e);
1275 std::string before, after;
1276 long before_sum = 0, after_sum = 0;
1277 bool counted =
true;
1280 long op_event_count(
const OpKind k,
const OpEvent e)
const
1282 return m_op_events[size_t(k)][size_t(e)].load(std::memory_order_relaxed);
1287 mutable std::array<std::array<std::atomic<long>, size_t(OpEvent::COUNT)>, size_t(OpKind::COUNT)>
1290 array<std::array<std::atomic<long>, size_t(SwapReject::COUNT)>, size_t(OpKind::COUNT) + 1>
1291 m_swap_reject_by_kind{};
1307 return after < before;
1317 bool is_surface_flip =
false;
1318 size_t sf_a = 0, sf_b = 0, sf_c = 0, sf_d = 0;
1331 bool is_edge_on_surface =
false;
1332 bool is_edge_open_boundary =
false;
1333 bool is_edge_on_feature =
false;
1334 size_t edge_order = 0;
1335 std::vector<std::pair<FaceAttributes, std::array<size_t, 3>>> changed_faces;
1345 double max_energy = 0.;
1346 double edge_length = 0.;
1347 std::vector<std::pair<FaceAttributes, std::array<size_t, 3>>> changed_faces;
1356 std::vector<std::array<size_t, 2>> boundary_edges;
1357 std::vector<size_t> changed_tids;
1358 std::vector<double> changed_energies;
1388 const std::vector<size_t>& tids,
1389 std::map<std::array<size_t, 2>,
bool>& cache);
1392 const std::vector<Tuple>& tets,
1393 const std::map<std::array<size_t, 2>,
bool>& cache);
1395 const std::vector<size_t>& tids,
1396 const std::map<std::array<size_t, 2>,
bool>& cache);
1399 const std::map<std::array<size_t, 2>,
bool>& cache,
1423 std::vector<size_t> ring;
1424 std::vector<size_t> frontier;
1425 std::vector<size_t> next;
1426 std::vector<size_t> one_ring;
1427 std::vector<uint32_t> stamp;
1430 std::vector<std::pair<size_t, double>> saved_qualities;
1435 const std::vector<size_t>&
1451 bool is_limit_length,
1453 size_t max_passes = 0,
1454 bool exact_ball_lock =
false);
serving as buffers for attributes data that can be modified by operations
Definition AttributeCollection.hpp:22
Several attribute collections for the same simplex type, behind one container.
Definition AttributeCollection.hpp:143
bool coord_equals(int k, const VecD &posf, const Rational &r) const
Whether coordinate k equals r, without materialising the whole position.
Definition ExactPosition.hpp:54
void store(const VecR &p)
Store an exact position that may differ from the double one.
Definition ExactPosition.hpp:60
VecR value(const VecD &posf) const
The exact position of a vertex whose double position is posf.
Definition ExactPosition.hpp:51
void clear()
The exact position is the double one: drop the stored copy.
Definition ExactPosition.hpp:70
Definition Rational.hpp:10
The rounded/exact bookkeeping shared by every mesh that keeps both coordinates.
Definition RationalPositions.h:21
Definition SurfaceTagAttributes.h:24
a Tuple refers to a global vid and a global tet id, and a local edge id and local face id
Definition TetMesh.h:60
size_t vert_capacity() const
get the current largest global vid
Definition TetMesh.h:379
Tuple tuple_from_vertex(size_t vid) const
get a Tuple from global vertex index
Definition TetMesh.cpp:702
virtual std::array< size_t, 3 > orient_tracked_face(const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const
Definition TetMesh.h:687
What tetwild and simwild's 3D mesh share.
Definition TetOptimizerMesh.h:51
bool m_collapse_limit_length
Definition TetOptimizerMesh.h:451
void smooth_vertices_colored(const std::vector< std::pair< std::string, Tuple > > &ops)
One smoothing sweep over ops (all "vertex_smooth"), one color class at a time.
Definition TetOptimizerMesh.cpp:435
std::string op_accounting_report(OpKind k) const
Definition TetOptimizerMesh.cpp:1456
void gradation_smooth_sizing(double grade, const std::vector< size_t > &seeds)
Grade the refined sizing region into its surroundings (monotone, only lowers).
Definition TetOptimizerMesh.cpp:494
bool m_tracks_orientation
The application set FaceAttributes::m_orientation at insertion, so the tracked surface carries the in...
Definition TetOptimizerMesh.h:119
double swap_edge_44_energy(const std::vector< std::array< size_t, 4 > > &tets, const int op_case) override
User specified energy to decide which of the 4 possible orientations should be chosen.
Definition TetOptimizerMesh.cpp:308
virtual void collapse_after_features(size_t, size_t)
Definition TetOptimizerMesh.h:1071
optimization::NewtonCounters m_newton
Definition TetOptimizerMesh.h:447
std::shared_ptr< history::VolumeRecorder > m_recorded_volume
Definition TetOptimizerMesh.h:610
bool swap_edge_44_before(const Tuple &t) override
User specified preparations and desideratas for an 4-4 edge swap before changing the connectivity.
Definition TetOptimizerMeshSwaps.cpp:694
size_t m_force_split_count
Force-splits taken in the current split pass. Diagnostic only.
Definition TetOptimizerMesh.h:458
AttributeContainerGroup m_vertex_attr_group
What p_vertex_attrs points at, so a derived class can register more.
Definition TetOptimizerMesh.h:158
bool vertex_is_on_surface(const size_t vid) const override
Is a vertex part of the substructure.
Definition TetOptimizerMesh.cpp:1094
SwapStage
Definition TetOptimizerMesh.h:1154
bool collapse_edge_after(const Tuple &t) override
User specified modifications and desideratas for after an edge collapse.
Definition TetOptimizerMeshCollapse.cpp:402
SwapRejectRole
Definition TetOptimizerMesh.h:1270
std::unique_ptr< std::atomic< int >[]> m_high_valence_claim
Per-pass claims for the shared high-valence split gate.
Definition TetOptimizerMesh.h:466
virtual std::shared_ptr< Envelope > smoothing_energy_envelope(const size_t vid) const =0
Envelope a surface vertex is pulled toward while smoothing. A real envelope, never a composite (see s...
std::vector< size_t > all_vertex_ids() const override
Every live vertex, in the mesh's own iteration order.
Definition TetOptimizerMesh.cpp:483
double region_max_quality_rel(const std::vector< size_t > &vids) const
Definition TetOptimizerMeshCollapse.cpp:663
bool m_coarsen_mode
Set for the duration of coarsen_mesh(); read-only while a pass is running.
Definition TetOptimizerMesh.h:1410
bool checks_tracked_surface() const override
m_params.check_surface_folds; see there.
Definition TetOptimizerMesh.h:626
virtual std::shared_ptr< Envelope > smoothing_containment_envelope(const size_t, const std::array< size_t, 3 > &face, const FaceAttributes &attr) const
Envelope the smoother checks tracked face face (attributes attr) at the moved vertex vid against; nul...
Definition TetOptimizerMesh.h:883
virtual void split_after_vertex_feature(size_t, bool)
Definition TetOptimizerMesh.h:1406
bool swap_face_after(const Tuple &t) override
User specified modifications and desideratas for after a 2-3 face swap.
Definition TetOptimizerMeshSwaps.cpp:587
EdgeAttCol m_feature_edge_attribute
Sized, protected and rolled back only once enable_feature_edge_tracking() ran.
Definition TetOptimizerMesh.h:261
bool m_in_operation_pass
True while a pass of the shared operations runs.
Definition TetOptimizerMesh.h:207
void record_surface_history(const std::string &metadata)
Definition TetOptimizerMesh.cpp:879
virtual std::shared_ptr< Envelope > surface_envelope_for_face(const std::array< size_t, 3 > &vids, const FaceAttributes &attr) const
Envelope the tracked-surface triangle vids must stay inside, given the attributes attr it carries – o...
Definition TetOptimizerMesh.h:729
virtual void update_attributes()
Update the attributes of the mesh after an iteration of operations.
Definition TetOptimizerMesh.h:570
virtual void smoothing_pass_done()
Definition TetOptimizerMesh.h:989
bool swap_edge_44_after(const Tuple &t) override
User specified modifications and desideratas for after a 4-4 edge swap.
Definition TetOptimizerMeshSwaps.cpp:746
bool swap_edge_before(const Tuple &t) override
User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.
Definition TetOptimizerMeshSwaps.cpp:116
std::vector< std::array< size_t, 3 > > oriented_tracked_faces() const
The tracked surface as an oriented soup: each tracked face emitted |m_orientation| times,...
Definition TetOptimizerMesh.cpp:704
bool swap_face_before(const Tuple &t) override
User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.
Definition TetOptimizerMeshSwaps.cpp:521
virtual void split_after_vertex(size_t, bool)
Application metadata not represented by the shared vertex attributes.
Definition TetOptimizerMesh.h:1084
bool vertex_has_feature_edge(size_t vid) const
Definition TetOptimizerMesh.cpp:1122
virtual bool boundary_edges_at_vertex_inside(size_t) const
Definition TetOptimizerMesh.h:901
std::array< size_t, 3 > orient_tracked_face(const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const override
Definition TetOptimizerMesh.cpp:1000
void feature_edges_cache(const std::vector< size_t > &tids, std::map< std::array< size_t, 2 >, bool > &cache)
Cache the feature tag of every edge of every tet in tids.
Definition TetOptimizerMesh.cpp:1255
bool swap_edge_56_after(const Tuple &t) override
User specified modifications and desideratas for after a 5-6 edge swap.
Definition TetOptimizerMeshSwaps.cpp:896
virtual bool split_after_cells(size_t, size_t, size_t, const std::vector< Tuple > &)
Restore application cell data on the children made by a split.
Definition TetOptimizerMesh.h:1076
bool collapse_breaks_feature_point(const size_t v1_id, const size_t v2_id) const
Definition TetOptimizerMesh.cpp:1198
bool storage_grows_on_demand() const override
Definition TetOptimizerMesh.h:473
virtual double cell_quality(const size_t tid) const =0
The quality of cell tid, and how to write it.
std::shared_ptr< Envelope > m_feature_envelope
Envelope around the input feature curves: the tube a tagged edge must stay in.
Definition TetOptimizerMesh.h:280
virtual std::shared_ptr< polysolve::nonlinear::Problem > smoothing_extra_energy(const size_t) const
An extra term the application adds to this vertex's smoothing objective, or null.
Definition TetOptimizerMesh.h:916
std::vector< std::vector< uint64_t > > m_recorded_sources
The input triangles each face of the recorded surface's first state lies on.
Definition TetOptimizerMesh.h:654
virtual bool collapse_before_vertex(size_t, size_t, double)
Definition TetOptimizerMesh.h:1057
void record_volume_history()
Definition TetOptimizerMesh.cpp:913
virtual bool smoothing_position_is_allowed(const size_t vid, const Vector3d &p) const
Definition TetOptimizerMesh.h:408
virtual std::vector< size_t > active_vertices() const
Definition TetOptimizerMesh.cpp:559
wmtk::threading::enumerable_thread_specific< std::unique_ptr< polysolve::nonlinear::Solver > > m_solver
Per-thread Newton solver for smoothing; created on first use.
Definition TetOptimizerMesh.h:440
size_t get_order_of_vertex(const size_t vid) const override
Get the order of a vertex.
Definition TetOptimizerMesh.cpp:1104
std::string m_debug_pass_name
Definition TetOptimizerMesh.h:661
double swap_edge_56_energy(const std::vector< std::array< size_t, 4 > > &tets, const int op_case) override
User specified energy to decide which of the 5 possible orientations should be chosen.
Definition TetOptimizerMesh.cpp:323
AttributeContainerGroup m_edge_attr_group
What p_edge_attrs points at, once a collection is registered with it.
Definition TetOptimizerMesh.h:196
std::string swap_reject_report() const
One line per nonzero counter, for a per-turn log. Does not reset.
Definition TetOptimizerMeshSwaps.cpp:225
std::vector< Vector3d > m_feature_points
Definition TetOptimizerMesh.h:354
virtual bool optimization_stalled(double prev, double cur)
Whether an iteration that moved the metric from prev to cur is stalled, and the sizing refinement sho...
Definition TetOptimizerMesh.h:1050
void feature_edges_restore_region(const std::vector< Tuple > &tets, const std::map< std::array< size_t, 2 >, bool > &cache)
Write back tags over every edge of every tet in tets (created regions).
Definition TetOptimizerMesh.cpp:1289
virtual double smoothing_ring_energy(const std::vector< Tuple > &ring, const bool stored) const
The number the shared smoother's projected step compares for a whole one-ring: a vertex held on a sur...
Definition TetOptimizerMesh.h:951
bool collapse_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge collapse before changing the connectivity.
Definition TetOptimizerMeshCollapse.cpp:100
virtual bool is_open_boundary_edge(const Tuple &e)
Whether edge e lies on the boundary of the tracked surface.
Definition TetOptimizerMesh.h:700
std::optional< history::SurfaceHistory > finish_surface_history(const history::SurfaceHistory *input=nullptr)
Bring the recorded surface up to date with the tracked faces, stop recording, log what the history ho...
Definition TetOptimizerMesh.cpp:937
int m_iterations_used
Shared TetWild/SimWild outer optimization schedule.
Definition TetOptimizerMesh.h:633
std::vector< std::pair< PositionKey, std::vector< uint32_t > > > m_insertion_sources
Definition TetOptimizerMesh.h:606
virtual void log_smoothing_pass_accounting()
Definition TetOptimizerMesh.h:984
bool is_tracked_face(size_t tid, int j) const override
The faces with m_is_surface_fs, for a surface history (TetMesh::start_surface_history).
Definition TetOptimizerMesh.cpp:995
bool is_inverted_f(const Tuple &loc) const
Inversion check using only the double positions.
Definition TetOptimizerMesh.cpp:571
virtual bool swap_after_cells(const std::vector< size_t > &, bool)
Propagate application data to the cells made by a successful topological swap.
Definition TetOptimizerMesh.h:1096
virtual double quality_rel(const size_t tid) const
A cell's quality relative to the quality it is required to reach; <= 1 means it meets it.
Definition TetOptimizerMesh.h:538
virtual bool optimization_bare_coarsen_passes() const
Whether the loop opens with an UNLIMITED-LENGTH collapse pass.
Definition TetOptimizerMesh.h:1022
AttributeContainerGroup m_face_attr_group
What p_face_attrs points at, so a derived class can register more.
Definition TetOptimizerMesh.h:173
std::vector< std::array< size_t, 2 > > tracked_feature_edges() const override
The tagged feature edges (m_feature_edge_attribute) that are edges of tracked faces.
Definition TetOptimizerMesh.cpp:754
virtual bool split_adjust_position(size_t, const std::vector< Tuple > &)
Definition TetOptimizerMesh.h:1082
std::atomic< size_t > m_inconsistent_orientation_flips
Surface flips that joined two faces not oriented alike (a fold of the tracked surface,...
Definition TetOptimizerMesh.h:130
int edge_incident_surface_face_count(const Tuple &e)
How many of the faces incident to edge e are on the tracked surface.
Definition TetOptimizerMesh.cpp:1041
bool split_edge_is_due(const Tuple &e) const
Definition TetOptimizerMeshSplit.cpp:125
bool round_vertex(const size_t vid) override
Definition TetOptimizerMesh.h:684
bool surface_triangle_is_outside(const size_t a, const size_t b, const size_t c, const FaceAttributes &attr) const
Definition TetOptimizerMesh.h:739
uint32_t m_op_epoch
Definition TetOptimizerMesh.h:1033
bool m_track_feature_edges
Whether the shared operations maintain m_feature_edge_attribute.
Definition TetOptimizerMesh.h:270
bool swap_edge_56_before(const Tuple &t) override
User specified preparations and desideratas for a 5-6 edge swap before changing the connectivity.
Definition TetOptimizerMeshSwaps.cpp:845
std::pair< size_t, size_t > feature_retention(double *worst_ratio=nullptr) const
Definition TetOptimizerMesh.cpp:1219
static constexpr double MAX_ENERGY
The sentinel get_quality returns for an element AMIPS cannot score.
Definition TetOptimizerMesh.h:421
bool split_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge split before changing the connectivity.
Definition TetOptimizerMeshSplit.cpp:141
bool use_colored_smoothing() const
Whether this pass smooths by color class (see OptimizerParameters::colored_smoothing).
Definition TetOptimizerMesh.cpp:430
virtual void optimization_iteration_done(int)
Definition TetOptimizerMesh.h:1025
std::vector< std::pair< std::array< size_t, 2 >, int > > tracked_surface_boundary() const
Mesh edges where the oriented tracked surface has a boundary.
Definition TetOptimizerMesh.cpp:719
bool swap_edge_after(const Tuple &t) override
User specified modifications and desideratas for after a 3-2 edge swap.
Definition TetOptimizerMeshSwaps.cpp:409
void update_attributes_and_history()
update_attributes(), then the change it made to the tracked surface, if recording one.
Definition TetOptimizerMesh.cpp:985
Eigen::Vector3d tracked_area_normal(const std::vector< std::array< size_t, 3 > > &faces) const
Definition TetOptimizerMesh.cpp:782
std::set< simplex::Edge > m_force_split_edges
Definition TetOptimizerMesh.h:456
bool swap_reject_kind_only(SwapReject r) const
Definition TetOptimizerMesh.h:1173
void enable_feature_edge_tracking()
Turn on feature-edge tracking. The collection joins m_edge_attr_group beside whatever the application...
Definition TetOptimizerMesh.h:294
bool feature_point_ball_contains(const size_t vid, const Vector3d &p) const
Definition TetOptimizerMesh.cpp:1209
bool smooth_before(const Tuple &t) override
The smoothing hooks. A derived class overriding them – or invariants(), which a smooth also runs – mu...
Definition TetOptimizerMesh.cpp:338
void add_edge_attributes(AbstractAttributeContainer *c)
Register an edge collection with m_edge_attr_group and point p_edge_attrs at the group.
Definition TetOptimizerMesh.h:235
optimization::SmoothRejectCounters m_smooth_rejects
Why smoothing attempts were refused, reported once per pass.
Definition TetOptimizerMesh.h:443
static OpKind & current_op_kind()
Definition TetOptimizerMesh.h:1250
size_t m_split_order_waits
The current split pass's ExecutePass::waits() and wait_defects().
Definition TetOptimizerMesh.h:497
size_t collapse_all_edges_impl(bool is_limit_length, int lock_ring, size_t max_passes=0, bool exact_ball_lock=false)
Definition TetOptimizerMeshCollapse.cpp:24
size_t coarsen_mesh()
Coarsen the mesh without letting the max energy rise.
Definition TetOptimizerMeshCollapse.cpp:715
bool round(const Tuple &v)
Round a vertex position to floating point, if that inverts no incident tet.
Definition TetOptimizerMesh.cpp:639
double m_feature_eps
Definition TetOptimizerMesh.h:357
bool op_accounting_unexplained(OpKind k) const
True when the report for k has a nonzero remainder: a refusal no counter named.
Definition TetOptimizerMesh.cpp:1447
bool smooth_vertex_reversible(size_t vid, CoarsenScratch &scr)
One smoothing attempt on vid, restoring everything it wrote if it is rejected.
Definition TetOptimizerMeshCollapse.cpp:674
std::array< std::array< double, 3 >, 3 > PositionKey
A tracked face by its corners' positions, sorted.
Definition TetOptimizerMesh.h:601
virtual std::tuple< double, double > optimization_quality_stats()
Definition TetOptimizerMesh.cpp:31
virtual double smoothing_cell_energy(const size_t, const double quality) const
The number the shared smoother compares for one cell, given the cell's quality (AMIPS^3) at the posit...
Definition TetOptimizerMesh.h:932
bool coarsen_collapse_edge(const Tuple &e, std::vector< Tuple > &new_tets)
One collapse under the coarsening rules, outside a coarsening pass.
Definition TetOptimizerMeshCollapse.cpp:703
bool m_track_feature_points
Whether the shared operations maintain the ids (enable_feature_point_tracking()).
Definition TetOptimizerMesh.h:359
bool feature_edges_at_vertex_inside(size_t vid) const
Definition TetOptimizerMesh.cpp:1179
double m_s_amips
Definition TetOptimizerMesh.h:432
double active_quality_threshold() const
Cell-quality threshold above which a tet is "active" (worth operating on) for the skip-good-regions f...
Definition TetOptimizerMesh.h:771
virtual bool split_before_cells(const Tuple &, const std::vector< Tuple > &)
Cache application cell data before a split. TetWild needs none; SimWild caches tags.
Definition TetOptimizerMesh.h:1074
long op_unaccounted(OpKind k) const
Attempts minus every outcome: 0 unless an exit of the TetMesh operation reports nothing.
Definition TetOptimizerMesh.cpp:1402
void substructure_feature_neighbors(size_t vid, std::vector< size_t > &out) const override
One-ring vertices x of vid where (vid, x) is 1D substructure NOT derivable from the surface complex (...
Definition TetOptimizerMesh.cpp:1165
const std::vector< size_t > & collect_vertex_ball(const size_t *seeds, size_t n_seeds, int n, CoarsenScratch &scr) const
Vertices within n edges of seeds, in BFS order. Uses coarsen_scratch.
Definition TetOptimizerMeshCollapse.cpp:602
virtual bool swap_quality_allowed(double after, double before, bool) const
Definition TetOptimizerMesh.h:1305
bool feature_edges_restore_remap(const std::map< std::array< size_t, 2 >, bool > &cache, size_t v_old, size_t v_new)
Write back tags for every cached edge, with v_old renamed to v_new (collapse).
Definition TetOptimizerMesh.cpp:1312
virtual bool swap_before_interior(const std::vector< size_t > &)
Application data attached to the old cells. TetWild has none; SimWild caches tags.
Definition TetOptimizerMesh.h:1090
static constexpr size_t NO_FEATURE_POINT
A vertex that stands for no feature point. See FeaturePointAttributes.
Definition TetOptimizerMesh.h:342
OptimizerParameters & m_params
Definition TetOptimizerMesh.h:425
FeaturePointAttCol m_feature_point_attribute
Registered with m_vertex_attr_group only once enable_feature_point_tracking() ran.
Definition TetOptimizerMesh.h:350
std::optional< std::vector< uint8_t > > finish_volume_history(const std::map< int64_t, std::string > &tag_names={})
Definition TetOptimizerMesh.cpp:919
bool m_preserve_feature_points
Whether the collapse and smoothing policy is on (its preserve argument).
Definition TetOptimizerMesh.h:361
bool swap_edge_56_accept_case(const std::array< size_t, 3 > &new_face) override
Filter which of the 5-6 orientations may be chosen.
Definition TetOptimizerMeshSwaps.cpp:389
void throw_if_in_operation_pass(const char *call) const
Definition TetOptimizerMesh.h:214
void on_slot_storage_grown() override
Definition TetOptimizerMesh.h:479
bool split_edge_after(const Tuple &loc) override
This function computes the attributes for the added simplices. User specified modifications and desid...
Definition TetOptimizerMeshSplit.cpp:242
std::shared_ptr< Envelope > m_envelope
Surface envelope: what a surface vertex is pulled toward and checked against.
Definition TetOptimizerMesh.h:428
void enable_feature_point_tracking(const bool preserve)
Turn on feature-point tracking, and the policy when preserve.
Definition TetOptimizerMesh.h:376
size_t substructure_order_of_edge(const std::array< size_t, 2 > &vids) const override
The orders substructure_link_condition consults, overridable so an application can widen the 1D subst...
Definition TetOptimizerMesh.cpp:1133
bool vertex_is_rounded(const size_t vid) const override
Whether this vertex's double position is currently trusted.
Definition TetOptimizerMesh.h:677
std::atomic< size_t > m_surface_fold_refusals
The operations check_surface_folds refused.
Definition TetOptimizerMesh.h:630
bool face_is_on_surface(const size_t fid) const override
Is a face part of the substructure.
Definition TetOptimizerMesh.cpp:1099
bool swap_edge_44_accept_case(const std::array< size_t, 2 > &new_edge) override
Filter which of the 4-4 orientations may be chosen.
Definition TetOptimizerMeshSwaps.cpp:379
bool smooth_after(const Tuple &t) override
User specified modifications and desideratas for after smoothing a vertex.
Definition TetOptimizerMesh.cpp:352
Definition Simplex.hpp:46
Definition enumerable_thread_specific.hpp:37
The parameters tetwild, triwild and simwild all share.
Definition OptimizerParameters.h:29
bool check_surface_folds
Definition OptimizerParameters.h:212
Per-thread buffers for the coarsening composite, so it allocates nothing.
Definition TetOptimizerMesh.h:1422
What coarsen_mesh() achieved, for the run report. Zeroed when the pass is off.
Definition TetOptimizerMesh.h:814
Definition TetOptimizerMesh.h:1342
std::vector< std::pair< std::array< size_t, 3 >, FaceAttributes > > surface_faces
Definition TetOptimizerMesh.h:1351
std::map< std::array< size_t, 2 >, bool > changed_edges
Feature-edge tags of the affected tets, by sorted vid pair (m_track_feature_edges).
Definition TetOptimizerMesh.h:1360
std::vector< std::pair< std::array< size_t, 3 >, int > > renamed_orientations
Definition TetOptimizerMesh.h:1355
double region_max_rel_before
Definition TetOptimizerMesh.h:1363
Per-edge feature tag: does this tet edge tile an input feature curve.
Definition TetOptimizerMesh.h:256
Definition TetOptimizerMesh.h:344
size_t m_feature_point_id
Index into m_feature_points, or NO_FEATURE_POINT.
Definition TetOptimizerMesh.h:346
A kind's hook refusals by reason: the nonzero leaves as "name=n" and their sums.
Definition TetOptimizerMesh.h:1274
Definition TetOptimizerMesh.h:1328
std::map< std::array< size_t, 2 >, bool > changed_edges
Feature-edge tags of the affected tets, by sorted vid pair (m_track_feature_edges).
Definition TetOptimizerMesh.h:1337
Definition TetOptimizerMesh.h:639
Definition TetOptimizerMesh.h:1311
int sf_orientation
Orientation of the flipped pair, measured along [a,b,c] (and so along [b,a,d]).
Definition TetOptimizerMesh.h:1321
std::map< std::array< size_t, 2 >, bool > changed_edges
Feature-edge tags of the affected tets, by sorted vid pair (m_track_feature_edges).
Definition TetOptimizerMesh.h:1315
bool sf_orientation_mismatch
The pair's two faces were not oriented alike; see prepare_surface_flip.
Definition TetOptimizerMesh.h:1323
Definition TetOptimizerMesh.h:54
size_t partition_id
Required for multi-threading.
Definition TetOptimizerMesh.h:77
size_t m_order
Definition TetOptimizerMesh.h:71
bool m_is_rounded
Definition TetOptimizerMesh.h:61
A complex and the edits it went through, in commit order.
Definition History.hpp:101
How the vertex solves of a smoothing pass ended: Newton iterations taken and the status polysolve sto...
Definition SmoothVertex.hpp:76
Why a smoothing attempt was refused, counted per pass.
Definition SmoothVertex.hpp:32
A topological fingerprint of a tracked surface inside a tet mesh.
Definition SurfaceTopology.hpp:23