public Edge <T> Subdivide(Edge <T> edge, List <BoundaryLine> lines, double alpha, CyclicInterval boundaryCount) { MeshCell <T> cell = edge.Cell; //Divide Ridge and update Ridge Arrays //------------------------------------- Vertex newVertex = DivideEdge(edge, alpha, out Edge <T> newRidge); edge.Twin.Cell.IntersectionVertex = newVertex.ID; //cell.IntersectionVertex = newVertex.ID; //Divide this cell //================================================================ //NewVertices Vertex[] verticesOfNewRidgeBoundary = new Vertex[lines.Count + 2]; verticesOfNewRidgeBoundary[0] = newVertex; verticesOfNewRidgeBoundary[verticesOfNewRidgeBoundary.Length - 1] = mesh.Vertices[cell.IntersectionVertex]; //Add Vertices of lines for (int i = 1; i < verticesOfNewRidgeBoundary.Length - 1; ++i) { verticesOfNewRidgeBoundary[verticesOfNewRidgeBoundary.Length - 1 - i] = lines[i - 1].End; int ID = mesh.AddVertex(verticesOfNewRidgeBoundary[verticesOfNewRidgeBoundary.Length - 1 - i]); } //New Ridges Edge <T>[] newEdges; Edge <T>[] newNeighborEdges; MeshCell <T> newCell = new MeshCell <T> { Node = new T() }; newCell.Node.Position = cell.Node.Position; mesh.AddCell(newCell); MeshMethods.CreateBoundaryEdge(verticesOfNewRidgeBoundary, cell, newCell, out newEdges, out newNeighborEdges, boundaryCount); //Link Ridges to old neighbors MeshMethods.InsertEdgesAndVertices(newEdges, newNeighborEdges); //dOnE, DoNe! return(edge); }
public Vertex DivideEdge(Edge <T> edge, double alpha, out Edge <T> newEdge) { Vector start = edge.Start.Position; Vector end = edge.End.Position; Vector intersection = start * (1 - alpha) + end * alpha; Vertex newVertex = new Vertex { Position = intersection, }; mesh.AddVertex(newVertex); newEdge = new Edge <T> { Start = newVertex, End = edge.End, Cell = edge.Cell }; Edge <T> newRidgeTwin = new Edge <T> { End = newVertex, Start = edge.End, Cell = edge.Twin.Cell, Twin = newEdge }; newEdge.Twin = newRidgeTwin; edge.End = newVertex; edge.Twin.Start = newVertex; MeshMethods.InsertEdgesAndVertices(newEdge); MeshMethods.InsertEdgesAndVertices(newRidgeTwin); return(newVertex); }