Merge branch 'not_useful' into temp_master

This commit is contained in:
supermerill 2018-07-26 13:04:22 +02:00
commit b840abe73c
3 changed files with 9 additions and 3 deletions

View File

@ -115,6 +115,7 @@ bool BridgeDetector::detect_angle(double bridge_direction_override)
}
double total_length = 0;
uint32_t nbLines = 0;
double max_length = 0;
{
Lines clipped_lines = intersection_ln(lines, clip_area);
@ -125,10 +126,11 @@ bool BridgeDetector::detect_angle(double bridge_direction_override)
double len = line.length();
total_length += len;
max_length = std::max(max_length, len);
nbLines++;
}
}
}
if (total_length == 0.)
if (total_length == 0. || nbLines == 0)
continue;
have_coverage = true;
@ -139,6 +141,7 @@ bool BridgeDetector::detect_angle(double bridge_direction_override)
// $directions_coverage{$angle} = sum(map $_->area, @{$self->coverage($angle)}) // 0;
// max length of bridged lines
candidates[i_angle].max_length = max_length;
candidates[i_angle].mean_length = total_length / nbLines;
}
// if no direction produced coverage, then there's no bridge direction
@ -149,10 +152,12 @@ bool BridgeDetector::detect_angle(double bridge_direction_override)
std::sort(candidates.begin(), candidates.end());
// if any other direction is within extrusion width of coverage, prefer it if shorter
// shorter = shorter max length, or if in espilon (10) range, the shorter mean length.
// TODO: There are two options here - within width of the angle with most coverage, or within width of the currently perferred?
size_t i_best = 0;
for (size_t i = 1; i < candidates.size() && candidates[i_best].coverage - candidates[i].coverage < this->spacing; ++ i)
if (candidates[i].max_length < candidates[i_best].max_length)
if (candidates[i].max_length < candidates[i_best].max_length ||
(candidates[i].max_length < candidates[i_best].max_length - 10 && candidates[i].mean_length < candidates[i_best].mean_length))
i_best = i;
this->angle = candidates[i_best].angle;

View File

@ -53,6 +53,7 @@ private:
double angle;
double coverage;
double max_length;
double mean_length;
};
public:
// Get possible briging direction candidates.

View File

@ -14,7 +14,7 @@ public:
virtual Fill* clone() const { return new FillGyroid(*this); }
// require bridge flow since most of this pattern hangs in air
virtual bool use_bridge_flow() const { return true; }
virtual bool use_bridge_flow() const { return false; }
protected:
virtual void _fill_surface_single(