Breaking changes for geometry entities:
Removed a bunch of properties (ID related) Renamed 'Boundary' and 'Region' properties to 'Label' git-svn-id: https://triangle.svn.codeplex.com/svn@77679 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
This commit is contained in:
@@ -470,12 +470,12 @@ namespace MeshExplorer.IO.Formats
|
||||
item.X.ToString(Util.Nfi),
|
||||
item.Y.ToString(Util.Nfi), seperator);
|
||||
|
||||
if (item.Boundary > 0)
|
||||
if (item.Label > 0)
|
||||
{
|
||||
useMarkers = true;
|
||||
}
|
||||
|
||||
markers.AppendFormat("{0}{1}", item.Boundary, seperator);
|
||||
markers.AppendFormat("{0}{1}", item.Label, seperator);
|
||||
|
||||
i++;
|
||||
}
|
||||
@@ -517,12 +517,12 @@ namespace MeshExplorer.IO.Formats
|
||||
writer.Write("{0},{1}{2}",
|
||||
item.P0, item.P1, seperator);
|
||||
|
||||
if (item.Boundary > 0)
|
||||
if (item.Label > 0)
|
||||
{
|
||||
useMarkers = true;
|
||||
}
|
||||
|
||||
markers.AppendFormat("{0}{1}", item.Boundary, seperator);
|
||||
markers.AppendFormat("{0}{1}", item.Label, seperator);
|
||||
|
||||
i++;
|
||||
}
|
||||
@@ -551,10 +551,16 @@ namespace MeshExplorer.IO.Formats
|
||||
seperator = (i == ne - 1) ? String.Empty : ", ";
|
||||
|
||||
writer.Write("{0},{1},{2}{3}",
|
||||
item.P0, item.P1, item.P2, seperator);
|
||||
item.GetVertexID(0),
|
||||
item.GetVertexID(1),
|
||||
item.GetVertexID(2),
|
||||
seperator);
|
||||
|
||||
neighbors.AppendFormat("{0},{1},{2}{3}",
|
||||
item.N0, item.N1, item.N2, seperator);
|
||||
item.GetNeighborID(0),
|
||||
item.GetNeighborID(1),
|
||||
item.GetNeighborID(2),
|
||||
seperator);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ namespace MeshExplorer.Topology
|
||||
{
|
||||
lbTriangle.Text = tri.ID.ToString();
|
||||
|
||||
lbV0.Text = tri.P0.ToString();
|
||||
lbV1.Text = tri.P1.ToString();
|
||||
lbV2.Text = tri.P2.ToString();
|
||||
lbV0.Text = tri.GetVertexID(0).ToString();
|
||||
lbV1.Text = tri.GetVertexID(1).ToString();
|
||||
lbV2.Text = tri.GetVertexID(2).ToString();
|
||||
|
||||
lbN0.Text = tri.N0.ToString();
|
||||
lbN1.Text = tri.N1.ToString();
|
||||
lbN2.Text = tri.N2.ToString();
|
||||
lbN0.Text = tri.GetNeighborID(0).ToString();
|
||||
lbN1.Text = tri.GetNeighborID(1).ToString();
|
||||
lbN2.Text = tri.GetNeighborID(2).ToString();
|
||||
|
||||
lbS0.Text = GetSegmentString(tri.GetSegment(0));
|
||||
lbS1.Text = GetSegmentString(tri.GetSegment(1));
|
||||
|
||||
@@ -6,8 +6,7 @@ namespace MeshExplorer.Topology
|
||||
using TriangleNet;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Rendering;
|
||||
using TriangleNet.Topology;
|
||||
|
||||
|
||||
public class TopologyRenderer
|
||||
{
|
||||
Projection zoom;
|
||||
@@ -165,9 +164,9 @@ namespace MeshExplorer.Topology
|
||||
// Draw triangles
|
||||
foreach (var tri in triangles)
|
||||
{
|
||||
p0 = points[tri.P0];
|
||||
p1 = points[tri.P1];
|
||||
p2 = points[tri.P2];
|
||||
p0 = points[tri.GetVertexID(0)];
|
||||
p1 = points[tri.GetVertexID(1)];
|
||||
p2 = points[tri.GetVertexID(2)];
|
||||
|
||||
zoom.WorldToScreen(ref p0);
|
||||
zoom.WorldToScreen(ref p1);
|
||||
@@ -194,9 +193,9 @@ namespace MeshExplorer.Topology
|
||||
// Draw triangles
|
||||
foreach (var tri in triangles)
|
||||
{
|
||||
p0 = points[tri.P0];
|
||||
p1 = points[tri.P1];
|
||||
p2 = points[tri.P2];
|
||||
p0 = points[tri.GetVertexID(0)];
|
||||
p1 = points[tri.GetVertexID(1)];
|
||||
p2 = points[tri.GetVertexID(2)];
|
||||
|
||||
zoom.WorldToScreen(ref p0);
|
||||
zoom.WorldToScreen(ref p1);
|
||||
@@ -269,9 +268,9 @@ namespace MeshExplorer.Topology
|
||||
{
|
||||
var p = new PointF[3];
|
||||
|
||||
p[0] = points[currentTri.P0];
|
||||
p[1] = points[currentTri.P1];
|
||||
p[2] = points[currentTri.P2];
|
||||
p[0] = points[currentTri.GetVertexID(0)];
|
||||
p[1] = points[currentTri.GetVertexID(1)];
|
||||
p[2] = points[currentTri.GetVertexID(2)];
|
||||
|
||||
zoom.WorldToScreen(ref p[0]);
|
||||
zoom.WorldToScreen(ref p[1]);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TriangleNet.Rendering.GDI
|
||||
|
||||
foreach (var layer in this.Context.RenderLayers)
|
||||
{
|
||||
if (!layer.IsEmpty && layer.IsActive)
|
||||
if (!layer.IsEmpty() && layer.IsEnabled)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,9 @@ namespace TriangleNet.Rendering
|
||||
IBuffer<float> Points { get; }
|
||||
IBuffer<int> Indices { get; }
|
||||
|
||||
bool IsActive { get; set; }
|
||||
bool IsEmpty { get; }
|
||||
bool IsEnabled { get; set; }
|
||||
|
||||
bool IsEmpty();
|
||||
|
||||
void Reset(bool clear);
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace TriangleNet.Rendering
|
||||
renderLayers.Add(new RenderLayer()); // 5 = vector field
|
||||
renderLayers.Add(new RenderLayer()); // 6 = contour lines
|
||||
|
||||
RenderLayers[1].IsEnabled = true;
|
||||
RenderLayers[2].IsEnabled = true;
|
||||
RenderLayers[3].IsEnabled = true;
|
||||
|
||||
this.zoom = zoom;
|
||||
this.colorManager = colorManager;
|
||||
}
|
||||
@@ -66,7 +70,7 @@ namespace TriangleNet.Rendering
|
||||
{
|
||||
get
|
||||
{
|
||||
return renderLayers.Any(layer => !layer.IsEmpty);
|
||||
return renderLayers.Any(layer => !layer.IsEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,10 +96,7 @@ namespace TriangleNet.Rendering
|
||||
this.zoom.Initialize(bounds);
|
||||
|
||||
RenderLayers[2].SetPolygon(data);
|
||||
RenderLayers[2].IsActive = true;
|
||||
|
||||
RenderLayers[3].SetPoints(RenderLayers[2].Points);
|
||||
RenderLayers[3].IsActive = true;
|
||||
}
|
||||
|
||||
public void Add(IMesh data, bool reset)
|
||||
@@ -115,21 +116,18 @@ namespace TriangleNet.Rendering
|
||||
this.zoom.Initialize(bounds);
|
||||
|
||||
RenderLayers[1].SetMesh(data, false);
|
||||
RenderLayers[1].IsActive = true;
|
||||
|
||||
RenderLayers[2].SetPoints(RenderLayers[1].Points);
|
||||
RenderLayers[2].SetPolygon(data);
|
||||
RenderLayers[2].IsActive = true;
|
||||
|
||||
RenderLayers[3].SetPoints(RenderLayers[1].Points);
|
||||
RenderLayers[3].IsActive = true;
|
||||
}
|
||||
|
||||
public void Add(ICollection<Point> points, IEnumerable<IEdge> edges, bool reset)
|
||||
{
|
||||
RenderLayers[4].SetPoints(points);
|
||||
RenderLayers[4].SetMesh(edges);
|
||||
RenderLayers[4].IsActive = true;
|
||||
RenderLayers[4].IsEnabled = true;
|
||||
}
|
||||
|
||||
public void Add(float[] data)
|
||||
@@ -139,7 +137,7 @@ namespace TriangleNet.Rendering
|
||||
RenderLayers[0].SetMesh(this.mesh, true);
|
||||
RenderLayers[0].AttachLayerData(data, colorManager.ColorMap);
|
||||
|
||||
RenderLayers[0].IsActive = true;
|
||||
RenderLayers[0].IsEnabled = true;
|
||||
}
|
||||
|
||||
public void Add(int[] data)
|
||||
@@ -149,12 +147,16 @@ namespace TriangleNet.Rendering
|
||||
RenderLayers[0].SetMesh(this.mesh, true);
|
||||
RenderLayers[0].AttachLayerData(data);
|
||||
|
||||
RenderLayers[0].IsActive = true;
|
||||
RenderLayers[0].IsEnabled = true;
|
||||
}
|
||||
|
||||
public void Enable(int layer, bool enabled)
|
||||
{
|
||||
renderLayers[layer].IsActive = enabled;
|
||||
renderLayers[layer].IsEnabled = enabled;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace TriangleNet.Rendering
|
||||
|
||||
public RenderLayer()
|
||||
{
|
||||
this.IsActive = false;
|
||||
this.IsEnabled = false;
|
||||
}
|
||||
|
||||
public int Count
|
||||
@@ -50,11 +50,11 @@ namespace TriangleNet.Rendering
|
||||
get { return colors; }
|
||||
}
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public bool IsEmpty
|
||||
public bool IsEmpty()
|
||||
{
|
||||
get { return (points == null || points.Count == 0); }
|
||||
return (points == null || points.Count == 0);
|
||||
}
|
||||
|
||||
public void Reset(bool clear)
|
||||
|
||||
@@ -129,9 +129,9 @@ namespace TriangleNet.Rendering.Util
|
||||
|
||||
foreach (var e in elements)
|
||||
{
|
||||
data[size * i + 0] = e.P0;
|
||||
data[size * i + 1] = e.P1;
|
||||
data[size * i + 2] = e.P2;
|
||||
data[size * i + 0] = e.GetVertexID(0);
|
||||
data[size * i + 1] = e.GetVertexID(1);
|
||||
data[size * i + 2] = e.GetVertexID(2);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TriangleNet.Geometry
|
||||
/// <summary>
|
||||
/// Gets the segments boundary mark.
|
||||
/// </summary>
|
||||
public int Boundary
|
||||
public int Label
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
@@ -58,7 +58,7 @@ namespace TriangleNet.Geometry
|
||||
{
|
||||
this.P0 = p0;
|
||||
this.P1 = p1;
|
||||
this.Boundary = boundary;
|
||||
this.Label = boundary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace TriangleNet.Geometry
|
||||
int P1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the segments boundary mark.
|
||||
/// Gets or sets a general-purpose label.
|
||||
/// </summary>
|
||||
int Boundary { get; }
|
||||
int Label { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,18 +62,12 @@ namespace TriangleNet.Geometry
|
||||
/// <param name="vertex">The vertex to insert.</param>
|
||||
void Add(Vertex vertex);
|
||||
|
||||
/// <summary>
|
||||
/// Add a segment to the polygon.
|
||||
/// </summary>
|
||||
/// <param name="segment">The segment to insert.</param>
|
||||
void Add(ISegment segment);
|
||||
|
||||
/// <summary>
|
||||
/// Add a segment to the polygon.
|
||||
/// </summary>
|
||||
/// <param name="segment">The segment to insert.</param>
|
||||
/// <param name="insert">If true, both endpoints will be added to the points list.</param>
|
||||
void Add(ISegment segment, bool insert);
|
||||
void Add(ISegment segment, bool insert = false);
|
||||
|
||||
/// <summary>
|
||||
/// Add a segment to the polygon.
|
||||
|
||||
@@ -14,70 +14,56 @@ namespace TriangleNet.Geometry
|
||||
public interface ITriangle
|
||||
{
|
||||
/// <summary>
|
||||
/// The triangle id.
|
||||
/// Gets or sets the triangle ID.
|
||||
/// </summary>
|
||||
int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// First vertex id of the triangle.
|
||||
/// Gets or sets a general-purpose label.
|
||||
/// </summary>
|
||||
int P0 { get; }
|
||||
/// <summary>
|
||||
/// Second vertex id of the triangle.
|
||||
/// </summary>
|
||||
int P1 { get; }
|
||||
/// <summary>
|
||||
/// Third vertex id of the triangle.
|
||||
/// </summary>
|
||||
int P2 { get; }
|
||||
/// <remarks>
|
||||
/// This is used for region information.
|
||||
/// </remarks>
|
||||
int Label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles vertex.
|
||||
/// </summary>
|
||||
/// <param name="index">The vertex index (0, 1 or 2).</param>
|
||||
/// <returns>The vertex of the specified corner index.</returns>
|
||||
Vertex GetVertex(int index);
|
||||
|
||||
/// <summary>
|
||||
/// True if the triangle implementation contains neighbor information.
|
||||
/// </summary>
|
||||
bool SupportsNeighbors { get; }
|
||||
|
||||
/// <summary>
|
||||
/// First neighbor.
|
||||
/// </summary>
|
||||
int N0 { get; }
|
||||
/// <summary>
|
||||
/// Second neighbor.
|
||||
/// </summary>
|
||||
int N1 { get; }
|
||||
/// <summary>
|
||||
/// Third neighbor.
|
||||
/// </summary>
|
||||
int N2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles neighbor.
|
||||
/// </summary>
|
||||
/// <param name="index">The vertex index (0, 1 or 2).</param>
|
||||
/// <returns>The neigbbor opposite of vertex with given index.</returns>
|
||||
ITriangle GetNeighbor(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles segment.
|
||||
/// </summary>
|
||||
/// <param name="index">The vertex index (0, 1 or 2).</param>
|
||||
/// <returns>The segment opposite of vertex with given index.</returns>
|
||||
ISegment GetSegment(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Triangle area constraint.
|
||||
/// Gets or sets the triangle area constraint.
|
||||
/// </summary>
|
||||
double Area { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Region ID the triangle belongs to.
|
||||
/// Gets the vertex at given index.
|
||||
/// </summary>
|
||||
int Region { get; }
|
||||
/// <param name="index">The local index (0, 1 or 2).</param>
|
||||
/// <returns>The vertex.</returns>
|
||||
Vertex GetVertex(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the vertex at given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The local index (0, 1 or 2).</param>
|
||||
/// <returns>The vertex ID.</returns>
|
||||
int GetVertexID(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the neighbor triangle at given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The local index (0, 1 or 2).</param>
|
||||
/// <returns>The neighbor triangle.</returns>
|
||||
ITriangle GetNeighbor(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the neighbor triangle at given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The local index (0, 1 or 2).</param>
|
||||
/// <returns>The neighbor triangle ID.</returns>
|
||||
int GetNeighborID(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the segment at given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The local index (0, 1 or 2).</param>
|
||||
/// <returns>The segment.</returns>
|
||||
ISegment GetSegment(int index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TriangleNet.Geometry
|
||||
internal int id;
|
||||
internal double x;
|
||||
internal double y;
|
||||
internal int mark;
|
||||
internal int label;
|
||||
|
||||
public Point()
|
||||
: this(0, 0, 0)
|
||||
@@ -28,11 +28,11 @@ namespace TriangleNet.Geometry
|
||||
{
|
||||
}
|
||||
|
||||
public Point(double x, double y, int mark)
|
||||
public Point(double x, double y, int label)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.mark = mark;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
@@ -65,12 +65,15 @@ namespace TriangleNet.Geometry
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertex boundary mark.
|
||||
/// Gets or sets a general-purpose label.
|
||||
/// </summary>
|
||||
public int Boundary
|
||||
/// <remarks>
|
||||
/// This is used for the vertex boundary mark.
|
||||
/// </remarks>
|
||||
public int Label
|
||||
{
|
||||
get { return this.mark; }
|
||||
set { this.mark = value; }
|
||||
get { return this.label; }
|
||||
set { this.label = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TriangleNet.Geometry
|
||||
Vertex v0;
|
||||
Vertex v1;
|
||||
|
||||
int boundary;
|
||||
int label;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Segment" /> class.
|
||||
@@ -29,12 +29,12 @@ namespace TriangleNet.Geometry
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Segment" /> class.
|
||||
/// </summary>
|
||||
public Segment(Vertex v0, Vertex v1, int boundary)
|
||||
public Segment(Vertex v0, Vertex v1, int label)
|
||||
{
|
||||
this.v0 = v0;
|
||||
this.v1 = v1;
|
||||
|
||||
this.boundary = boundary;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,10 +84,10 @@ namespace TriangleNet.Geometry
|
||||
/// <summary>
|
||||
/// Gets or sets the segments boundary mark.
|
||||
/// </summary>
|
||||
public int Boundary
|
||||
public int Label
|
||||
{
|
||||
get { return boundary; }
|
||||
set { boundary = value; }
|
||||
get { return label; }
|
||||
set { label = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace TriangleNet.IO
|
||||
foreach (var v in mesh.vertices.Values)
|
||||
{
|
||||
// Vertex number, x and y coordinates and marker.
|
||||
stream.WriteLine("{0} {1} {2} {3}", v.hash, v.x.ToString(nfi), v.y.ToString(nfi), v.mark);
|
||||
stream.WriteLine("{0} {1} {2} {3}", v.hash, v.x.ToString(nfi), v.y.ToString(nfi), v.label);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace TriangleNet.IO
|
||||
public class InputTriangle : ITriangle
|
||||
{
|
||||
internal int[] vertices;
|
||||
internal int region;
|
||||
internal int label;
|
||||
internal double area;
|
||||
|
||||
public InputTriangle(int p0, int p1, int p2)
|
||||
@@ -35,65 +35,12 @@ namespace TriangleNet.IO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first corners vertex id.
|
||||
/// Region ID the triangle belongs to.
|
||||
/// </summary>
|
||||
public int P0
|
||||
public int Label
|
||||
{
|
||||
get { return this.vertices[0]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the seconds corners vertex id.
|
||||
/// </summary>
|
||||
public int P1
|
||||
{
|
||||
get { return this.vertices[1]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the third corners vertex id.
|
||||
/// </summary>
|
||||
public int P2
|
||||
{
|
||||
get { return this.vertices[2]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified corners vertex.
|
||||
/// </summary>
|
||||
public Vertex GetVertex(int index)
|
||||
{
|
||||
return null; // TODO: throw NotSupportedException?
|
||||
}
|
||||
|
||||
public bool SupportsNeighbors
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public int N0
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
|
||||
public int N1
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
|
||||
public int N2
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
|
||||
public ITriangle GetNeighbor(int index)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ISegment GetSegment(int index)
|
||||
{
|
||||
return null;
|
||||
get { return label; }
|
||||
set { label = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -106,12 +53,31 @@ namespace TriangleNet.IO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Region ID the triangle belongs to.
|
||||
/// Gets the specified corners vertex.
|
||||
/// </summary>
|
||||
public int Region
|
||||
public Vertex GetVertex(int index)
|
||||
{
|
||||
get { return region; }
|
||||
set { region = value; }
|
||||
return null; // TODO: throw NotSupportedException?
|
||||
}
|
||||
|
||||
public int GetVertexID(int index)
|
||||
{
|
||||
return vertices[index];
|
||||
}
|
||||
|
||||
public ITriangle GetNeighbor(int index)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int GetNeighborID(int index)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ISegment GetSegment(int index)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace TriangleNet.IO
|
||||
// Read a vertex marker.
|
||||
if (marks > 0 && line.Length > 3 + attributes)
|
||||
{
|
||||
v.Boundary = int.Parse(line[3 + attributes]);
|
||||
v.Label = int.Parse(line[3 + attributes]);
|
||||
}
|
||||
|
||||
if (attributes > 0)
|
||||
@@ -559,7 +559,7 @@ namespace TriangleNet.IO
|
||||
{
|
||||
int region = 0;
|
||||
validRegion = int.TryParse(line[4], out region);
|
||||
tri.region = region;
|
||||
tri.label = region;
|
||||
}
|
||||
|
||||
triangles.Add(tri);
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace TriangleNet.IO
|
||||
if (markers)
|
||||
{
|
||||
// Write the boundary marker.
|
||||
writer.Write(" {0}", vertex.mark);
|
||||
writer.Write(" {0}", vertex.label);
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
@@ -166,7 +166,7 @@ namespace TriangleNet.IO
|
||||
|
||||
if (regions)
|
||||
{
|
||||
writer.Write(" {0}", tri.tri.region);
|
||||
writer.Write(" {0}", tri.tri.label);
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
@@ -213,7 +213,7 @@ namespace TriangleNet.IO
|
||||
// Segment number, indices of its two endpoints, and possibly a marker.
|
||||
if (hasMarkers)
|
||||
{
|
||||
writer.WriteLine("{0} {1} {2} {3}", j, p.ID, q.ID, seg.Boundary);
|
||||
writer.WriteLine("{0} {1} {2} {3}", j, p.ID, q.ID, seg.Label);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -711,7 +711,7 @@ namespace TriangleNet
|
||||
horiz.SetOrg(newvertex);
|
||||
|
||||
// Set the region of a new triangle.
|
||||
newbotright.tri.region = botright.tri.region;
|
||||
newbotright.tri.label = botright.tri.label;
|
||||
|
||||
if (behavior.VarArea)
|
||||
{
|
||||
@@ -728,7 +728,7 @@ namespace TriangleNet
|
||||
topright.SetOrg(newvertex);
|
||||
|
||||
// Set the region of another new triangle.
|
||||
newtopright.tri.region = topright.tri.region;
|
||||
newtopright.tri.label = topright.tri.label;
|
||||
|
||||
if (behavior.VarArea)
|
||||
{
|
||||
@@ -793,9 +793,9 @@ namespace TriangleNet
|
||||
splitseg.Sym();
|
||||
|
||||
// Transfer the subsegment's boundary marker to the vertex if required.
|
||||
if (newvertex.mark == 0)
|
||||
if (newvertex.label == 0)
|
||||
{
|
||||
newvertex.mark = splitseg.seg.boundary;
|
||||
newvertex.label = splitseg.seg.boundary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,8 +834,8 @@ namespace TriangleNet
|
||||
horiz.SetApex(newvertex);
|
||||
|
||||
// Set the region of the new triangles.
|
||||
newbotleft.tri.region = horiz.tri.region;
|
||||
newbotright.tri.region = horiz.tri.region;
|
||||
newbotleft.tri.label = horiz.tri.label;
|
||||
newbotright.tri.label = horiz.tri.label;
|
||||
|
||||
if (behavior.VarArea)
|
||||
{
|
||||
@@ -1043,9 +1043,9 @@ namespace TriangleNet
|
||||
|
||||
// Assign region.
|
||||
// TODO: check region ok (no Math.Min necessary)
|
||||
region = Math.Min(top.tri.region, horiz.tri.region);
|
||||
top.tri.region = region;
|
||||
horiz.tri.region = region;
|
||||
region = Math.Min(top.tri.label, horiz.tri.label);
|
||||
top.tri.label = region;
|
||||
horiz.tri.label = region;
|
||||
|
||||
if (behavior.VarArea)
|
||||
{
|
||||
@@ -1128,13 +1128,13 @@ namespace TriangleNet
|
||||
triorg = tri.Org();
|
||||
tridest = tri.Dest();
|
||||
// Mark vertices if possible.
|
||||
if (triorg.mark == 0)
|
||||
if (triorg.label == 0)
|
||||
{
|
||||
triorg.mark = subsegmark;
|
||||
triorg.label = subsegmark;
|
||||
}
|
||||
if (tridest.mark == 0)
|
||||
if (tridest.label == 0)
|
||||
{
|
||||
tridest.mark = subsegmark;
|
||||
tridest.label = subsegmark;
|
||||
}
|
||||
// Check if there's already a subsegment here.
|
||||
tri.Pivot(ref newsubseg);
|
||||
|
||||
@@ -893,9 +893,9 @@ namespace TriangleNet.Meshing.Algorithm
|
||||
if (dissolveedge.tri.id != Mesh.DUMMY)
|
||||
{
|
||||
markorg = dissolveedge.Org();
|
||||
if (markorg.mark == 0)
|
||||
if (markorg.label == 0)
|
||||
{
|
||||
markorg.mark = 1;
|
||||
markorg.label = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,9 +175,9 @@ namespace TriangleNet.Meshing.Algorithm
|
||||
if (dissolveedge.tri.id != Mesh.DUMMY)
|
||||
{
|
||||
markorg = dissolveedge.Org();
|
||||
if (markorg.mark == 0)
|
||||
if (markorg.label == 0)
|
||||
{
|
||||
markorg.mark = 1;
|
||||
markorg.label = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,9 +734,9 @@ namespace TriangleNet.Meshing.Algorithm
|
||||
if (dissolveedge.tri.id != Mesh.DUMMY)
|
||||
{
|
||||
markorg = dissolveedge.Org();
|
||||
if (markorg.mark == 0)
|
||||
if (markorg.label == 0)
|
||||
{
|
||||
markorg.mark = 1;
|
||||
markorg.label = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace TriangleNet.Meshing
|
||||
// Record the triangle for processing after the
|
||||
// holes have been carved.
|
||||
regionTris[i] = searchtri.tri;
|
||||
regionTris[i].region = region.id;
|
||||
regionTris[i].label = region.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ namespace TriangleNet.Meshing
|
||||
{
|
||||
mesh.insegments++;
|
||||
|
||||
label = seg.Boundary;
|
||||
label = seg.Label;
|
||||
|
||||
// TODO: wrap segment dictionary access in try / catch?
|
||||
|
||||
@@ -337,13 +337,13 @@ namespace TriangleNet.Meshing
|
||||
hullsubseg.seg.boundary = 1;
|
||||
horg = hulltri.Org();
|
||||
hdest = hulltri.Dest();
|
||||
if (horg.mark == 0)
|
||||
if (horg.label == 0)
|
||||
{
|
||||
horg.mark = 1;
|
||||
horg.label = 1;
|
||||
}
|
||||
if (hdest.mark == 0)
|
||||
if (hdest.label == 0)
|
||||
{
|
||||
hdest.mark = 1;
|
||||
hdest.label = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,13 +450,13 @@ namespace TriangleNet.Meshing
|
||||
}
|
||||
norg = neighbor.Org();
|
||||
ndest = neighbor.Dest();
|
||||
if (norg.mark == 0)
|
||||
if (norg.label == 0)
|
||||
{
|
||||
norg.mark = 1;
|
||||
norg.label = 1;
|
||||
}
|
||||
if (ndest.mark == 0)
|
||||
if (ndest.label == 0)
|
||||
{
|
||||
ndest.mark = 1;
|
||||
ndest.label = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,13 +119,11 @@ namespace TriangleNet.Meshing
|
||||
{
|
||||
tri.tri = item;
|
||||
|
||||
corner[0] = triangles[i].P0;
|
||||
corner[1] = triangles[i].P1;
|
||||
corner[2] = triangles[i].P2;
|
||||
|
||||
// Copy the triangle's three corners.
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
corner[j] = triangles[i].GetVertexID(j);
|
||||
|
||||
if ((corner[j] < 0) || (corner[j] >= mesh.invertices))
|
||||
{
|
||||
Log.Instance.Error("Triangle has an invalid vertex index.", "MeshReader.Reconstruct()");
|
||||
@@ -134,7 +132,7 @@ namespace TriangleNet.Meshing
|
||||
}
|
||||
|
||||
// Read the triangle's attributes.
|
||||
tri.tri.region = triangles[i].Region;
|
||||
tri.tri.label = triangles[i].Label;
|
||||
|
||||
// TODO: VarArea
|
||||
if (mesh.behavior.VarArea)
|
||||
@@ -239,7 +237,7 @@ namespace TriangleNet.Meshing
|
||||
sorg = polygon.Segments[i].GetVertex(0);
|
||||
sdest = polygon.Segments[i].GetVertex(1);
|
||||
|
||||
boundmarker = polygon.Segments[i].Boundary;
|
||||
boundmarker = polygon.Segments[i].Label;
|
||||
|
||||
if ((sorg.id < 0 || sorg.id >= mesh.invertices) || (sdest.id < 0 || sdest.id >= mesh.invertices))
|
||||
{
|
||||
@@ -364,7 +362,7 @@ namespace TriangleNet.Meshing
|
||||
{
|
||||
vertex = new HVertex(v.x, v.y);
|
||||
vertex.id = v.id;
|
||||
vertex.mark = v.mark;
|
||||
vertex.label = v.label;
|
||||
|
||||
vertices[v.id] = vertex;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace TriangleNet.Meshing
|
||||
|
||||
segments.Add(new Segment(a, b, 1));
|
||||
|
||||
a.Boundary = b.Boundary = 1;
|
||||
a.Label = b.Label = 1;
|
||||
|
||||
// Right
|
||||
a = points[nx * (ny + 1) + j];
|
||||
@@ -173,7 +173,7 @@ namespace TriangleNet.Meshing
|
||||
|
||||
segments.Add(new Segment(a, b, 1));
|
||||
|
||||
a.Boundary = b.Boundary = 1;
|
||||
a.Label = b.Label = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nx; i++)
|
||||
@@ -184,7 +184,7 @@ namespace TriangleNet.Meshing
|
||||
|
||||
segments.Add(new Segment(a, b, 1));
|
||||
|
||||
a.Boundary = b.Boundary = 1;
|
||||
a.Label = b.Label = 1;
|
||||
|
||||
// Top
|
||||
a = points[i * (ny + 1) + nx];
|
||||
@@ -192,7 +192,7 @@ namespace TriangleNet.Meshing
|
||||
|
||||
segments.Add(new Segment(a, b, 1));
|
||||
|
||||
a.Boundary = b.Boundary = 1;
|
||||
a.Label = b.Label = 1;
|
||||
}
|
||||
|
||||
// Add triangles.
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace TriangleNet.Meshing.Iterators
|
||||
public void Process(Triangle triangle)
|
||||
{
|
||||
// Default action is to just set the region id for all trianlges.
|
||||
this.Process(triangle, (tri) => { tri.region = triangle.region; });
|
||||
this.Process(triangle, (tri) => { tri.label = triangle.label; });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace TriangleNet.Smoothing
|
||||
|
||||
foreach (var face in voronoi.Faces)
|
||||
{
|
||||
if (face.generator.mark == 0)
|
||||
if (face.generator.label == 0)
|
||||
{
|
||||
Centroid(face, out x, out y);
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
namespace TriangleNet.Topology.DCEL
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using TriangleNet.Geometry;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A face of DCEL mesh.
|
||||
/// </summary>
|
||||
@@ -86,6 +87,23 @@ namespace TriangleNet.Topology.DCEL
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates all half-edges of the face boundary.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<HalfEdge> EnumerateEdges()
|
||||
{
|
||||
var edge = this.Edge;
|
||||
int first = edge.ID;
|
||||
|
||||
do
|
||||
{
|
||||
yield return edge;
|
||||
|
||||
edge = edge.Next;
|
||||
} while (edge.ID != first);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("F-ID {0}", id);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace TriangleNet.Topology
|
||||
/// <summary>
|
||||
/// Gets the segment boundary mark.
|
||||
/// </summary>
|
||||
public int Boundary
|
||||
public int Label
|
||||
{
|
||||
get { return this.boundary; }
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace TriangleNet.Topology
|
||||
internal Otri[] neighbors;
|
||||
internal Vertex[] vertices;
|
||||
internal Osub[] subsegs;
|
||||
internal int region;
|
||||
internal int label;
|
||||
internal double area;
|
||||
internal bool infected;
|
||||
|
||||
@@ -57,84 +57,12 @@ namespace TriangleNet.Topology
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first corners vertex id.
|
||||
/// Region ID the triangle belongs to.
|
||||
/// </summary>
|
||||
public int P0
|
||||
public int Label
|
||||
{
|
||||
get { return this.vertices[0] == null ? -1 : this.vertices[0].id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the seconds corners vertex id.
|
||||
/// </summary>
|
||||
public int P1
|
||||
{
|
||||
get { return this.vertices[1] == null ? -1 : this.vertices[1].id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the third corners vertex id.
|
||||
/// </summary>
|
||||
public int P2
|
||||
{
|
||||
get { return this.vertices[2] == null ? -1 : this.vertices[2].id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified corners vertex.
|
||||
/// </summary>
|
||||
public Vertex GetVertex(int index)
|
||||
{
|
||||
return this.vertices[index]; // TODO: Check range?
|
||||
}
|
||||
|
||||
public bool SupportsNeighbors
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first neighbors id.
|
||||
/// </summary>
|
||||
public int N0
|
||||
{
|
||||
get { return this.neighbors[0].tri.id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the second neighbors id.
|
||||
/// </summary>
|
||||
public int N1
|
||||
{
|
||||
get { return this.neighbors[1].tri.id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the third neighbors id.
|
||||
/// </summary>
|
||||
public int N2
|
||||
{
|
||||
get { return this.neighbors[2].tri.id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles' neighbor.
|
||||
/// </summary>
|
||||
/// <param name="index">The neighbor index (0, 1 or 2).</param>
|
||||
/// <returns>The neigbbor opposite of vertex with given index.</returns>
|
||||
public ITriangle GetNeighbor(int index)
|
||||
{
|
||||
return neighbors[index].tri.hash == Mesh.DUMMY ? null : neighbors[index].tri;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles segment.
|
||||
/// </summary>
|
||||
/// <param name="index">The vertex index (0, 1 or 2).</param>
|
||||
/// <returns>The segment opposite of vertex with given index.</returns>
|
||||
public ISegment GetSegment(int index)
|
||||
{
|
||||
return subsegs[index].seg.hash == Mesh.DUMMY ? null : subsegs[index].seg;
|
||||
get { return this.label; }
|
||||
set { this.label = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,11 +75,42 @@ namespace TriangleNet.Topology
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Region ID the triangle belongs to.
|
||||
/// Gets the specified corners vertex.
|
||||
/// </summary>
|
||||
public int Region
|
||||
public Vertex GetVertex(int index)
|
||||
{
|
||||
get { return this.region; }
|
||||
return this.vertices[index]; // TODO: Check range?
|
||||
}
|
||||
|
||||
public int GetVertexID(int index)
|
||||
{
|
||||
return this.vertices[index].id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles' neighbor.
|
||||
/// </summary>
|
||||
/// <param name="index">The neighbor index (0, 1 or 2).</param>
|
||||
/// <returns>The neigbbor opposite of vertex with given index.</returns>
|
||||
public ITriangle GetNeighbor(int index)
|
||||
{
|
||||
return neighbors[index].tri.hash == Mesh.DUMMY ? null : neighbors[index].tri;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int GetNeighborID(int index)
|
||||
{
|
||||
return neighbors[index].tri.hash == Mesh.DUMMY ? -1 : neighbors[index].tri.id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a triangles segment.
|
||||
/// </summary>
|
||||
/// <param name="index">The vertex index (0, 1 or 2).</param>
|
||||
/// <returns>The segment opposite of vertex with given index.</returns>
|
||||
public ISegment GetSegment(int index)
|
||||
{
|
||||
return subsegs[index].seg.hash == Mesh.DUMMY ? null : subsegs[index].seg;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace TriangleNet.Voronoi.Legacy
|
||||
foreach (var v in mesh.vertices.Values)
|
||||
{
|
||||
// TODO: Need a reliable way to check if a vertex is on a segment
|
||||
if (v.type == VertexType.FreeVertex || v.Boundary == 0)
|
||||
if (v.type == VertexType.FreeVertex || v.label == 0)
|
||||
{
|
||||
ConstructCell(v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user