Files
ShrlAlgoToolkit/ShrlAlgoToolkit.RevitAddins/RvIndependent/MetroGauges/LandXMLData/BorderLine.cs
2025-04-24 20:56:10 +08:00

182 lines
4.0 KiB
C#

using System.Xml.Serialization;
namespace ShrlAlgo.RvKits.RvIndependent.MetroGauges.LandXMLData
{
[XmlType("BorderLine")]
[Serializable]
public class BorderLine
{
public BorderLine()
{
Points = new List<Point3D>();
}
[XmlIgnore]
public Point3D this[int index]
{
get
{
if (index < Points.Count)
{
return Points[index];
}
throw new IndexOutOfRangeException();
}
set
{
if (index < Points.Count)
{
Points[index] = value;
return;
}
if (index == Points.Count)
{
Points.Add(value);
return;
}
throw new IndexOutOfRangeException();
}
}
[XmlIgnore]
public int Count => Points.Count;
[XmlIgnore]
public bool IsReadOnly => false;
[XmlIgnore]
public string NameIndex => Name + " " + Index;
[XmlAttribute("i")]
public int Index { get; set; }
[XmlElement("BorderPoint")]
public List<Point3D> Points { get; set; }
[XmlAttribute("name")]
public string Name { get; set; }
public void Add(Point3D item)
{
Points.Add(item);
}
public void Clear()
{
Points.Clear();
}
public bool Contains(Point3D item)
{
return Points.Contains(item);
}
public void CopyTo(Point3D[] array, int arrayIndex)
{
Points.CopyTo(array, arrayIndex);
}
public override bool Equals(object obj)
{
return this == (BorderLine)obj;
}
public IEnumerator<Point3D> GetEnumerator()
{
return Points.GetEnumerator();
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public int IndexOf(Point3D item)
{
return Points.IndexOf(item);
}
public void Insert(int index, Point3D item)
{
Points.Insert(index, item);
}
public static bool operator ==(BorderLine b1, BorderLine b2)
{
if (ReferenceEquals(b1, b2))
{
return true;
}
if (b1 == null || b2 == null)
{
return false;
}
if (b1.Index == b2.Index && b1.Name == b2.Name && b1.Count == b2.Count)
{
for (int i = 0; i < b1.Count; i++)
{
if (b1[i] != b2[i])
{
return false;
}
}
return true;
}
return false;
}
public static bool operator !=(BorderLine b1, BorderLine b2)
{
if (ReferenceEquals(b1, b2))
{
return false;
}
if (b1 == null || b2 == null)
{
return true;
}
if (b1.Index == b2.Index && b1.Name == b2.Name && b1.Count == b2.Count)
{
for (int i = 0; i < b1.Count; i++)
{
if (b1[i] != b2[i])
{
return true;
}
}
return false;
}
return true;
}
public bool Remove(Point3D item)
{
return Points.Remove(item);
}
public void RemoveAt(int index)
{
Points.RemoveAt(index);
}
public void Transform(GeometryTransformations transformations)
{
foreach (Point3D point in Points)
{
transformations.Transform(point);
}
}
}
}