| 1535 | } |
| 1536 | |
| 1537 | std::shared_ptr<ObjectGcode> exportToolPathToGCode( const std::vector<GCommand>& commands ) |
| 1538 | { |
| 1539 | auto gcodeSource = std::make_shared<std::vector<std::string>>(); |
| 1540 | |
| 1541 | for ( const auto& command : commands ) |
| 1542 | { |
| 1543 | std::ostringstream gcode; |
| 1544 | gcode << "G"; |
| 1545 | gcode << ( ( command.arcPlane != ArcPlane::None ) ? int( command.arcPlane ) : int( command.type ) ); |
| 1546 | |
| 1547 | if ( !std::isnan( command.x ) ) |
| 1548 | gcode << " X" << command.x; |
| 1549 | |
| 1550 | if ( !std::isnan( command.y ) ) |
| 1551 | gcode << " Y" << command.y; |
| 1552 | |
| 1553 | if ( !std::isnan( command.z ) ) |
| 1554 | gcode << " Z" << command.z; |
| 1555 | |
| 1556 | if ( !std::isnan( command.arcCenter.x ) ) |
| 1557 | gcode << " I" << command.arcCenter.x; |
| 1558 | |
| 1559 | if ( !std::isnan( command.arcCenter.y ) ) |
| 1560 | gcode << " J" << command.arcCenter.y; |
| 1561 | |
| 1562 | if ( !std::isnan( command.arcCenter.z ) ) |
| 1563 | gcode << " K" << command.arcCenter.z; |
| 1564 | |
| 1565 | if ( !std::isnan( command.feed ) ) |
| 1566 | gcode << " F" << command.feed; |
| 1567 | |
| 1568 | gcode << std::endl; |
| 1569 | gcodeSource->push_back( gcode.str() ); |
| 1570 | } |
| 1571 | |
| 1572 | auto res = std::make_shared<ObjectGcode>(); |
| 1573 | res->setGcodeSource( gcodeSource ); |
| 1574 | res->setName( "Tool Path" ); |
| 1575 | res->setLineWidth( 1.0f ); |
| 1576 | return res; |
| 1577 | } |
| 1578 | |
| 1579 | float distSqrToLineSegment( const MR::Vector2f p, const MR::Vector2f& seg0, const MR::Vector2f& seg1 ) |
| 1580 | { |
nothing calls this directly
no test coverage detected