mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 14:05:57 +08:00
medial axis optimisation
This commit is contained in:
parent
6e49c80f01
commit
64937e2380
@ -20,6 +20,19 @@ namespace Slic3r {
|
|||||||
void
|
void
|
||||||
MedialAxis::build(Polylines &polylines)
|
MedialAxis::build(Polylines &polylines)
|
||||||
{
|
{
|
||||||
|
//TODO: special case for triangles
|
||||||
|
// take the longest edge
|
||||||
|
// take the opposite vertex and get the otho dist
|
||||||
|
// move the longest edge by X% that dist (depends on angle? from 1/2 to 1/4? or always 1/3?) use move dist as width
|
||||||
|
// clip it and then enlarge it into anchor
|
||||||
|
// note: ensure that if anchor is over only one edge, it's not the one choosen.
|
||||||
|
|
||||||
|
//TODO: special case for quasi-rectangle
|
||||||
|
// take longest (not-anchor if any) edge
|
||||||
|
// get mid-dist for each adjascent edge
|
||||||
|
// use these point to get the line, with the mid-dist as widths.
|
||||||
|
// enlarge it into anchor
|
||||||
|
|
||||||
ThickPolylines tp;
|
ThickPolylines tp;
|
||||||
this->build(tp);
|
this->build(tp);
|
||||||
polylines.insert(polylines.end(), tp.begin(), tp.end());
|
polylines.insert(polylines.end(), tp.begin(), tp.end());
|
||||||
@ -215,15 +228,20 @@ MedialAxis::validate_edge(const VD::edge_type* edge, Lines &lines, std::map<cons
|
|||||||
if (!this->expolygon.contains(line.a)) return false;
|
if (!this->expolygon.contains(line.a)) return false;
|
||||||
} else {
|
} else {
|
||||||
//test if (!expolygon.contains(line))
|
//test if (!expolygon.contains(line))
|
||||||
Polylines external_bits = diff_pl(Polylines{ Polyline{ line.a, line.b } }, expolygon);
|
//this if isn't perfect (the middle of the line may still be out of the polygon)
|
||||||
if (!external_bits.empty()){
|
//but this edge-case shouldn't occur anyway, by the way the voronoi is built.
|
||||||
//check if the bits that are not inside are under epsilon length
|
if (!expolygon.contains(line.a) || !expolygon.contains(line.b)) { //this if reduced diff_pl from 25% to 18% cpu usage
|
||||||
coordf_t max_length = 0;
|
//this line can count for 25% of slicing time, if not enclosed in if
|
||||||
for (Polyline &poly : external_bits){
|
Polylines external_bits = diff_pl(Polylines{ Polyline{ line.a, line.b } }, expolygon);
|
||||||
max_length = std::max(max_length, poly.length());
|
if (!external_bits.empty()) {
|
||||||
|
//check if the bits that are not inside are under epsilon length
|
||||||
|
coordf_t max_length = 0;
|
||||||
|
for (Polyline& poly : external_bits) {
|
||||||
|
max_length = std::max(max_length, poly.length());
|
||||||
|
}
|
||||||
|
if (max_length > SCALED_EPSILON)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (max_length > SCALED_EPSILON)
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user