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

Function interpolateArcs

source/MRVoxels/MRToolPath.cpp:1490–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1488}
1489
1490Expected<void> interpolateArcs( std::vector<GCommand>& commands, const ArcInterpolationParams& params, Axis axis )
1491{
1492 const ArcPlane arcPlane = ( axis == Axis::X ) ? ArcPlane::YZ :
1493 ( axis == Axis::Y ) ? ArcPlane::XZ :
1494 ArcPlane::XY;
1495
1496 commands.insert( commands.begin(), { .arcPlane = arcPlane } );
1497 size_t startIndex = 1u;
1498
1499 for ( int i = 0; startIndex < commands.size(); ++i )
1500 {
1501 if ( ( i & 0x3FF ) && !reportProgress( params.cb, float( startIndex ) / commands.size() ) )
1502 return unexpectedOperationCanceled();
1503
1504 while ( startIndex != commands.size() && ( commands[startIndex].type != MoveType::Linear || std::isnan( coord( commands[startIndex], axis ) ) ) )
1505 ++startIndex;
1506
1507 if ( ++startIndex >= commands.size() )
1508 return {};
1509
1510 auto endIndex = startIndex + 1;
1511 while ( endIndex != commands.size() && std::isnan( coord( commands[endIndex], axis ) ) )
1512 ++endIndex;
1513
1514 const size_t segmentSize = endIndex - startIndex;
1515 const auto interpolatedSegment = replaceLineSegmentsWithCircularArcs( std::span<GCommand>( &commands[startIndex], segmentSize ), params.eps, params.maxRadius, axis );
1516 if ( interpolatedSegment.empty() )
1517 {
1518 startIndex = endIndex;
1519 continue;
1520 }
1521
1522 if ( interpolatedSegment.size() != segmentSize )
1523 {
1524 commands.erase( commands.begin() + startIndex + 1, commands.begin() + endIndex );
1525 commands.insert( commands.begin() + startIndex + 1, interpolatedSegment.begin(), interpolatedSegment.end() );
1526 }
1527
1528 startIndex = startIndex + interpolatedSegment.size() + 1;
1529 }
1530
1531 if ( !reportProgress( params.cb, 1.0f ) )
1532 return unexpectedOperationCanceled();
1533
1534 return {};
1535}
1536
1537std::shared_ptr<ObjectGcode> exportToolPathToGCode( const std::vector<GCommand>& commands )
1538{

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected