MeshLib C++ Docs
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
16
17// projecting the vertex attributes of the old onto the new one
18// returns false if canceled by progress bar
19template<typename F>
20bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
21
22// projecting the face attributes of the old onto the new one
23// returns false if canceled by progress bar
24template<typename F>
25bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
26
27
28template<typename F>
29bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
30{
31 return BitSetParallelFor( mp.mesh.topology.getVertIds( mp.region ), [&] ( VertId id )
32 {
33 auto point = !params.xfs.rigidXfPoint ? mp.mesh.points[id] : ( *params.xfs.rigidXfPoint )( mp.mesh.points[id] );
34 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
35 auto res = projectionResult.mtp;
36 VertId v1 = oldMesh.topology.org( res.e );
37 VertId v2 = oldMesh.topology.dest( res.e );
38 VertId v3 = oldMesh.topology.dest( oldMesh.topology.next( res.e ) );
39 func( id, projectionResult, v1, v2, v3 );
40 },
41 params.progressCb );
42}
43
44template<typename F>
45bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
46{
47 return BitSetParallelFor( mp.mesh.topology.getFaceIds( mp.region ), [&] ( FaceId newFaceId )
48 {
49 auto point = !params.xfs.rigidXfPoint ? mp.mesh.triCenter( newFaceId ) : ( *params.xfs.rigidXfPoint )( mp.mesh.triCenter( newFaceId ) );
50 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
51 func( newFaceId, projectionResult );
52 },
53 params.progressCb );
54}
55
56}
auto BitSetParallelFor(const BS &bs, F &&f, Cb &&... cb)
Definition MRBitSetParallelFor.h:189
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
struct MRMESH_CLASS Mesh
Definition MRMesh/MRMeshFwd.h:520
bool projectVertAttribute(const MeshVertPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:29
bool projectFaceAttribute(const MeshPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:45
Definition MRMesh/MRMeshProject.h:28
Definition MRMesh/MRMesh.h:23
Definition MRProjectionMeshAttribute.h:12
MeshProjectionTransforms xfs
Definition MRProjectionMeshAttribute.h:13
ProgressCallback progressCb
Definition MRProjectionMeshAttribute.h:14