-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathVertex.cs
125 lines (110 loc) · 3.74 KB
/
Vertex.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// -----------------------------------------------------------------------
// <copyright file="Vertex.cs" company="">
// Triangle.NET Copyright (c) 2012-2022 Christian Woltering
// </copyright>
// -----------------------------------------------------------------------
namespace TriangleNet.Geometry
{
using System;
using TriangleNet.Topology;
/// <summary>
/// The vertex data structure.
/// </summary>
public class Vertex : Point
{
// Hash for dictionary. Will be set by mesh instance.
internal int hash;
#if USE_ATTRIBS
internal double[] attributes;
#endif
internal VertexType type;
internal Otri tri;
/// <summary>
/// Initializes a new instance of the <see cref="Vertex" /> class.
/// </summary>
public Vertex()
: this(0, 0, 0)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Vertex" /> class.
/// </summary>
/// <param name="x">The x coordinate of the vertex.</param>
/// <param name="y">The y coordinate of the vertex.</param>
public Vertex(double x, double y)
: this(x, y, 0)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Vertex" /> class.
/// </summary>
/// <param name="x">The x coordinate of the vertex.</param>
/// <param name="y">The y coordinate of the vertex.</param>
/// <param name="mark">The boundary mark.</param>
public Vertex(double x, double y, int mark)
: base(x, y, mark)
{
type = VertexType.InputVertex;
}
/// <summary>
/// Initializes a new instance of the <see cref="Vertex" /> class.
/// </summary>
/// <param name="x">The x coordinate of the vertex.</param>
/// <param name="y">The y coordinate of the vertex.</param>
/// <param name="mark">The boundary mark.</param>
/// <param name="type">The vertex type.</param>
public Vertex(double x, double y, int mark, VertexType type)
: base(x, y, mark)
{
this.type = type;
}
#if USE_ATTRIBS
/// <summary>
/// Initializes a new instance of the <see cref="Vertex" /> class.
/// </summary>
/// <param name="x">The x coordinate of the vertex.</param>
/// <param name="y">The y coordinate of the vertex.</param>
/// <param name="mark">The boundary mark.</param>
/// <param name="attribs">The number of point attributes.</param>
public Vertex(double x, double y, int mark, int attribs)
: this(x, y, mark)
{
if (attribs > 0)
{
this.attributes = new double[attribs];
}
}
#endif
#region Public properties
#if USE_ATTRIBS
/// <summary>
/// Gets the vertex attributes (may be null).
/// </summary>
public double[] Attributes
{
get { return this.attributes; }
}
#endif
/// <summary>
/// Gets the vertex type.
/// </summary>
public VertexType Type => type;
/// <summary>
/// Gets the specified coordinate of the vertex.
/// </summary>
/// <param name="i">Coordinate index.</param>
/// <returns>X coordinate, if index is 0, Y coordinate, if index is 1.</returns>
public double this[int i]
{
get
{
if (i == 0) return x;
if (i == 1) return y;
throw new ArgumentOutOfRangeException("Index must be 0 or 1.");
}
}
#endregion
/// <inheritdoc />
public override int GetHashCode() => hash;
}
}