Example #1
0
        public void Read_StructuredGrid_File(string filename)
        {
            vtkXMLStructuredGridReader reader = new vtkXMLStructuredGridReader();

            reader.SetFileName(filename);

            reader.Update();

            vtkStructuredGrid structuredGrid = reader.GetOutput();



            dimensions = structuredGrid.GetDimensions();

            vtkPoints points = structuredGrid.GetPoints();

            int             numPoints = (int)structuredGrid.GetNumberOfPoints();
            List <Vector3d> point_dat = new List <Vector3d>();

            if (numPoints != 0)
            {
                // Read Point Data
                double[] pt;
                for (int i = 0; i < numPoints; i++)
                {
                    pt = points.GetPoint(i);
                    point_dat.Add(new Vector3d((float)pt[0], (float)pt[1], (float)pt[2]));
                }

                if (this.vertex_data.ContainsKey("vertices"))
                {
                    this.vertex_data["vertices"] = point_dat;
                }
                else
                {
                    this.vertex_data.Add("vertices", point_dat);
                }
                Console.WriteLine("All points read in correctly!");
            }
            vtkPointData scalarValues = structuredGrid.GetPointData();

            // Load point attributes
            this.Load_Point_Attributes(scalarValues);
        }