38 auto preCollapse = [&] ( EdgeId edgeToCollapse,
const Vector3f& newEdgeOrgPos )
40 const auto org = mesh.
topology.
org( edgeToCollapse );
42 const auto orgPos = mesh.
orgPnt( edgeToCollapse );
43 const auto destPos = mesh.
destPnt( edgeToCollapse );
45 const auto ab = destPos - orgPos;
46 const auto dt =
dot( newEdgeOrgPos - orgPos, ab );
47 const auto abLengthSq = ab.lengthSq();
53 if ( dt >= abLengthSq )
55 data[org] = data[dest];
59 const auto ratio = dt / abLengthSq;
60 data[org] = ( 1 - ratio ) * data[org] + ratio * data[dest];
#define MRMESH_API
Definition MRMeshFwd.h:85
Vector<T> is indexed by size_t.
Definition MRVector.h:24
PreCollapseCallback meshPreCollapseVertAttribute(const Mesh &mesh, const MeshAttributesToUpdate ¶ms)
auto dot(const Matrix2< T > &a, const Matrix2< T > &b) -> decltype(dot(a.x, b.x))
double-dot product: x = a : b
Definition MRMatrix2.h:142
VertId dest(EdgeId he) const
returns destination vertex of half-edge
Definition MRMeshTopology.h:112
VertId org(EdgeId he) const
returns origin vertex of half-edge
Definition MRMeshTopology.h:109
std::function< bool(EdgeId edgeToCollapse, const Vector3f &newEdgeOrgPos)> PreCollapseCallback
Definition MRMeshFwd.h:596
auto preCollapseVertAttribute(const Mesh &mesh, Vector< T, VertId > &data)
Definition MRMeshDecimateCallbacks.h:36
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
the attribute data of the mesh that needs to be updated
Definition MRMeshAttributesToUpdate.h:13
Vector3f orgPnt(EdgeId e) const
returns coordinates of the edge origin
Definition MRMesh.h:72
Vector3f destPnt(EdgeId e) const
returns coordinates of the edge destination
Definition MRMesh.h:75
MeshTopology topology
Definition MRMesh.h:25