Esempio n. 1
0
        /// <summary>
        /// Get merge roles for federated models, used to work out Model Merge Precedence Rules
        /// </summary>
        private Dictionary <XbimModel, COBieMergeRoles> LinkRoleToModel()
        {
            Dictionary <IfcRole, COBieMergeRoles>   mapMergeRoles        = MapRolesForMerge();//assign merge role to a IfcRoleEnum value
            Dictionary <XbimModel, COBieMergeRoles> mapModelToMergeRoles = new Dictionary <XbimModel, COBieMergeRoles>();

            //mapModelToMergeRoles.Add(Model, COBieMergeRoles.Unknown); //assume that it is just the holder model(xBIMf) (as xbim is creating holding file .xbimf) for and all the models are in the Model.RefencedModels property

            //now get the referenced models
            foreach (var refModel in Model.ReferencedModels)
            {
                IfcDocumentInformation doc   = refModel.DocumentInformation;
                IfcOrganization        owner = doc.DocumentOwner as IfcOrganization;
                if ((owner != null) && (owner.Roles != null))
                {
                    COBieMergeRoles mergeRoles = COBieMergeRoles.Unknown;

                    foreach (var role in owner.Roles)
                    {
                        IfcRole roleitem = role.Role;

                        if (mapMergeRoles[roleitem] != COBieMergeRoles.Unknown)
                        {
                            mergeRoles = mergeRoles | mapMergeRoles[roleitem]; //use in if's ((mergeRoles & COBieMergeRoles.Architectural) == COBieMergeRoles.Architectural)
                            //remove the unknown as we now have at least one value
                            if ((mergeRoles & COBieMergeRoles.Unknown) == COBieMergeRoles.Unknown)
                            {
                                mergeRoles = mergeRoles ^ COBieMergeRoles.Unknown;
                            }
                        }
                    }
                    mapModelToMergeRoles.Add(refModel.Model, mergeRoles);
                }
            }
            return(mapModelToMergeRoles);
        }
Esempio n. 2
0
        //private void Add_Click(object sender, RoutedEventArgs e)
        //{
        //    XbimModel model = DataContext as XbimModel;
        //    if (model != null)
        //    {
        //        AddFederatedModel fdlg = new AddFederatedModel();
        //        bool? done = fdlg.ShowDialog();
        //        if (done.HasValue && done.Value == true)
        //        {
        //            string fileName = fdlg.FileName;
        //            string ext = System.IO.Path.GetExtension(fileName);
        //            using (XbimModel refM = new XbimModel())
        //            {
        //                if (string.Compare(ext, ".xbim", true) != 0)
        //                {
        //                    refM.CreateFrom(fileName, null, null, true);
        //                    XbimMesher.GenerateGeometry(refM);
        //                    fileName = System.IO.Path.ChangeExtension(fileName, "xbim");
        //                }
        //            }
        //            IfcRole role = fdlg.Role;
        //            if (role == IfcRole.UserDefined)
        //                model.AddModelReference(fileName, fdlg.OrganisationName, fdlg.RoleName);
        //            else
        //                model.AddModelReference(fileName, fdlg.OrganisationName, role);
        //        }
        //    }
        //}


        private void Add_Click(object sender, RoutedEventArgs e)
        {
            XbimModel model = DataContext as XbimModel;

            if (model != null)
            {
                AddFederatedModel fdlg = new AddFederatedModel();
                bool?done = fdlg.ShowDialog();
                if (done.HasValue && done.Value == true)
                {
                    string fileName = fdlg.FileName;
                    string ext      = System.IO.Path.GetExtension(fileName);
                    using (XbimModel refM = new XbimModel())
                    {
                        if (string.Compare(ext, ".xbim", true) != 0)
                        {
                            refM.CreateFrom(fileName, null, null, true);
                            var m3D = new Xbim3DModelContext(refM);
                            m3D.CreateContext();
                            fileName = System.IO.Path.ChangeExtension(fileName, "xbim");
                        }
                    }
                    IfcRole role = fdlg.Role;
                    if (role == IfcRole.UserDefined)
                    {
                        model.AddModelReference(fileName, fdlg.OrganisationName, fdlg.RoleName);
                    }
                    else
                    {
                        model.AddModelReference(fileName, fdlg.OrganisationName, role);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Map ifcRols to the MergeRole for COBie
        /// </summary>
        /// <returns></returns>
        private Dictionary <IfcRole, COBieMergeRoles> MapRolesForMerge()
        {
            Dictionary <IfcRole, COBieMergeRoles> mapRoles = new Dictionary <IfcRole, COBieMergeRoles>();

            foreach (var item in Enum.GetValues(typeof(IfcRole)))
            {
                IfcRole role = (IfcRole)item;
                switch (role)
                {
                case IfcRole.Supplier:
                case IfcRole.Manufacturer:
                case IfcRole.Contractor:
                case IfcRole.Subcontractor:
                case IfcRole.StructuralEngineer:
                case IfcRole.CostEngineer:
                case IfcRole.Client:
                case IfcRole.BuildingOwner:
                case IfcRole.BuildingOperator:
                case IfcRole.ProjectManager:
                case IfcRole.FacilitiesManager:
                case IfcRole.CivilEngineer:
                case IfcRole.ComissioningEngineer:
                case IfcRole.Engineer:
                case IfcRole.Consultant:
                case IfcRole.ConstructionManager:
                case IfcRole.FieldConstructionManager:
                case IfcRole.Owner:
                case IfcRole.Reseller:
                case IfcRole.UserDefined:
                    mapRoles.Add(role, COBieMergeRoles.Unknown);
                    break;

                case IfcRole.Architect:
                    mapRoles.Add(role, COBieMergeRoles.Architectural);
                    break;

                case IfcRole.MechanicalEngineer:
                    mapRoles.Add(role, COBieMergeRoles.Mechanical);
                    break;

                case IfcRole.ElectricalEngineer:
                    mapRoles.Add(role, COBieMergeRoles.Electrical);
                    break;

                default:
                    mapRoles.Add(role, COBieMergeRoles.Unknown);
                    break;
                }
            }

            return(mapRoles);
        }
Esempio n. 4
0
        public void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
                _role = (IfcRole)Enum.Parse(typeof(IfcRole), value.EnumVal, true);
                break;

            case 1:
                _userDefinedRole = value.StringVal;
                break;

            case 2:
                _description = value.StringVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
Esempio n. 5
0
        /// <summary>
        ///   Converts a string to a Role or a User defined role if necessary
        /// </summary>
        /// <param name = "value"></param>
        private void ConvertRoleString(string value, ref IfcRole role, ref IfcLabel?userDefinedRole)
        {
            if (string.IsNullOrEmpty(value))
            {
                return;                              //illegal to set a role to nothing
            }
            string roleStr = value.Trim();

            string roleWithoutSpaces = roleStr.Replace(" ", "");

            if (Enum.IsDefined(typeof(IfcRole), roleWithoutSpaces))
            {
                IfcRole roleEnum = (IfcRole)Enum.Parse(typeof(IfcRole), roleWithoutSpaces, true);
                role            = roleEnum; //call this to ensure correct change notification
                userDefinedRole = null;
            }
            else
            {
                userDefinedRole = roleStr;
                role            = IfcRole.UserDefined;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Convert RoleFilter to IfcActorRole, need to be within a transaction
 /// </summary>
 /// <param name="role">RoleFilter</param>
 /// <param name="ifcRole">IfcRole</param>
 /// <returns></returns>
 private IfcActorRole MapRole(RoleFilter role, IfcRole ifcRole)
 {
     if (_fedModel.IsTransacting)
     {
         IfcActorRole actorRole = _fedModel.Instances.New <IfcActorRole>();
         if (ifcRole == IfcRole.UserDefined)
         {
             actorRole.Role            = IfcRole.UserDefined;
             actorRole.UserDefinedRole = role.ToString();
         }
         else
         {
             actorRole.Role = ifcRole;
         }
         actorRole.Description = role.ToString();
         RoleMap.Add(role, actorRole);
         return(actorRole);
     }
     else
     {
         throw new InvalidOperationException("MapRole: No transaction currently in model");
     }
 }
Esempio n. 7
0
 public IfcActorRole(IfcActorRole cloneFrom, bool deep)
 {
     _role            = cloneFrom.Role;
     _userDefinedRole = cloneFrom.UserDefinedRole;
     _description     = cloneFrom.Description;
 }
Esempio n. 8
0
 /// <summary>
 ///   Creates a new actorrole and initializes with the role
 /// </summary>
 public IfcActorRole(IfcRole role)
 {
     this.Role = role;
 }
Esempio n. 9
0
 /// <summary>
 /// Convert RoleFilter to IfcActorRole, need to be within a transaction
 /// </summary>
 /// <param name="role">RoleFilter</param>
 /// <param name="ifcRole">IfcRole</param>
 /// <returns></returns>
 private IfcActorRole MapRole(RoleFilter role, IfcRole ifcRole)
 {
     if (_fedModel.IsTransacting)
     {
         IfcActorRole actorRole = _fedModel.Instances.New<IfcActorRole>();
         if (ifcRole == IfcRole.UserDefined)
         {
             actorRole.Role = IfcRole.UserDefined;
             actorRole.UserDefinedRole = role.ToString();
         }
         else
         {
             actorRole.Role = ifcRole;
         }
         actorRole.Description = role.ToString();
         RoleMap.Add(role, actorRole);
         return actorRole;
     }
     else
     {
         throw new InvalidOperationException("MapRole: No transaction currently in model");
     }
 }