diff --git a/Geometry_Engine/Create/NurbSurface.cs b/Geometry_Engine/Create/NurbsSurface.cs
similarity index 100%
rename from Geometry_Engine/Create/NurbSurface.cs
rename to Geometry_Engine/Create/NurbsSurface.cs
diff --git a/Geometry_Engine/Geometry_Engine.csproj b/Geometry_Engine/Geometry_Engine.csproj
index 0385f47b4..56585b7a3 100644
--- a/Geometry_Engine/Geometry_Engine.csproj
+++ b/Geometry_Engine/Geometry_Engine.csproj
@@ -149,6 +149,7 @@
+
diff --git a/Geometry_Engine/Query/Degree.cs b/Geometry_Engine/Query/Degree.cs
index 513b2d39f..62e4b8f8d 100644
--- a/Geometry_Engine/Query/Degree.cs
+++ b/Geometry_Engine/Query/Degree.cs
@@ -37,18 +37,5 @@ public static int Degree(this NurbsCurve curve)
}
/***************************************************/
-
- public static List Degrees(this NurbsSurface surf)
- {
- int uDegree = 1;
- int vDegree = 1;
- while (surf.UKnots[uDegree - 1] == surf.UKnots[uDegree])
- uDegree++;
- while (surf.VKnots[vDegree - 1] == surf.VKnots[vDegree])
- vDegree++;
- return new List() { uDegree, vDegree };
- }
-
- /***************************************************/
}
}
diff --git a/Geometry_Engine/Query/IsClosed.cs b/Geometry_Engine/Query/IsClosed.cs
index 734cff141..243751069 100644
--- a/Geometry_Engine/Query/IsClosed.cs
+++ b/Geometry_Engine/Query/IsClosed.cs
@@ -110,6 +110,19 @@ public static bool IIsClosed(this ICurve curve, double tolerance = Tolerance.Dis
return IsClosed(curve as dynamic, tolerance);
}
+
+ /***************************************************/
+ /**** Public Methods - Nurbs Surfaces ****/
+ /***************************************************/
+
+ public static bool IsClosed(this NurbsSurface surface, double tolerance = Tolerance.Distance)
+ {
+ double sqTolerance = tolerance * tolerance;
+ List uvCount = surface.UVCount();
+ return Enumerable.Range(0, uvCount[1]).All(i => surface.ControlPoints[i].SquareDistance(surface.ControlPoints[surface.ControlPoints.Count - uvCount[1] + i]) <= sqTolerance)
+ || Enumerable.Range(0, uvCount[0]).All(i => surface.ControlPoints[i * uvCount[1]].SquareDistance(surface.ControlPoints[(i + 1) * uvCount[1] - 1]) <= sqTolerance);
+ }
+
/***************************************************/
}
}
diff --git a/Geometry_Engine/Query/IsPeriodic.cs b/Geometry_Engine/Query/IsPeriodic.cs
new file mode 100644
index 000000000..43f543549
--- /dev/null
+++ b/Geometry_Engine/Query/IsPeriodic.cs
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the Buildings and Habitats object Model (BHoM)
+ * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved.
+ *
+ * Each contributor holds copyright over their respective contributions.
+ * The project versioning (Git) records all such contribution source information.
+ *
+ *
+ * The BHoM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3.0 of the License, or
+ * (at your option) any later version.
+ *
+ * The BHoM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this code. If not, see .
+ */
+
+using System.Collections.Generic;
+using BH.oM.Geometry;
+
+namespace BH.Engine.Geometry
+{
+ public static partial class Query
+ {
+ /***************************************************/
+ /**** Public Methods ****/
+ /***************************************************/
+
+ public static bool IsPeriodic(this NurbsSurface surface)
+ {
+ int uMultiplicity = 1;
+ int vMultiplicity = 1;
+
+ while (surface.UKnots[uMultiplicity - 1] == surface.UKnots[uMultiplicity])
+ uMultiplicity++;
+ while (surface.VKnots[vMultiplicity - 1] == surface.VKnots[vMultiplicity])
+ vMultiplicity++;
+
+ return (uMultiplicity != surface.UDegree || vMultiplicity != surface.VDegree);
+ }
+
+ /***************************************************/
+ }
+}
diff --git a/Geometry_Engine/Query/UVCount.cs b/Geometry_Engine/Query/UVCount.cs
index 40b0ad698..0eb99e5c4 100644
--- a/Geometry_Engine/Query/UVCount.cs
+++ b/Geometry_Engine/Query/UVCount.cs
@@ -33,8 +33,7 @@ public static partial class Query
public static List UVCount(this NurbsSurface surf)
{
- List degrees = surf.Degrees();
- return new List { surf.UKnots.Count - degrees[0] + 1, surf.VKnots.Count - degrees[1] + 1 };
+ return new List { surf.UKnots.Count - surf.UDegree + 1, surf.VKnots.Count - surf.VDegree + 1 };
}
/***************************************************/