Wildmeshing Toolkit
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
wmtk::ExactPosition< VecR, VecD > Class Template Reference

A vertex's exact (rational) position, stored only while it differs from the vertex's double position. More...

#include <ExactPosition.hpp>

Public Member Functions

 ExactPosition (const ExactPosition &o)
 
ExactPosition & operator= (const ExactPosition &o)
 
VecR value (const VecD &posf) const
 The exact position of a vertex whose double position is posf.
 
bool coord_equals (int k, const VecD &posf, const Rational &r) const
 Whether coordinate k equals r, without materialising the whole position.
 
void store (const VecR &p)
 Store an exact position that may differ from the double one.
 
void clear ()
 The exact position is the double one: drop the stored copy.
 
bool stored () const
 

Private Attributes

std::unique_ptr< VecR > m_p
 

Detailed Description

template<class VecR, class VecD>
class wmtk::ExactPosition< VecR, VecD >

A vertex's exact (rational) position, stored only while it differs from the vertex's double position.

The optimizer meshes keep every vertex position twice: as doubles, which everything reads, and as rationals, which only the exact predicates read and only while a vertex cannot be rounded. Once a vertex is rounded its exact position IS its double position – the code keeps the two equal by construction – so the rational copy carries no information, yet it cost a Vector of GMP rationals per vertex slot: 32 bytes inline per coordinate plus heap limbs, roughly 290 bytes per 3D vertex and most of a vertex slot's footprint.

So the rational position lives behind a pointer that is null whenever it would equal the double one, and value() rebuilds it from the double position on demand. Reads see exactly the value they saw before; only vertices that are genuinely not representable in doubles (and the few that are mid-operation) pay for the rational storage.

Copying copies the stored position. There are deliberately no move operations: moving one of these copies it, as moving the Vector of Rationals it replaces did (Rational has no move constructor), so attribute slots moved from during consolidation keep their contents.


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