Skip to content

Commit

Permalink
#1298 rebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelbaran authored and al-fisher committed Nov 16, 2019
1 parent 0f711dc commit 4089b33
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 15 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions Geometry_Engine/Geometry_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<Compile Include="Query\IsCoplanar.cs" />
<Compile Include="Query\IsLinear.cs" />
<Compile Include="Query\IsOnCurve.cs" />
<Compile Include="Query\IsPeriodic.cs" />
<Compile Include="Query\IsPlanar.cs" />
<Compile Include="Query\IsPolylinear.cs" />
<Compile Include="Query\IsQuad.cs" />
Expand Down
13 changes: 0 additions & 13 deletions Geometry_Engine/Query/Degree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,5 @@ public static int Degree(this NurbsCurve curve)
}

/***************************************************/

public static List<int> 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<int>() { uDegree, vDegree };
}

/***************************************************/
}
}
13 changes: 13 additions & 0 deletions Geometry_Engine/Query/IsClosed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> 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);
}

/***************************************************/
}
}
49 changes: 49 additions & 0 deletions Geometry_Engine/Query/IsPeriodic.cs
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

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);
}

/***************************************************/
}
}
3 changes: 1 addition & 2 deletions Geometry_Engine/Query/UVCount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public static partial class Query

public static List<int> UVCount(this NurbsSurface surf)
{
List<int> degrees = surf.Degrees();
return new List<int> { surf.UKnots.Count - degrees[0] + 1, surf.VKnots.Count - degrees[1] + 1 };
return new List<int> { surf.UKnots.Count - surf.UDegree + 1, surf.VKnots.Count - surf.VDegree + 1 };
}

/***************************************************/
Expand Down

0 comments on commit 4089b33

Please sign in to comment.