Пример #1
0
        public static MemoryModel OpenRead(string fileName, ILogger logger, ReportProgressDelegate progressDel = null)
        {
            //step21 text file can resolve version in parser
            if (fileName.IsStepTextFile())
            {
                using (var file = File.OpenRead(fileName))
                {
                    return(OpenReadStep21(file, logger, progressDel));
                }
            }

            var version = GetSchemaVersion(fileName); //an exception is thrown if this fails
            var ef      = GetFactory(version);

            var model = new MemoryModel(ef, logger);

            if (fileName.IsStepZipFile())
            {
                model.LoadZip(fileName, progressDel);
            }
            else if (fileName.IsStepXmlFile())
            {
                model.LoadXml(fileName, progressDel);
            }
            else
            {
                throw new FileLoadException($"Unsupported file type extension: {Path.GetExtension(fileName)}");
            }

            return(model);
        }
Пример #2
0
        /// <summary>
        /// Reads schema version from the stream on the fly inside the parser so it doesn't need to
        /// access the file twice.
        /// </summary>
        /// <param name="stream">Input stream for step21 text file</param>
        /// <param name="logger">Logger</param>
        /// <param name="progressDel">Progress delegate</param>
        /// <param name="ignoreTypes">A list of ifc types to skip</param>
        /// <param name="allowMissingReferences">Allow referenced entities that are not in the model, default false</param>
        /// <param name="keepOrder">When true, serialised file will maintain order of entities from the original file (or order of creation)</param>
        /// <returns>New memory model</returns>
        public static MemoryModel OpenReadStep21(Stream stream, ILogger logger    = null, ReportProgressDelegate progressDel = null,
                                                 IEnumerable <string> ignoreTypes = null, bool allowMissingReferences        = false, bool keepOrder = true)
        {
            var model = new MemoryModel((IEnumerable <string> schemas) =>
            {
                var schema = GetStepFileXbimSchemaVersion(schemas);
                return(GetFactory(schema));
            }, logger)
            {
                AllowMissingReferences = allowMissingReferences
            };

            if (!keepOrder)
            {
                model.DiscardNaturalOrder();
            }
            long len = -1;

            try
            {
                len = stream.Length;
            }
            catch (Exception)
            {
                // if lenght is not supported use len as previously set;
            }

            model.LoadStep21(stream, len, progressDel, ignoreTypes);
            return(model);
        }
Пример #3
0
        /// <summary>
        /// Reads schema version fron the stream on the fly inside the parser so it doesn't need to
        /// access the file twice.
        /// </summary>
        /// <param name="stream">Input stream for step21 text file</param>
        /// <param name="logger">Logger</param>
        /// <param name="progressDel">Progress delegate</param>
        /// <param name="ignoreTypes">A list of ifc types to skip</param>
        /// <returns>New memory model</returns>
        public static MemoryModel OpenReadStep21(Stream stream, ILogger logger    = null, ReportProgressDelegate progressDel = null,
                                                 IEnumerable <string> ignoreTypes = null)
        {
            var model = new MemoryModel((IEnumerable <string> schemas) =>
            {
                var schema = GetStepFileXbimSchemaVersion(schemas);
                return(GetFactory(schema));
            }, logger);

            model.LoadStep21(stream, stream.Length, progressDel, ignoreTypes);
            return(model);
        }
Пример #4
0
        public override XbimSchemaVersion GetXbimSchemaVersion(string modelPath)
        {
            var storageType = modelPath.StorageType();

            if (storageType == StorageType.Invalid)
            {
                return(XbimSchemaVersion.Unsupported);
            }

            if (storageType != StorageType.Xbim)
            {
                return(MemoryModel.GetSchemaVersion(modelPath));
            }

            throw new NotImplementedException("The MemoryModelProvider does not support reading of XBIM models");
        }
Пример #5
0
        /// <summary>
        /// Reads schema version from the stream on the fly inside the parser so it doesn't need to
        /// access the file twice.
        /// </summary>
        /// <param name="stream">Input stream for step21 text file</param>
        /// <param name="logger">Logger</param>
        /// <param name="progressDel">Progress delegate</param>
        /// <param name="ignoreTypes">A list of ifc types to skip</param>
        /// <param name="allowMissingReferences">Allow referenced entities that are not in the model, default false</param>
        /// <param name="keepOrder">When true, serialised file will maintain order of entities from the original file (or order of creation)</param>
        /// <returns>New memory model</returns>
        public static MemoryModel OpenReadStep21(Stream stream, ILogger logger    = null, ReportProgressDelegate progressDel = null,
                                                 IEnumerable <string> ignoreTypes = null, bool allowMissingReferences        = false, bool keepOrder = true)
        {
            var model = new MemoryModel((IEnumerable <string> schemas) =>
            {
                var schema = GetStepFileXbimSchemaVersion(schemas);
                return(GetFactory(schema));
            }, logger)
            {
                AllowMissingReferences = allowMissingReferences
            };

            if (!keepOrder)
            {
                model.DiscardNaturalOrder();
            }
            model.LoadStep21(stream, stream.Length, progressDel, ignoreTypes);
            return(model);
        }
Пример #6
0
 public EntityCollection(MemoryModel model, int labelFrom = 0)
 {
     CurrentLabel = Math.Max(CurrentLabel, labelFrom);
     _model       = model;
     _internal    = XbimMultiValueDictionary <Type, IPersistEntity> .Create(() => new HashSet <IPersistEntity>(new EntityLabelComparer()));
 }
Пример #7
0
 public Transaction(MemoryModel model)
 {
     _model = model;
 }
Пример #8
0
 public Transaction(MemoryModel model, string name)
 {
     Name   = name;
     _model = model;
 }