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{
15
16
23
26template<typename F>
27bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
28
31template<typename F>
32bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params = {} );
33
42[[nodiscard]] MRMESH_API Expected<void> projectObjectMeshData(
43 const ObjectMeshData& oldMeshData, ObjectMeshData& newMeshData, const FaceBitSet* region = nullptr,
44 const ProjectAttributeParams& params = {} );
45
46template<typename F>
47bool projectVertAttribute( const MeshVertPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
48{
49 return BitSetParallelFor( mp.mesh.topology.getVertIds( mp.region ), [&] ( VertId id )
50 {
51 auto point = !params.xfs.rigidXfPoint ? mp.mesh.points[id] : ( *params.xfs.rigidXfPoint )( mp.mesh.points[id] );
52 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
53 auto res = projectionResult.mtp;
54 VertId v1 = oldMesh.topology.org( res.e );
55 VertId v2 = oldMesh.topology.dest( res.e );
56 VertId v3 = oldMesh.topology.dest( oldMesh.topology.next( res.e ) );
57 func( id, projectionResult, v1, v2, v3 );
58 },
59 params.progressCb );
60}
61
62template<typename F>
63bool projectFaceAttribute( const MeshPart& mp, const Mesh& oldMesh, F&& func, const ProjectAttributeParams& params )
64{
65 return BitSetParallelFor( mp.mesh.topology.getFaceIds( mp.region ), [&] ( FaceId newFaceId )
66 {
67 auto point = !params.xfs.rigidXfPoint ? mp.mesh.triCenter( newFaceId ) : ( *params.xfs.rigidXfPoint )( mp.mesh.triCenter( newFaceId ) );
68 auto projectionResult = findProjection( point, oldMesh, FLT_MAX, params.xfs.nonRigidXfTree );
69 func( newFaceId, projectionResult );
70 },
71 params.progressCb );
72}
73
74}
auto BitSetParallelFor(const BS &bs, F &&f, Cb &&... cb)
Definition MRBitSetParallelFor.h:154
MeshProjectionTransforms xfs
Definition MRProjectionMeshAttribute.h:20
tl::expected< T, E > Expected
Definition MRExpected.h:31
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:47
ProgressCallback progressCb
Definition MRProjectionMeshAttribute.h:21
bool projectFaceAttribute(const MeshPart &mp, const Mesh &oldMesh, F &&func, const ProjectAttributeParams &params={})
Definition MRProjectionMeshAttribute.h:63
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshProject.h:34
Definition MRMesh.h:23
mesh and its per-element attributes for ObjectMeshHolder
Definition MRObjectMeshData.h:17
this structure contains transformation for projection from one mesh to another and progress callback
Definition MRProjectionMeshAttribute.h:19