void HandleLastCell(List <BoundaryLine> lines) { //Handle last cell //----------------------------------------------------------- switch (state.Case) { case IntersectionCase.NotIntersecting: lines.AddRange(firstCell.linesFirstCell); meshIntersecter.CloseMesh(lines, firstCell.firstCellCutRidge, boundaryLines.LineIndex()); break; case IntersectionCase.EndOfLine: case IntersectionCase.EndOfEdgeAndLine: if (firstCell.CutCase != IntersectionCase.StartOfLine) { CyclicInterval lineIndex = boundaryLines.LineIndex(); lineIndex.Previous(); meshIntersecter.CloseMesh(firstCell.firstCellCutRidge, lineIndex); } break; case IntersectionCase.EndOfEdge: case IntersectionCase.InMiddle: default: throw new Exception(); } }
public void CloseMesh(List <BoundaryLine> lines, Edge <T> firstCutEdge, CyclicInterval boundaryCount) { MeshCell <T> cell = firstCutEdge.Cell; //Divide this cell //================================================================ //NewVertices Vertex[] verticesOfNewRidgeBoundary = new Vertex[lines.Count + 2]; verticesOfNewRidgeBoundary[0] = firstCutEdge.End; verticesOfNewRidgeBoundary[verticesOfNewRidgeBoundary.Length - 1] = mesh.Vertices[cell.IntersectionVertex]; //Add Vertices of lines for (int i = 1; i < verticesOfNewRidgeBoundary.Length - 1; ++i) { verticesOfNewRidgeBoundary[i] = lines[lines.Count - i].End; int ID = mesh.AddVertex(verticesOfNewRidgeBoundary[i]); } //New Edges MeshCell <T> newCell = new MeshCell <T>(); mesh.AddCell(newCell); MeshMethods.CreateBoundaryEdge( verticesOfNewRidgeBoundary, cell, newCell, out Edge <T>[] newEdges, out Edge <T>[] newNeighborEdges,
public static void CreateBoundaryEdge <T>( Vertex[] vertices, MeshCell <T> cell, MeshCell <T> neighborCell, out Edge <T>[] ridges, out Edge <T>[] twinEdges, CyclicInterval boundaryCount) { int count = vertices.Length - 1; ridges = new Edge <T> [count]; twinEdges = new Edge <T> [count]; for (int i = 0; i < count; ++i) { Edge <T> ridge = new Edge <T> { Start = vertices[i], End = vertices[i + 1], Cell = cell, IsBoundary = true, BoundaryEdgeNumber = boundaryCount.Current(), }; Edge <T> twinRidge = new Edge <T> { Start = vertices[i + 1], End = vertices[i], Twin = ridge, Cell = neighborCell, IsBoundary = true, BoundaryEdgeNumber = boundaryCount.Current(), }; ridge.Twin = twinRidge; ridges[i] = ridge; twinEdges[count - 1 - i] = twinRidge; boundaryCount.Previous(); } }
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); }