Esempio n. 1
0
 public void ParseProduct(IfcProduct product)
 {
     this.Name            = product.FriendlyName;
     this.IfcType         = product.GetType().Name;
     this.PropertySummary = this.CreatePropertySummary(product);
     Console.Write(this.PropertySummary);
 }
Esempio n. 2
0
        private static void AnalyseProperties(IfcProduct ifcProduct, List <NodeItem> nodes)
        {
            string entityName = GetEntityNameFromType(ifcProduct.GetType().ToString());

            if (nodes.Any(n => n.Name == entityName))
            {
                NodeItem classNode = nodes.Where(n => n.Name == entityName && n.Type == NodeItem.NodeItemType.Classification).FirstOrDefault();
                classNode.ExistCount++;
                CountExistInPset(ifcProduct, classNode);
                CountExistInQto(ifcProduct, classNode);
            }
        }
Esempio n. 3
0
        private IEnumerable <IfcProduct> GetCandidatesFromNode(IfcProduct original, XbimOctree <IfcProduct> node)
        {
            if (original != null && node != null)
            {
                //content which if from other models
                var nodeContent = node.Content().Where(nc => (nc.ModelOf != original.ModelOf) && (nc.GetType() == original.GetType()));
                var prodBBox    = XbimRect3D.Empty;

                foreach (var candidate in nodeContent)
                {
                    //check BBoxes for equality
                    var contBBox = _prodBBsB[candidate];
                    prodBBox = _prodBBsA[original];
                    if (XbimAABBoxAnalyser.AlmostEqual(contBBox, prodBBox, _precision))
                    {
                        if (!_processedFromB.Contains(candidate))
                        {
                            _processedFromB.Add(candidate);
                        }
                        yield return(candidate);
                    }

                    //cope with the situation when product's bbox is on the border and
                    //it's equivalent from the second model might have end up on the higher level
                    var borderDirections = BBoxBorderDirections(node.Bounds, prodBBox);
                    var parents          = GetParentsInDirections(borderDirections, node);
                    foreach (var parent in parents)
                    {
                        foreach (var item in GetCandidatesFromNode(original, parent))//recursion
                        {
                            if (!_processedFromB.Contains(candidate))
                            {
                                _processedFromB.Add(candidate);
                            }
                            yield return(candidate);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Add the Impact and fill with data from COBieComponentRow
        /// </summary>
        /// <param name="row">COBieImpactRow holding the data</param>
        private void AddImpact(COBieImpactRow row)
        {
            string pSetName    = "Pset_EnvironmentalImpactValues";
            string description = Constants.DEFAULT_STRING;

            if (ValidateString(row.Description))
            {
                description = row.Description;
            }

            IfcPropertySet ifcPropertySet = null;

            if (row.SheetName.ToLower().Trim() == "type")
            {
                if (IfcTypeObjects == null)
                {
                    IfcTypeObjects = Model.Instances.OfType <IfcTypeObject>();
                }
                IfcTypeObject ifcTypeObject = IfcTypeObjects.Where(to => to.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                if (ifcTypeObject != null)
                {
                    if (XBimContext.IsMerge)
                    {
                        ifcPropertySet = ifcTypeObject.GetPropertySet(pSetName);
                        if (ifcPropertySet != null) //Property set Pset_EnvironmentalImpactValues already set so assume exists so skip
                        {
#if DEBUG
                            Console.WriteLine("{0} Pset_EnvironmentalImpactValues Property set so skip on merge", ifcTypeObject.GetType().Name);
#endif
                            return;
                        }
                    }

                    ifcPropertySet = AddPropertySet(ifcTypeObject, pSetName, description);
                }
            }
            else
            {
                if (IfcProducts == null)
                {
                    IfcProducts = Model.Instances.OfType <IfcProduct>();
                }
                IfcProduct ifcProduct = IfcProducts.Where(to => to.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                if (ifcProduct != null)
                {
                    if (XBimContext.IsMerge)
                    {
                        ifcPropertySet = ifcProduct.GetPropertySet(pSetName);
                        if (ifcPropertySet != null)//Property set Pset_EnvironmentalImpactValues already set so assume exists so skip
                        {
#if DEBUG
                            Console.WriteLine("{0} Pset_EnvironmentalImpactValues Property set so skip on merge", ifcProduct.GetType().Name);
#endif
                            return;
                        }
                    }

                    ifcPropertySet = AddPropertySet(ifcProduct, pSetName, description);
                }
            }

            //check we have a property set from the found SheetName/RowName object
            if (ifcPropertySet != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History.
                SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                //using statement will set the Model.OwnerHistoryAddObject to ifcPropertySet.OwnerHistory as OwnerHistoryAddObject is used upon any property changes,
                //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
                using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcPropertySet.OwnerHistory))
                {
                    if (ValidateString(row.Name))
                    {
                        AddPropertySingleValue(ifcPropertySet, "ImpactName", "Impact Name", new IfcText(row.Name), null);
                    }

                    if (ValidateString(row.ImpactType))
                    {
                        AddPropertySingleValue(ifcPropertySet, "ImpactType", "Impact Type", new IfcText(row.ImpactType), null);
                    }

                    if (ValidateString(row.ImpactStage))
                    {
                        AddPropertySingleValue(ifcPropertySet, "ImpactStage", "Impact Stage", new IfcText(row.ImpactStage), null);
                    }

                    if (ValidateString(row.Value))
                    {
                        IfcValue ifcValue = SetValue(row.Value);

                        IfcUnit ifcUnit = null;
                        if (ValidateString(row.ImpactUnit))
                        {
                            ifcUnit = GetDurationUnit(row.ImpactUnit); //see if time unit
                            //see if we can convert to a IfcSIUnit
                            if (ifcUnit == null)
                            {
                                ifcUnit = GetSIUnit(row.ImpactUnit);
                            }
                            //OK set as a user defined
                            if (ifcUnit == null)
                            {
                                ifcUnit = SetContextDependentUnit(row.ImpactUnit);
                            }
                        }
                        AddPropertySingleValue(ifcPropertySet, "Value", "Value", ifcValue, ifcUnit);
                    }

                    if (ValidateString(row.LeadInTime))
                    {
                        IfcValue ifcValue = SetValue(row.LeadInTime);
                        AddPropertySingleValue(ifcPropertySet, "LeadInTime", "Lead In Time", ifcValue, null);
                    }

                    if (ValidateString(row.Duration))
                    {
                        IfcValue ifcValue = SetValue(row.Duration);
                        AddPropertySingleValue(ifcPropertySet, "Duration", "Duration", ifcValue, null);
                    }

                    if (ValidateString(row.LeadOutTime))
                    {
                        IfcValue ifcValue = SetValue(row.LeadOutTime);
                        AddPropertySingleValue(ifcPropertySet, "LeadOutTime", "Lead Out Time", ifcValue, null);
                    }

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcPropertySet);

                    //row.Description done above on property set
                }
            }
        }