/******************************************************************************
*
* The MIT License (MIT)
*
* LiquidVolumeFX.MIConvexHull, Copyright (c) 2015 David Sehnal, Matthew Campbell
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*****************************************************************************/
namespace LiquidVolumeFX.MIConvexHull
{
///
/// A class representing an (undirected) edge of the Voronoi graph.
///
/// The type of the t vertex.
/// The type of the t cell.
public class VoronoiEdge
where TVertex : IVertex
where TCell : TriangulationCell
{
///
/// Create an instance of the edge.
///
public VoronoiEdge()
{
}
///
/// Create an instance of the edge.
///
/// The source.
/// The target.
public VoronoiEdge(TCell source, TCell target)
{
Source = source;
Target = target;
}
///
/// Source of the edge.
///
/// The source.
public TCell Source { get; internal set; }
///
/// Target of the edge.
///
/// The target.
public TCell Target { get; internal set; }
///
/// ...
///
/// The object to compare with the current object.
/// true if the specified is equal to this instance; otherwise, false.
public override bool Equals(object obj)
{
var other = obj as VoronoiEdge;
if (other == null) return false;
if (ReferenceEquals(this, other)) return true;
return (Source == other.Source && Target == other.Target)
|| (Source == other.Target && Target == other.Source);
}
///
/// ...
///
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
public override int GetHashCode()
{
var hash = 23;
hash = hash*31 + Source.GetHashCode();
return hash*31 + Target.GetHashCode();
}
}
}