예제 #1
0
        public IEnumerator <Edge <T> > GetNeighborFromEdgeNeighbor(Edge <T> edge)
        {
            MeshCell <T>           newCell   = MeshMethods.GetNeighbour(edge);
            AfterCutEdgeEnumerator ridgeEnum = new AfterCutEdgeEnumerator(newCell.Edges, edge);

            return(ridgeEnum);
        }
예제 #2
0
        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,
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }