| 74 | } |
| 75 | |
| 76 | Expected<Mesh> preprocessMesh( const Mesh& inputMesh, const ToolPathParams& params, bool needToDecimate ) |
| 77 | { |
| 78 | Mesh meshCopy = inputMesh; |
| 79 | |
| 80 | if ( !params.flatTool ) |
| 81 | { |
| 82 | OffsetParameters offsetParams; |
| 83 | offsetParams.signDetectionMode = SignDetectionMode::Unsigned; |
| 84 | offsetParams.voxelSize = params.voxelSize; |
| 85 | offsetParams.callBack = subprogress( params.cb, 0.0f, 0.15f ); |
| 86 | const auto offsetRes = offsetMesh( inputMesh, params.millRadius, offsetParams ); |
| 87 | if ( !offsetRes ) |
| 88 | return unexpected( offsetRes.error() ); |
| 89 | |
| 90 | meshCopy = *offsetRes; |
| 91 | } |
| 92 | |
| 93 | if ( params.xf ) |
| 94 | meshCopy.transform( *params.xf ); |
| 95 | |
| 96 | if ( !reportProgress( params.cb, 0.15f ) ) |
| 97 | return unexpectedOperationCanceled(); |
| 98 | |
| 99 | if ( auto e = FixUndercuts::fix( meshCopy, { .findParameters = {.upDirection = Vector3f::plusZ()},.voxelSize = params.voxelSize } ); !e ) |
| 100 | return unexpected( std::move( e.error() ) ); |
| 101 | |
| 102 | if ( !reportProgress( params.cb, 0.20f ) ) |
| 103 | return unexpectedOperationCanceled(); |
| 104 | |
| 105 | if ( needToDecimate ) |
| 106 | { |
| 107 | const auto decimateResult = decimateMesh( meshCopy, { .progressCallback = subprogress( params.cb, 0.20f, 0.25f ) } ); |
| 108 | if ( decimateResult.cancelled ) |
| 109 | return unexpectedOperationCanceled(); |
| 110 | } |
| 111 | |
| 112 | return meshCopy; |
| 113 | } |
| 114 | |
| 115 | // compute surface path between given edge points |
| 116 | void addSurfacePath( std::vector<GCommand>& gcode, const Mesh& mesh, const MeshEdgePoint& start, const MeshEdgePoint& end ) |
no test coverage detected