| 183 | } |
| 184 | |
| 185 | Expected<Mesh> distanceMapToMesh( const DistanceMap& distMap, const AffineXf3f& toWorld, ProgressCallback cb ) |
| 186 | { |
| 187 | auto resX = distMap.resX(); |
| 188 | auto resY = distMap.resY(); |
| 189 | |
| 190 | if (resX < 2 || resY < 2) |
| 191 | { |
| 192 | return unexpected( "Cannot create mesh from degenerated 1x1 distance map." ); |
| 193 | } |
| 194 | |
| 195 | return makeRegularGridMesh( resX, resY, [&]( size_t x, size_t y ) |
| 196 | { |
| 197 | return distMap.isValid( x, y ); |
| 198 | }, |
| 199 | [&]( size_t x, size_t y ) |
| 200 | { |
| 201 | return distMap.unproject( x, y, toWorld ).value_or( Vector3f{} ); |
| 202 | }, {}, cb ); |
| 203 | } |
| 204 | |
| 205 | MRMESH_API Image convertDistanceMapToImage( const DistanceMap& dm, float threshold ) |
| 206 | { |