示例#1
0
        // find propertySet that contains the property
        private List <IntPtr> findPropertySets(IntPtr iPropertyInstance)
        {
            var listPropSetInst = new List <IntPtr>();

            if (iPropertyInstance != IntPtr.Zero)
            {
                IntPtr iPropertySetsCount;
                IntPtr propertySets = getAggregator("ifcPropertySet", out iPropertySetsCount);
                foreach (IntPtr iPropertySetInstance in findEntity(propertySets, iPropertySetsCount))
                {
                    IntPtr propertiesInstance;
                    _ifcEngine.GetAttribute(iPropertySetInstance, "HasProperties", IfcEngine.SdaiType.Aggregation, out propertiesInstance);
                    if (propertiesInstance != IntPtr.Zero)
                    {
                        var iPropertiesCount = _ifcEngine.GetMemberCount(propertiesInstance);
                        foreach (IntPtr iPropertyInst in findEntity(propertiesInstance, iPropertiesCount))
                        {
                            if (iPropertyInst.Equals(iPropertyInstance))
                            {
                                listPropSetInst.Add(iPropertySetInstance);
                            }
                        }
                    }
                }
            }
            return(listPropSetInst);
        }
示例#2
0
            private List <IntPtr> findElements(List <IntPtr> listPropSets)
            {
                var objectList = new List <IntPtr>();

                foreach (IntPtr iPropertySetInstance in listPropSets)
                {
                    // find element that contains the propertySet
                    if (iPropertySetInstance != IntPtr.Zero)
                    {
                        IntPtr iEntityCount;
                        IntPtr relDefProperties = getAggregator("ifcRelDefinesByProperties", out iEntityCount);
                        foreach (IntPtr iRelDefPropInstance in findEntity(relDefProperties, iEntityCount))
                        {
                            IntPtr propertySetDef;
                            _ifcEngine.GetAttribute(iRelDefPropInstance, "RelatingPropertyDefinition", IfcEngine.SdaiType.Instance, out propertySetDef);

                            if (propertySetDef.Equals(iPropertySetInstance))
                            {
                                IntPtr objectInstances;
                                _ifcEngine.GetAttribute(iRelDefPropInstance, "RelatedObjects", IfcEngine.SdaiType.Aggregation, out objectInstances);
                                var iObjectCount = _ifcEngine.GetMemberCount(objectInstances);
                                foreach (IntPtr iObjectInstance in findEntity(objectInstances, iObjectCount))
                                {
                                    objectList.Add(iObjectInstance);
                                }
                            }
                        }
                    }
                }
                return(objectList);
            }
示例#3
0
        private void RetrieveObjects(IntPtr ifcModel, string sObjectSPFFName, string ObjectDisplayName)
        {
            IntPtr ifcObjectInstances  = _ifcEngine.GetEntityExtent(ifcModel, ObjectDisplayName),
                   noIfcObjectIntances = _ifcEngine.GetMemberCount(ifcObjectInstances);

            if (noIfcObjectIntances != IntPtr.Zero)
            {
                IFCItem NewItem = null;
                if (_rootIfcItem == null)
                {
                    _rootIfcItem = new IFCItem();
                    _rootIfcItem.CreateItem(null, IntPtr.Zero, "", ObjectDisplayName, "", "");

                    NewItem = _rootIfcItem;
                }
                else
                {
                    IFCItem LastItem = _rootIfcItem;
                    while (LastItem != null)
                    {
                        if (LastItem.next == null)
                        {
                            LastItem.next = new IFCItem();
                            LastItem.next.CreateItem(null, IntPtr.Zero, "", ObjectDisplayName, "", "");

                            NewItem = LastItem.next;

                            break;
                        }
                        else
                        {
                            LastItem = LastItem.next;
                        }
                    }
                    ;
                }


                for (int i = 0; i < noIfcObjectIntances.ToInt32(); ++i)
                {
                    IntPtr ifcObjectIns = IntPtr.Zero;
                    _ifcEngine.GetAggregationElement(ifcObjectInstances, i, IfcEngine.SdaiType.Instance, out ifcObjectIns);

                    IntPtr value = IntPtr.Zero;
                    _ifcEngine.GetAttribute(ifcObjectIns, "GlobalId", IfcEngine.SdaiType.Unicode, out value);

                    string globalID = Marshal.PtrToStringUni((IntPtr)value);

                    value = IntPtr.Zero;
                    _ifcEngine.GetAttribute(ifcObjectIns, "Name", IfcEngine.SdaiType.Unicode, out value);

                    string name = Marshal.PtrToStringUni((IntPtr)value);

                    value = IntPtr.Zero;
                    _ifcEngine.GetAttribute(ifcObjectIns, "Description", IfcEngine.SdaiType.Unicode, out value);

                    string description = Marshal.PtrToStringUni((IntPtr)value);

                    IFCItem subItem = new IFCItem();
                    subItem.CreateItem(NewItem, ifcObjectIns, ObjectDisplayName, globalID, name, description);
                }
            }
        }
示例#4
0
        private void CreateTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem)
        {
            IntPtr ifcType    = IFCEngine.GetInstanceType(ifcItem.instance);
            string strIfcType = Marshal.PtrToStringAnsi(ifcType);

            IFCEngine.GetAttribute(ifcItem.instance, "Name", IfcEngine.SdaiType.Unicode, out IntPtr name);

            string strName = Marshal.PtrToStringUni(name);

            IFCEngine.GetAttribute(ifcItem.instance, "Description", IfcEngine.SdaiType.Unicode, out IntPtr description);

            string strDescription = Marshal.PtrToStringUni(description);

            string strItemText = "'" + (string.IsNullOrEmpty(strName) ? "<name>" : strName) +
                                 "', '" + (string.IsNullOrEmpty(strDescription) ? "<description>" : strDescription) +
                                 "' (" + strIfcType + ")";

            if ((ifcParent != null) && (ifcParent.treeNode != null))
            {
                ifcItem.treeNode = new TreeViewItem()
                {
                    Header = strItemText
                };
                ifcParent.treeNode.Items.Add(ifcItem.treeNode);
            }
            else
            {
                ifcItem.treeNode = new TreeViewItem()
                {
                    Header = strItemText
                };
                treeControl.Items.Add(ifcItem.treeNode);
            }

            if (ifcItem.ifcItem == null)
            {
                // item without visual representation
                Random rand       = new Random();
                byte[] colorValue = new byte[4];
                rand.NextBytes(colorValue);

                var color = System.Windows.Media.Color.FromArgb(
                    (byte)(255 - colorValue[0] * 255),
                    (byte)(colorValue[1] * 255),
                    (byte)(colorValue[2] * 255),
                    (byte)(colorValue[3] * 255));


                ifcItem.treeNode.Foreground = new SolidColorBrush(color);//Colors.Gray
            }

            ifcItem.treeNode.Tag = ifcItem;
        }
示例#5
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="iParentInstance"></param>
        /// <param name="strEntityName"></param>

        private void AddChildrenTreeItems(IFCTreeItem ifcParent, IntPtr iParentInstance, string strEntityName)
        {
            // check for decomposition
            IntPtr decompositionInstance;

            _ifcEngine.GetAttribute(iParentInstance, "IsDecomposedBy", IfcEngine.SdaiType.Aggregation, out decompositionInstance);

            if (decompositionInstance == IntPtr.Zero)
            {
                return;
            }

            var iDecompositionsCount = _ifcEngine.GetMemberCount(decompositionInstance);

            for (int iDecomposition = 0; iDecomposition < iDecompositionsCount.ToInt32(); iDecomposition++)
            {
                IntPtr iDecompositionInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(decompositionInstance, iDecomposition, IfcEngine.SdaiType.Instance, out iDecompositionInstance);

                if (!IsInstanceOf(iDecompositionInstance, "IFCRELAGGREGATES"))
                {
                    continue;
                }

                IntPtr objectInstances;
                _ifcEngine.GetAttribute(iDecompositionInstance, "RelatedObjects", IfcEngine.SdaiType.Aggregation, out objectInstances);

                var iObjectsCount = _ifcEngine.GetMemberCount(objectInstances);
                for (int iObject = 0; iObject < iObjectsCount.ToInt32(); iObject++)
                {
                    IntPtr iObjectInstance = IntPtr.Zero;
                    _ifcEngine.GetAggregationElement(objectInstances, iObject, IfcEngine.SdaiType.Instance, out iObjectInstance);

                    if (!IsInstanceOf(iObjectInstance, strEntityName))
                    {
                        continue;
                    }

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = iObjectInstance;

                    CreateTreeItem(ifcParent, ifcTreeItem);

                    switch (strEntityName)
                    {
                    case "IfcSite": {
                        AddChildrenTreeItems(ifcTreeItem, iObjectInstance, "IfcBuilding");
                    }
                    break;

                    case "IfcBuilding": {
                        AddChildrenTreeItems(ifcTreeItem, iObjectInstance, "IfcBuildingStorey");
                    }
                    break;

                    case "IfcBuildingStorey": {
                        AddElementTreeItems(ifcTreeItem, iObjectInstance);
                    }
                    break;

                    default:
                        break;
                    }
                } // for (int iObject = ...
            }     // for (int iDecomposition = ...
        }