DNA Calib 1.1
Project brief
Classes | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
dna::SurjectiveMapping< TFrom, TTo > Struct Template Reference

#include <SurjectiveMapping.h>

Inheritance diagram for dna::SurjectiveMapping< TFrom, TTo >:
Inheritance graph
Collaboration diagram for dna::SurjectiveMapping< TFrom, TTo >:
Collaboration graph

Classes

struct  Pair
 

Public Member Functions

 SurjectiveMapping (MemoryResource *memRes)
 
Pair get (std::size_t index) const
 
void add (TFrom from_, TTo to_)
 
void set (std::size_t index, TFrom from_, TTo to_)
 
void removeIf (std::function< bool(const TFrom &, const TTo &)> predicate)
 
void updateFrom (const UnorderedMap< TFrom, TFrom > &mapping)
 
void updateTo (const UnorderedMap< TTo, TTo > &mapping)
 
std::size_t size () const
 
void clear ()
 

Protected Attributes

Vector< TFrom > from
 
Vector< TTo > to
 

Private Member Functions

template<typename U >
void update (Vector< U > &target, const UnorderedMap< U, U > &mapping)
 

Constructor & Destructor Documentation

◆ SurjectiveMapping()

template<typename TFrom , typename TTo = TFrom>
dna::SurjectiveMapping< TFrom, TTo >::SurjectiveMapping ( MemoryResource memRes)
inlineexplicit
28 :
29 from{memRes},
30 to{memRes} {
31 }
Vector< TFrom > from
Definition: dna/SurjectiveMapping.h:96
Vector< TTo > to
Definition: dna/SurjectiveMapping.h:97

Member Function Documentation

◆ add()

template<typename TFrom , typename TTo = TFrom>
void dna::SurjectiveMapping< TFrom, TTo >::add ( TFrom  from_,
TTo  to_ 
)
inline
38 {
39 from.push_back(from_);
40 to.push_back(to_);
41 }

References dna::SurjectiveMapping< TFrom, TTo >::from, and dna::SurjectiveMapping< TFrom, TTo >::to.

◆ clear()

template<typename TFrom , typename TTo = TFrom>
void dna::SurjectiveMapping< TFrom, TTo >::clear ( )
inline

◆ get()

template<typename TFrom , typename TTo = TFrom>
Pair dna::SurjectiveMapping< TFrom, TTo >::get ( std::size_t  index) const
inline
33 {
34 assert(index < size());
35 return {from[index], to[index]};
36 }
std::size_t size() const
Definition: dna/SurjectiveMapping.h:77

References dna::SurjectiveMapping< TFrom, TTo >::from, dna::SurjectiveMapping< TFrom, TTo >::size(), and dna::SurjectiveMapping< TFrom, TTo >::to.

◆ removeIf()

template<typename TFrom , typename TTo = TFrom>
void dna::SurjectiveMapping< TFrom, TTo >::removeIf ( std::function< bool(const TFrom &, const TTo &)>  predicate)
inline
52 {
53 assert(from.size() == to.size());
54
55 auto itFrom = from.begin();
56 auto itTo = to.begin();
57
58 while (itFrom != from.end()) {
59 if (predicate(*itFrom, *itTo)) {
60 itFrom = from.erase(itFrom);
61 itTo = to.erase(itTo);
62 } else {
63 ++itFrom;
64 ++itTo;
65 }
66 }
67 }

References dna::SurjectiveMapping< TFrom, TTo >::from, and dna::SurjectiveMapping< TFrom, TTo >::to.

Referenced by dna::BlendShapeFilter::apply(), dna::MeshFilter::apply(), dnac::BlendShapeFilter::apply(), and dnac::MeshFilter::apply().

◆ set()

template<typename TFrom , typename TTo = TFrom>
void dna::SurjectiveMapping< TFrom, TTo >::set ( std::size_t  index,
TFrom  from_,
TTo  to_ 
)
inline
43 {
44 if (index >= size()) {
45 from.resize(index + 1ul);
46 to.resize(index + 1ul);
47 }
48 from[index] = from_;
49 to[index] = to_;
50 }

References dna::SurjectiveMapping< TFrom, TTo >::from, dna::SurjectiveMapping< TFrom, TTo >::size(), and dna::SurjectiveMapping< TFrom, TTo >::to.

◆ size()

template<typename TFrom , typename TTo = TFrom>
std::size_t dna::SurjectiveMapping< TFrom, TTo >::size ( ) const
inline

◆ update()

template<typename TFrom , typename TTo = TFrom>
template<typename U >
void dna::SurjectiveMapping< TFrom, TTo >::update ( Vector< U > &  target,
const UnorderedMap< U, U > &  mapping 
)
inlineprivate
89 {
90 std::transform(target.begin(), target.end(), target.begin(), [&mapping](U oldValue) {
91 return mapping.at(oldValue);
92 });
93 }

Referenced by dna::SurjectiveMapping< TFrom, TTo >::updateFrom(), and dna::SurjectiveMapping< TFrom, TTo >::updateTo().

◆ updateFrom()

template<typename TFrom , typename TTo = TFrom>
void dna::SurjectiveMapping< TFrom, TTo >::updateFrom ( const UnorderedMap< TFrom, TFrom > &  mapping)
inline
69 {
70 update(from, mapping);
71 }
void update(Vector< U > &target, const UnorderedMap< U, U > &mapping)
Definition: dna/SurjectiveMapping.h:89

References dna::SurjectiveMapping< TFrom, TTo >::from, and dna::SurjectiveMapping< TFrom, TTo >::update().

Referenced by dna::MeshFilter::apply(), and dnac::MeshFilter::apply().

◆ updateTo()

template<typename TFrom , typename TTo = TFrom>
void dna::SurjectiveMapping< TFrom, TTo >::updateTo ( const UnorderedMap< TTo, TTo > &  mapping)
inline

Member Data Documentation

◆ from

template<typename TFrom , typename TTo = TFrom>
Vector<TFrom> dna::SurjectiveMapping< TFrom, TTo >::from
protected

◆ to

template<typename TFrom , typename TTo = TFrom>
Vector<TTo> dna::SurjectiveMapping< TFrom, TTo >::to
protected

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