MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / TEST

Function TEST

tests/T_Extension.cpp:8–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace LNLib;
7
8TEST(Test_Extension, Curve)
9{
10 int degree = 2;
11 std::vector<double> kv = { 0,0,0,1,2,3,3,3};
12 std::vector<XYZW> cps = { XYZW(XYZ(0,0,0),1), XYZW(XYZ(1,1,0),4), XYZW(XYZ(3,2,0),1), XYZW(XYZ(4,1,0),1), XYZW(XYZ(5,-1,0),1)};
13
14 LN_NurbsCurve curve;
15 curve.Degree = degree;
16 curve.KnotVector = kv;
17 curve.ControlPoints = cps;
18
19 double originLength = NurbsCurve::ApproximateLength(curve);
20 LN_NurbsCurve tangentResult;
21 NurbsCurve::Extend(curve, 10, true, ExtensionType::Tangent, tangentResult);
22 double extensionLength = NurbsCurve::ApproximateLength(tangentResult);
23 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(extensionLength, originLength + 10, Constants::DistanceEpsilon));
24 NurbsCurve::Extend(curve, 10, false, ExtensionType::Tangent, tangentResult);
25 extensionLength = NurbsCurve::ApproximateLength(tangentResult);
26 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(extensionLength, originLength + 10, Constants::DistanceEpsilon));
27
28 LN_NurbsCurve arcResult;
29 NurbsCurve::Extend(curve, 10, true, ExtensionType::Arc, arcResult);
30 extensionLength = NurbsCurve::ApproximateLength(arcResult);
31 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(extensionLength, originLength + 10, Constants::DistanceEpsilon));
32 NurbsCurve::Extend(curve, 10, false, ExtensionType::Arc, arcResult);
33 extensionLength = NurbsCurve::ApproximateLength(arcResult);
34 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(extensionLength, originLength + 10, Constants::DistanceEpsilon));
35
36 LN_NurbsCurve naturalResult;
37 NurbsCurve::Extend(curve, 10, true, ExtensionType::Natural, naturalResult);
38 extensionLength = NurbsCurve::ApproximateLength(naturalResult);
39 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(extensionLength, originLength + 10, Constants::DistanceEpsilon));
40 NurbsCurve::Extend(curve, 10, false, ExtensionType::Natural, naturalResult);
41 extensionLength = NurbsCurve::ApproximateLength(naturalResult);
42 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(extensionLength, originLength + 10, Constants::DistanceEpsilon));
43}

Callers

nothing calls this directly

Calls 2

XYZWClass · 0.50
XYZClass · 0.50

Tested by

no test coverage detected