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

Function preprocessMesh

source/MRVoxels/MRToolPath.cpp:76–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76Expected<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
116void addSurfacePath( std::vector<GCommand>& gcode, const Mesh& mesh, const MeshEdgePoint& start, const MeshEdgePoint& end )

Callers 3

lacingToolPathFunction · 0.85
constantZToolPathFunction · 0.85
constantCuspToolPathFunction · 0.85

Calls 9

subprogressFunction · 0.85
offsetMeshFunction · 0.85
reportProgressFunction · 0.85
decimateMeshFunction · 0.85
errorMethod · 0.80
fixFunction · 0.70
unexpectedFunction · 0.50
transformMethod · 0.45

Tested by

no test coverage detected