/// <summary> /// Initialize buffers and lists. /// </summary> /// <param name="config"></param> void InitializeData(ConvexHullComputationConfig config) { ConvexHull = new IndexBuffer(); UnprocessedFaces = new FaceList(); ConvexFaces = new IndexBuffer(); FacePool = new ConvexFaceInternal[(Dimension + 1) * 10]; // must be initialized before object manager AffectedFaceFlags = new bool[(Dimension + 1) * 10]; ObjectManager = new MIConvexHull.ObjectManager(this); Center = new double[Dimension]; TraverseStack = new IndexBuffer(); UpdateBuffer = new int[Dimension]; UpdateIndices = new int[Dimension]; EmptyBuffer = new IndexBuffer(); AffectedFaceBuffer = new IndexBuffer(); ConeFaceBuffer = new SimpleList <DeferredFace>(); SingularVertices = new HashSet <int>(); BeyondBuffer = new IndexBuffer(); ConnectorTable = new ConnectorList[ConnectorTableSize]; for (int i = 0; i < ConnectorTableSize; i++) { ConnectorTable[i] = new ConnectorList(); } VertexMarks = new bool[Vertices.Length]; VertexAdded = new bool[Vertices.Length]; InitializePositions(config); MathHelper = new MIConvexHull.MathHelper(Dimension, Positions); }
private void InitializeData(ConvexHullComputationConfig config) { this.UnprocessedFaces = new FaceList(); this.ConvexFaces = new IndexBuffer(); this.FacePool = new ConvexFaceInternal[(this.Dimension + 1) * 10]; this.AffectedFaceFlags = new bool[(this.Dimension + 1) * 10]; this.ObjectManager = new MIConvexHull.ObjectManager(this); this.Center = new double[this.Dimension]; this.TraverseStack = new IndexBuffer(); this.UpdateBuffer = new int[this.Dimension]; this.UpdateIndices = new int[this.Dimension]; this.EmptyBuffer = new IndexBuffer(); this.AffectedFaceBuffer = new IndexBuffer(); this.ConeFaceBuffer = new SimpleList <DeferredFace>(); this.SingularVertices = new HashSet <int>(); this.BeyondBuffer = new IndexBuffer(); this.ConnectorTable = new ConnectorList[0x7e1]; for (int i = 0; i < 0x7e1; i++) { this.ConnectorTable[i] = new ConnectorList(); } this.VertexMarks = new bool[this.Vertices.Length]; this.InitializePositions(config); this.MathHelper = new MIConvexHull.MathHelper(this.Dimension, this.Positions); }
/// <summary> /// Initialize buffers and lists. /// </summary> void Initialize() { ConvexHull = new List <VertexWrap>(); UnprocessedFaces = new FaceList(); // new LinkedList<ConvexFaceInternal>(); ConvexFaces = new List <ConvexFaceInternal>(); Center = new double[Dimension]; ntX = new double[Dimension]; ntY = new double[Dimension]; ntZ = new double[Dimension]; TraverseStack = new Stack <ConvexFaceInternal>(); UpdateBuffer = new ConvexFaceInternal[Dimension]; UpdateIndices = new int[Dimension]; RecycledFaceStack = new Stack <ConvexFaceInternal>(); ConnectorStack = new Stack <FaceConnector>(); EmptyBufferStack = new Stack <VertexBuffer>(); EmptyBuffer = new VertexBuffer(); AffectedFaceBuffer = new List <ConvexFaceInternal>(); BeyondBuffer = new VertexBuffer(); ConnectorTable = Enumerable.Range(0, ConnectorTableSize).Select(_ => new ConnectorList()).ToArray(); nDNormalSolveVector = new double[Dimension]; jaggedNDMatrix = new double[Dimension][]; for (var i = 0; i < Dimension; i++) { nDNormalSolveVector[i] = 1.0; jaggedNDMatrix[i] = new double[Dimension]; } nDMatrix = new double[Dimension, Dimension]; }
/// <summary> /// Initializes a new instance of the <see cref="ConvexHullAlgorithm" /> class. /// </summary> /// <param name="vertices">The vertices.</param> /// <param name="lift">if set to <c>true</c> [lift].</param> /// <param name="PlaneDistanceTolerance">The plane distance tolerance.</param> /// <exception cref="System.InvalidOperationException">Dimension of the input must be 2 or greater.</exception> /// <exception cref="System.ArgumentException">There are too few vertices (m) for the n-dimensional space. (m must be greater + /// than the n, but m is + NumberOfVertices + and n is + NumOfDimensions</exception> /// <exception cref="InvalidOperationException">PointTranslationGenerator cannot be null if PointTranslationType is enabled. /// or /// Dimension of the input must be 2 or greater.</exception> /// <exception cref="ArgumentException">There are too few vertices (m) for the n-dimensional space. (m must be greater " + /// "than the n, but m is " + NumberOfVertices + " and n is " + Dimension</exception> internal ConvexHullAlgorithm(IVertex[] vertices, bool lift, double PlaneDistanceTolerance) { IsLifted = lift; Vertices = vertices; NumberOfVertices = vertices.Length; NumOfDimensions = DetermineDimension(); if (IsLifted) { NumOfDimensions++; } if (NumOfDimensions < 2) { throw new ConvexHullGenerationException(ConvexHullCreationResultOutcome.DimensionSmallerTwo, "Dimension of the input must be 2 or greater."); } if (NumOfDimensions == 2) { throw new ConvexHullGenerationException(ConvexHullCreationResultOutcome.DimensionTwoWrongMethod, "Dimension of the input is 2. Thus you should use the Create2D method" + " instead of the Create."); } if (NumberOfVertices <= NumOfDimensions) { throw new ConvexHullGenerationException(ConvexHullCreationResultOutcome.NotEnoughVerticesForDimension, "There are too few vertices (m) for the n-dimensional space. (m must be greater " + "than the n, but m is " + NumberOfVertices + " and n is " + NumOfDimensions); } this.PlaneDistanceTolerance = PlaneDistanceTolerance; UnprocessedFaces = new FaceList(); ConvexFaces = new IndexBuffer(); FacePool = new ConvexFaceInternal[(NumOfDimensions + 1) * 10]; // must be initialized before object manager AffectedFaceFlags = new bool[(NumOfDimensions + 1) * 10]; ObjectManager = new ObjectManager(this); Center = new double[NumOfDimensions]; TraverseStack = new IndexBuffer(); UpdateBuffer = new int[NumOfDimensions]; UpdateIndices = new int[NumOfDimensions]; EmptyBuffer = new IndexBuffer(); AffectedFaceBuffer = new IndexBuffer(); ConeFaceBuffer = new SimpleList <DeferredFace>(); SingularVertices = new HashSet <int>(); BeyondBuffer = new IndexBuffer(); ConnectorTable = new ConnectorList[Constants.ConnectorTableSize]; for (var i = 0; i < Constants.ConnectorTableSize; i++) { ConnectorTable[i] = new ConnectorList(); } VertexVisited = new bool[NumberOfVertices]; Positions = new double[NumberOfVertices * NumOfDimensions]; boundingBoxPoints = new List <int> [NumOfDimensions]; minima = new double[NumOfDimensions]; maxima = new double[NumOfDimensions]; mathHelper = new MathHelper(NumOfDimensions, Positions); }
/// <summary> /// Initializes a new instance of the <see cref="ConvexHullAlgorithm" /> class. /// </summary> /// <param name="vertices">The vertices.</param> /// <param name="lift">if set to <c>true</c> [lift].</param> /// <param name="PlaneDistanceTolerance">The plane distance tolerance.</param> /// <exception cref="System.InvalidOperationException">Dimension of the input must be 2 or greater.</exception> /// <exception cref="System.ArgumentException">There are too few vertices (m) for the n-dimensional space. (m must be greater + /// than the n, but m is + NumberOfVertices + and n is + NumOfDimensions</exception> /// <exception cref="InvalidOperationException">PointTranslationGenerator cannot be null if PointTranslationType is enabled. /// or /// Dimension of the input must be 2 or greater.</exception> /// <exception cref="ArgumentException">There are too few vertices (m) for the n-dimensional space. (m must be greater " + /// "than the n, but m is " + NumberOfVertices + " and n is " + Dimension</exception> private ConvexHullAlgorithm(IVertex[] vertices, bool lift, float PlaneDistanceTolerance) { IsLifted = lift; Vertices = vertices; NumberOfVertices = vertices.Length; NumOfDimensions = DetermineDimension(); if (IsLifted) { NumOfDimensions++; } if (NumOfDimensions < 2) { throw new InvalidOperationException("Dimension of the input must be 2 or greater."); } if (NumberOfVertices <= NumOfDimensions) { throw new ArgumentException( "There are too few vertices (m) for the n-dimensional space. (m must be greater " + "than the n, but m is " + NumberOfVertices + " and n is " + NumOfDimensions); } this.PlaneDistanceTolerance = PlaneDistanceTolerance; UnprocessedFaces = new FaceList(); ConvexFaces = new IndexBuffer(); FacePool = new ConvexFaceInternal[(NumOfDimensions + 1) * 10]; // must be initialized before object manager AffectedFaceFlags = new bool[(NumOfDimensions + 1) * 10]; ObjectManager = new ObjectManager(this); Center = new float[NumOfDimensions]; TraverseStack = new IndexBuffer(); UpdateBuffer = new int[NumOfDimensions]; UpdateIndices = new int[NumOfDimensions]; EmptyBuffer = new IndexBuffer(); AffectedFaceBuffer = new IndexBuffer(); ConeFaceBuffer = new SimpleList <DeferredFace>(); SingularVertices = new HashSet <int>(); BeyondBuffer = new IndexBuffer(); ConnectorTable = new ConnectorList[Constants.ConnectorTableSize]; for (var i = 0; i < Constants.ConnectorTableSize; i++) { ConnectorTable[i] = new ConnectorList(); } VertexVisited = new bool[NumberOfVertices]; Positions = new float[NumberOfVertices * NumOfDimensions]; boundingBoxPoints = new List <int> [NumOfDimensions]; minima = new float[NumOfDimensions]; maxima = new float[NumOfDimensions]; mathHelper = new MathHelper(NumOfDimensions, Positions); }
/// <summary> /// Initialize buffers and lists. /// </summary> void Initialize() { ConvexHull = new List <VertexWrap>(); UnprocessedFaces = new FaceList(); // new LinkedList<ConvexFaceInternal>(); ConvexFaces = new List <ConvexFaceInternal>(); ObjectManager = new MIConvexHull.ObjectManager(Dimension); MathHelper = new MIConvexHull.MathHelper(Dimension); Center = new double[Dimension]; TraverseStack = new Stack <ConvexFaceInternal>(); UpdateBuffer = new ConvexFaceInternal[Dimension]; UpdateIndices = new int[Dimension]; EmptyBuffer = new VertexBuffer(); AffectedFaceBuffer = new List <ConvexFaceInternal>(); ConeFaceBuffer = new List <DeferredFace>(); SingularVertices = new HashSet <VertexWrap>(); BeyondBuffer = new VertexBuffer(); ConnectorTable = Enumerable.Range(0, ConnectorTableSize).Select(_ => new ConnectorList()).ToArray(); }
/// <summary> /// Initialize buffers and lists. /// </summary> /// <param name="config"></param> void InitializeData(ConvexHullComputationConfig config) { UnprocessedFaces = new FaceList(); ConvexFaces = new IndexBuffer(); FacePool = new ConvexFaceInternal[(Dimension + 1) * 10]; // must be initialized before object manager AffectedFaceFlags = new bool[(Dimension + 1) * 10]; ObjectManager = new MIConvexHull.ObjectManager(this); Center = new double[Dimension]; TraverseStack = new IndexBuffer(); UpdateBuffer = new int[Dimension]; UpdateIndices = new int[Dimension]; EmptyBuffer = new IndexBuffer(); AffectedFaceBuffer = new IndexBuffer(); ConeFaceBuffer = new SimpleList<DeferredFace>(); SingularVertices = new HashSet<int>(); BeyondBuffer = new IndexBuffer(); ConnectorTable = new ConnectorList[ConnectorTableSize]; for (int i = 0; i < ConnectorTableSize; i++) ConnectorTable[i] = new ConnectorList(); VertexMarks = new bool[Vertices.Length]; InitializePositions(config); MathHelper = new MIConvexHull.MathHelper(Dimension, Positions); }