private static IMeshFile GetProviderInstance(string path) { string ext = Path.GetExtension(path); IMeshFile provider = null; if (container.ContainsKey(ext)) { provider = container[ext]; } else { provider = CreateProviderInstance(ext); } return(provider); }
private static IMeshFile CreateProviderInstance(string ext) { // TODO: automate by using IMeshFormat's Extensions property. IMeshFile provider = null; if (ext == ".node" || ext == ".poly" || ext == ".ele") { provider = new TriangleFile(); } if (provider == null) { throw new NotImplementedException("File format not implemented."); } container.Add(ext, provider); return(provider); }
/// <summary> /// Save the current mesh to given file. /// </summary> public static void Save(string path, Mesh mesh) { IMeshFile provider = GetProviderInstance(path); provider.Write(mesh, path); }
/// <summary> /// Returns true, if the given file contains mesh information. /// </summary> /// <param name="path"></param> /// <returns></returns> public static bool ContainsMeshData(string path) { IMeshFile provider = GetProviderInstance(path); return(provider.ContainsMeshData(path)); }
/// <summary> /// Read a mesh from given file. /// </summary> /// <param name="path"></param> /// <returns></returns> public static Mesh Import(string path) { IMeshFile provider = GetProviderInstance(path); return(provider.Import(path)); }
/// <summary> /// Read an input geometry from given file. /// </summary> public static InputGeometry Read(string path) { IMeshFile provider = GetProviderInstance(path); return(provider.Read(path)); }