| | 1 | | // <copyright file="ObjCurveIndex.cs" company="Jérémy Ansel"> |
| | 2 | | // Copyright (c) 2017, 2019 Jérémy Ansel |
| | 3 | | // </copyright> |
| | 4 | | // <license> |
| | 5 | | // Licensed under the MIT license. See LICENSE.txt |
| | 6 | | // </license> |
| | 7 | |
|
| | 8 | | using System.Globalization; |
| | 9 | |
|
| | 10 | | namespace JeremyAnsel.Media.WavefrontObj |
| | 11 | | { |
| | 12 | | [System.Diagnostics.DebuggerDisplay("Curve Index:{Curve2D} Start:{Start} End:{End}")] |
| | 13 | | public struct ObjCurveIndex : IEquatable<ObjCurveIndex> |
| | 14 | | { |
| | 15 | | private float start; |
| | 16 | |
|
| | 17 | | private float end; |
| | 18 | |
|
| | 19 | | private int curve2D; |
| | 20 | |
|
| | 21 | | public ObjCurveIndex(float startParameter, float endParameter, int curve2DIndex) |
| | 22 | | { |
| 72 | 23 | | this.start = startParameter; |
| 72 | 24 | | this.end = endParameter; |
| 72 | 25 | | this.curve2D = curve2DIndex; |
| 72 | 26 | | } |
| | 27 | |
|
| | 28 | | public float Start |
| | 29 | | { |
| 57 | 30 | | get { return this.start; } |
| 6 | 31 | | set { this.start = value; } |
| | 32 | | } |
| | 33 | |
|
| | 34 | | public float End |
| | 35 | | { |
| 57 | 36 | | get { return this.end; } |
| 6 | 37 | | set { this.end = value; } |
| | 38 | | } |
| | 39 | |
|
| | 40 | | public int Curve2D |
| | 41 | | { |
| 57 | 42 | | get { return this.curve2D; } |
| 6 | 43 | | set { this.curve2D = value; } |
| | 44 | | } |
| | 45 | |
|
| | 46 | | public override bool Equals(object? obj) |
| | 47 | | { |
| 0 | 48 | | return obj is ObjCurveIndex index && Equals(index); |
| | 49 | | } |
| | 50 | |
|
| | 51 | | public bool Equals(ObjCurveIndex other) |
| | 52 | | { |
| 0 | 53 | | return start == other.start && |
| 0 | 54 | | end == other.end && |
| 0 | 55 | | curve2D == other.curve2D; |
| | 56 | | } |
| | 57 | |
|
| | 58 | | public override int GetHashCode() |
| | 59 | | { |
| 0 | 60 | | var hashCode = -540012629; |
| 0 | 61 | | hashCode = hashCode * -1521134295 + start.GetHashCode(); |
| 0 | 62 | | hashCode = hashCode * -1521134295 + end.GetHashCode(); |
| 0 | 63 | | hashCode = hashCode * -1521134295 + curve2D.GetHashCode(); |
| 0 | 64 | | return hashCode; |
| | 65 | | } |
| | 66 | |
|
| | 67 | | public override string ToString() |
| | 68 | | { |
| 27 | 69 | | return string.Concat( |
| 27 | 70 | | this.Start.ToString("F6", CultureInfo.InvariantCulture), |
| 27 | 71 | | " ", |
| 27 | 72 | | this.End.ToString("F6", CultureInfo.InvariantCulture), |
| 27 | 73 | | " ", |
| 27 | 74 | | this.Curve2D.ToString(CultureInfo.InvariantCulture)); |
| | 75 | | } |
| | 76 | |
|
| | 77 | | public static bool operator ==(ObjCurveIndex left, ObjCurveIndex right) |
| | 78 | | { |
| 0 | 79 | | return left.Equals(right); |
| | 80 | | } |
| | 81 | |
|
| | 82 | | public static bool operator !=(ObjCurveIndex left, ObjCurveIndex right) |
| | 83 | | { |
| 0 | 84 | | return !(left == right); |
| | 85 | | } |
| | 86 | | } |
| | 87 | | } |
| | 88 | |
|