|
KiCad PCB EDA Suite
|
#include <boost/test/unit_test.hpp>#include <limits>#include <vector>#include <geometry/shape_poly_set.h>#include <geometry/shape_compound.h>#include <geometry/shape_segment.h>#include <geometry/shape_rect.h>Go to the source code of this file.
Functions | |
| BOOST_AUTO_TEST_CASE (FirstColdCollideBuildsTheIndex) | |
| A cold Collide() must come back indexed. | |
| BOOST_AUTO_TEST_CASE (TriPointersSurviveMove) | |
| The contract the index must not break: DRC_RTREE stores raw TRI pointers, so a geometry Move() must translate the triangles in place, never replace them. | |
| BOOST_AUTO_TEST_CASE (CompoundNearMissNotPruned) | |
| The prune box must be BBox() inflated by the clearance, not BBox( aClearance ): SHAPE_COMPOUND::BBox() ignores its argument, so the latter silently drops near-miss triangles. | |
| BOOST_AUTO_TEST_CASE (MinDistanceMatchesFullScan) | |
| Minimum distances must match the full scan even at awkward positions: probes equidistant to adjacent triangles, plus one at exactly the clearance distance to pin the inclusive/exclusive box-overlap boundary. | |
| BOOST_AUTO_TEST_CASE (SubThresholdPolygonMatchesFullScan) | |
| Every other case here uses a blob big enough to index, so the un-indexed branch of the walk never runs. | |
| BOOST_AUTO_TEST_CASE (CheckIndexDropped) | |
| The set-level invariant this design rests on: every SHAPE_POLY_SET operation that rebuilds, discards or moves the triangles drops the set's index, so a live index can never describe stale geometry. | |
| BOOST_AUTO_TEST_CASE | ( | CheckIndexDropped | ) |
The set-level invariant this design rests on: every SHAPE_POLY_SET operation that rebuilds, discards or moves the triangles drops the set's index, so a live index can never describe stale geometry.
(With one tree per set, TRIANGULATED_POLYGON's own mutators can no longer self-guard – this is the trade-off of the combined-tree design.)
Each mutation with reachable geometry is checked twice over: the mechanism (the index is gone immediately afterwards) and the behavior (post-mutation results match the oracle, so a stale index could not hide). The assigned geometry in the copy-assign leg is far from the old, so a stale index could not accidentally agree.
Definition at line 357 of file test_shape_poly_set_triangle_index.cpp.
References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SHAPE_POLY_SET::CacheTriangulation(), delta, SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::TriangulatedPolyCount(), and SHAPE_POLY_SET::TriangulationIndex().
| BOOST_AUTO_TEST_CASE | ( | CompoundNearMissNotPruned | ) |
The prune box must be BBox() inflated by the clearance, not BBox( aClearance ): SHAPE_COMPOUND::BBox() ignores its argument, so the latter silently drops near-miss triangles.
This is the exact falsifier for that bug.
Definition at line 263 of file test_shape_poly_set_triangle_index.cpp.
References SHAPE_COMPOUND::AddShape(), and BOOST_CHECK_EQUAL().
| BOOST_AUTO_TEST_CASE | ( | FirstColdCollideBuildsTheIndex | ) |
A cold Collide() must come back indexed.
MakeBlob() pre-triangulates, so every other case warms the already-valid early-out of cacheTriangulation(); this one starts with no cached triangulation at all, so the lazy build has to run on the fresh-triangulation exit too.
Definition at line 205 of file test_shape_poly_set_triangle_index.cpp.
References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), BOOST_AUTO_TEST_CASE(), BOOST_REQUIRE(), SHAPE_POLY_SET::Collide(), SHAPE_POLY_SET::TriangulatedPolyCount(), and SHAPE_POLY_SET::TriangulationIndex().
| BOOST_AUTO_TEST_CASE | ( | MinDistanceMatchesFullScan | ) |
Minimum distances must match the full scan even at awkward positions: probes equidistant to adjacent triangles, plus one at exactly the clearance distance to pin the inclusive/exclusive box-overlap boundary.
(Which equidistant triangle reports the collision is not pinned – see PROBE_RESULT.)
Definition at line 293 of file test_shape_poly_set_triangle_index.cpp.
References BOOST_CHECK_EQUAL(), and clearance.
| BOOST_AUTO_TEST_CASE | ( | SubThresholdPolygonMatchesFullScan | ) |
Every other case here uses a blob big enough to index, so the un-indexed branch of the walk never runs.
A polygon below the threshold exercises it: results must be identical either way, because whether an index exists is a performance decision, not a semantic one.
Definition at line 319 of file test_shape_poly_set_triangle_index.cpp.
References SHAPE_POLY_SET::AddOutline(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SHAPE_POLY_SET::CacheTriangulation(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::GetTriangleCount(), SHAPE_POLY_SET::TriangulatedPolyCount(), and SHAPE_POLY_SET::TriangulatedPolygon().
| BOOST_AUTO_TEST_CASE | ( | TriPointersSurviveMove | ) |
The contract the index must not break: DRC_RTREE stores raw TRI pointers, so a geometry Move() must translate the triangles in place, never replace them.
Definition at line 224 of file test_shape_poly_set_triangle_index.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), delta, SHAPE_POLY_SET::GetIndexableSubshapes(), SHAPE_POLY_SET::Move(), and moved.