MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / getClosestEdge

Function getClosestEdge

source/MRMesh/MRMeshMath.cpp:88–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88UndirectedEdgeId getClosestEdge( const MeshTopology & topology, const VertCoords & points, const PointOnFace & p )
89{
90 EdgeId e = topology.edgeWithLeft( p.face );
91 Vector3f a, b, c;
92 getLeftTriPoints( topology, points, e, a, b, c );
93
94 auto distSq = [&]( const LineSegm3f & l )
95 {
96 return ( p.point - closestPointOnLineSegm( p.point, l ) ).lengthSq();
97 };
98
99 UndirectedEdgeId res = e.undirected();
100 float closestDistSq = distSq( { a, b } );
101
102 e = topology.prev( e.sym() );
103 if ( auto eDistSq = distSq( { b, c } ); eDistSq < closestDistSq )
104 {
105 res = e.undirected();
106 closestDistSq = eDistSq;
107 }
108
109 e = topology.prev( e.sym() );
110 if ( auto eDistSq = distSq( { c, a } ); eDistSq < closestDistSq )
111 {
112 res = e.undirected();
113 closestDistSq = eDistSq;
114 }
115
116 return res;
117}
118
119Vector3f triCenter( const MeshTopology & topology, const VertCoords & points, FaceId f )
120{

Callers

nothing calls this directly

Calls 7

closestPointOnLineSegmFunction · 0.85
edgeWithLeftMethod · 0.80
undirectedMethod · 0.80
getLeftTriPointsFunction · 0.70
lengthSqMethod · 0.45
prevMethod · 0.45
symMethod · 0.45

Tested by

no test coverage detected