Exemplo n.º 1
0
        DataHeader ReadDataHeader(PclBinaryReader reader)
        {
            var data = new DataHeader();
            // Magic number line ("ply")
            string line = reader.ReadLine();

            if (line != "ply")
            {
                throw new ArgumentException("Magic number ('ply') mismatch.");
            }

            // Read header contents.
            while (true)
            {
                // Read a line and split it with white space.
                line = reader.ReadLine();
                if (line == "end_header")
                {
                    break;
                }

                var col = line.Split(' ');
                switch (col[0])
                {
                case "comment":
                    continue;

                // Element declaration (unskippable)
                case "element" when col[1] == "vertex":
Exemplo n.º 2
0
        PointCloudData ImportAsPointCloudData(string path)
        {
            var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            var reader = new PclBinaryReader(ReadFully(stream));

            var header = ReadDataHeader(reader);
            var body   = ReadDataBody(header, reader);

            var data = ScriptableObject.CreateInstance <PointCloudData>();

            data.Initialize(body.Vertices, body.Normals, body.Colors, Scale, PivotOffset, NormalRotation);
            data.name = Path.GetFileNameWithoutExtension(path);

            return(data);
        }