/// <summary> /// Takes sequence of vertices, turns them into face and returns active part of face in replacedBy /// </summary> /// <param name="selected">Sequence of original vertices.</param> /// <param name="replacedBy">Sequence of new vertices.</param> /// <param name="faceSize">size of face used when connecting selected.</param> void Replace(IList <VertexStack> selected, out List <VertexStack> replacedBy, int faceSize) { var newFace = selected.Select(x => x.ID).ToList(); //střed vybraných bude neaktivní for (int i = 1; i < selected.Count - 1; i++) { SingleVertex temp = selected[i].Peek().Clone(); temp.IsActive = false; selected[i].Push(temp); } replacedBy = new List <VertexStack>(); replacedBy.Add(selected[0]); selected[0].Push(selected[0].Peek().Clone()); for (int i = 0; i < faceSize - selected.Count; i++) { VertexStack tempVS = new VertexStack(triarc.CountOfVertices); newFace.Add(tempVS.ID); triarc.vertices.Add(tempVS); triarc.CountOfVertices++; SingleVertex tempV = new SingleVertex(); tempV.A = replacedBy[i]; tempV.IsActive = true; tempVS.Push(tempV); SingleVertex tempP = replacedBy[i].Pop(); if (tempP.B == null) { tempP.B = tempVS; } else { tempP.C = tempVS; } replacedBy[i].Push(tempP); replacedBy.Add(tempVS); } //and connect last { VertexStack tempVS = selected[selected.Count - 1]; SingleVertex tempV = tempVS.Peek().Clone(); tempV.C = replacedBy[replacedBy.Count - 1]; tempV.IsActive = true; tempVS.Push(tempV); SingleVertex tempP = replacedBy[replacedBy.Count - 1].Pop(); if (tempP.B == null) { tempP.B = tempVS; } else { tempP.C = tempVS; } replacedBy[replacedBy.Count - 1].Push(tempP); replacedBy.Add(tempVS); } triarc.Faces.Add(newFace); }
/// <summary> /// Clones this object. /// </summary> /// <returns>Clone of this object.</returns> public SingleVertex Clone() { var clone = new SingleVertex(); clone.A = this.A; clone.B = this.B; clone.c = this.c; clone.IsActive = this.IsActive; return(clone); }
public void CreateOuterBoundaryVertices(long boundary) { VertexStack Outside = new VertexStack(-1); SingleVertex o = new SingleVertex(); o.A = Outside; o.B = Outside; o.C = Outside; o.IsActive = false; Outside.Push(o); List <VertexStack> vrcholy = new List <VertexStack>(); for (int i = 0; i < NumberOfVerticesInOuterBoundary; i++) { vrcholy.Add(new VertexStack(i)); vrcholy[i].Push(new SingleVertex()); } //praví sousedé + aktivní for (int i = 0; i < NumberOfVerticesInOuterBoundary; i++) { SingleVertex temp = vrcholy[i].Pop(); temp.IsActive = true; temp.A = vrcholy[(i + 1) % NumberOfVerticesInOuterBoundary]; vrcholy[i].Push(temp); } //leví sousedé for (int i = 1; i < NumberOfVerticesInOuterBoundary + 1; i++) { SingleVertex temp = vrcholy[i % NumberOfVerticesInOuterBoundary].Pop(); temp.B = vrcholy[(i - 1) % NumberOfVerticesInOuterBoundary]; vrcholy[i % NumberOfVerticesInOuterBoundary].Push(temp); } for (int i = 0; i < NumberOfVerticesInOuterBoundary; i++) { if ((boundary & ((long)1 << i)) == 0) { SingleVertex temp = vrcholy[i].Pop(); temp.C = Outside; vrcholy[i].Push(temp); } } this.vertices = vrcholy; this.CountOfVertices = vertices.Count; }
/// <summary> /// Inserts a vertex on top of stack. /// </summary> /// <param name="vertex"></param> public void Push(SingleVertex vertex) { stack.Push(vertex); }