Do not overwrite input vertex ids
git-svn-id: https://triangle.svn.codeplex.com/svn@77158 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
This commit is contained in:
@@ -586,7 +586,7 @@ namespace TriangleNet
|
||||
/// Read the vertices from memory.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
internal void TransferNodes(ICollection<Vertex> points)
|
||||
internal void TransferNodes(IList<Vertex> points)
|
||||
{
|
||||
this.invertices = points.Count;
|
||||
this.mesh_dim = 2;
|
||||
@@ -598,17 +598,29 @@ namespace TriangleNet
|
||||
throw new Exception("Input must have at least three input vertices.");
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
var v = points[0];
|
||||
|
||||
foreach (Vertex p in points)
|
||||
// Check attributes.
|
||||
this.nextras = v.attributes == null ? 0 : v.attributes.Length;
|
||||
|
||||
// Simple heuristic to check if ids are already set. We assume that if the
|
||||
// first two vertex ids are distinct, then all input vertices have pairwise
|
||||
// distinct ids.
|
||||
bool userId = (v.ID != points[1].ID);
|
||||
|
||||
foreach (var p in points)
|
||||
{
|
||||
if (first)
|
||||
if (userId)
|
||||
{
|
||||
this.nextras = p.attributes == null ? 0 : p.attributes.Length;
|
||||
first = false;
|
||||
}
|
||||
p.hash = p.id;
|
||||
|
||||
p.hash = p.id = this.hash_vtx++;
|
||||
// Make sure the hash counter gets updated.
|
||||
hash_vtx = Math.Max(p.hash, hash_vtx);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.hash = p.id = hash_vtx++;
|
||||
}
|
||||
|
||||
this.vertices.Add(p.hash, p);
|
||||
this.bounds.Expand(p);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace TriangleNet.Meshing.Algorithm
|
||||
/// Sorts the vertices, calls a recursive procedure to triangulate them, and
|
||||
/// removes the bounding box, setting boundary markers as appropriate.
|
||||
/// </remarks>
|
||||
public IMesh Triangulate(ICollection<Vertex> points)
|
||||
public IMesh Triangulate(IList<Vertex> points)
|
||||
{
|
||||
this.mesh = new Mesh();
|
||||
this.mesh.TransferNodes(points);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace TriangleNet.Meshing.Algorithm
|
||||
/// </summary>
|
||||
/// <returns>Returns the number of edges on the convex hull of the
|
||||
/// triangulation.</returns>
|
||||
public IMesh Triangulate(ICollection<Vertex> points)
|
||||
public IMesh Triangulate(IList<Vertex> points)
|
||||
{
|
||||
this.mesh = new Mesh();
|
||||
this.mesh.TransferNodes(points);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace TriangleNet.Meshing.Algorithm
|
||||
double xminextreme; // Nonexistent x value used as a flag in sweepline.
|
||||
List<SplayNode> splaynodes;
|
||||
|
||||
public IMesh Triangulate(ICollection<Vertex> points)
|
||||
public IMesh Triangulate(IList<Vertex> points)
|
||||
{
|
||||
this.mesh = new Mesh();
|
||||
this.mesh.TransferNodes(points);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace TriangleNet.Meshing
|
||||
}
|
||||
|
||||
/// <inherit />
|
||||
public IMesh Triangulate(ICollection<Vertex> points)
|
||||
public IMesh Triangulate(IList<Vertex> points)
|
||||
{
|
||||
return triangulator.Triangulate(points);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ namespace TriangleNet.Meshing
|
||||
/// </summary>
|
||||
/// <param name="points">Collection of points.</param>
|
||||
/// <returns>Mesh</returns>
|
||||
IMesh Triangulate(ICollection<Vertex> points);
|
||||
IMesh Triangulate(IList<Vertex> points);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user