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

Function computeGeodesicPathApprox

source/MRMesh/MRSurfacePath.cpp:346–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346Expected<SurfacePath, PathError> computeGeodesicPathApprox( const Mesh & mesh,
347 const MeshTriPoint & start, const MeshTriPoint & end, GeodesicPathApprox atype )
348{
349 MR_TIMER;
350 if ( atype == GeodesicPathApprox::FastMarching )
351 return computeFastMarchingPath( mesh, start, end );
352
353 SurfacePath res;
354 if ( !fromSameTriangle( mesh.topology, MeshTriPoint{ start }, MeshTriPoint{ end } ) )
355 {
356 VertId v1, v2;
357 EdgePath edgePath = ( atype == GeodesicPathApprox::DijkstraBiDir ) ?
358 buildShortestPathBiDir( mesh, start, end, &v1, &v2 ) :
359 buildShortestPathAStar( mesh, start, end, &v1, &v2 );
360 if ( !v1 || !v2 )
361 return unexpected( PathError::StartEndNotConnected );
362
363 // remove last segment from the path if end-point and the origin of last segment belong to one triangle
364 while( !edgePath.empty()
365 && fromSameTriangle( mesh.topology, MeshTriPoint{ end }, MeshTriPoint{ MeshEdgePoint{ edgePath.back(), 0 } } ) )
366 {
367 v2 = mesh.topology.org( edgePath.back() );
368 edgePath.pop_back();
369 }
370
371 // remove first segment from the path if start-point and the destination of first segment belong to one triangle
372 while( !edgePath.empty()
373 && fromSameTriangle( mesh.topology, MeshTriPoint{ start }, MeshTriPoint{ MeshEdgePoint{ edgePath.front(), 1 } } ) )
374 {
375 v1 = mesh.topology.dest( edgePath.front() );
376 edgePath.erase( edgePath.begin() );
377 }
378
379 if ( edgePath.empty() )
380 {
381 assert ( v1 == v2 );
382 res = { MeshEdgePoint( mesh.topology.edgeWithOrg( v1 ), 0.0f ) };
383 }
384 else
385 {
386 res.reserve( edgePath.size() + 1 );
387 for ( EdgeId e : edgePath )
388 res.emplace_back( e, 0.0f );
389 res.emplace_back( edgePath.back(), 1.0f );
390 }
391 }
392 return res;
393}
394
395SurfacePath computeSteepestDescentPath( const MeshPart & mp, const VertScalars & field,
396 const MeshTriPoint & start, const ComputeSteepestDescentPathSettings & settings )

Callers 1

computeGeodesicPathFunction · 0.85

Calls 14

computeFastMarchingPathFunction · 0.85
buildShortestPathBiDirFunction · 0.85
buildShortestPathAStarFunction · 0.85
pop_backMethod · 0.80
eraseMethod · 0.80
fromSameTriangleFunction · 0.70
unexpectedFunction · 0.70
emptyMethod · 0.45
orgMethod · 0.45
destMethod · 0.45
beginMethod · 0.45
edgeWithOrgMethod · 0.45

Tested by

no test coverage detected