Skip to content

Commit b52cb82

Browse files
roystgnrmiaoyinb
authored andcommitted
Unit tests for "tangent" ray/hole intersection
1 parent 890d938 commit b52cb82

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

tests/mesh/mesh_triangulation.C

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public:
5454
// This covers an old poly2tri collinearity-tolerance bug
5555
CPPUNIT_TEST( testPoly2TriHolesExtraRefined );
5656

57-
// This covers a more recent tolerance bug when verifying holes
57+
// These cover more recent tolerance issues when verifying holes
5858
CPPUNIT_TEST( testPoly2TriHolePerturbed );
59+
CPPUNIT_TEST( testPoly2TriHoleTangentPerturbed );
5960

6061
CPPUNIT_TEST( testPoly2TriNonUniformRefined );
6162
CPPUNIT_TEST( testPoly2TriHolesNonUniformRefined );
@@ -68,6 +69,7 @@ public:
6869
CPPUNIT_TEST( testTriangleInterp2 );
6970
CPPUNIT_TEST( testTriangleHoles );
7071
CPPUNIT_TEST( testTriangleHolePerturbed );
72+
CPPUNIT_TEST( testTriangleHoleTangentPerturbed );
7173
CPPUNIT_TEST( testTriangleMeshedHoles );
7274
CPPUNIT_TEST( testTriangleEdges );
7375
CPPUNIT_TEST( testTriangleSegments );
@@ -517,6 +519,65 @@ public:
517519
}
518520

519521

522+
void testTriangulatorHoleTangentPerturbed(MeshBase & mesh,
523+
TriangulatorInterface & triangulator)
524+
{
525+
// Points based on a simplification of a hole verification failure
526+
// case
527+
mesh.add_point(Point(200,0), 0);
528+
mesh.add_point(Point(200,100), 1);
529+
mesh.add_point(Point(100,100), 2);
530+
mesh.add_point(Point(0,100), 3);
531+
mesh.add_point(Point(-100,100), 4);
532+
mesh.add_point(Point(-200,100), 5);
533+
mesh.add_point(Point(-200,0), 6);
534+
mesh.add_point(Point(-200,-100), 7);
535+
mesh.add_point(Point(-100,-100), 8);
536+
mesh.add_point(Point(0,-100), 9);
537+
mesh.add_point(Point(100,-100), 10);
538+
mesh.add_point(Point(200,-100), 11);
539+
540+
commonSettings(triangulator);
541+
542+
// Two diamond holes, in *almost* the center of each half of that
543+
// rectangle
544+
TriangulatorInterface::PolygonHole
545+
left_diamond(Point(-100,4.e-16),
546+
std::sqrt(2)/2, 4),
547+
right_diamond(Point(100,-4.e-16),
548+
std::sqrt(2)/2, 4);
549+
const std::vector<TriangulatorInterface::Hole*> holes
550+
{ &left_diamond, &right_diamond };
551+
triangulator.attach_hole_list(&holes);
552+
553+
triangulator.triangulate();
554+
555+
CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(22));
556+
557+
// Center coordinates for all the elements we expect
558+
const Real r2p200o6 = (std::sqrt(Real(2))+200)/6,
559+
r2p400o6 = (std::sqrt(Real(2))+400)/6;
560+
561+
std::vector <Point> expected_centers
562+
{ {50+r2p400o6,100./3},
563+
{50+r2p400o6,-100./3},
564+
{50+100./3,r2p400o6}, {50-100./3,r2p400o6},
565+
{50+100./3,-r2p400o6}, {50-100./3,-r2p400o6},
566+
{50+r2p200o6,r2p200o6}, {50-r2p200o6,r2p200o6},
567+
{50+r2p200o6,-r2p200o6}, {50-r2p200o6,-r2p200o6},
568+
{50-r2p400o6,100./3},
569+
{50-r2p400o6,-100./3},
570+
{-50+100./3,r2p400o6}, {50-100./3,r2p400o6},
571+
{-50+100./3,-r2p400o6}, {50-100./3,-r2p400o6},
572+
{-50+r2p200o6,r2p200o6}, {50-r2p200o6,r2p200o6},
573+
{-50+r2p200o6,-r2p200o6}, {50-r2p200o6,-r2p200o6},
574+
{0,100./3}, {0,-100./3}
575+
};
576+
577+
testFoundCenters(mesh, expected_centers);
578+
}
579+
580+
520581
void testTriangulatorMeshedHoles(MeshBase & mesh,
521582
TriangulatorInterface & triangulator)
522583
{
@@ -710,6 +771,16 @@ public:
710771
}
711772

712773

774+
void testTriangleHoleTangentPerturbed()
775+
{
776+
LOG_UNIT_TEST;
777+
778+
Mesh mesh(*TestCommWorld);
779+
TriangleInterface triangle(mesh);
780+
testTriangulatorHoleTangentPerturbed(mesh, triangle);
781+
}
782+
783+
713784
void testTriangleMeshedHoles()
714785
{
715786
LOG_UNIT_TEST;
@@ -804,6 +875,16 @@ public:
804875
}
805876

806877

878+
void testPoly2TriHoleTangentPerturbed()
879+
{
880+
LOG_UNIT_TEST;
881+
882+
Mesh mesh(*TestCommWorld);
883+
Poly2TriTriangulator p2t_tri(mesh);
884+
testTriangulatorHoleTangentPerturbed(mesh, p2t_tri);
885+
}
886+
887+
807888
void testPoly2TriMeshedHoles()
808889
{
809890
LOG_UNIT_TEST;

0 commit comments

Comments
 (0)