示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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));
        }
示例#5
0
        /// <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));
        }
示例#6
0
        /// <summary>
        /// Read an input geometry from given file.
        /// </summary>
        public static InputGeometry Read(string path)
        {
            IMeshFile provider = GetProviderInstance(path);

            return(provider.Read(path));
        }