Wildmeshing Toolkit
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
wmtk::history::TrackedRecorder< N > Class Template Reference

Records a tracked complex: some of the faces of a mesh, or some of its edges, which the mesh gives no ids of their own – the tracked faces of a tet mesh (N = 3), the tracked edges of a triangle mesh (N = 2). More...

#include <TrackedRecorder.hpp>

Classes

struct  Change
 What an operation did to the tracked complex, as the mesh saw it at its commit point. More...
 
struct  Stats
 How the commits were recorded. More...
 

Public Types

using Cell = std::array< size_t, N >
 A face by mesh vertex ids.
 
using MeshFeature = std::array< size_t, N - 1 >
 A feature by mesh vertex ids.
 
using Positions = std::function< Eigen::Vector3d(size_t)>
 
using Orient = std::function< Cell(const Cell &)>
 A tracked face's corners, in the order that orients it.
 

Public Member Functions

 TrackedRecorder (const std::vector< Cell > &faces, Positions position, Orient orient, const std::vector< MeshFeature > &features={})
 
std::vector< MeshFeature > features () const
 
std::vector< uint64_t > mesh_vertex_ids () const
 
std::array< size_t, 2 > commit (Change &&c)
 
void renumber (const std::vector< size_t > &old_to_new)
 The mesh renumbered its vertices: old_to_new[v], size_t(-1) for a vertex gone.
 
size_t resync (const std::vector< Cell > &faces)
 
Stats stats () const
 
const History< N > & history () const
 Not synchronised: read once the mesh is done.
 
History< N > & history ()
 
const BasicReplay< N > & complex () const
 The complex as it is now.
 
std::optional< uint64_t > face_id (const Cell &t) const
 
std::optional< uint64_t > vertex_id (size_t v) const
 The vertex of the complex a mesh vertex is, if it is on it. Not synchronised.
 
std::vector< uint64_t > vertex_ids (const std::vector< size_t > &vs) const
 

Private Member Functions

std::optional< uint64_t > live (size_t v) const
 
std::optional< uint64_t > lookup (const Cell &t) const
 
uint64_t fresh_vertex (size_t v)
 
std::optional< Edit > as_split (const Change &c, const std::vector< Cell > &before, const std::vector< Cell > &removed, const std::vector< Cell > &added, std::vector< uint64_t > &fresh)
 
std::optional< Edit > as_collapse (Change &c, const std::vector< Cell > &before, const std::vector< Cell > &after)
 
std::optional< Edit > as_swap (const std::vector< Cell > &removed, const std::vector< Cell > &added)
 
void record (Edit &&e, const std::vector< size_t > &written, const std::vector< uint64_t > &fresh)
 Records e – applies it, then the moves of written and of fresh vertices.
 
Edit replacement (const std::vector< Cell > &removed, const std::vector< Cell > &added, std::vector< uint64_t > &fresh)
 The replace_faces edit taking away removed and adding added (mesh ids, sorted).
 

Private Attributes

std::mutex m_mutex
 
Positions m_position
 
Orient m_orient
 
std::vector< uint64_t > m_complex_of
 
std::vector< size_t > m_mesh_of
 
History< N > m_history
 
BasicReplay< N > m_replay
 
std::vector< Eigen::Vector3d > m_known
 The last position recorded for each vertex of the complex.
 
uint64_t m_next_face = 0
 
Stats m_stats
 

Static Private Attributes

static constexpr uint64_t kNone = uint64_t(-1)
 

Detailed Description

template<int N>
class wmtk::history::TrackedRecorder< N >

Records a tracked complex: some of the faces of a mesh, or some of its edges, which the mesh gives no ids of their own – the tracked faces of a tet mesh (N = 3), the tracked edges of a triangle mesh (N = 2).

The complex gets ids here: one for each mesh vertex on it, one for each face (triangle or segment), so the history is in the terms a TriMesh records in (History, replayed by BasicReplay) and a renumbering of the mesh changes nothing in it. At each commit an operation reports the tracked faces around it before and after, by mesh vertex ids. The recorder finds the edit that takes the one to the other – an edge split, an edge collapse, an edge swap – checks that it gives exactly the faces after, and records it; a change no edit fits it records as it is (EditKind::replace_faces), which a map cannot follow. A face keeps the corner order it had, through the edits' rules; one that only a replace_faces makes takes the order orient gives.

Features (History::features) are carried by the edits' rules alone; the mesh must keep them by the same rules. On curves a feature point keeps its vertex on the complex without any segment, so a collapse that removes one is recorded even when no segment changes.

Commits may come concurrently from operations whose regions do not overlap. They are serialised here, while each operation still holds its locks, so the order of the edits is a valid serial order of the run, as for BasicRecorder.

Constructor & Destructor Documentation

◆ TrackedRecorder()

template<int N>
wmtk::history::TrackedRecorder< N >::TrackedRecorder ( const std::vector< Cell > &  faces,
Positions  position,
Orient  orient,
const std::vector< MeshFeature > &  features = {} 
)

The tracked complex now, any corner order; orient orders the faces of the snapshot, whose vertices' mesh ids the history keeps (History::input_vertex_ids). features: the mesh's features on it (History::features), by mesh vertex ids. On a surface those off it are dropped; on curves a feature point off them is a vertex of the complex all the same.

Member Function Documentation

◆ commit()

template<int N>
std::array< size_t, 2 > wmtk::history::TrackedRecorder< N >::commit ( Change &&  c)

Records c; returns the range of edits it added to the history, [first, last): empty when the complex did not change.

◆ face_id()

template<int N>
std::optional< uint64_t > wmtk::history::TrackedRecorder< N >::face_id ( const Cell &  t) const

The face of the complex a mesh face is, if it is one the recorder knows. Not synchronised.

◆ features()

template<int N>
std::vector< typename TrackedRecorder< N >::MeshFeature > wmtk::history::TrackedRecorder< N >::features ( ) const

The features as the edits have carried them, by mesh vertex ids, each sorted, sorted; those with a vertex the mesh no longer has left out.

◆ mesh_vertex_ids()

template<int N>
std::vector< uint64_t > wmtk::history::TrackedRecorder< N >::mesh_vertex_ids ( ) const

The mesh vertex of every vertex of the complex, kNoVertex for one with none (gone); index with the ids of the history's last state (History::output_vertex_ids).

◆ resync()

template<int N>
size_t wmtk::history::TrackedRecorder< N >::resync ( const std::vector< Cell > &  faces)

Brings the complex in line with faces, every tracked face of the mesh, after a change outside the operations: one replace_faces edit, if anything differs. Returns how many faces it removed and added.

◆ vertex_ids()

template<int N>
std::vector< uint64_t > wmtk::history::TrackedRecorder< N >::vertex_ids ( const std::vector< size_t > &  vs) const

vertex_id() of each of vs, kNoVertex for one off the complex, synchronised with the commits: an operation may ask about the vertices it holds while others commit.

Member Data Documentation

◆ m_complex_of

template<int N>
std::vector<uint64_t> wmtk::history::TrackedRecorder< N >::m_complex_of
private

Mesh vertex -> vertex of the complex, and back. Before the history: the snapshot fills them.


The documentation for this class was generated from the following files: