/// <summary> /// Writes a geometrymesh to a file, given a streamwriter. /// </summary> /// <param name="type">The geometry mesh.</param> /// <param name="location">The streamwriter.</param> public void WriteFile(GeometryMesh type, StreamWriter writer) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } g3.OFFWriter offWriter = new g3.OFFWriter(); List <WriteMesh> serialisableMeshes = new List <WriteMesh>() { new WriteMesh(type.Base) }; IOWriteResult result = offWriter.Write(writer, serialisableMeshes, Options); if (result.code != IOCode.Ok) { throw new G3WriterException(result); } IOConventions.WriteIfNormalised(type.IsNormalised, writer); }
IOWriteResult Write_OFF(string sFilename, List <WriteMesh> vMeshes, WriteOptions options) { StreamWriter w = new StreamWriter(sFilename); if (w.BaseStream == null) { return(new IOWriteResult(IOCode.FileAccessError, "Could not open file " + sFilename + " for writing")); } OFFWriter writer = new OFFWriter(); var result = writer.Write(w, vMeshes, options); w.Close(); return(result); }