Ejemplo n.º 1
0
        public VtkMesh(IReadOnlyList <TNode> nodes, IReadOnlyList <ICell <TNode> > elements)
        {
            this.OriginalNodes    = nodes;
            this.OriginalElements = elements;

            var vtkPoints    = new VtkPoint[nodes.Count];
            var nodes2Points = new Dictionary <TNode, VtkPoint>();

            for (int i = 0; i < vtkPoints.Length; ++i)
            {
                TNode node = nodes[i];
                vtkPoints[i]       = new VtkPoint(i, node.X, node.Y, node.Z);
                nodes2Points[node] = vtkPoints[i]; //TODO: Even more memory waste.
            }
            this.VtkPoints = vtkPoints;

            var vtkCells = new VtkCell[elements.Count];

            for (int i = 0; i < vtkCells.Length; ++i)
            {
                ICell <TNode> element  = elements[i];
                var           vertices = new VtkPoint[element.Nodes.Count];
                for (int j = 0; j < vertices.Length; ++j)
                {
                    vertices[j] = nodes2Points[element.Nodes[j]];
                }
                vtkCells[i] = new VtkCell(element.CellType, vertices);
            }
            this.VtkCells = vtkCells;
        }
Ejemplo n.º 2
0
        public VtkMeshDiscontinuous(IReadOnlyList <TNode> nodes, IReadOnlyList <ICell <TNode> > elements)
        {
            this.OriginalNodes    = nodes;
            this.OriginalElements = elements;
            var vtkPoints = new List <VtkPoint>();
            var vtkCells  = new VtkCell[elements.Count];
            int pointID   = 0;

            for (int e = 0; e < elements.Count; ++e)
            {
                ICell <TNode> element      = elements[e];
                var           cellVertices = new VtkPoint[element.Nodes.Count];
                for (int i = 0; i < element.Nodes.Count; ++i)
                {
                    var point = new VtkPoint(pointID++, element.Nodes[i]);
                    cellVertices[i] = point;
                    vtkPoints.Add(point);
                }
                var cell = new VtkCell(element.CellType, cellVertices);
                vtkCells[e] = cell;
            }
            this.VtkPoints = vtkPoints;
            this.VtkCells  = vtkCells;
        }