@@ -303,8 +303,9 @@ std::optional<MeshEdgePoint> SurfacePathBuilder::findPrevPoint( const MeshTriPoi
303303 return res;
304304}
305305
306- tl::expected<std::vector<MeshEdgePoint>, PathError> computeSurfacePath ( const MeshPart & mp,
307- const MeshTriPoint & start, const MeshTriPoint & end, int numPostProcessIters, const VertBitSet* vertRegion )
306+ tl::expected<std::vector<MeshEdgePoint>, PathError> computeSurfacePath ( const MeshPart & mp,
307+ const MeshTriPoint & start, const MeshTriPoint & end, int numPostProcessIters,
308+ const VertBitSet* vertRegion, Vector<float , VertId> * outSurfaceDistances )
308309{
309310 MR_TIMER;
310311 std::vector<MeshEdgePoint> res;
@@ -325,7 +326,7 @@ tl::expected<std::vector<MeshEdgePoint>, PathError> computeSurfacePath( const Me
325326
326327 // build distances from end to start, so to get correct path in reverse order
327328 bool connected = false ;
328- const auto distances = computeSurfaceDistances ( mp.mesh , end, start, vertRegion, &connected );
329+ auto distances = computeSurfaceDistances ( mp.mesh , end, start, vertRegion, &connected );
329330 if ( !connected )
330331 return tl::make_unexpected ( PathError::StartEndNotConnected );
331332
@@ -345,14 +346,17 @@ tl::expected<std::vector<MeshEdgePoint>, PathError> computeSurfacePath( const Me
345346 assert ( !res.empty () );
346347 reducePath ( mp.mesh , start, res, end, numPostProcessIters );
347348
349+ if ( outSurfaceDistances )
350+ *outSurfaceDistances = std::move ( distances );
348351 return res;
349352}
350353
351354HashMap<VertId, VertId> computeClosestSurfacePathTargets ( const Mesh & mesh,
352- const VertBitSet & starts, const VertBitSet & ends, const VertBitSet * vertRegion )
355+ const VertBitSet & starts, const VertBitSet & ends,
356+ const VertBitSet * vertRegion, Vector<float , VertId> * outSurfaceDistances )
353357{
354358 MR_TIMER;
355- const auto distances = computeSurfaceDistances ( mesh, ends, starts, FLT_MAX, vertRegion );
359+ auto distances = computeSurfaceDistances ( mesh, ends, starts, FLT_MAX, vertRegion );
356360
357361 HashMap<VertId, VertId> res;
358362 res.reserve ( starts.count () );
@@ -384,6 +388,8 @@ HashMap<VertId, VertId> computeClosestSurfacePathTargets( const Mesh & mesh,
384388 res[v] = last->getClosestVertex ( mesh.topology );
385389 } );
386390
391+ if ( outSurfaceDistances )
392+ *outSurfaceDistances = std::move ( distances );
387393 return res;
388394}
389395
0 commit comments