MeshLib
 
Loading...
Searching...
No Matches
MRMapping.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRVector.h"
5
6namespace MR
7{
8
9// oldData - the data that needs to be compared
10// newToOld - how to compare indexes
11// for greater optimality, it is worth making a resize for newData in advance
12template<typename ValueT, typename IndexT>
14 const Vector<ValueT, Id<IndexT>>& oldData,
15 const Vector<Id<IndexT>, Id<IndexT>>& newToOld,
16 Vector<ValueT, Id<IndexT>>& newData )
17{
18 for ( Id<IndexT> newId( 0 ); newId < newToOld.size(); ++newId )
19 if ( auto oldId = newToOld[newId] )
20 newData.autoResizeSet( newId, oldData[oldId] );
21}
22
23// oldData - the data that needs to be compared
24// newToOld - how to compare indexes
25// for greater optimality, it is worth making a resize for newData in advance
26template<typename ValueT, typename IndexT>
28 const Vector<ValueT, Id<IndexT>>& oldData,
29 const Vector<Id<IndexT>, Id<IndexT>>& newToOld,
30 Vector<ValueT, Id<IndexT>>& newData )
31{
32 for ( Id<IndexT> oldId( 0 ); oldId < newToOld.size(); ++oldId )
33 if ( auto newId = newToOld[oldId] )
34 newData.autoResizeSet( newId, oldData[oldId] );
35}
36
37}
Definition MRMesh/MRId.h:13
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
Definition MRCameraOrientationPlugin.h:8
void mapNewToOldVector(const Vector< ValueT, Id< IndexT > > &oldData, const Vector< Id< IndexT >, Id< IndexT > > &newToOld, Vector< ValueT, Id< IndexT > > &newData)
Definition MRMapping.h:13
void mapOldToNewVector(const Vector< ValueT, Id< IndexT > > &oldData, const Vector< Id< IndexT >, Id< IndexT > > &newToOld, Vector< ValueT, Id< IndexT > > &newData)
Definition MRMapping.h:27