WIP Reworking of "ensure vertical wall thickness".

1) Flipped the order of "discover_vertical_shells" and "process_external_surfaces",
   now the external surfaces are expanded after "discover_vertical_shells"
   aka "ensure vertical wall thickness" is solved.
2) Reworked LayerRegion::process_external_surfaces() to only expand into
   "ensure vertical wall thickness" regions, also the expansion is done
   in small steps to avoid overflowing into neighbor regions.

also:
Utility functions reserve_more(), reserve_power_of_2(), reserve_more_power_of_2()
Various SurfaceCollecion::filter_xxx() modified to accept an initializer list of surface types.
New bridges detector refactored to accept overhang boundaries.
BoundingBoxWrapper was moved from RetractCrossingPerimeters to AABBTreeIndirect.
This commit is contained in:
Vojtech Bubnik 2023-01-02 13:19:27 +01:00
parent fb85baf889
commit fde0d68c40
12 changed files with 841 additions and 308 deletions

View file

@ -251,4 +251,34 @@ SCENARIO("Region expansion basics", "[RegionExpansion]") {
}
}
}
GIVEN("square with hole, hole edge anchored") {
Polygon outer{ { -1 * ten, -1 * ten }, { 2 * ten, -1 * ten }, { 2 * ten, 2 * ten }, { -1 * ten, 2 * ten } };
Polygon hole { { 0, ten }, { ten, ten }, { ten, 0 }, { 0, 0 } };
Polygon anchor{ { 0, 0 }, { ten, 0 }, { ten, ten }, { 0, ten } };
ExPolygon boundary(outer);
boundary.holes = { hole };
WHEN("expanded") {
static constexpr const float expansion = scaled<float>(5.);
std::vector<Polygons> expanded = Algorithm::expand_expolygons({ ExPolygon{anchor} }, { boundary },
expansion,
scaled<float>(0.4), // expansion step
15); // max num steps
#if 0
SVG::export_expolygons(DEBUG_TEMP_DIR "square_with_hole_anchored-out.svg",
{ { { { ExPolygon{anchor} } }, { "anchor", "orange", 0.5f } },
{ { { boundary } }, { "boundary", "blue", 0.5f } },
{ { union_ex(expanded.front()) }, { "expanded", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif
THEN("The anchor expands into a single region with a hole") {
REQUIRE(expanded.size() == 1);
REQUIRE(expanded.front().size() == 2);
}
THEN("The area of anchor is correct") {
double area_calculated = area(expanded.front());
double area_expected = double(expansion) * 4. * double(ten) + M_PI * sqr(expansion);
REQUIRE(is_approx(area_expected, area_calculated, sqr(scaled<double>(0.6))));
}
}
}
}