OpenABF 2.1.0
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
OpenABF::detail::hlscm::DecimationMesh< T > Class Template Reference

Lightweight flat-array mesh for decimation. More...

Public Member Functions

template<class MeshPtr >
void build (const MeshPtr &mesh, const std::vector< std::size_t > &pinIndices)
 
auto num_alive_verts () const -> std::size_t
 
auto num_alive_faces () const -> std::size_t
 
auto try_collapse (std::size_t vRemove, std::size_t vKeep, std::vector< std::size_t > *outKeepNbrs=nullptr) -> std::optional< CollapseRecord< T > >
 Try to collapse edge (vRemove → vKeep), returning a collapse record.
 
auto collapse_cost (std::size_t v0, std::size_t v1) const -> T
 
auto is_alive (std::size_t v) const -> bool
 
auto is_collapsible (std::size_t v) const -> bool
 
auto vertex_neighbors (std::size_t v) const -> std::vector< std::size_t >
 
auto snapshot () const -> HierarchyLevel< T >
 
auto rebuild_and_get_edges () -> const std::vector< std::pair< std::size_t, std::size_t > > &
 

Private Member Functions

void compute_quadrics_ ()
 
void build_edges_ ()
 

Static Private Member Functions

static auto computeBarycentric_ (const Vec< T, 3 > &a, const Vec< T, 3 > &b, const Vec< T, 3 > &c, const Vec< T, 3 > &p) -> std::array< T, 3 >
 

Private Attributes

std::vector< Vec< T, 3 > > positions_
 
std::vector< boolalive_
 
std::vector< boolis_boundary_
 
std::vector< boolis_pinned_
 
std::vector< Quadric< T > > quadrics_
 
std::vector< std::array< std::size_t, 3 > > faces_
 
std::vector< boolface_alive_
 
std::vector< std::vector< std::size_t > > vert_faces_
 
std::size_t num_alive_verts_ {0}
 
std::size_t num_alive_faces_ {0}
 
std::vector< std::pair< std::size_t, std::size_t > > edges_
 
std::vector< std::size_t > scratch_shared_
 
std::vector< std::size_t > scratch_remove_
 
std::vector< std::array< std::size_t, 3 > > scratch_post_faces_
 
std::vector< std::size_t > scratch_nbrs_a_
 
std::vector< std::size_t > scratch_nbrs_b_
 
std::vector< std::size_t > scratch_shared_nbrs_
 

Detailed Description

template<typename T>
class OpenABF::detail::hlscm::DecimationMesh< T >

Lightweight flat-array mesh for decimation.

Copies vertex positions and face connectivity from a HalfEdgeMesh into flat vectors, builds adjacency structures, and supports half-edge collapse.

Member Function Documentation

◆ build()

template<typename T >
template<class MeshPtr >
void OpenABF::detail::hlscm::DecimationMesh< T >::build ( const MeshPtr mesh,
const std::vector< std::size_t > &  pinIndices 
)
inline

Build from a HalfEdgeMesh

◆ build_edges_()

template<typename T >
void OpenABF::detail::hlscm::DecimationMesh< T >::build_edges_ ( )
inlineprivate

Rebuild the unique-edge list from the live faces.

◆ collapse_cost()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::collapse_cost ( std::size_t  v0,
std::size_t  v1 
) const -> T
inline

Compute collapse cost for edge (v0 → v1): Q_merged evaluated at v1

◆ compute_quadrics_()

template<typename T >
void OpenABF::detail::hlscm::DecimationMesh< T >::compute_quadrics_ ( )
inlineprivate

Recompute per-vertex QEM quadrics from the live faces (Garland-Heckbert).

◆ computeBarycentric_()

template<typename T >
static auto OpenABF::detail::hlscm::DecimationMesh< T >::computeBarycentric_ ( const Vec< T, 3 > &  a,
const Vec< T, 3 > &  b,
const Vec< T, 3 > &  c,
const Vec< T, 3 > &  p 
) -> std::array<T, 3>
inlinestaticprivate

Compute barycentric coordinates of point p in triangle (a, b, c)

◆ is_alive()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::is_alive ( std::size_t  v) const -> bool
inline

Check if a vertex is alive

◆ is_collapsible()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::is_collapsible ( std::size_t  v) const -> bool
inline

Check if a vertex is collapsible (not pinned, alive)

◆ num_alive_faces()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::num_alive_faces ( ) const -> std::size_t
inline

Get number of alive faces

◆ num_alive_verts()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::num_alive_verts ( ) const -> std::size_t
inline

Get number of alive vertices

◆ rebuild_and_get_edges()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::rebuild_and_get_edges ( ) -> const std::vector<std::pair<std::size_t, std::size_t>>&
inline

Rebuild the edge list from alive faces and return it

◆ snapshot()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::snapshot ( ) const -> HierarchyLevel<T>
inline

Take a snapshot of surviving vertices and faces for a hierarchy level

◆ try_collapse()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::try_collapse ( std::size_t  vRemove,
std::size_t  vKeep,
std::vector< std::size_t > *  outKeepNbrs = nullptr 
) -> std::optional<CollapseRecord<T>>
inline

Try to collapse edge (vRemove → vKeep), returning a collapse record.

Returns nullopt if the collapse is invalid.

Parameters
outKeepNbrsOptional out-vector. On a successful collapse it is overwritten with vKeep's post-collapse neighbor vertex indices (sorted, unique). Passing a caller- owned vector here lets the PQ-update path reuse the allocation across collapses instead of letting vertex_neighbors() allocate a fresh vector each time.

◆ vertex_neighbors()

template<typename T >
auto OpenABF::detail::hlscm::DecimationMesh< T >::vertex_neighbors ( std::size_t  v) const -> std::vector<std::size_t>
inline

Get alive neighbour vertices of v (sorted, deduped).

Production code path uses try_collapse's outKeepNbrs out-param to avoid this method's per-call allocation; this overload is retained only as the oracle for the HLSCMInternal.TryCollapse_* tests.

Member Data Documentation

◆ alive_

template<typename T >
std::vector<bool> OpenABF::detail::hlscm::DecimationMesh< T >::alive_
private

Per-vertex alive flag; collapses set entries to false.

◆ edges_

template<typename T >
std::vector<std::pair<std::size_t, std::size_t> > OpenABF::detail::hlscm::DecimationMesh< T >::edges_
private

Unique-edge list, rebuilt on demand by build_edges_().

◆ face_alive_

template<typename T >
std::vector<bool> OpenABF::detail::hlscm::DecimationMesh< T >::face_alive_
private

Per-face alive flag; collapses retire faces by setting entries to false.

◆ faces_

template<typename T >
std::vector<std::array<std::size_t, 3> > OpenABF::detail::hlscm::DecimationMesh< T >::faces_
private

Face connectivity: each face is three vertex indices into positions_.

◆ is_boundary_

template<typename T >
std::vector<bool> OpenABF::detail::hlscm::DecimationMesh< T >::is_boundary_
private

Per-vertex boundary flag, copied from the source mesh.

◆ is_pinned_

template<typename T >
std::vector<bool> OpenABF::detail::hlscm::DecimationMesh< T >::is_pinned_
private

Per-vertex pinned flag; pinned vertices cannot be removed by collapse.

◆ num_alive_faces_

template<typename T >
std::size_t OpenABF::detail::hlscm::DecimationMesh< T >::num_alive_faces_ {0}
private

Count of alive faces (kept current across collapses).

◆ num_alive_verts_

template<typename T >
std::size_t OpenABF::detail::hlscm::DecimationMesh< T >::num_alive_verts_ {0}
private

Count of alive vertices (kept current across collapses).

◆ positions_

template<typename T >
std::vector<Vec<T, 3> > OpenABF::detail::hlscm::DecimationMesh< T >::positions_
private

Per-vertex 3D positions, indexed by original vertex index.

◆ quadrics_

template<typename T >
std::vector<Quadric<T> > OpenABF::detail::hlscm::DecimationMesh< T >::quadrics_
private

Per-vertex QEM quadrics accumulated from incident face planes.

◆ scratch_nbrs_a_

template<typename T >
std::vector<std::size_t> OpenABF::detail::hlscm::DecimationMesh< T >::scratch_nbrs_a_
private

Scratch buffer: neighbor list of one endpoint.

◆ scratch_nbrs_b_

template<typename T >
std::vector<std::size_t> OpenABF::detail::hlscm::DecimationMesh< T >::scratch_nbrs_b_
private

Scratch buffer: neighbor list of the other endpoint.

◆ scratch_post_faces_

template<typename T >
std::vector<std::array<std::size_t, 3> > OpenABF::detail::hlscm::DecimationMesh< T >::scratch_post_faces_
private

Scratch buffer: post-collapse face rewrites.

◆ scratch_remove_

template<typename T >
std::vector<std::size_t> OpenABF::detail::hlscm::DecimationMesh< T >::scratch_remove_
private

Scratch buffer: faces to retire on a collapse.

◆ scratch_shared_

template<typename T >
std::vector<std::size_t> OpenABF::detail::hlscm::DecimationMesh< T >::scratch_shared_
private

Scratch buffer: neighbor indices shared between two endpoints.

◆ scratch_shared_nbrs_

template<typename T >
std::vector<std::size_t> OpenABF::detail::hlscm::DecimationMesh< T >::scratch_shared_nbrs_
private

Scratch buffer: deduplicated union of scratch_nbrs_a_ and scratch_nbrs_b_.

◆ vert_faces_

template<typename T >
std::vector<std::vector<std::size_t> > OpenABF::detail::hlscm::DecimationMesh< T >::vert_faces_
private

Per-vertex incident face list.