public override void Import(ref MeshModel mesh) { using (BufferedStream sr = new BufferedStream(File.OpenRead(mesh.FilePath))) { int byteCount; PlyObjectHeader headerObj = this.GetPlyObjectHeader(sr, out byteCount); sr.Position = byteCount; switch (headerObj.Format) { case PlyFormat.ascii: this.ParserASCII(headerObj, sr, ref mesh); break; case PlyFormat.binary_big_endian: using (EndianessBinaryReader br = new EndianessBinaryReader(sr, Endianess.BigEndian)) { this.ParserBinary(headerObj, br, ref mesh); } break; case PlyFormat.binary_little_endian: using (EndianessBinaryReader br = new EndianessBinaryReader(sr, Endianess.LittleEndian)) { this.ParserBinary(headerObj, br, ref mesh); } break; default: throw new FormatException("Invalid File format!"); break; } } }
private void ParserPlyModel() { using (BufferedStream sr = new BufferedStream(File.OpenRead(this.path))) { int byteCount; PlyObjectHeader headerObj = this.GetPlyObjectHeader(sr, out byteCount); this.triangles = new Triangle[headerObj.Elements["face"].Count]; sr.Position = byteCount; switch (headerObj.Format) { case PlyFormat.ascii: this.ParserASCII(headerObj, sr); break; case PlyFormat.binary_big_endian: using (EndianessBinaryReader br = new EndianessBinaryReader(sr, Endianess.BigEndian)) { this.ParserBinary(headerObj, br); } break; case PlyFormat.binary_little_endian: using (EndianessBinaryReader br = new EndianessBinaryReader(sr, Endianess.LittleEndian)) { this.ParserBinary(headerObj, br); } break; default: throw new FormatException("Invalid File format!"); break; } } }
private void ParserPlyModel() { using (BufferedStream sr = new BufferedStream(File.OpenRead(this.path))) { int byteCount; PlyObjectHeader headerObj = this.GetPlyObjectHeader(sr, out byteCount); this.triangles = new Triangle[headerObj.Elements["face"].Count]; sr.Position = byteCount; switch (headerObj.Format) { case PlyFormat.ascii: FileInfo info = new FileInfo(this.path); byte[] file = new byte[info.Length]; sr.Read(file, 0, file.Length); string content = Encoding.ASCII.GetString(file); this.ParserASCII(headerObj, content); file = null; content = null; GC.Collect(); GC.WaitForPendingFinalizers(); //antes = DateTime.Now; //this.ParserASCII(headerObj, sr); //TimeSpan depoisNovo = antes - DateTime.Now; //System.Windows.Forms.MessageBox.Show("Tempo Novo: " + depoisNovo); break; case PlyFormat.binary_big_endian: using (EndianessBinaryReader br = new EndianessBinaryReader(sr, Endianess.BigEndian)) { this.ParserBinary(headerObj, br); } break; case PlyFormat.binary_little_endian: using (EndianessBinaryReader br = new EndianessBinaryReader(sr, Endianess.LittleEndian)) { this.ParserBinary(headerObj, br); } break; default: throw new FormatException("Invalid File format!"); } } }