| | 1 | | using Newtonsoft.Json; |
| | 2 | | using System; |
| | 3 | | using System.ComponentModel; |
| | 4 | | using System.ComponentModel.DataAnnotations; |
| | 5 | |
|
| | 6 | | namespace Morpho25.Geometry |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Nesting grids class. |
| | 10 | | /// </summary> |
| | 11 | | public class NestingGrids : IEquatable<NestingGrids> |
| | 12 | | { |
| | 13 | | [DisplayName("First Material")] |
| | 14 | | [Description("First profile material to use.")] |
| | 15 | | [MinLength(6, ErrorMessage = "The value cannot exceed 6 characters.")] |
| | 16 | | [MaxLength(6, ErrorMessage = "The value cannot exceed 6 characters.")] |
| | 17 | | [JsonProperty("firstMaterial")] |
| | 18 | | /// <summary> |
| | 19 | | /// First material. |
| | 20 | | /// </summary> |
| 18 | 21 | | public string FirstMaterial { get; private set; } |
| | 22 | |
|
| | 23 | | [DisplayName("Second Material")] |
| | 24 | | [Description("Second profile material to use.")] |
| | 25 | | [MinLength(6, ErrorMessage = "The value cannot exceed 6 characters.")] |
| | 26 | | [MaxLength(6, ErrorMessage = "The value cannot exceed 6 characters.")] |
| | 27 | | [JsonProperty("secondMaterial")] |
| | 28 | | /// <summary> |
| | 29 | | /// Second material. |
| | 30 | | /// </summary> |
| 18 | 31 | | public string SecondMaterial { get; private set; } |
| | 32 | |
|
| | 33 | | [DisplayName("Number Of Cells")] |
| | 34 | | [Description("Number of cell to add to domain.")] |
| | 35 | | [JsonProperty("numberOfCells")] |
| | 36 | | /// <summary> |
| | 37 | | /// Number of cells. |
| | 38 | | /// </summary> |
| 18 | 39 | | public uint NumberOfCells { get; private set; } |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Create a new nesting grids object. |
| | 43 | | /// </summary> |
| 4 | 44 | | public NestingGrids() |
| 4 | 45 | | { |
| 4 | 46 | | NumberOfCells = 0; |
| 4 | 47 | | FirstMaterial = Material.DEFAULT_SOIL; |
| 4 | 48 | | SecondMaterial = Material.DEFAULT_SOIL; |
| 4 | 49 | | } |
| | 50 | |
|
| | 51 | | [JsonConstructor] |
| | 52 | | /// <summary> |
| | 53 | | /// Create a new nesting grids object. |
| | 54 | | /// </summary> |
| | 55 | | /// <param name="numberOfCells">Number of cells.</param> |
| | 56 | | /// <param name="firstMaterial">First material.</param> |
| | 57 | | /// <param name="secondMaterial">Second material.</param> |
| 8 | 58 | | public NestingGrids(uint numberOfCells, |
| 8 | 59 | | string firstMaterial, |
| 8 | 60 | | string secondMaterial) |
| 8 | 61 | | { |
| 8 | 62 | | NumberOfCells = numberOfCells; |
| 8 | 63 | | FirstMaterial = firstMaterial; |
| 8 | 64 | | SecondMaterial = secondMaterial; |
| 8 | 65 | | } |
| | 66 | | public bool Equals(NestingGrids other) |
| 2 | 67 | | { |
| 2 | 68 | | if (other == null) |
| 0 | 69 | | return false; |
| | 70 | |
|
| 2 | 71 | | if (other != null |
| 2 | 72 | | && other.NumberOfCells == this.NumberOfCells |
| 2 | 73 | | && other.FirstMaterial == this.FirstMaterial |
| 2 | 74 | | && other.SecondMaterial == this.SecondMaterial) |
| 2 | 75 | | return true; |
| | 76 | | else |
| 0 | 77 | | return false; |
| 2 | 78 | | } |
| | 79 | |
|
| | 80 | | public override bool Equals(Object obj) |
| 0 | 81 | | { |
| 0 | 82 | | if (obj == null) |
| 0 | 83 | | return false; |
| | 84 | |
|
| 0 | 85 | | var faceObj = obj as NestingGrids; |
| 0 | 86 | | if (faceObj == null) |
| 0 | 87 | | return false; |
| | 88 | | else |
| 0 | 89 | | return Equals(faceObj); |
| 0 | 90 | | } |
| | 91 | |
|
| | 92 | | public override int GetHashCode() |
| 0 | 93 | | { |
| | 94 | | unchecked |
| 0 | 95 | | { |
| 0 | 96 | | int hash = 17; |
| 0 | 97 | | hash = hash * 23 + FirstMaterial.GetHashCode(); |
| 0 | 98 | | hash = hash * 23 + SecondMaterial.GetHashCode(); |
| 0 | 99 | | hash = hash * 23 + NumberOfCells.GetHashCode(); |
| 0 | 100 | | return hash; |
| | 101 | | } |
| 0 | 102 | | } |
| | 103 | |
|
| | 104 | | public static bool operator ==(NestingGrids nesting1, NestingGrids nesting2) |
| 25 | 105 | | { |
| 25 | 106 | | if (((object)nesting1) == null || ((object)nesting2) == null) |
| 23 | 107 | | return Object.Equals(nesting1, nesting2); |
| | 108 | |
|
| 2 | 109 | | return nesting1.Equals(nesting2); |
| 25 | 110 | | } |
| | 111 | |
|
| | 112 | | public static bool operator !=(NestingGrids nesting1, NestingGrids nesting2) |
| 2 | 113 | | { |
| 2 | 114 | | return !(nesting1 == nesting2); |
| 2 | 115 | | } |
| | 116 | | } |
| | 117 | | } |