| 11 | using namespace LNLib; |
| 12 | |
| 13 | TEST(Test_Advanced, All) |
| 14 | { |
| 15 | { |
| 16 | int degree = 2; |
| 17 | std::vector<double> kv = { 0,0,0,1,2,3,3,3 }; |
| 18 | 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) }; |
| 19 | XYZ direction = XYZ(1, 1, 0); |
| 20 | double distance = 5; |
| 21 | int moveIndex = 3; |
| 22 | |
| 23 | LN_NurbsCurve curve; |
| 24 | curve.Degree = degree; |
| 25 | curve.KnotVector = kv; |
| 26 | curve.ControlPoints = cps; |
| 27 | |
| 28 | LN_NurbsCurve newCurve; |
| 29 | bool result = NurbsCurve::ControlPointReposition(curve, 2, moveIndex, direction, distance, newCurve); |
| 30 | EXPECT_TRUE(result); |
| 31 | } |
| 32 | { |
| 33 | int degree = 2; |
| 34 | std::vector<double> kv = { 0,0,0,1,2,3,3,3 }; |
| 35 | 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) }; |
| 36 | XYZ direction = XYZ(1, 1, 0); |
| 37 | double distance = 5; |
| 38 | int moveIndex = 3; |
| 39 | |
| 40 | LN_NurbsCurve curve; |
| 41 | curve.Degree = degree; |
| 42 | curve.KnotVector = kv; |
| 43 | curve.ControlPoints = cps; |
| 44 | |
| 45 | LN_NurbsCurve newCurve; |
| 46 | NurbsCurve::WeightModification(curve, 2, moveIndex, distance, newCurve); |
| 47 | |
| 48 | std::vector<XYZW> updatedCps = newCurve.ControlPoints; |
| 49 | EXPECT_TRUE(updatedCps[moveIndex].IsAlmostEqualTo(cps[moveIndex])); |
| 50 | EXPECT_FALSE(MathUtils::IsAlmostEqualTo(updatedCps[moveIndex].GetW(), cps[moveIndex].GetW())); |
| 51 | } |
| 52 | { |
| 53 | int degree = 2; |
| 54 | std::vector<double> kv = { 0,0,0,1,2,3,3,3 }; |
| 55 | 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) }; |
| 56 | XYZ direction = XYZ(1, 1, 0); |
| 57 | double distance = 5; |
| 58 | int moveIndex = 3; |
| 59 | |
| 60 | LN_NurbsCurve curve; |
| 61 | curve.Degree = degree; |
| 62 | curve.KnotVector = kv; |
| 63 | curve.ControlPoints = cps; |
| 64 | |
| 65 | LN_NurbsCurve newCurve; |
| 66 | NurbsCurve::NeighborWeightsModification(curve, 2, moveIndex, distance, 2.0, newCurve); |
| 67 | |
| 68 | std::vector<XYZW> updatedCps = newCurve.ControlPoints; |
| 69 | EXPECT_FALSE(MathUtils::IsAlmostEqualTo(updatedCps[moveIndex].GetW(), cps[moveIndex].GetW())); |
| 70 | EXPECT_FALSE(MathUtils::IsAlmostEqualTo(updatedCps[moveIndex + 1].GetW(), cps[moveIndex + 1].GetW())); |
nothing calls this directly
no test coverage detected