public TriangleHashSet StitchPolys(TriangleHashSet polys, out BoarderHashSet stitchedEdge)
    {
        TriangleHashSet stichedPolys = new TriangleHashSet();

        stichedPolys.IterationIndex = Vertices.Count;

        stitchedEdge = polys.CreateBoarderHashSet();
        var originalVerts = stitchedEdge.RemoveDublicates();
        var newVerts      = CloneVertices(originalVerts);

        stitchedEdge.Seperate(originalVerts, newVerts);

        foreach (TriangleBoarder edge in stitchedEdge)
        {
            // Create new triangles along the edges to connect ones beside each other

            var stitch_poly1 = new MeshTriangle(edge.OuterVertices[0],
                                                edge.OuterVertices[1],
                                                edge.InnerVertices[0]);
            var stitch_poly2 = new MeshTriangle(edge.OuterVertices[1],
                                                edge.InnerVertices[1],
                                                edge.InnerVertices[0]);
            // Add 'em to their neighbours
            edge.InnerTriangle.UpdateNeighbour(edge.OuterTriangle, stitch_poly2);
            edge.OuterTriangle.UpdateNeighbour(edge.InnerTriangle, stitch_poly1);

            MeshTriangles.Add(stitch_poly1);
            MeshTriangles.Add(stitch_poly2);

            stichedPolys.Add(stitch_poly1);
            stichedPolys.Add(stitch_poly2);
        }

        //Swap to the new vertices on the inner polys.
        foreach (MeshTriangle poly in polys)
        {
            for (int i = 0; i < 3; i++)
            {
                int vert_id = poly.VertexIndices[i];
                if (!originalVerts.Contains(vert_id))
                {
                    continue;
                }
                int vert_index = originalVerts.IndexOf(vert_id);
                poly.VertexIndices[i] = newVerts[vert_index];
            }
        }

        return(stichedPolys);
    }
    public BoarderHashSet CreateBoarderHashSet()
    {
        BoarderHashSet boarderSet = new BoarderHashSet();

        foreach (MeshTriangle triangle in this)
        {
            foreach (MeshTriangle neighbor in triangle.Neighbours)
            {
                if (this.Contains(neighbor))
                {
                    continue;
                }
                TriangleBoarder boarder = new TriangleBoarder(triangle, neighbor);
                boarderSet.Add(boarder);
            }
        }
        return(boarderSet);
    }