rename resolution_factor to min_step_clipper
This commit is contained in:
committed by
Kacper Donat
parent
c5db88b8c6
commit
ccce111ea5
@@ -1590,7 +1590,7 @@ double Adaptive2d::CalcCutArea(
|
||||
maxFi += 2 * std::numbers::pi;
|
||||
}
|
||||
|
||||
if (preventConventional && interPathLen >= RESOLUTION_FACTOR) {
|
||||
if (preventConventional && interPathLen >= MIN_STEP_CLIPPER) {
|
||||
// detect conventional mode cut - we want only climb mode
|
||||
IntPoint midPoint(
|
||||
long(c2.X + toolRadiusScaled * cos(0.5 * (maxFi + minFi))),
|
||||
@@ -1608,7 +1608,7 @@ double Adaptive2d::CalcCutArea(
|
||||
|
||||
double scanDistance = 2.5 * toolRadiusScaled;
|
||||
// stepping through path discretized to stepDistance
|
||||
double stepDistance = min(double(RESOLUTION_FACTOR), interPathLen / 24) + 1;
|
||||
double stepDistance = min(double(MIN_STEP_CLIPPER), interPathLen / 24) + 1;
|
||||
const IntPoint* prevPt = &interPath->front();
|
||||
double distance = 0;
|
||||
for (size_t j = 1; j < ipc2_size; j++) {
|
||||
@@ -1762,29 +1762,16 @@ std::list<AdaptiveOutput> Adaptive2d::Execute(
|
||||
//**********************************
|
||||
|
||||
// keep the tolerance in workable range
|
||||
if (tolerance < 0.01) {
|
||||
tolerance = 0.01;
|
||||
}
|
||||
if (tolerance > 0.2) {
|
||||
tolerance = 0.2;
|
||||
}
|
||||
tolerance = max(tolerance, 0.01);
|
||||
tolerance = min(tolerance, 1.0);
|
||||
|
||||
scaleFactor = RESOLUTION_FACTOR / tolerance;
|
||||
long maxScaleFactor = toolDiameter < 1.0 ? 10000 : 1000;
|
||||
|
||||
if (stepOverFactor * toolDiameter < 1.0) {
|
||||
scaleFactor *= 1.0 / (stepOverFactor * toolDiameter);
|
||||
}
|
||||
|
||||
|
||||
if (scaleFactor > maxScaleFactor) {
|
||||
scaleFactor = maxScaleFactor;
|
||||
}
|
||||
// scaleFactor = round(scaleFactor);
|
||||
// 1/"tolerance" = number of min-size adaptive steps per stepover
|
||||
scaleFactor = MIN_STEP_CLIPPER / tolerance / (stepOverFactor * toolDiameter);
|
||||
|
||||
current_region = 0;
|
||||
cout << "Tool Diameter: " << toolDiameter << endl;
|
||||
cout << "Accuracy: " << round(10000.0 / scaleFactor) / 10 << " um" << endl;
|
||||
cout << "Min step size: " << round(MIN_STEP_CLIPPER / scaleFactor * 1000 * 10) / 10 << " um"
|
||||
<< endl;
|
||||
cout << flush;
|
||||
|
||||
toolRadiusScaled = long(toolDiameter * scaleFactor / 2);
|
||||
@@ -1932,8 +1919,8 @@ std::list<AdaptiveOutput> Adaptive2d::Execute(
|
||||
|
||||
if (opType == OperationType::otProfilingInside || opType == OperationType::otProfilingOutside) {
|
||||
double offset = opType == OperationType::otProfilingInside
|
||||
? -2 * (helixRampRadiusScaled + toolRadiusScaled) - RESOLUTION_FACTOR
|
||||
: 2 * (helixRampRadiusScaled + toolRadiusScaled) + RESOLUTION_FACTOR;
|
||||
? -2 * (helixRampRadiusScaled + toolRadiusScaled) - MIN_STEP_CLIPPER
|
||||
: 2 * (helixRampRadiusScaled + toolRadiusScaled) + MIN_STEP_CLIPPER;
|
||||
for (const auto& current : inputPaths) {
|
||||
int nesting = getPathNestingLevel(current, inputPaths);
|
||||
if (nesting % 2 != 0 && (polyTreeNestingLimit == 0 || nesting <= polyTreeNestingLimit)) {
|
||||
@@ -2010,7 +1997,7 @@ bool Adaptive2d::FindEntryPoint(
|
||||
for (int iter = 0; iter < 10; iter++) {
|
||||
clipof.Clear();
|
||||
clipof.AddPaths(checkPaths, JoinType::jtSquare, EndType::etClosedPolygon);
|
||||
double step = RESOLUTION_FACTOR;
|
||||
double step = MIN_STEP_CLIPPER;
|
||||
double currentDelta = -1;
|
||||
clipof.Execute(incOffset, currentDelta);
|
||||
while (!incOffset.empty()) {
|
||||
@@ -2196,7 +2183,7 @@ bool Adaptive2d::IsAllowedToCutTrough(
|
||||
else {
|
||||
Clipper clip;
|
||||
double distance = sqrt(DistanceSqrd(p1, p2));
|
||||
double stepSize = min(0.5 * stepOverScaled, 8 * RESOLUTION_FACTOR);
|
||||
double stepSize = min(0.5 * stepOverScaled, 8 * MIN_STEP_CLIPPER);
|
||||
if (distance < stepSize / 2) { // not significant cut
|
||||
Perf_IsAllowedToCutTrough.Stop();
|
||||
return true;
|
||||
@@ -2246,7 +2233,7 @@ bool Adaptive2d::ResolveLinkPath(
|
||||
double directDistance = sqrt(DistanceSqrd(startPoint, endPoint));
|
||||
Paths linkPaths;
|
||||
|
||||
double scanStep = 2 * RESOLUTION_FACTOR;
|
||||
double scanStep = 2 * MIN_STEP_CLIPPER;
|
||||
if (scanStep > scaleFactor * 0.1) {
|
||||
scanStep = scaleFactor * 0.1;
|
||||
}
|
||||
@@ -2431,8 +2418,8 @@ bool Adaptive2d::MakeLeadPath(
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
if (IsAllowedToCutTrough(
|
||||
IntPoint(
|
||||
currentPoint.X + RESOLUTION_FACTOR * nextDir.X,
|
||||
currentPoint.Y + RESOLUTION_FACTOR * nextDir.Y
|
||||
currentPoint.X + MIN_STEP_CLIPPER * nextDir.X,
|
||||
currentPoint.Y + MIN_STEP_CLIPPER * nextDir.Y
|
||||
),
|
||||
nextPoint,
|
||||
clearedArea,
|
||||
@@ -2853,14 +2840,14 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths)
|
||||
Perf_ProcessPolyNode.Stop();
|
||||
return;
|
||||
}
|
||||
fout << "Helix entry " << entryPoint << endl;
|
||||
fout << "Helix entry " << entryPoint << "\n";
|
||||
}
|
||||
|
||||
EngagePoint engage(engageBounds); // engage point stepping instance
|
||||
|
||||
if (outsideEntry) {
|
||||
engage.moveToClosestPoint(toolPos, 2 * RESOLUTION_FACTOR);
|
||||
engage.moveForward(RESOLUTION_FACTOR);
|
||||
engage.moveToClosestPoint(toolPos, 2 * MIN_STEP_CLIPPER);
|
||||
engage.moveForward(MIN_STEP_CLIPPER);
|
||||
toolPos = engage.getCurrentPoint();
|
||||
toolDir = engage.getCurrentDir();
|
||||
entryPoint = toolPos;
|
||||
@@ -2874,7 +2861,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths)
|
||||
output.HelixCenterPoint.first = double(entryPoint.X) / scaleFactor;
|
||||
output.HelixCenterPoint.second = double(entryPoint.Y) / scaleFactor;
|
||||
|
||||
long stepScaled = long(RESOLUTION_FACTOR);
|
||||
long stepScaled = long(MIN_STEP_CLIPPER);
|
||||
IntPoint engagePoint;
|
||||
|
||||
IntPoint newToolPos;
|
||||
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
void ApplyStockToLeave(Paths& inputPaths);
|
||||
|
||||
private: // constants for fine tuning
|
||||
const double RESOLUTION_FACTOR = 16.0;
|
||||
const double MIN_STEP_CLIPPER = 16.0;
|
||||
const int MAX_ITERATIONS = 10;
|
||||
const double AREA_ERROR_FACTOR = 0.05; /* how precise to match the cut area to optimal,
|
||||
reasonable value: 0.05 = 5%*/
|
||||
|
||||
Reference in New Issue
Block a user