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

Function interpolateLines

source/MRVoxels/MRToolPath.cpp:1649–1689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1647}
1648
1649Expected<void> interpolateLines( std::vector<GCommand>& commands, const LineInterpolationParams& params, Axis axis )
1650{
1651 size_t startIndex = 0u;
1652
1653 for ( int i = 0; startIndex < commands.size(); ++i )
1654 {
1655 if ( ( i & 0x3FF ) && !reportProgress( params.cb, float( startIndex ) / commands.size() ) )
1656 return unexpectedOperationCanceled();
1657
1658 while ( startIndex != commands.size() && ( commands[startIndex].type != MoveType::Linear || std::isnan( coord( commands[startIndex], axis ) ) ) )
1659 ++startIndex;
1660
1661 if ( ++startIndex >= commands.size() )
1662 return {};
1663
1664 auto endIndex = startIndex + 1;
1665 while ( endIndex != commands.size() && std::isnan( coord( commands[endIndex], axis ) ) && commands[endIndex].type == MoveType::Linear )
1666 ++endIndex;
1667
1668 const size_t segmentSize = endIndex - startIndex;
1669 const auto interpolatedSegment = replaceStraightSegmentsWithOneLine( std::span<GCommand>( &commands[startIndex], segmentSize ), params.eps, params.maxLength, axis );
1670 if ( interpolatedSegment.empty() )
1671 {
1672 startIndex = endIndex;
1673 continue;
1674 }
1675
1676 if ( interpolatedSegment.size() != segmentSize )
1677 {
1678 commands.erase( commands.begin() + startIndex + 1, commands.begin() + endIndex );
1679 commands.insert( commands.begin() + startIndex + 1, interpolatedSegment.begin(), interpolatedSegment.end() );
1680 }
1681
1682 startIndex = startIndex + interpolatedSegment.size() + 1;
1683 }
1684
1685 if ( !reportProgress( params.cb, 1.0f ) )
1686 return unexpectedOperationCanceled();
1687
1688 return {};
1689}
1690
1691FaceBitSet smoothSelection( Mesh& mesh, const FaceBitSet& region, float expandOffset, float shrinkOffset )
1692{

Callers

nothing calls this directly

Calls 10

reportProgressFunction · 0.85
coordFunction · 0.85
eraseMethod · 0.80
insertMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected