From 772a740ee5c782f8f5c84e02e5905ca6c542a05a Mon Sep 17 00:00:00 2001 From: Mirco Bianchini Date: Wed, 6 Oct 2021 20:30:53 +1100 Subject: [PATCH] Integrated the comments. --- .../Data/NurbsSurfaceCollection.cs | 2 +- .../Geometry/NurbsSurfaceTests.cs | 30 +++++++++---------- src/GShark/Geometry/NurbsSurface.cs | 20 ++++++------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/GShark.Test.XUnit/Data/NurbsSurfaceCollection.cs b/src/GShark.Test.XUnit/Data/NurbsSurfaceCollection.cs index b16ac282..44f04767 100644 --- a/src/GShark.Test.XUnit/Data/NurbsSurfaceCollection.cs +++ b/src/GShark.Test.XUnit/Data/NurbsSurfaceCollection.cs @@ -87,7 +87,7 @@ public static NurbsSurface Loft() NurbsCurve crv2 = new NurbsCurve(pts3, 3); List crvs = new List { ln, crv0, poly, crv1, crv2 }; - return NurbsSurface.Lofted(crvs); + return NurbsSurface.FromLoft(crvs); } } } diff --git a/src/GShark.Test.XUnit/Geometry/NurbsSurfaceTests.cs b/src/GShark.Test.XUnit/Geometry/NurbsSurfaceTests.cs index a5b27f9b..c44d071f 100644 --- a/src/GShark.Test.XUnit/Geometry/NurbsSurfaceTests.cs +++ b/src/GShark.Test.XUnit/Geometry/NurbsSurfaceTests.cs @@ -88,7 +88,7 @@ public void It_Returns_A_Normal_Lofted_Surface_By_Opened_Curves(double u, double Point3 expectedPt = new Point3(pt[0], pt[1], pt[2]); // Act - NurbsSurface surface = NurbsSurface.Lofted(NurbsCurveCollection.OpenCurves()); + NurbsSurface surface = NurbsSurface.FromLoft(NurbsCurveCollection.OpenCurves()); Point3 evalPt = surface.PointAt(u, v); // Assert @@ -106,7 +106,7 @@ public void It_Returns_A_Loose_Lofted_Surface_By_Opened_Curves(double u, double Point3 expectedPt = new Point3(pt[0], pt[1], pt[2]); // Act - NurbsSurface surface = NurbsSurface.Lofted(NurbsCurveCollection.OpenCurves(), LoftType.Loose); + NurbsSurface surface = NurbsSurface.FromLoft(NurbsCurveCollection.OpenCurves(), LoftType.Loose); Point3 evalPt = surface.PointAt(u, v); // Assert @@ -124,7 +124,7 @@ public void It_Returns_A_Loose_Lofted_Surface_By_Closed_Curves(double u, double Point3 expectedPt = new Point3(pt[0], pt[1], pt[2]); // Act - NurbsSurface surface = NurbsSurface.Lofted(NurbsCurveCollection.ClosedCurves(), LoftType.Loose); + NurbsSurface surface = NurbsSurface.FromLoft(NurbsCurveCollection.ClosedCurves(), LoftType.Loose); Point3 evalPt = surface.PointAt(u, v); // Assert @@ -136,7 +136,7 @@ public void It_Returns_A_Loose_Lofted_Surface_By_Closed_Curves(double u, double public void Lofted_Surface_Throws_An_Exception_If_The_Curves_Are_Null() { // Act - Func func = () => NurbsSurface.Lofted(null); + Func func = () => NurbsSurface.FromLoft(null); // Assert func.Should().Throw() @@ -151,7 +151,7 @@ public void Lofted_Surface_Throws_An_Exception_If_There_Are_Null_Curves() crvs.Add(null); // Act - Func func = () => NurbsSurface.Lofted(crvs); + Func func = () => NurbsSurface.FromLoft(crvs); // Assert func.Should().Throw() @@ -165,7 +165,7 @@ public void Lofted_Surface_Throws_An_Exception_If_Curves_Count_Are_Less_Than_Two NurbsBase[] crvs = { NurbsCurveCollection.OpenCurves()[0] }; // Act - Func func = () => NurbsSurface.Lofted(crvs); + Func func = () => NurbsSurface.FromLoft(crvs); // Assert func.Should().Throw() @@ -180,7 +180,7 @@ public void Lofted_Surface_Throws_An_Exception_If_The_All_Curves_Are_Not_Closed_ crvs[1] = crvs[1].Close(); // Act - Func func = () => NurbsSurface.Lofted(crvs); + Func func = () => NurbsSurface.FromLoft(crvs); // Assert func.Should().Throw() @@ -221,7 +221,7 @@ public void Returns_True_If_Two_Surfaces_Are_Equals() public void Returns_True_If_Surface_Is_Close() { // Act - NurbsSurface surface = NurbsSurface.Lofted(NurbsCurveCollection.ClosedCurves(), LoftType.Loose); + NurbsSurface surface = NurbsSurface.FromLoft(NurbsCurveCollection.ClosedCurves(), LoftType.Loose); // Assert surface.IsClosed(SurfaceDirection.V).Should().BeTrue(); @@ -381,12 +381,12 @@ public void It_Returns_A_Revolved_Surface_From_A_Line() // Assert revolvedSurface0.ControlPointLocations - .Zip(expectedPts0, (pt0, pt1) => pt0.SequenceEqual(pt1)) + .Zip(expectedPts0, (ptsA, ptsB) => ptsA.SequenceEqual(ptsB)) .All(res => res) .Should().BeTrue(); revolvedSurface1.ControlPointLocations - .Zip(expectedPts1, (pt0, pt1) => pt0.SequenceEqual(pt1)) + .Zip(expectedPts1, (ptsA, ptsB) => ptsA.SequenceEqual(ptsB)) .All(res => res) .Should().BeTrue(); } @@ -425,13 +425,13 @@ public void It_Returns_A_Revolved_Surface_From_An_Arc() // Assert revolvedSurface.ControlPointLocations - .Zip(expectedPts, (pt0, pt1) => pt0.SequenceEqual(pt1)) + .Zip(expectedPts, (ptsA, ptsB) => ptsA.SequenceEqual(ptsB)) .All(res => res) .Should().BeTrue(); } [Fact] - public void It_Returns_A_Extruded_Surface() + public void It_Creates_A_NurbsSurface_From_Extrusion() { // Arrange List ptsA = new List @@ -455,11 +455,11 @@ public void It_Returns_A_Extruded_Surface() List> expectedPts = new List> {ptsA, ptsB}; // Act - NurbsSurface extrudedSurface = NurbsSurface.Extruded(direction, curve); + NurbsSurface extrudedSurface = NurbsSurface.FromExtrusion(direction, curve); // Assert extrudedSurface.ControlPointLocations - .Zip(expectedPts, (pt0, pt1) => pt0.SequenceEqual(pt1)) + .Zip(expectedPts, (ptsA, ptsB) => ptsA.SequenceEqual(ptsB)) .All(res => res) .Should().BeTrue(); extrudedSurface.DegreeU.Should().Be(1); @@ -467,7 +467,7 @@ public void It_Returns_A_Extruded_Surface() } [Fact] - public void It_Returns_A_Sweep_Surface() + public void It_Creates_A_NurbsSurface_From_Swep() { // Arrange List ptsA = new List diff --git a/src/GShark/Geometry/NurbsSurface.cs b/src/GShark/Geometry/NurbsSurface.cs index 1870c1f8..d99b7b04 100644 --- a/src/GShark/Geometry/NurbsSurface.cs +++ b/src/GShark/Geometry/NurbsSurface.cs @@ -1,11 +1,11 @@ -using GShark.Core; -using GShark.Enumerations; -using GShark.ExtendedMethods; -using GShark.Interfaces; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; +using GShark.Core; +using GShark.Enumerations; +using GShark.ExtendedMethods; +using GShark.Interfaces; namespace GShark.Geometry { @@ -154,7 +154,7 @@ public static NurbsSurface FromPoints(int degreeU, int degreeV, ListSet of a minimum of two curves to create the surface. /// Enum to choose the type of loft generation. /// A NURBS surface. - public static NurbsSurface Lofted(IList curves, LoftType loftType = LoftType.Normal) + public static NurbsSurface FromLoft(IList curves, LoftType loftType = LoftType.Normal) { if (curves == null) throw new ArgumentException("An invalid number of curves to perform the loft."); @@ -224,7 +224,7 @@ public static NurbsSurface Lofted(IList curves, LoftType loftType = L /// The extrusion direction. /// The profile curve to extrude. /// The extruded surface. - public static NurbsSurface Extruded(Vector3 direction, NurbsBase profile) + public static NurbsSurface FromExtrusion(Vector3 direction, NurbsBase profile) { Transform xForm = Core.Transform.Translation(direction); List translatedControlPts = @@ -247,13 +247,13 @@ public static NurbsSurface FromSweep(NurbsBase rail, NurbsBase profile) List frames = rail.PerpendicularFrames(tValues); List curves = new List {profile}; - foreach (Plane frame in frames.Skip(1)) + for (int i = 1; i <= frames.Count; i++) { - Transform xForm = Core.Transform.PlaneToPlane(frames[0], frame); + Transform xForm = Core.Transform.PlaneToPlane(frames[0], frames[i]); curves.Add(((NurbsCurve)curves[0]).Transform(xForm)); } - return Lofted(curves); + return FromLoft(curves); } ///