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

Function findSeparationPoint

source/MRMesh/MRDistanceMap.cpp:588–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586};
587
588SeparationPoint findSeparationPoint( const DistanceMap& dm, const Vector2i& p, NeighborDir dir, float isoValue )
589{
590 const auto v0 = dm.getValue( p.x, p.y );
591 auto p1 = p;
592 p1[int( dir )]++;
593 if ( p1.x >= dm.resX() || p1.y >= dm.resY() )
594 return {};
595 const auto v1 = dm.getValue( p1.x, p1.y );
596 if ( v0 == DistanceMap::NOT_VALID_VALUE || v1 == DistanceMap::NOT_VALID_VALUE )
597 return {};
598 const bool low0 = v0 < isoValue;
599 const bool low1 = v1 < isoValue;
600 if ( low0 == low1 )
601 return {};
602
603 const float ratio = std::abs( isoValue - v0 ) / std::abs( v1 - v0 );
604 SeparationPoint res;
605 res.position = ( 1.0f - ratio ) * Vector2f( p ) +
606 ratio * Vector2f( p1 ) + Vector2f::diagonal( 0.5f );
607 res.vid =0_v;// real number now is not important, only that it is valid
608 return res;
609}
610
611}
612

Callers 1

Calls 5

absFunction · 0.85
diagonalFunction · 0.85
resXMethod · 0.80
resYMethod · 0.80
getValueMethod · 0.45

Tested by

no test coverage detected