33 auto preCollapse = [&] ( EdgeId edgeToCollapse,
const Vector3f& newEdgeOrgPos )
35 const auto org = mesh.
topology.
org( edgeToCollapse );
37 const auto orgPos = mesh.
orgPnt( edgeToCollapse );
38 const auto destPos = mesh.
destPnt( edgeToCollapse );
40 const auto ab = destPos - orgPos;
41 const auto dt = dot( newEdgeOrgPos - orgPos, ab );
42 const auto abLengthSq = ab.lengthSq();
48 if ( dt >= abLengthSq )
50 data[org] = data[dest];
54 const auto ratio = dt / abLengthSq;
55 data[org] = ( 1 - ratio ) * data[org] + ratio * data[dest];
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
VertId dest(EdgeId he) const
returns destination vertex of half-edge
Definition MRMesh/MRMeshTopology.h:89
VertId org(EdgeId he) const
returns origin vertex of half-edge
Definition MRMesh/MRMeshTopology.h:86
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
Definition MRCameraOrientationPlugin.h:8
struct MRMESH_CLASS Mesh
Definition MRMesh/MRMeshFwd.h:475
MRMESH_API PreCollapseCallback meshPreCollapseVertAttribute(const Mesh &mesh, const MeshAttributesToUpdate ¶ms)
std::function< bool(EdgeId edgeToCollapse, const Vector3f &newEdgeOrgPos)> PreCollapseCallback
Definition MRMesh/MRMeshFwd.h:427
auto preCollapseVertAttribute(const Mesh &mesh, Vector< T, VertId > &data)
Definition MRMeshDecimateCallbacks.h:31
Definition MRMeshAttributesToUpdate.h:10
Definition MRMesh/MRMesh.h:23
Vector3f orgPnt(EdgeId e) const
returns coordinates of the edge origin
Definition MRMesh/MRMesh.h:62
Vector3f destPnt(EdgeId e) const
returns coordinates of the edge destination
Definition MRMesh/MRMesh.h:65
MeshTopology topology
Definition MRMesh/MRMesh.h:24