Skip to content

Commit

Permalink
Integrated the comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
sonomirco committed Oct 6, 2021
1 parent b5dc439 commit 772a740
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/GShark.Test.XUnit/Data/NurbsSurfaceCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static NurbsSurface Loft()
NurbsCurve crv2 = new NurbsCurve(pts3, 3);
List<NurbsBase> crvs = new List<NurbsBase> { ln, crv0, poly, crv1, crv2 };

return NurbsSurface.Lofted(crvs);
return NurbsSurface.FromLoft(crvs);
}
}
}
30 changes: 15 additions & 15 deletions src/GShark.Test.XUnit/Geometry/NurbsSurfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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<NurbsSurface> func = () => NurbsSurface.Lofted(null);
Func<NurbsSurface> func = () => NurbsSurface.FromLoft(null);

// Assert
func.Should().Throw<Exception>()
Expand All @@ -151,7 +151,7 @@ public void Lofted_Surface_Throws_An_Exception_If_There_Are_Null_Curves()
crvs.Add(null);

// Act
Func<NurbsSurface> func = () => NurbsSurface.Lofted(crvs);
Func<NurbsSurface> func = () => NurbsSurface.FromLoft(crvs);

// Assert
func.Should().Throw<Exception>()
Expand All @@ -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<NurbsSurface> func = () => NurbsSurface.Lofted(crvs);
Func<NurbsSurface> func = () => NurbsSurface.FromLoft(crvs);

// Assert
func.Should().Throw<Exception>()
Expand All @@ -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<NurbsSurface> func = () => NurbsSurface.Lofted(crvs);
Func<NurbsSurface> func = () => NurbsSurface.FromLoft(crvs);

// Assert
func.Should().Throw<Exception>()
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<Point3> ptsA = new List<Point3>
Expand All @@ -455,19 +455,19 @@ public void It_Returns_A_Extruded_Surface()
List<List<Point3>> expectedPts = new List<List<Point3>> {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);
extrudedSurface.DegreeV.Should().Be(curve.Degree);
}

[Fact]
public void It_Returns_A_Sweep_Surface()
public void It_Creates_A_NurbsSurface_From_Swep()
{
// Arrange
List<Point3> ptsA = new List<Point3>
Expand Down
20 changes: 10 additions & 10 deletions src/GShark/Geometry/NurbsSurface.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -154,7 +154,7 @@ public static NurbsSurface FromPoints(int degreeU, int degreeV, List<List<Point3
/// <param name="curves">Set of a minimum of two curves to create the surface.</param>
/// <param name="loftType">Enum to choose the type of loft generation.</param>
/// <returns>A NURBS surface.</returns>
public static NurbsSurface Lofted(IList<NurbsBase> curves, LoftType loftType = LoftType.Normal)
public static NurbsSurface FromLoft(IList<NurbsBase> curves, LoftType loftType = LoftType.Normal)
{
if (curves == null)
throw new ArgumentException("An invalid number of curves to perform the loft.");
Expand Down Expand Up @@ -224,7 +224,7 @@ public static NurbsSurface Lofted(IList<NurbsBase> curves, LoftType loftType = L
/// <param name="direction">The extrusion direction.</param>
/// <param name="profile">The profile curve to extrude.</param>
/// <returns>The extruded surface.</returns>
public static NurbsSurface Extruded(Vector3 direction, NurbsBase profile)
public static NurbsSurface FromExtrusion(Vector3 direction, NurbsBase profile)
{
Transform xForm = Core.Transform.Translation(direction);
List<Point4> translatedControlPts =
Expand All @@ -247,13 +247,13 @@ public static NurbsSurface FromSweep(NurbsBase rail, NurbsBase profile)
List<Plane> frames = rail.PerpendicularFrames(tValues);
List<NurbsBase> curves = new List<NurbsBase> {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);
}

/// <summary>
Expand Down

0 comments on commit 772a740

Please sign in to comment.