MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / TEST

Function TEST

source/MRTest/MRPolylineDecimateTests.cpp:9–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7{
8
9TEST( MRMesh, DecimatePolyline )
10{
11 std::vector< Contour2f> testContours;
12 // rhombus
13 Contour2f contRhombus;
14 contRhombus.push_back( Vector2f( 0.f, 0.f ) );
15 contRhombus.push_back( Vector2f( 1.f, 1.f ) );
16 contRhombus.push_back( Vector2f( 2.f, 1.f ) );
17 contRhombus.push_back( Vector2f( 2.f, 0.f ) );
18 contRhombus.push_back( Vector2f( 0.f, 0.f ) );
19 testContours.push_back( contRhombus );
20
21 // square
22 Contour2f contSquare;
23 contRhombus.push_back( Vector2f( 0.f, 0.f ) );
24 contRhombus.push_back( Vector2f( 0.f, 1.f ) );
25 contRhombus.push_back( Vector2f( 1.f, 1.f ) );
26 contRhombus.push_back( Vector2f( 1.f, 0.f ) );
27 testContours.push_back( contRhombus );
28
29 // square with self-intersections
30 Contour2f contSquareSelfIntersected;
31 contSquareSelfIntersected.push_back( Vector2f( 0.f, 0.f ) );
32 contSquareSelfIntersected.push_back( Vector2f( 1.f, 1.f ) );
33 contSquareSelfIntersected.push_back( Vector2f( 0.f, 1.f ) );
34 contSquareSelfIntersected.push_back( Vector2f( 1.f, 0.f ) );
35 contSquareSelfIntersected.push_back( Vector2f( 0.f, 0.f ) );
36 testContours.push_back( contSquareSelfIntersected );
37
38 // simple small line
39 Contour2f smallLine;
40 smallLine.push_back( Vector2f( 0.f, 0.f ) );
41 smallLine.push_back( Vector2f( 1.f, 1.f ) );
42 smallLine.push_back( Vector2f( 2.f, 2.f ) );
43 testContours.push_back( smallLine );
44
45 // arc
46 Contour2f contArc;
47 contArc.push_back( Vector2f( -2.f, 0.f ) );
48 contArc.push_back( Vector2f( -1.f, 1.f ) );
49 contArc.push_back( Vector2f( 0.f, 1.5f ) );
50 contArc.push_back( Vector2f( 1.f, 1.f ) );
51 contArc.push_back( Vector2f( 2.f, 0.f ) );
52 testContours.push_back( contArc );
53
54 for( auto& cont : testContours )
55 {
56 DecimatePolylineSettings2 settings;
57 settings.maxDeletedVertices = 3;
58 settings.maxError = 100.f;
59 settings.touchBdVertices = false;
60
61 MR::Polyline2 pl( { cont } );
62 auto plBack = pl;
63 auto decRes = decimatePolyline( pl, settings );
64
65 int validLines = 0;
66 for ( UndirectedEdgeId ue{0}; ue < pl.topology.undirectedEdgeSize(); ++ue )

Callers

nothing calls this directly

Calls 4

decimatePolylineFunction · 0.85
push_backMethod · 0.80
undirectedEdgeSizeMethod · 0.45
isLoneEdgeMethod · 0.45

Tested by

no test coverage detected