Skip to content

Commit

Permalink
GetLength method
Browse files Browse the repository at this point in the history
for getting the length of a single edge, not all of them at once
  • Loading branch information
Dan-Piker committed Nov 18, 2013
1 parent 7b3a6a7 commit 94ba6c7
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Plankton/PlanktonHalfedgeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,29 @@ public double[] GetLengths()
double[] Lengths = new double[this.Count];
for (int i = 0; i < this.Count; i += 2)
{
double EdgeLength = -1;
if (this[i].IsUnused == false)
{
PlanktonXYZ Start = _mesh.Vertices[this[i].StartVertex].ToXYZ();
PlanktonXYZ End = _mesh.Vertices[this[i+1].StartVertex].ToXYZ();
EdgeLength = (End - Start).Length();
}
double EdgeLength = GetLength(i);
Lengths[i] = EdgeLength;
Lengths[i + 1] = EdgeLength;
}
return Lengths;
}

public double GetLength(int index)
/// <summary>
/// Measure the length of a single halfedge
/// </summary>
/// <returns>The length of the halfedge, or -1 if unused</returns>
{
double EdgeLength = -1;
if (this[index].IsUnused == false)
{
PlanktonXYZ Start = _mesh.Vertices[this[index].StartVertex].ToXYZ();
PlanktonXYZ End = _mesh.Vertices[this.EndVertex(index)].ToXYZ();
EdgeLength = (End - Start).Length();
}
return EdgeLength;
}

#endregion

#region Euler operators
Expand Down

0 comments on commit 94ba6c7

Please sign in to comment.