MeshLib
 
Loading...
Searching...
No Matches
MRProjectionMeshAttribute.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh.h"
5#include "MRMeshProject.h"
7
8namespace MR
9{
10
11// projecting the vertex attributes of the old onto the new one
12// returns false if canceled by progress bar
13template<typename F>
14bool projectVertAttribute( const Mesh& newMesh, const Mesh& oldMesh, F&& func, ProgressCallback progressCb );
15
16// projecting the face attributes of the old onto the new one
17// returns false if canceled by progress bar
18template<typename F>
19bool projectFaceAttribute( const Mesh& newMesh, const Mesh& oldMesh, F&& func, ProgressCallback progressCb );
20
21
22template<typename F>
23bool projectVertAttribute( const Mesh& newMesh, const Mesh& oldMesh, F&& func, ProgressCallback progressCb )
24{
25 return BitSetParallelFor( newMesh.topology.getValidVerts(), [&] ( VertId id )
26 {
27 auto projectionResult = findProjection( newMesh.points[id], oldMesh );
28 auto res = projectionResult.mtp;
29 VertId v1 = oldMesh.topology.org( res.e );
30 VertId v2 = oldMesh.topology.dest( res.e );
31 VertId v3 = oldMesh.topology.dest( oldMesh.topology.next( res.e ) );
32 func( id, projectionResult, v1, v2, v3 );
33 },
34 progressCb );
35}
36
37template<typename F>
38bool projectFaceAttribute( const Mesh& newMesh, const Mesh& oldMesh, F&& func, ProgressCallback progressCb )
39{
40 return BitSetParallelFor( newMesh.topology.getValidFaces(), [&] ( FaceId newFaceId )
41 {
42 auto projectionResult = findProjection( newMesh.triCenter( newFaceId ), oldMesh );
43 func( newFaceId, projectionResult );
44 },
45 progressCb );
46}
47
48}
int VertId
Definition MRDotNet/MRMeshFwd.h:51
int FaceId
Definition MRDotNet/MRMeshFwd.h:53
const VertBitSet & getValidVerts() const
returns cached set of all valid vertices
Definition MRMesh/MRMeshTopology.h:190
const FaceBitSet & getValidFaces() const
returns cached set of all valid faces
Definition MRMesh/MRMeshTopology.h:256
represents a mesh, including topology (connectivity) information and point coordinates,
Definition MRDotNet/MRMesh.h:30
auto BitSetParallelFor(const BS &bs, F &&f, Cb &&... cb)
Definition MRBitSetParallelFor.h:189
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:571
Definition MRCameraOrientationPlugin.h:8
bool projectFaceAttribute(const Mesh &newMesh, const Mesh &oldMesh, F &&func, ProgressCallback progressCb)
Definition MRProjectionMeshAttribute.h:38
bool projectVertAttribute(const Mesh &newMesh, const Mesh &oldMesh, F &&func, ProgressCallback progressCb)
Definition MRProjectionMeshAttribute.h:23
Definition MRMesh/MRMesh.h:23
MeshTopology topology
Definition MRMesh/MRMesh.h:24