medial axis fix: add epsilon offset when trying to see if points are inside a polygon

This commit is contained in:
supermerill 2019-04-15 11:25:07 +02:00
parent 96b0865d87
commit 2e01f1c208

View File

@ -186,7 +186,17 @@ MedialAxis::validate_edge(const VD::edge_type* edge)
// in this case, contains(line) returns a false positive
if (!this->expolygon.contains(line.a)) return false;
} else {
if (!this->expolygon.contains(line)) return false;
//test if (!expolygon.contains(line))
Polylines external_bits = diff_pl(Polylines{ Polyline{ line.a, line.b } }, expolygon);
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;
}
}
// retrieve the original line segments which generated the edge we're checking