/// <summary>
        /// Opens the specified stream, s. Note that as a Portable class library
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="solid">The solid.</param>
        /// <returns>TessellatedSolid.</returns>
        /// <exception cref="Exception">Cannot open file without extension (e.g. f00.stl).
        /// or
        /// This function has been recently removed.
        /// or
        /// Cannot determine format from extension (not .stl, .ply, .3ds, .lwo, .obj, .objx, or .off.</exception>
        /// <exception cref="System.Exception">Cannot open file without extension (e.g. f00.stl).
        /// or
        /// This function has been recently removed.
        /// or
        /// Cannot determine format from extension (not .stl, .ply, .3ds, .lwo, .obj, .objx, or .off.</exception>
        public static void Open(Stream s, string filename, out TessellatedSolid solid)
        {
            try
            {
                var extension = GetFileTypeFromExtension(Path.GetExtension(filename));
                switch (extension)
                {
                case FileType.STL_ASCII:
                case FileType.STL_Binary:
                    solid = STLFileData.OpenSolids(s, filename)[0];     // Standard Tessellation or StereoLithography
                    break;

                case FileType.ThreeMF:
                    solid = ThreeMFFileData.OpenSolids(s, filename)[0];
                    break;

                case FileType.Model3MF:
                    solid = ThreeMFFileData.OpenModelFile(s, filename)[0];
                    break;

                case FileType.AMF:
                    solid = AMFFileData.OpenSolids(s, filename)[0];
                    break;

                case FileType.OFF:
                    solid = OFFFileData.OpenSolid(s, filename);
                    // http://en.wikipedia.org/wiki/OFF_(file_format)
                    break;

                case FileType.PLY_ASCII:
                case FileType.PLY_Binary:
                    solid = PLYFileData.OpenSolid(s, filename);
                    break;

                case FileType.SHELL:
                    solid = ShellFileData.OpenSolids(s, filename)[0];
                    break;

                case FileType.STEP:
                    solid = STEPFileData.OpenSolids(s, filename)[0];
                    break;

                default:
                    var serializer = new JsonSerializer();
                    var sr         = new StreamReader(s);
                    using (var reader = new JsonTextReader(sr))
                        solid = serializer.Deserialize <TessellatedSolid>(reader);
                    break;
                }
            }
            catch (Exception exc)
            {
                throw new Exception("Cannot open file. Message: " + exc.Message);
            }
        }
        public static Solid Open(Stream s, string filename = "")
        {
#if !DEBUG
            try
            {
#endif
            var extension = GetFileTypeFromExtension(Path.GetExtension(filename));
            switch (extension)
            {
            case FileType.STL_ASCII:
            case FileType.STL_Binary:
                return(STLFileData.OpenSolids(s, filename)[0]);        // Standard Tessellation or StereoLithography

            case FileType.ThreeMF:
                return(ThreeMFFileData.OpenSolids(s, filename)[0]);

            case FileType.Model3MF:
                return(ThreeMFFileData.OpenModelFile(s, filename)[0]);

            case FileType.AMF:
                return(AMFFileData.OpenSolids(s, filename)[0]);

            case FileType.OFF:
                return(OFFFileData.OpenSolid(s, filename));

            case FileType.PLY_ASCII:
            case FileType.PLY_Binary:
                return(PLYFileData.OpenSolid(s, filename));

            case FileType.SHELL:
                return(ShellFileData.OpenSolids(s, filename)[0]);

            case FileType.STEP:
                return(STEPFileData.OpenSolids(s, filename)[0]);

            default:
                var serializer = new JsonSerializer();
                var sr         = new StreamReader(s);
                using (var reader = new JsonTextReader(sr))
                {
                    JObject jObject    = JObject.Load(reader);
                    var     typeString = ((string)jObject["TVGLSolidType"]);
                    if (string.IsNullOrWhiteSpace(typeString))
                    {
                        return(null);
                    }
                    var type = Type.GetType(typeString);
                    if (type == null)
                    {
                        var assembly = Assembly.LoadFrom((string)jObject["InAssembly"]);
                        type = assembly.GetType(typeString);
                    }
                    if (type == null)
                    {
                        return(null);
                    }
                    return((Solid)JsonConvert.DeserializeObject(jObject.ToString(), type));
                }
            }
#if !DEBUG
        }

        catch (Exception exc)
        {
            throw new Exception("Cannot open file. Message: " + exc.Message);
        }
#endif
        }