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

Method getXYDerivativeMaps

source/MRMesh/MRDistanceMap.cpp:1104–1150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1102}
1103
1104std::pair< DistanceMap, DistanceMap > DistanceMap::getXYDerivativeMaps() const
1105{
1106 auto res = std::make_pair( DistanceMap( resX(), resY() ), DistanceMap( resX(), resY() ) );
1107 DistanceMap& dx = res.first;
1108 DistanceMap& dy = res.second;
1109 if ( resX() < 3 || resY() < 3 )
1110 {
1111 return res;
1112 }
1113
1114 ParallelFor( 1, (int)resY() - 1, [&] ( int y )
1115 {
1116 for ( auto x = 1; x < resX() - 1; ++x )
1117 {
1118 const auto val = get( x, y );
1119 if ( !val )
1120 continue;
1121
1122 const auto valxpos = get( x + 1, y );
1123 const auto valxneg = get( x - 1, y );
1124 if ( valxpos )
1125 if ( valxneg )
1126 dx.set( x, y, ( ( *valxpos ) - ( *valxneg ) ) / 2.f );
1127 else
1128 dx.set( x, y, ( *valxpos ) - ( *val ) );
1129 else
1130 if ( valxneg )
1131 dx.set( x, y, ( *val ) - ( *valxneg ) );
1132 else
1133 dx.unset( x, y );
1134
1135 const auto valypos = get( x, y + 1 );
1136 const auto valyneg = get( x, y - 1 );
1137 if ( valypos )
1138 if ( valyneg )
1139 dy.set( x, y, ( ( *valypos ) - ( *valyneg ) ) / 2.f );
1140 else
1141 dy.set( x, y, ( *valypos ) - ( *val ) );
1142 else
1143 if ( valyneg )
1144 dy.set( x, y, ( *val ) - ( *valyneg ) );
1145 else
1146 dy.unset( x, y );
1147 }
1148 } );
1149 return res;
1150}
1151
1152DistanceMap combineXYderivativeMaps( std::pair<DistanceMap, DistanceMap> XYderivativeMaps )
1153{

Callers

nothing calls this directly

Calls 5

DistanceMapClass · 0.85
ParallelForFunction · 0.85
unsetMethod · 0.80
getFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected