Пример #1
0
        /// <summary>
        /// save point to *ply with same name as *.csv
        /// , fill parameter "to_ply" with filename *.csv
        /// </summary>
        /// <param name="to_ply"></param>
        private void Write_PLY(string to_ply)
        {
            string        filename = to_ply.Replace(".csv", ".ply");
            List <Vector> points   = new List <Vector>();
            int           i        = 0;

            double[] coordinat = new double[3];
            //Console.WriteLine(to_ply);
            using (CsvFileWriter writer = new CsvFileWriter(filename))
            {
                uint point_count = _pointcloud.NumberOfPoints();
                for (uint y = 0; y < point_count; y++)
                {
                    coordinat = (_pointcloud.ReturnPointAtIndex(y));
                    Vector vector = new Vector(coordinat);
                    points.Add(vector);
                }

                i = Convert.ToInt16(point_count);
                int    index  = 0;
                CsvRow row    = new CsvRow();
                string header = "ply\nformat ascii 1.0\nelement vertex " + i + "\nproperty float x\nproperty float y\nproperty float z\nend_header";
                row.Add(header);
                writer.WriteRow(row);
                for (int k = 0; k < i; k++)
                {
                    row = new CsvRow();
                    string s = String.Format("{0}", points[k]);
                    s     = s.Replace(",", " ");
                    index = s.IndexOf("]");
                    String data = s.Substring(1, index - 1);

                    //for (int j = 1; j < 2; j++)
                    //{
                    //    index[j] = s.IndexOf('[', index[j - 1] + 1);
                    //    Console.WriteLine(index[j]);
                    //}

                    row.Add(data);
                    writer.WriteRow(row);
                }
                Console.WriteLine(i);
            }
        }