Esempio n. 1
0
        private void ReadHeader()
        {
            plyHeader = new PLYHeader();
            string magic = streamReader.ReadLine();
            if( magic != "ply" )
            {
                throw new InvalidDataException( "PLY files must have \"ply\" as the first line." );
            }
            dataBegin += 1 + magic.Length;

            string formatLine = streamReader.ReadLine();
            string[] delimiters = new string[] { " " };
            string[] formatTokens = formatLine.Split( delimiters, StringSplitOptions.RemoveEmptyEntries );

            dataBegin += 1 + formatLine.Length;

            if( formatTokens.Length != 3 )
            {
                throw new InvalidDataException( "Invalid format line: " + formatLine );
            }

            if( formatTokens[ 0 ] != "format" )
            {
                throw new InvalidDataException( "Invalid format line: " + formatLine );
            }

            switch( formatTokens[ 1 ] )
            {
                case "ascii":
                    fileMode = PLYFileMode.ASCII;
                    break;

                case "binary_little_endian":
                    fileMode = PLYFileMode.BINARY_LITTLE_ENDIAN;
                    break;

                case "binary_big_endian":
                    fileMode = PLYFileMode.BINARY_BIG_ENDIAN;
                    throw new InvalidDataException( "Reading binary_big_endian is not supported." );

                default:
                    throw new InvalidDataException( "Invalid format line: " + formatLine );
            }
        }
Esempio n. 2
0
 // event triggers
 private void OnHeaderRead( PLYHeader plyHeader )
 {
     if( HeaderRead != null )
     {
         HeaderRead( plyHeader );
     }
 }