MeshLib Documentation
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 MeshVertPart& mp, 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 MeshPart& mp, const Mesh& oldMesh, F&& func, ProgressCallback progressCb );
20
21
22template<typename F>
23bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, ProgressCallback progressCb )
24{
25 return BitSetParallelFor( mp.mesh.topology.getVertIds( mp.region ), [&] ( VertId id )
26 {
27 auto projectionResult = findProjection( mp.mesh.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 MeshPart& mp, const Mesh& oldMesh, F&& func, ProgressCallback progressCb )
39{
40 return BitSetParallelFor( mp.mesh.topology.getFaceIds( mp.region ), [&] ( FaceId newFaceId )
41 {
42 auto projectionResult = findProjection( mp.mesh.triCenter( newFaceId ), oldMesh );
43 func( newFaceId, projectionResult );
44 },
45 progressCb );
46}
47
48}
auto BitSetParallelFor(const BS &bs, F &&f, Cb &&... cb)
Definition MRBitSetParallelFor.h:189
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:576
Definition MRCameraOrientationPlugin.h:8
struct MRMESH_CLASS Mesh
Definition MRMesh/MRMeshFwd.h:475
bool projectFaceAttribute(const MeshPart &mp, const Mesh &oldMesh, F &&func, ProgressCallback progressCb)
Definition MRProjectionMeshAttribute.h:38
bool projectVertAttribute(const MeshVertPart &mp, const Mesh &oldMesh, F &&func, ProgressCallback progressCb)
Definition MRProjectionMeshAttribute.h:23
Definition MRMesh/MRMesh.h:23