Пример #1
0
        /// <summary>
        /// Opens an IFC file, Ifcxml, IfcZip, xbim from a file path
        /// </summary>
        /// <param name="path">the file name of the ifc, ifczip, ifcxml or xbim file to be opened</param>
        /// <param name="editorDetails">This is only required if the store is opened for editing</param>
        /// <param name="ifcDatabaseSizeThreshHold">Expressed in MB. If not defined the DefaultIfcDatabaseSizeThreshHold is used,
        /// IFC files below this size will be opened in memory, above this size a database will be created. If -1 is specified an in memory model will be
        /// created for all IFC files that are opened. Xbim files are always opened as databases</param>
        /// <param name="progDelegate"></param>
        /// <param name="accessMode"></param>
        /// <param name="codePageOverride">
        /// A CodePage that will be used to read implicitly encoded one-byte-char strings. If -1 is specified the default ISO8859-1
        /// encoding will be used accoring to the Ifc specification. </param>
        public static IfcStore Open(string path, XbimEditorCredentials editorDetails = null, double?ifcDatabaseSizeThreshHold = null,
                                    ReportProgressDelegate progDelegate = null, XbimDBAccess accessMode = XbimDBAccess.Read, int codePageOverride = -1)
        {
            path = Path.GetFullPath(path);

            if (!Directory.Exists(Path.GetDirectoryName(path) ?? ""))
            {
                throw new DirectoryNotFoundException(Path.GetDirectoryName(path) + " directory was not found");
            }
            if (!File.Exists(path))
            {
                throw new FileNotFoundException(path + " file was not found");
            }

            var newStore   = new IfcStore(); // we need an instance
            var ifcVersion = newStore.ModelProvider.GetXbimSchemaVersion(path);

            if (ifcVersion == XbimSchemaVersion.Unsupported)
            {
                throw new FileLoadException(path + " is not a valid IFC file format, ifc, ifcxml, ifczip and xBIM are supported.");
            }

            var model = newStore.ModelProvider.Open(path, ifcVersion, ifcDatabaseSizeThreshHold, progDelegate, accessMode, codePageOverride);

            newStore.AssignModel(model, editorDetails, ifcVersion);
            return(newStore);
        }
Пример #2
0
        private void AssignModel(IModel model, XbimEditorCredentials editorDetails, XbimSchemaVersion schema)
        {
            Model                 = model;
            Model.EntityNew      += Model_EntityNew;
            Model.EntityDeleted  += Model_EntityDeleted;
            Model.EntityModified += Model_EntityModified;
            FileName              = Model.Header.FileName.Name;
            SetupEditing(editorDetails);

            LoadReferenceModels();
            IO.Memory.MemoryModel.CalculateModelFactors(model);
        }
Пример #3
0
        /// <summary>
        /// Sets up the model to track changes and apply an editor/ownerhistory
        /// </summary>
        /// <param name="editorDetails"></param>
        private void SetupEditing(XbimEditorCredentials editorDetails)
        {
            if (editorDetails == null)
            {
                EditorDetails = new XbimEditorCredentials()
                {
                    ApplicationDevelopersName = "Unspecified",
                    ApplicationVersion        = "Unspecified",
                    ApplicationFullName       = "Unspecified",
                    EditorsFamilyName         = Environment.UserName,
                    EditorsOrganisationName   = "Unspecified",
                    EditorsGivenName          = ""
                };
            }
            else
            {
                EditorDetails = editorDetails;
            }

            Model.EntityNew      += IfcRootInit;
            Model.EntityModified += IfcRootModified;
        }
Пример #4
0
        /// <summary>
        /// Constructor used to create a new model for edit
        /// </summary>
        /// <param name="storageType"></param>
        /// <param name="ifcVersion"></param>
        /// <param name="editorDetails"></param>
        protected IfcStore(XbimStoreType storageType, XbimSchemaVersion ifcVersion, XbimEditorCredentials editorDetails) : this()
        {
            var model = ModelProvider.Create(ifcVersion, storageType);

            AssignModel(model, editorDetails, ifcVersion);
        }
Пример #5
0
        /// <summary>
        /// Constructor used to create a new persistent model with specified path
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="ifcVersion"></param>
        /// <param name="editorDetails"></param>
        protected IfcStore(string filepath, XbimSchemaVersion ifcVersion, XbimEditorCredentials editorDetails) : this()
        {
            var model = ModelProvider.Create(ifcVersion, filepath);

            AssignModel(model, editorDetails, ifcVersion);
        }
Пример #6
0
        /// <summary>
        /// You can use this function to open IFC model from a <see cref="Stream"/>.
        /// You need to know file type (IFC, IFCZIP, IFCXML) and schema type (IFC2x3 or IFC4) to be able to use this function.
        /// If you don't know, you should the overloaded <see cref="Open(string, XbimEditorCredentials, double?, ReportProgressDelegate, XbimDBAccess, int)"/>
        /// method which takes file paths as an argument, and can automatically detect schema and file type.
        /// If are opening an *.xbim file you should also use the path-based overload because Esent database needs to operate
        /// on the file and this function will have to create temporal file if it is not a file stream.
        /// If the input is a FileStream, be aware this method may call <see cref="Stream.Close"/> on it to keep exclusive access.
        /// </summary>
        /// <param name="stream">Stream of data</param>
        /// <param name="dataType">Type of data (*.ifc, *.ifcxml, *.ifczip)</param>
        /// <param name="schema">IFC schema (IFC2x3, IFC4). Other schemas are not supported by this class.</param>
        /// <param name="modelType">Type of model to be used. You can choose between EsentModel and MemoryModel</param>
        /// <param name="editorDetails">Optional details. You should always pass these if you are going to change the data.</param>
        /// <param name="accessMode">Access mode to the stream. This is only important if you choose EsentModel. MemoryModel is completely in memory so this is not relevant</param>
        /// <param name="progDelegate">Progress reporting delegate</param>
        /// <param name="codePageOverride">
        /// A CodePage that will be used to read implicitly encoded one-byte-char strings. If -1 is specified the default ISO8859-1
        /// encoding will be used accoring to the Ifc specification. </param>
        /// <returns></returns>
        public static IfcStore Open(Stream stream, StorageType dataType, XbimSchemaVersion schema, XbimModelType modelType, XbimEditorCredentials editorDetails = null,
                                    XbimDBAccess accessMode = XbimDBAccess.Read, ReportProgressDelegate progDelegate = null, int codePageOverride = -1)
        {
            var newStore = new IfcStore();
            var model    = newStore.ModelProvider.Open(stream, dataType, schema, modelType, accessMode, progDelegate, codePageOverride);

            newStore.AssignModel(model, editorDetails, schema);
            return(newStore);
        }
Пример #7
0
 public static IfcStore Create(XbimEditorCredentials editorDetails, XbimSchemaVersion ifcVersion, XbimStoreType storageType)
 {
     return(new IfcStore(storageType, ifcVersion, editorDetails));
 }
Пример #8
0
 /// <summary>
 /// Creates a Database store at the specified location
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="editorDetails"></param>
 /// <param name="ifcVersion"></param>
 /// <returns></returns>
 public static IfcStore Create(string filePath, XbimEditorCredentials editorDetails, XbimSchemaVersion ifcVersion)
 {
     return(new IfcStore(filePath, ifcVersion, editorDetails));
 }