KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_poly_triangulation.cpp File Reference
#include <geometry/shape_poly_set.h>
#include <geometry/shape_line_chain.h>
#include <geometry/polygon_triangulation.h>
#include <trigo.h>
#include <thread>
#include <chrono>
#include <future>
#include <filesystem>
#include <fstream>
#include <qa_utils/geometry/geometry.h>
#include <qa_utils/numeric.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include "geom_test_utils.h"

Go to the source code of this file.

Classes

struct  POLYGON_TRIANGULATION_TEST_ACCESS
 
class  TRIANGULATION_TEST_FIXTURE
 

Functions

SHAPE_LINE_CHAIN createSquare (int size=100, VECTOR2I offset=VECTOR2I(0, 0))
 
SHAPE_LINE_CHAIN createTriangle (int size=100, VECTOR2I offset=VECTOR2I(0, 0))
 
SHAPE_LINE_CHAIN createConcavePolygon (int size=100)
 
SHAPE_LINE_CHAIN createSerpentinePolygon (int step=20000, int teeth=16)
 
bool validateTriangulation (const SHAPE_POLY_SET::TRIANGULATED_POLYGON &result, const SHAPE_LINE_CHAIN &original, bool strict=true)
 
int countSpikeyTriangles (const SHAPE_POLY_SET::TRIANGULATED_POLYGON &aResult)
 
bool parsePolyFileForTest (const fs::path &aPath, std::vector< SHAPE_POLY_SET > &aZones)
 
double computeBoardSpikeyRatio (const fs::path &aPath)
 
 BOOST_AUTO_TEST_CASE (BasicTriangleTriangulation)
 
 BOOST_AUTO_TEST_CASE (BasicSquareTriangulation)
 
 BOOST_AUTO_TEST_CASE (SplitFirstFracturePartitionProducesMultipleLeaves)
 
 BOOST_AUTO_TEST_CASE (EarLookaheadImprovesBadTriangulationCase)
 
 BOOST_AUTO_TEST_CASE (ConcavePolygonTriangulation)
 
 BOOST_AUTO_TEST_CASE (HintDataOptimization)
 
 BOOST_AUTO_TEST_CASE (HintDataOptimizationWithSimplifiedInput)
 
 BOOST_AUTO_TEST_CASE (HintDataInvalidation)
 
 BOOST_AUTO_TEST_CASE (DegeneratePolygons)
 
 BOOST_AUTO_TEST_CASE (ZeroAreaPolygon)
 
 BOOST_AUTO_TEST_CASE (MemoryManagement)
 
 BOOST_AUTO_TEST_CASE (LargePolygonStressTest)
 
 BOOST_AUTO_TEST_CASE (ConcurrentTriangulation)
 
 BOOST_AUTO_TEST_CASE (SelfIntersectingPolygon)
 
 BOOST_AUTO_TEST_CASE (Issue18083_SelfIntersectingPolygonArea)
 Test case for GitLab issue #18083: Self-intersecting filled shape is not completely filled.
 
 BOOST_AUTO_TEST_CASE (NearlyCollinearVertices)
 
 BOOST_AUTO_TEST_CASE (DuplicateVertices)
 
 BOOST_AUTO_TEST_CASE (ExtremeCoordinates)
 
 BOOST_AUTO_TEST_CASE (ErrorRecoveryAndCleanup)
 
 BOOST_AUTO_TEST_CASE (TriangulatedPolygonInterface)
 
 BOOST_AUTO_TEST_CASE (SourceOutlineIndexTracking)
 
 BOOST_AUTO_TEST_CASE (PerformanceRegression)
 
 BOOST_AUTO_TEST_CASE (ParallelPartitionTriangulation)
 Verify that the parallel partition triangulation path produces correct results by registering a task submitter that uses std::async and triangulating a polygon large enough to trigger balanced partitioning (>50K vertices produces 4 leaves).
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/23]

◆ BOOST_AUTO_TEST_CASE() [2/23]

◆ BOOST_AUTO_TEST_CASE() [3/23]

◆ BOOST_AUTO_TEST_CASE() [4/23]

◆ BOOST_AUTO_TEST_CASE() [5/23]

◆ BOOST_AUTO_TEST_CASE() [6/23]

◆ BOOST_AUTO_TEST_CASE() [7/23]

BOOST_AUTO_TEST_CASE ( EarLookaheadImprovesBadTriangulationCase )

Definition at line 309 of file test_poly_triangulation.cpp.

References BOOST_TEST(), and computeBoardSpikeyRatio().

◆ BOOST_AUTO_TEST_CASE() [8/23]

◆ BOOST_AUTO_TEST_CASE() [9/23]

◆ BOOST_AUTO_TEST_CASE() [10/23]

◆ BOOST_AUTO_TEST_CASE() [11/23]

◆ BOOST_AUTO_TEST_CASE() [12/23]

◆ BOOST_AUTO_TEST_CASE() [13/23]

BOOST_AUTO_TEST_CASE ( Issue18083_SelfIntersectingPolygonArea )

Test case for GitLab issue #18083: Self-intersecting filled shape is not completely filled.

A self-touching polygon where one vertex lies on a non-adjacent edge creates a "pinch point". The polygon appears to form a figure-8 shape that should be fully filled on both sides.

The polygon from the issue has points: (165,87), (179,87), (174,94), (169,87), (167,94) where vertex (169,87) lies on the segment from (165,87) to (179,87).

This test verifies that the triangulation correctly fills both regions of the self-touching polygon by checking that the total triangulated area equals the sum of both triangular lobes.

Definition at line 656 of file test_poly_triangulation.cpp.

References std::abs(), SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), BOOST_TEST(), SHAPE_POLY_SET::CacheTriangulation(), SHAPE_POLY_SET::IsSelfIntersecting(), SHAPE_POLY_SET::IsTriangulationUpToDate(), SHAPE_LINE_CHAIN::SetClosed(), SHAPE_POLY_SET::TriangulatedPolyCount(), and SHAPE_POLY_SET::TriangulatedPolygon().

◆ BOOST_AUTO_TEST_CASE() [14/23]

◆ BOOST_AUTO_TEST_CASE() [15/23]

◆ BOOST_AUTO_TEST_CASE() [16/23]

◆ BOOST_AUTO_TEST_CASE() [17/23]

BOOST_AUTO_TEST_CASE ( ParallelPartitionTriangulation )

Verify that the parallel partition triangulation path produces correct results by registering a task submitter that uses std::async and triangulating a polygon large enough to trigger balanced partitioning (>50K vertices produces 4 leaves).

Definition at line 908 of file test_poly_triangulation.cpp.

References std::abs(), SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Area(), BOOST_TEST(), SHAPE_POLY_SET::CacheTriangulation(), SHAPE_POLY_SET::IsTriangulationUpToDate(), M_PI, radius, SHAPE_LINE_CHAIN::SetClosed(), SHAPE_POLY_SET::TriangulatedPolyCount(), and SHAPE_POLY_SET::TriangulatedPolygon().

◆ BOOST_AUTO_TEST_CASE() [18/23]

BOOST_AUTO_TEST_CASE ( PerformanceRegression )

◆ BOOST_AUTO_TEST_CASE() [19/23]

◆ BOOST_AUTO_TEST_CASE() [20/23]

BOOST_AUTO_TEST_CASE ( SourceOutlineIndexTracking )

◆ BOOST_AUTO_TEST_CASE() [21/23]

BOOST_AUTO_TEST_CASE ( SplitFirstFracturePartitionProducesMultipleLeaves )

◆ BOOST_AUTO_TEST_CASE() [22/23]

◆ BOOST_AUTO_TEST_CASE() [23/23]

◆ computeBoardSpikeyRatio()

double computeBoardSpikeyRatio ( const fs::path & aPath)

◆ countSpikeyTriangles()

int countSpikeyTriangles ( const SHAPE_POLY_SET::TRIANGULATED_POLYGON & aResult)

◆ createConcavePolygon()

SHAPE_LINE_CHAIN createConcavePolygon ( int size = 100)

Definition at line 85 of file test_poly_triangulation.cpp.

References chain.

Referenced by BOOST_AUTO_TEST_CASE().

◆ createSerpentinePolygon()

SHAPE_LINE_CHAIN createSerpentinePolygon ( int step = 20000,
int teeth = 16 )

Definition at line 98 of file test_poly_triangulation.cpp.

References chain.

Referenced by BOOST_AUTO_TEST_CASE().

◆ createSquare()

◆ createTriangle()

SHAPE_LINE_CHAIN createTriangle ( int size = 100,
VECTOR2I offset = VECTOR2I(0, 0) )

◆ parsePolyFileForTest()

bool parsePolyFileForTest ( const fs::path & aPath,
std::vector< SHAPE_POLY_SET > & aZones )

Definition at line 201 of file test_poly_triangulation.cpp.

References SHAPE_POLY_SET::Parse().

Referenced by computeBoardSpikeyRatio().

◆ validateTriangulation()