MeshLib C++ Docs
Loading...
Searching...
No Matches
MRProjectionMeshAttribute.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRAffineXf.h"
5#include "MRMatrix3.h"
6#include "MRMesh.h"
8#include "MRMeshProject.h"
10
11namespace MR
12{
13
20
23template<typename F>
24bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
25
28template<typename F>
29bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
30
40 const ObjectMeshData& oldMeshData, ObjectMeshData& newMeshData, const FaceBitSet* region = nullptr,
41 const ProjectAttributeParams& params = {} );
42
43template<typename F>
44bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
45{
46 return BitSetParallelFor( mp.mesh.topology.getVertIds( mp.region ), [&] ( VertId id )
47 {
48 auto point = !params.xfs.rigidXfPoint ? mp.mesh.points[id] : ( *params.xfs.rigidXfPoint )( mp.mesh.points[id] );
49 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
50 auto res = projectionResult.mtp;
51 VertId v1 = oldMesh.topology.org( res.e );
52 VertId v2 = oldMesh.topology.dest( res.e );
53 VertId v3 = oldMesh.topology.dest( oldMesh.topology.next( res.e ) );
54 func( id, projectionResult, v1, v2, v3 );
55 },
56 params.progressCb );
57}
58
59template<typename F>
60bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
61{
62 return BitSetParallelFor( mp.mesh.topology.getFaceIds( mp.region ), [&] ( FaceId newFaceId )
63 {
64 auto point = !params.xfs.rigidXfPoint ? mp.mesh.triCenter( newFaceId ) : ( *params.xfs.rigidXfPoint )( mp.mesh.triCenter( newFaceId ) );
65 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
66 func( newFaceId, projectionResult );
67 },
68 params.progressCb );
69}
70
71}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
auto BitSetParallelFor(const BS &bs, F &&f, Cb &&... cb)
Definition MRBitSetParallelFor.h:191
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:732
Definition MRCameraOrientationPlugin.h:8
struct MRMESH_CLASS Mesh
Definition MRMesh/MRMeshFwd.h:617
tl::expected< T, E > Expected
Definition MRExpected.h:28
MRMESH_API Expected< void > projectObjectMeshData(const ObjectMeshData &oldMeshData, ObjectMeshData &newMeshData, const FaceBitSet *region=nullptr, const ProjectAttributeParams &params={})
finds attributes of new mesh by projecting faces/vertices on old mesh
bool projectVertAttribute(const MeshVertPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:44
bool projectFaceAttribute(const MeshPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:60
Definition MRMesh/MRMeshProject.h:34
Definition MRMesh/MRMesh.h:23
mesh and its per-element attributes for ObjectMeshHolder
Definition MRObjectMeshData.h:14
this structure contains transformation for projection from one mesh to another and progress callback
Definition MRProjectionMeshAttribute.h:16
MeshProjectionTransforms xfs
Definition MRProjectionMeshAttribute.h:17
ProgressCallback progressCb
Definition MRProjectionMeshAttribute.h:18