Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }