From 4258de5b8aa080aaa87141cc417ef6f5f6882ff5 Mon Sep 17 00:00:00 2001 From: jiayu Date: Mon, 20 May 2024 23:07:28 +0800 Subject: [PATCH] test swept surface: failing --- tests/T_CommonSurfaces.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/T_CommonSurfaces.cpp b/tests/T_CommonSurfaces.cpp index dab9128..87845aa 100644 --- a/tests/T_CommonSurfaces.cpp +++ b/tests/T_CommonSurfaces.cpp @@ -110,4 +110,33 @@ TEST(Test_CommonSurfaces, CreateRevolvedSurface) EXPECT_TRUE(result); XYZ C0 = NurbsSurface::GetPointOnSurface(surface, UV(0.5, 0.5)); EXPECT_TRUE(C0.IsAlmostEqualTo(XYZ(sqrt(2) / 4.0, sqrt(2) / 4.0, 0.5))); -} \ No newline at end of file +} + +TEST(Test_CommonSurfaces, CreateTranslationalSweepSurface) +{ + // Make circular profile. + XYZ center(0, 0, 0); + XYZ xAxis(1, 0, 0); + XYZ yAxis(0, 1, 0); + double startRad = 0; + double endRad = Constants::Pi * 2; + double radius = 5; + LN_NurbsCurve profile; + NurbsCurve::CreateArc(center, xAxis, yAxis, startRad, endRad, radius, radius, profile); + + // Make linear trajectory. + LN_NurbsCurve trajectory; + XYZ start(0, 0, 0); + double height = 7; + XYZ end(0, 0, height); + NurbsCurve::CreateLine(start, end, trajectory); + + // Make translational swept surface. + LN_NurbsSurface surface; + NurbsSurface::CreateTranslationalSweepSurface(profile, trajectory, surface); + + // Verify area. + double expectedArea = (endRad - startRad) * radius * height; + double area = NurbsSurface::ApproximateArea(surface); + EXPECT_NEAR(area, expectedArea, 1e-4); +}