MeshLib C++ Docs
Loading...
Searching...
No Matches
MRProjectionMeshAttribute.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRAffineXf.h"
4#include "MRMesh.h"
6#include "MRMeshProject.h"
8
9namespace MR
10{
11
17
18// projecting the vertex attributes of the old onto the new one
19// returns false if canceled by progress bar
20template<typename F>
21bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
22
23// projecting the face attributes of the old onto the new one
24// returns false if canceled by progress bar
25template<typename F>
26bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
27
28
29template<typename F>
30bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
31{
32 return BitSetParallelFor( mp.mesh.topology.getVertIds( mp.region ), [&] ( VertId id )
33 {
34 auto point = !params.xfs.rigidXfPoint ? mp.mesh.points[id] : ( *params.xfs.rigidXfPoint )( mp.mesh.points[id] );
35 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
36 auto res = projectionResult.mtp;
37 VertId v1 = oldMesh.topology.org( res.e );
38 VertId v2 = oldMesh.topology.dest( res.e );
39 VertId v3 = oldMesh.topology.dest( oldMesh.topology.next( res.e ) );
40 func( id, projectionResult, v1, v2, v3 );
41 },
42 params.progressCb );
43}
44
45template<typename F>
46bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
47{
48 return BitSetParallelFor( mp.mesh.topology.getFaceIds( mp.region ), [&] ( FaceId newFaceId )
49 {
50 auto point = !params.xfs.rigidXfPoint ? mp.mesh.triCenter( newFaceId ) : ( *params.xfs.rigidXfPoint )( mp.mesh.triCenter( newFaceId ) );
51 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
52 func( newFaceId, projectionResult );
53 },
54 params.progressCb );
55}
56
57}
auto BitSetParallelFor(const BS &bs, F &&f, Cb &&... cb)
Definition MRBitSetParallelFor.h:191
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:728
Definition MRCameraOrientationPlugin.h:8
struct MRMESH_CLASS Mesh
Definition MRMesh/MRMeshFwd.h:617
bool projectVertAttribute(const MeshVertPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:30
bool projectFaceAttribute(const MeshPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:46
Definition MRMesh/MRMeshProject.h:34
Definition MRMesh/MRMesh.h:23
Definition MRProjectionMeshAttribute.h:13
MeshProjectionTransforms xfs
Definition MRProjectionMeshAttribute.h:14
ProgressCallback progressCb
Definition MRProjectionMeshAttribute.h:15