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

Function constantCuspToolPath

source/MRVoxels/MRToolPath.cpp:1022–1357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1020}
1021
1022Expected<ToolPathResult> constantCuspToolPath( const MeshPart& mp, const ConstantCuspParams& params )
1023{
1024 ToolPathResult res;
1025
1026 if ( !params.offsetMesh )
1027 {
1028 auto preprocessedMesh = preprocessMesh( mp.mesh, params, false );
1029 if ( !preprocessedMesh )
1030 return unexpected( preprocessedMesh.error() );
1031
1032 res.modifiedMesh = std::move( *preprocessedMesh );
1033 }
1034 else
1035 {
1036 res.modifiedMesh = params.offsetMesh->mesh;
1037 }
1038 const auto box = res.modifiedMesh.computeBoundingBox();
1039
1040 const Vector3f normal = Vector3f::plusZ();
1041 float minZ = box.min.z + params.millRadius;
1042 float safeZ = std::max( box.max.z + params.millRadius, params.safeZ );
1043
1044 const auto undercutPlane = MR::Plane3f::fromDirAndPt( normal, { 0.0f, 0.0f, minZ } );
1045
1046 //compute the lowest contour that might be processed
1047 const auto undercutSection = extractPlaneSections( res.modifiedMesh, undercutPlane ).front();
1048 Polyline3 undercutPolyline;
1049 undercutPolyline.addFromSurfacePath( res.modifiedMesh, undercutSection );
1050 const auto undercutContour = undercutPolyline.contours().front();
1051
1052 // if there are multiple independent zones selected we need to process them separately
1053 const auto processZone = [&] ( const std::vector<SurfacePath>& startSurfacePaths, Vector3f lastPoint, ProgressCallback cb ) -> std::string
1054 {
1055 ExtractIsolinesParams extractionParams
1056 {
1057 .startSurfacePaths = startSurfacePaths,
1058 .startContours = params.startContours,
1059 .startVertices = params.startVertices,
1060 .sectionStep = params.sectionStep,
1061 .bypassDir = params.bypassDir,
1062 .cb = subprogress( cb, 0.0f, 0.4f )
1063 };
1064 //compute isolines based on the start point or the bounding contour
1065 auto extractRes = extractAllIsolines( res.modifiedMesh, extractionParams );
1066 if ( !extractRes.has_value() )
1067 return extractRes.error();
1068
1069 auto& extract = *extractRes;
1070 res.modifiedMesh = extract.meshAfterCut;
1071
1072 if ( !extract.old2NewMap.empty() )
1073 {
1074 const auto oldRegion = res.modifiedRegion;
1075 res.modifiedRegion = extract.region;
1076
1077 BitSetParallelFor( oldRegion, [&] ( FaceId f )
1078 {
1079 for ( auto& newFace : extract.old2NewMap[f] )

Callers

nothing calls this directly

Calls 15

preprocessMeshFunction · 0.85
maxFunction · 0.85
extractPlaneSectionsFunction · 0.85
subprogressFunction · 0.85
extractAllIsolinesFunction · 0.85
BitSetParallelForFunction · 0.85
reportProgressFunction · 0.85
transitOverSafeZFunction · 0.85
computeSurfacePathFunction · 0.85
findInnerShellVertsFunction · 0.85
orgRingFunction · 0.85

Tested by

no test coverage detected