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

Function smoothSelection

source/MRVoxels/MRToolPath.cpp:1691–1775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1689}
1690
1691FaceBitSet smoothSelection( Mesh& mesh, const FaceBitSet& region, float expandOffset, float shrinkOffset )
1692{
1693 auto innerVerts = getIncidentVerts( mesh.topology, region );
1694 auto dists = computeSurfaceDistances( mesh, innerVerts );
1695 BitSetParallelFor( getInnerVerts( mesh.topology, region ), [&] ( VertId v )
1696 {
1697 dists[v] = -dists[v];
1698 } );
1699
1700 auto isolines = extractIsolines( mesh.topology, dists, expandOffset );
1701
1702 HashMap<VertId, float> startVerticesWithDists;
1703 const auto components = MeshComponents::getAllComponentsVertsSeparatedByPaths( mesh, isolines );
1704 VertBitSet extendedVerts;
1705 for ( const auto& component : components )
1706 {
1707 if ( component.intersects( innerVerts ) )
1708 extendedVerts |= component;
1709 }
1710
1711 for ( const auto& isoline : isolines )
1712 {
1713 Polyline3 polyline;
1714 polyline.addFromSurfacePath( mesh, isoline );
1715
1716 for ( const auto& ep : isoline )
1717 {
1718 const VertId org = mesh.topology.org( ep.e );
1719 const VertId dest = mesh.topology.dest( ep.e );
1720
1721 if ( ep.inVertex() )
1722 {
1723 startVerticesWithDists.insert_or_assign( org, 0.0f );
1724 continue;
1725 }
1726
1727 auto proj = findProjectionOnPolyline( mesh.points[org], polyline );
1728 startVerticesWithDists.insert_or_assign( org, sqrt( proj.distSq ) );
1729
1730 proj = findProjectionOnPolyline( mesh.points[dest], polyline );
1731 startVerticesWithDists.insert_or_assign( dest, sqrt( proj.distSq ) );
1732 }
1733 }
1734
1735 dists = computeSurfaceDistances( mesh, startVerticesWithDists );
1736
1737 BitSetParallelFor( extendedVerts, [&] ( VertId v )
1738 {
1739 dists[v] = -dists[v];
1740 } );
1741
1742 isolines = extractIsolines( mesh.topology, dists, shrinkOffset );
1743
1744 FaceBitSet res;
1745
1746 const auto origMesh = mesh;
1747
1748 const auto meshContours = convertSurfacePathsToMeshContours( mesh, isolines );

Callers 1

constantCuspToolPathFunction · 0.85

Calls 15

getIncidentVertsFunction · 0.85
computeSurfaceDistancesFunction · 0.85
BitSetParallelForFunction · 0.85
getInnerVertsFunction · 0.85
extractIsolinesFunction · 0.85
findProjectionOnPolylineFunction · 0.85
cutMeshFunction · 0.85
edgeCurvMetricFunction · 0.85
addFromSurfacePathMethod · 0.80

Tested by

no test coverage detected