public static void GetImageInfo(string filename)
        {
            ImageWidth  = 0;
            ImageHeight = 0;

            SimplePointFile.OpenReadFile(filename);

            int lines = 0;

            double[] pixels = { 0, 0 };
            double[] temp;
            while ((temp = SimplePointFile.ReadLine()) != null)
            {
                pixels = temp;
                lines++;
            }

            //Console.WriteLine("File Lines:" + lines);
            if (lines == ((int)pixels[0] + 1) * ((int)pixels[1] + 1))
            {
                ImageWidth  = (int)pixels[0] + 1;
                ImageHeight = (int)pixels[1] + 1;
            }
            else
            {
                throw new NotSupportedException("File Type Error!");
            }

            SimplePointFile.CloseReadFile();
        }
Example #2
0
        public static void ReadDataFromFile(string filename)
        {
            try
            {
                SimplePointFile.GetImageInfo(filename);

                ImageWidth  = SimplePointFile.ImageWidth;
                ImageHeight = SimplePointFile.ImageHeight;

                //Console.WriteLine("ImageWidth:" + ImageWidth);
                //Console.WriteLine("ImageHeight:" + ImageHeight);

                var points = vtkPoints.New();

                var colorArray = vtkUnsignedCharArray.New();
                colorArray.SetNumberOfComponents(3);

                ImageData = vtkImageData.New();
                ImageData.SetExtent(0, ImageWidth - 1, 0, ImageHeight - 1, 0, 0);
                ImageData.SetNumberOfScalarComponents(1);
                ImageData.SetScalarTypeToUnsignedChar();


                SimplePointFile.OpenReadFile(filename);
                double[] data;
                while ((data = SimplePointFile.ReadLine()) != null)
                {
                    points.InsertNextPoint(data[0], data[1], data[2]);
                    colorArray.InsertNextTuple3(data[3], data[4], data[5]);

                    ImageData.SetScalarComponentFromDouble((int)data[0], (int)data[1], 0, 0, data[3]);
                }

                PolyData = vtkPolyData.New();
                PolyData.SetPoints(points);
                PolyData.GetPointData().SetScalars(colorArray);
                PolyData.Update();

                //Console.WriteLine("PolyData & ImageData Load.");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                SimplePointFile.CloseReadFile();
            }
        }
Example #3
0
        public static void UpdateDepthFormFile(string filename)
        {
            var points = vtkPoints.New();

            SimplePointFile.OpenReadFile(filename);
            double[] data;
            while ((data = SimplePointFile.ReadShortLine()) != null)
            {
                points.InsertNextPoint(data[0], data[1], data[2]);
            }

            PolyData.SetPoints(points);
            PolyData.Update();

            SimplePointFile.CloseReadFile();
        }