// Copyright (c) 2013-2015 Robert Rouhani and other contributors (see CONTRIBUTORS file). // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE using System; using System.Collections.Generic; using System.Linq; using SharpNav.Geometry; namespace SharpNav { //TODO should this be ISet? Are the extra methods useful? /// /// A set of contours around the regions of a , used as the edges of a /// . /// public class ContourSet : ICollection { private List contours; private BBox3 bounds; private int width; private int height; /// /// Initializes a new instance of the class. /// /// A collection of s. /// The bounding box that contains all of the s. /// The width, in voxel units, of the world. /// The height, in voxel units, of the world. public ContourSet(IEnumerable contours, BBox3 bounds, int width, int height) { this.contours = contours.ToList(); this.bounds = bounds; this.width = width; this.height = height; } /// /// Gets the number of s in the set. /// public int Count { get { return contours.Count; } } /// /// Gets the world-space bounding box of the set. /// public BBox3 Bounds { get { return bounds; } } /// /// Gets the width of the set, not including the border size specified in . /// public int Width { get { return width; } } /// /// Gets the height of the set, not including the border size specified in . /// public int Height { get { return height; } } /// /// Gets a value indicating whether the is read-only. /// bool ICollection.IsReadOnly { get { return true; } } /// /// Checks if a specified is contained in the . /// /// A contour. /// A value indicating whether the set contains the specified contour. public bool Contains(Contour item) { return contours.Contains(item); } /// /// Copies the s in the set to an array. /// /// The array to copy to. /// The zero-based index in array at which copying begins. public void CopyTo(Contour[] array, int arrayIndex) { contours.CopyTo(array, arrayIndex); } /// /// Returns an enumerator that iterates through the entire . /// /// An enumerator. public IEnumerator GetEnumerator() { return contours.GetEnumerator(); } //TODO support the extra ICollection methods later? /// /// Add a new contour to the set /// /// The contour to add void ICollection.Add(Contour item) { throw new InvalidOperationException(); } /// /// (Not implemented) Clear the list /// void ICollection.Clear() { throw new InvalidOperationException(); } /// /// (Not implemented) Remove a contour from the set /// /// The contour to remove /// throw InvalidOperatorException bool ICollection.Remove(Contour item) { throw new InvalidOperationException(); } /// /// Gets an enumerator that iterates through the set /// /// The enumerator System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } } }