示例#1
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        private IFCItem FindIFCItem(IFCItem ifcParent, IFCTreeItem ifcTreeItem)
        {
            if (ifcParent == null)
            {
                return(null);
            }

            IFCItem ifcIterator = ifcParent;

            while (ifcIterator != null)
            {
                if (ifcIterator.ifcID == ifcTreeItem.instance)
                {
                    return(ifcIterator);
                }

                IFCItem ifcItem = FindIFCItem(ifcIterator.child, ifcTreeItem);
                if (ifcItem != null)
                {
                    return(ifcItem);
                }

                ifcIterator = ifcIterator.next;
            }

            return(FindIFCItem(ifcParent.child, ifcTreeItem));
        }
示例#2
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="ifcItem"></param>
        private void CreateTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem)
        {
            IntPtr ifcType    = _ifcEngine.GetInstanceType(ifcItem.instance);
            string strIfcType = Marshal.PtrToStringAnsi(ifcType);

            IntPtr name;

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

            string strName = Marshal.PtrToStringUni(name);

            IntPtr description;

            _ifcEngine.GetAttribute(ifcItem.instance, "Description", IfcEngine.SdaiType.Unicode, out 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
                ifcItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray);
            }

            ifcItem.treeNode.Tag = ifcItem;
        }
示例#3
0
        /// <summary>
        /// Helper
        /// </summary>
        private void CreateProjectTreeItems()
        {
            var iEntityID      = _ifcEngine.GetEntityExtent(_ifcModel, "IfcProject");
            var iEntitiesCount = _ifcEngine.GetMemberCount(iEntityID);

            for (int iEntity = 0; iEntity < iEntitiesCount.ToInt32(); iEntity++)
            {
                IntPtr iInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(iEntityID, iEntity, IfcEngine.SdaiType.Instance, out iInstance);

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

                CreateTreeItem(null, ifcTreeItem);

                AddChildrenTreeItems(ifcTreeItem, iInstance, "IfcSite");
            } // for (int iEntity = ...
        }
示例#4
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="iParentInstance"></param>
        unsafe void getRGB_surfaceStyle(IFCTreeItem ifcTreeItem, IntPtr iParentInstance)
        {
            IntPtr stylesInstance;

            _ifcEngine.GetAttribute(iParentInstance, "Styles", IfcEngine.SdaiType.Aggregation, out stylesInstance);

            var iStylesCount = _ifcEngine.GetMemberCount(stylesInstance);

            for (int iStyle = 0; iStyle < iStylesCount.ToInt32(); iStyle++)
            {
                var iStyleInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(stylesInstance, iStyle, IfcEngine.SdaiType.Instance, out iStyleInstance);

                if (iStyleInstance == IntPtr.Zero)
                {
                    continue;
                }

                IntPtr surfaceColour;
                _ifcEngine.GetAttribute(iStyleInstance, "SurfaceColour", IfcEngine.SdaiType.Instance, out surfaceColour);

                if (surfaceColour == IntPtr.Zero)
                {
                    continue;
                }

                double R = 0;
                _ifcEngine.GetAttribute(surfaceColour, "Red", IfcEngine.SdaiType.Real, out *(IntPtr *)&R);

                double G = 0;
                _ifcEngine.GetAttribute(surfaceColour, "Green", IfcEngine.SdaiType.Real, out *(IntPtr *)&G);

                double B = 0;
                _ifcEngine.GetAttribute(surfaceColour, "Blue", IfcEngine.SdaiType.Real, out *(IntPtr *)&B);

                ifcTreeItem.ifcColor   = new IFCItemColor();
                ifcTreeItem.ifcColor.R = (float)R;
                ifcTreeItem.ifcColor.G = (float)G;
                ifcTreeItem.ifcColor.B = (float)B;

                return;
            } // for (int iStyle = ...
        }
示例#5
0
        /// <summary>
        /// Helper
        /// </summary>
        private void CreateNotReferencedTreeItems()
        {
            IFCTreeItem ifcTreeItem = new IFCTreeItem();

            ifcTreeItem.treeNode = new TreeViewItem()
            {
                Header = "Not Referenced"
            };
            _treeControl.Items.Add(ifcTreeItem.treeNode);
            ifcTreeItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray);
            ifcTreeItem.treeNode.Tag        = ifcTreeItem;

            FindNonReferencedIFCItems(_ifcRoot, ifcTreeItem.treeNode);

            if (ifcTreeItem.treeNode.Items.Count == 0)
            {
                // don't show empty Not Referenced item
                _treeControl.Items.Remove(ifcTreeItem.treeNode);
            }
        }
示例#6
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        private void FindNonReferencedIFCItems(IFCItem ifcParent, TreeViewItem tnNotReferenced)
        {
            if (ifcParent == null)
            {
                return;
            }

            IFCItem ifcIterator = ifcParent;

            while (ifcIterator != null)
            {
                if ((ifcIterator.ifcTreeItem == null) && (ifcIterator.ifcID != IntPtr.Zero))
                {
                    string strItemText = "'" + (string.IsNullOrEmpty(ifcIterator.name) ? "<name>" : ifcIterator.name) +
                                         "' = '" + (string.IsNullOrEmpty(ifcIterator.description) ? "<description>" : ifcIterator.description) +
                                         "' (" + (string.IsNullOrEmpty(ifcIterator.ifcType) ? ifcIterator.globalID : ifcIterator.ifcType) + ")";

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = ifcIterator.ifcID;
                    ifcTreeItem.treeNode = new TreeViewItem()
                    {
                        Header = strItemText
                    };
                    tnNotReferenced.Items.Add(ifcTreeItem.treeNode);
                    ifcTreeItem.ifcItem      = FindIFCItem(_ifcRoot, ifcTreeItem);
                    ifcIterator.ifcTreeItem  = ifcTreeItem;
                    ifcTreeItem.treeNode.Tag = ifcTreeItem;

                    if (ifcTreeItem.ifcItem != null)
                    {
                        ifcTreeItem.ifcItem.ifcTreeItem = ifcTreeItem;
                    }
                }

                FindNonReferencedIFCItems(ifcIterator.child, tnNotReferenced);

                ifcIterator = ifcIterator.next;
            }

            FindNonReferencedIFCItems(ifcParent.child, tnNotReferenced);
        }
示例#7
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="iParentInstance"></param>
        void getRGB_presentationStyleAssignment(IFCTreeItem ifcTreeItem, IntPtr iParentInstance)
        {
            IntPtr stylesInstance;

            _ifcEngine.GetAttribute(iParentInstance, "Styles", IfcEngine.SdaiType.Aggregation, out stylesInstance);

            var iStylesCount = _ifcEngine.GetMemberCount(stylesInstance);

            for (int iStyle = 0; iStyle < iStylesCount.ToInt32(); iStyle++)
            {
                var iStyleInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(stylesInstance, iStyle, IfcEngine.SdaiType.Instance, out iStyleInstance);

                if (iStyleInstance == IntPtr.Zero)
                {
                    continue;
                }

                getRGB_surfaceStyle(ifcTreeItem, iStyleInstance);
            } // for (int iStyle = ...
        }
示例#8
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        /// <param name="iParentInstance"></param>
        void searchDeeper(IFCTreeItem ifcTreeItem, IntPtr iParentInstance)
        {
            IntPtr styledByItem;

            _ifcEngine.GetAttribute(iParentInstance, "StyledByItem", IfcEngine.SdaiType.Instance, out styledByItem);

            if (styledByItem != IntPtr.Zero)
            {
                getRGB_styledItem(ifcTreeItem, styledByItem);
                if (ifcTreeItem.ifcColor != null)
                {
                    return;
                }
            }

            if (IsInstanceOf(iParentInstance, "IFCBOOLEANCLIPPINGRESULT"))
            {
                IntPtr firstOperand;
                _ifcEngine.GetAttribute(iParentInstance, "FirstOperand", IfcEngine.SdaiType.Instance, out firstOperand);

                if (firstOperand != IntPtr.Zero)
                {
                    searchDeeper(ifcTreeItem, firstOperand);
                }
            } // if (IsInstanceOf(iParentInstance, "IFCBOOLEANCLIPPINGRESULT"))
            else
            {
                if (IsInstanceOf(iParentInstance, "IFCMAPPEDITEM"))
                {
                    IntPtr mappingSource;
                    _ifcEngine.GetAttribute(iParentInstance, "MappingSource", IfcEngine.SdaiType.Instance, out mappingSource);

                    IntPtr mappedRepresentation;
                    _ifcEngine.GetAttribute(mappingSource, "MappedRepresentation", IfcEngine.SdaiType.Instance, out mappedRepresentation);

                    if (mappedRepresentation != IntPtr.Zero)
                    {
                        IntPtr representationIdentifier;
                        _ifcEngine.GetAttribute(mappedRepresentation, "RepresentationIdentifier", IfcEngine.SdaiType.Unicode, out representationIdentifier);

                        if (Marshal.PtrToStringUni(representationIdentifier) == "Body")
                        {
                            IntPtr itemsInstance;
                            _ifcEngine.GetAttribute(mappedRepresentation, "Items", IfcEngine.SdaiType.Aggregation, out itemsInstance);

                            var iItemsCount = _ifcEngine.GetMemberCount(itemsInstance);
                            for (int iItem = 0; iItem < iItemsCount.ToInt32(); iItem++)
                            {
                                var iItemInstance = IntPtr.Zero;
                                _ifcEngine.GetAggregationElement(itemsInstance, iItem, IfcEngine.SdaiType.Instance, out iItemInstance);

                                styledByItem = IntPtr.Zero;
                                _ifcEngine.GetAttribute(iItemInstance, "StyledByItem", IfcEngine.SdaiType.Instance, out styledByItem);

                                if (styledByItem != IntPtr.Zero)
                                {
                                    getRGB_styledItem(ifcTreeItem, styledByItem);
                                }
                                else
                                {
                                    searchDeeper(ifcTreeItem, iItemInstance);
                                } // else if (iItemInstance != 0)

                                if (ifcTreeItem.ifcColor != null)
                                {
                                    return;
                                }
                            } // for (int iItem = ...
                        }     // if (Marshal.PtrToStringAnsi(representationIdentifier) == "Body")
                    }         // if (mappedRepresentation != IntPtr.Zero)
                }             // if (IsInstanceOf(iParentInstance, "IFCMAPPEDITEM"))
            }                 // else if (IsInstanceOf(iParentInstance, "IFCBOOLEANCLIPPINGRESULT"))
        }
示例#9
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="iParentInstance"></param>
        unsafe void getRGB_surfaceStyle(IFCTreeItem ifcTreeItem, IntPtr iParentInstance)
        {
            IntPtr stylesInstance;
            _ifcEngine.GetAttribute(iParentInstance, "Styles", IfcEngine.SdaiType.Aggregation, out stylesInstance);

            var iStylesCount = _ifcEngine.GetMemberCount(stylesInstance);
            for (int iStyle = 0; iStyle < iStylesCount.ToInt32(); iStyle++) {
                var iStyleInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(stylesInstance, iStyle, IfcEngine.SdaiType.Instance, out iStyleInstance);

                if (iStyleInstance == IntPtr.Zero) {
                    continue;
                }

                IntPtr surfaceColour;
                _ifcEngine.GetAttribute(iStyleInstance, "SurfaceColour", IfcEngine.SdaiType.Instance, out surfaceColour);

                if (surfaceColour == IntPtr.Zero) {
                    continue;
                }

                double R = 0;
                _ifcEngine.GetAttribute(surfaceColour, "Red", IfcEngine.SdaiType.Real, out *(IntPtr*)&R);

                double G = 0;
                _ifcEngine.GetAttribute(surfaceColour, "Green", IfcEngine.SdaiType.Real, out *(IntPtr*)&G);

                double B = 0;
                _ifcEngine.GetAttribute(surfaceColour, "Blue", IfcEngine.SdaiType.Real, out *(IntPtr*)&B);

                ifcTreeItem.ifcColor = new IFCItemColor();
                ifcTreeItem.ifcColor.R = (float)R;
                ifcTreeItem.ifcColor.G = (float)G;
                ifcTreeItem.ifcColor.B = (float)B;

                return;
            } // for (int iStyle = ...
        }
示例#10
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="iParentInstance"></param>
        private void AddElementTreeItems(IFCTreeItem ifcParent, IntPtr iParentInstance)
        {
            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++)
            {
                var 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);

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = iObjectInstance;
                    ifcTreeItem.ifcItem  = FindIFCItem(_ifcRoot, ifcTreeItem);

                    CreateTreeItem(ifcParent, ifcTreeItem);

                    _dicCheckedElements[GetItemType(iObjectInstance)] = true;

                    if (ifcTreeItem.ifcItem != null)
                    {
                        ifcTreeItem.ifcItem.ifcTreeItem = ifcTreeItem;
                    }
                } // for (int iObject = ...
            }     // for (int iDecomposition = ...

            // check for elements
            IntPtr elementsInstance;

            _ifcEngine.GetAttribute(iParentInstance, "ContainsElements", IfcEngine.SdaiType.Aggregation, out elementsInstance);

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

            var iElementsCount = _ifcEngine.GetMemberCount(elementsInstance);

            for (int iElement = 0; iElement < iElementsCount.ToInt32(); iElement++)
            {
                IntPtr iElementInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(elementsInstance, iElement, IfcEngine.SdaiType.Instance, out iElementInstance);

                if (!IsInstanceOf(iElementInstance, "IFCRELCONTAINEDINSPATIALSTRUCTURE"))
                {
                    continue;
                }

                IntPtr objectInstances;
                _ifcEngine.GetAttribute(iElementInstance, "RelatedElements", IfcEngine.SdaiType.Aggregation, out objectInstances);

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

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = iObjectInstance;
                    ifcTreeItem.ifcItem  = FindIFCItem(_ifcRoot, ifcTreeItem);

                    CreateTreeItem(ifcParent, ifcTreeItem);

                    _dicCheckedElements[GetItemType(iObjectInstance)] = true;

                    if (ifcTreeItem.ifcItem != null)
                    {
                        ifcTreeItem.ifcItem.ifcTreeItem = ifcTreeItem;

                        GetColor(ifcTreeItem);
                    }

                    IntPtr definedByInstances;
                    _ifcEngine.GetAttribute(iObjectInstance, "IsDefinedBy", IfcEngine.SdaiType.Aggregation, out definedByInstances);

                    if (definedByInstances == IntPtr.Zero)
                    {
                        continue;
                    }

                    var iDefinedByCount = _ifcEngine.GetMemberCount(definedByInstances);
                    for (int iDefinedBy = 0; iDefinedBy < iDefinedByCount.ToInt32(); iDefinedBy++)
                    {
                        var iDefinedByInstance = IntPtr.Zero;
                        _ifcEngine.GetAggregationElement(definedByInstances, iDefinedBy, IfcEngine.SdaiType.Instance, out iDefinedByInstance);

                        if (IsInstanceOf(iDefinedByInstance, "IFCRELDEFINESBYPROPERTIES"))
                        {
                            AddPropertyTreeItems(ifcTreeItem, iDefinedByInstance);
                        }
                        else
                        {
                            if (IsInstanceOf(iDefinedByInstance, "IFCRELDEFINESBYTYPE"))
                            {
                                // NA
                            }
                        }
                    }
                } // for (int iObject = ...
            }     // for (int iDecomposition = ...
        }
示例#11
0
        /// <summary>
        /// Helper.
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        void GetColor(IFCTreeItem ifcTreeItem)
        {
            if (ifcTreeItem == null)
            {
                throw new ArgumentException("The item is null.");
            }

            // C++ => getRGB_object()
            IntPtr representationInstance;

            _ifcEngine.GetAttribute(ifcTreeItem.instance, "Representation", IfcEngine.SdaiType.Instance, out representationInstance);
            if (representationInstance == IntPtr.Zero)
            {
                return;
            }

            // C++ => getRGB_productDefinitionShape()
            IntPtr representationsInstance;

            _ifcEngine.GetAttribute(representationInstance, "Representations", IfcEngine.SdaiType.Aggregation, out representationsInstance);

            var iRepresentationsCount = _ifcEngine.GetMemberCount(representationsInstance);

            for (int iRepresentation = 0; iRepresentation < iRepresentationsCount.ToInt32(); iRepresentation++)
            {
                var iShapeInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(representationsInstance, iRepresentation, IfcEngine.SdaiType.Instance, out iShapeInstance);

                if (iShapeInstance == IntPtr.Zero)
                {
                    continue;
                }

                // C++ => getRGB_shapeRepresentation()
                IntPtr representationIdentifier;
                _ifcEngine.GetAttribute(iShapeInstance, "RepresentationIdentifier", IfcEngine.SdaiType.Unicode, out representationIdentifier);

                if (Marshal.PtrToStringUni(representationIdentifier) == "Body")
                {
                    IntPtr itemsInstance;
                    _ifcEngine.GetAttribute(iShapeInstance, "Items", IfcEngine.SdaiType.Aggregation, out itemsInstance);

                    var iItemsCount = _ifcEngine.GetMemberCount(itemsInstance);
                    for (int iItem = 0; iItem < iItemsCount.ToInt32(); iItem++)
                    {
                        var iItemInstance = IntPtr.Zero;
                        _ifcEngine.GetAggregationElement(itemsInstance, iItem, IfcEngine.SdaiType.Instance, out iItemInstance);

                        IntPtr styledByItem;
                        _ifcEngine.GetAttribute(iItemInstance, "StyledByItem", IfcEngine.SdaiType.Instance, out styledByItem);

                        if (styledByItem != IntPtr.Zero)
                        {
                            getRGB_styledItem(ifcTreeItem, styledByItem);
                        }
                        else
                        {
                            searchDeeper(ifcTreeItem, iItemInstance);
                        } // else if (iItemInstance != 0)

                        if (ifcTreeItem.ifcColor != null)
                        {
                            return;
                        }
                    } // for (int iItem = ...
                }
            }         // for (int iRepresentation = ...
        }
示例#12
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="iParentInstance"></param>     
        private void AddPropertyTreeItems(IFCTreeItem ifcParent, IntPtr iParentInstance)
        {
            IntPtr propertyInstances;
            _ifcEngine.GetAttribute(iParentInstance, "RelatingPropertyDefinition", IfcEngine.SdaiType.Instance, out propertyInstances);

            if (IsInstanceOf(propertyInstances, "IFCELEMENTQUANTITY")) {
                IFCTreeItem ifcPropertySetTreeItem = new IFCTreeItem();
                ifcPropertySetTreeItem.instance = propertyInstances;

                CreateTreeItem(ifcParent, ifcPropertySetTreeItem);

                // check for quantity
                IntPtr quantitiesInstance;
                _ifcEngine.GetAttribute(propertyInstances, "Quantities", IfcEngine.SdaiType.Aggregation, out quantitiesInstance);

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

                var iQuantitiesCount = _ifcEngine.GetMemberCount(quantitiesInstance);
                for (int iQuantity = 0; iQuantity < iQuantitiesCount.ToInt32(); iQuantity++) {
                    var iQuantityInstance = IntPtr.Zero;
                    _ifcEngine.GetAggregationElement(quantitiesInstance, iQuantity, IfcEngine.SdaiType.Instance, out iQuantityInstance);

                    IFCTreeItem ifcQuantityTreeItem = new IFCTreeItem();
                    ifcQuantityTreeItem.instance = iQuantityInstance;

                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYLENGTH"))
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYLENGTH");
                    else
                        if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYAREA"))
                            CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYAREA");
                        else
                            if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYVOLUME"))
                                CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYVOLUME");
                            else
                                if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYCOUNT"))
                                    CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYCOUNT");
                                else
                                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYWEIGTH"))
                                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYWEIGTH");
                                    else
                                        if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYTIME"))
                                            CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYTIME");
                } // for (int iQuantity = ...
            } else {
                if (IsInstanceOf(propertyInstances, "IFCPROPERTYSET")) {
                    IFCTreeItem ifcPropertySetTreeItem = new IFCTreeItem();
                    ifcPropertySetTreeItem.instance = propertyInstances;

                    CreateTreeItem(ifcParent, ifcPropertySetTreeItem);

                    // check for quantity
                    IntPtr propertiesInstance;
                    _ifcEngine.GetAttribute(propertyInstances, "HasProperties", IfcEngine.SdaiType.Aggregation, out propertiesInstance);

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

                    var iPropertiesCount = _ifcEngine.GetMemberCount(propertiesInstance);
                    for (int iProperty = 0; iProperty < iPropertiesCount.ToInt32(); iProperty++) {
                        var iPropertyInstance = IntPtr.Zero;
                        _ifcEngine.GetAggregationElement(propertiesInstance, iProperty, IfcEngine.SdaiType.Instance, out iPropertyInstance);

                        if (!IsInstanceOf(iPropertyInstance, "IFCPROPERTYSINGLEVALUE"))
                            continue;

                        IFCTreeItem ifcPropertyTreeItem = new IFCTreeItem();
                        ifcPropertyTreeItem.instance = iPropertyInstance;

                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcPropertyTreeItem, "IFCPROPERTYSINGLEVALUE");
                    } // for (int iProperty = ...
                }
            }
        }
示例#13
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 = ...
        }
示例#14
0
        /// <summary>
        /// Helper
        /// </summary>
        private void CreateProjectTreeItems()
        {
            var iEntityID = _ifcEngine.GetEntityExtent(_ifcModel, "IfcProject");
            var iEntitiesCount = _ifcEngine.GetMemberCount(iEntityID);

            for (int iEntity = 0; iEntity < iEntitiesCount.ToInt32(); iEntity++) {
                IntPtr iInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(iEntityID, iEntity, IfcEngine.SdaiType.Instance, out iInstance);

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

                CreateTreeItem(null, ifcTreeItem);

                AddChildrenTreeItems(ifcTreeItem, iInstance, "IfcSite");
            } // for (int iEntity = ...
        }
示例#15
0
        /// <summary>
        /// Helper
        /// </summary>
        private void CreateNotReferencedTreeItems()
        {
            IFCTreeItem ifcTreeItem = new IFCTreeItem();
            ifcTreeItem.treeNode = new TreeViewItem() { Header = "Not Referenced" };
            _treeControl.Items.Add(ifcTreeItem.treeNode);
            ifcTreeItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray);
            ifcTreeItem.treeNode.Tag = ifcTreeItem;

            FindNonReferencedIFCItems(_ifcRoot, ifcTreeItem.treeNode);

            if (ifcTreeItem.treeNode.Items.Count == 0) {
                // don't show empty Not Referenced item
                _treeControl.Items.Remove(ifcTreeItem.treeNode);
            }
        }
示例#16
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="ifcItem"></param>
        private void CreatePropertyTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem, string strProperty)
        {
            IntPtr ifcType = _ifcEngine.GetInstanceType(ifcItem.instance);
            string strIfcType = Marshal.PtrToStringAnsi(ifcType);

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

            string strName = Marshal.PtrToStringUni(name);

            string strValue = string.Empty;
            switch (strProperty) {
                case "IFCQUANTITYLENGTH": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "LengthValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                case "IFCQUANTITYAREA": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "AreaValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                case "IFCQUANTITYVOLUME": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "VolumeValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                case "IFCQUANTITYCOUNT": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "CountValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                case "IFCQUANTITYWEIGTH": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "WeigthValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                case "IFCQUANTITYTIME": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "TimeValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                case "IFCPROPERTYSINGLEVALUE": {
                        IntPtr value;
                        _ifcEngine.GetAttribute(ifcItem.instance, "NominalValue", IfcEngine.SdaiType.Unicode, out value);

                        strValue = Marshal.PtrToStringUni(value);
                    }
                    break;

                default:
                    throw new Exception("Unknown property.");
            } // switch (strProperty)

            string strItemText = "'" + (string.IsNullOrEmpty(strName) ? "<name>" : strName) +
                    "' = '" + (string.IsNullOrEmpty(strValue) ? "<value>" : strValue) +
                    "' (" + 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
                ifcItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray);
            }
        }
示例#17
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="iParentInstance"></param>     
        private void AddElementTreeItems(IFCTreeItem ifcParent, IntPtr iParentInstance)
        {
            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++) {
                var 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);

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = iObjectInstance;
                    ifcTreeItem.ifcItem = FindIFCItem(_ifcRoot, ifcTreeItem);

                    CreateTreeItem(ifcParent, ifcTreeItem);

                    _dicCheckedElements[GetItemType(iObjectInstance)] = true;

                    if (ifcTreeItem.ifcItem != null) {
                        ifcTreeItem.ifcItem.ifcTreeItem = ifcTreeItem;
                    }
                } // for (int iObject = ...
            } // for (int iDecomposition = ...

            // check for elements
            IntPtr elementsInstance;
            _ifcEngine.GetAttribute(iParentInstance, "ContainsElements", IfcEngine.SdaiType.Aggregation, out elementsInstance);

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

            var iElementsCount = _ifcEngine.GetMemberCount(elementsInstance);
            for (int iElement = 0; iElement < iElementsCount.ToInt32(); iElement++) {
                IntPtr iElementInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(elementsInstance, iElement, IfcEngine.SdaiType.Instance, out iElementInstance);

                if (!IsInstanceOf(iElementInstance, "IFCRELCONTAINEDINSPATIALSTRUCTURE")) {
                    continue;
                }

                IntPtr objectInstances;
                _ifcEngine.GetAttribute(iElementInstance, "RelatedElements", IfcEngine.SdaiType.Aggregation, out objectInstances);

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

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = iObjectInstance;
                    ifcTreeItem.ifcItem = FindIFCItem(_ifcRoot, ifcTreeItem);

                    CreateTreeItem(ifcParent, ifcTreeItem);

                    _dicCheckedElements[GetItemType(iObjectInstance)] = true;

                    if (ifcTreeItem.ifcItem != null) {
                        ifcTreeItem.ifcItem.ifcTreeItem = ifcTreeItem;

                        GetColor(ifcTreeItem);
                    }

                    IntPtr definedByInstances;
                    _ifcEngine.GetAttribute(iObjectInstance, "IsDefinedBy", IfcEngine.SdaiType.Aggregation, out definedByInstances);

                    if (definedByInstances == IntPtr.Zero) {
                        continue;
                    }

                    var iDefinedByCount = _ifcEngine.GetMemberCount(definedByInstances);
                    for (int iDefinedBy = 0; iDefinedBy < iDefinedByCount.ToInt32(); iDefinedBy++) {
                        var iDefinedByInstance = IntPtr.Zero;
                        _ifcEngine.GetAggregationElement(definedByInstances, iDefinedBy, IfcEngine.SdaiType.Instance, out iDefinedByInstance);

                        if (IsInstanceOf(iDefinedByInstance, "IFCRELDEFINESBYPROPERTIES")) {
                            AddPropertyTreeItems(ifcTreeItem, iDefinedByInstance);
                        } else {
                            if (IsInstanceOf(iDefinedByInstance, "IFCRELDEFINESBYTYPE")) {
                                // NA
                            }
                        }
                    }
                } // for (int iObject = ...
            } // for (int iDecomposition = ...
        }
示例#18
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="ifcItem"></param>
        private void CreateTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem)
        {
            IntPtr ifcType = _ifcEngine.GetInstanceType(ifcItem.instance);
            string strIfcType = Marshal.PtrToStringAnsi(ifcType);

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

            string strName = Marshal.PtrToStringUni(name);

            IntPtr description;
            _ifcEngine.GetAttribute(ifcItem.instance, "Description", IfcEngine.SdaiType.Unicode, out 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
                ifcItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray);
            }

            ifcItem.treeNode.Tag = ifcItem;
        }
示例#19
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="iStyledByItemInstance"></param>
        void getRGB_styledItem(IFCTreeItem ifcTreeItem, IntPtr iStyledByItemInstance)
        {
            IntPtr stylesInstance;
            _ifcEngine.GetAttribute(iStyledByItemInstance, "Styles", IfcEngine.SdaiType.Aggregation, out stylesInstance);

            var iStylesCount = _ifcEngine.GetMemberCount(stylesInstance);
            for (int iStyle = 0; iStyle < iStylesCount.ToInt32(); iStyle++) {
                var iStyleInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(stylesInstance, iStyle, IfcEngine.SdaiType.Instance, out iStyleInstance);

                if (iStyleInstance == IntPtr.Zero) {
                    continue;
                }

                getRGB_presentationStyleAssignment(ifcTreeItem, iStyleInstance);
            } // for (int iStyle = ...
        }
示例#20
0
        /// <summary>
        /// Helper. 
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        void GetColor(IFCTreeItem ifcTreeItem)
        {
            if (ifcTreeItem == null) {
                throw new ArgumentException("The item is null.");
            }

            // C++ => getRGB_object()
            IntPtr representationInstance;
            _ifcEngine.GetAttribute(ifcTreeItem.instance, "Representation", IfcEngine.SdaiType.Instance, out representationInstance);
            if (representationInstance == IntPtr.Zero) {
                return;
            }

            // C++ => getRGB_productDefinitionShape()
            IntPtr representationsInstance;
            _ifcEngine.GetAttribute(representationInstance, "Representations", IfcEngine.SdaiType.Aggregation, out representationsInstance);

            var iRepresentationsCount = _ifcEngine.GetMemberCount(representationsInstance);
            for (int iRepresentation = 0; iRepresentation < iRepresentationsCount.ToInt32(); iRepresentation++) {
                var iShapeInstance = IntPtr.Zero;
                _ifcEngine.GetAggregationElement(representationsInstance, iRepresentation, IfcEngine.SdaiType.Instance, out iShapeInstance);

                if (iShapeInstance == IntPtr.Zero) {
                    continue;
                }

                // C++ => getRGB_shapeRepresentation()
                IntPtr representationIdentifier;
                _ifcEngine.GetAttribute(iShapeInstance, "RepresentationIdentifier", IfcEngine.SdaiType.Unicode, out representationIdentifier);

                if (Marshal.PtrToStringUni(representationIdentifier) == "Body") {
                    IntPtr itemsInstance;
                    _ifcEngine.GetAttribute(iShapeInstance, "Items", IfcEngine.SdaiType.Aggregation, out itemsInstance);

                    var iItemsCount = _ifcEngine.GetMemberCount(itemsInstance);
                    for (int iItem = 0; iItem < iItemsCount.ToInt32(); iItem++) {
                        var iItemInstance = IntPtr.Zero;
                        _ifcEngine.GetAggregationElement(itemsInstance, iItem, IfcEngine.SdaiType.Instance, out iItemInstance);

                        IntPtr styledByItem;
                        _ifcEngine.GetAttribute(iItemInstance, "StyledByItem", IfcEngine.SdaiType.Instance, out styledByItem);

                        if (styledByItem != IntPtr.Zero) {
                            getRGB_styledItem(ifcTreeItem, styledByItem);
                        } else {
                            searchDeeper(ifcTreeItem, iItemInstance);
                        } // else if (iItemInstance != 0)

                        if (ifcTreeItem.ifcColor != null) {
                            return;
                        }
                    } // for (int iItem = ...
                }
            } // for (int iRepresentation = ...
        }
示例#21
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        private void FindNonReferencedIFCItems(IFCItem ifcParent, TreeViewItem tnNotReferenced)
        {
            if (ifcParent == null) {
                return;
            }

            IFCItem ifcIterator = ifcParent;
            while (ifcIterator != null) {
                if ((ifcIterator.ifcTreeItem == null) && (ifcIterator.ifcID != IntPtr.Zero)) {
                    string strItemText = "'" + (string.IsNullOrEmpty(ifcIterator.name) ? "<name>" : ifcIterator.name) +
                            "' = '" + (string.IsNullOrEmpty(ifcIterator.description) ? "<description>" : ifcIterator.description) +
                            "' (" + (string.IsNullOrEmpty(ifcIterator.ifcType) ? ifcIterator.globalID : ifcIterator.ifcType) + ")";

                    IFCTreeItem ifcTreeItem = new IFCTreeItem();
                    ifcTreeItem.instance = ifcIterator.ifcID;
                    ifcTreeItem.treeNode = new TreeViewItem() { Header = strItemText };
                    tnNotReferenced.Items.Add(ifcTreeItem.treeNode);
                    ifcTreeItem.ifcItem = FindIFCItem(_ifcRoot, ifcTreeItem);
                    ifcIterator.ifcTreeItem = ifcTreeItem;
                    ifcTreeItem.treeNode.Tag = ifcTreeItem;

                    if (ifcTreeItem.ifcItem != null) {
                        ifcTreeItem.ifcItem.ifcTreeItem = ifcTreeItem;
                    }
                }

                FindNonReferencedIFCItems(ifcIterator.child, tnNotReferenced);

                ifcIterator = ifcIterator.next;
            }

            FindNonReferencedIFCItems(ifcParent.child, tnNotReferenced);
        }
示例#22
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        private IFCItem FindIFCItem(IFCItem ifcParent, IFCTreeItem ifcTreeItem)
        {
            if (ifcParent == null) {
                return null;
            }

            IFCItem ifcIterator = ifcParent;
            while (ifcIterator != null) {
                if (ifcIterator.ifcID == ifcTreeItem.instance) {
                    return ifcIterator;
                }

                IFCItem ifcItem = FindIFCItem(ifcIterator.child, ifcTreeItem);
                if (ifcItem != null) {
                    return ifcItem;
                }

                ifcIterator = ifcIterator.next;
            }

            return FindIFCItem(ifcParent.child, ifcTreeItem);
        }
示例#23
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="iParentInstance"></param>
        private void AddPropertyTreeItems(IFCTreeItem ifcParent, IntPtr iParentInstance)
        {
            IntPtr propertyInstances;

            _ifcEngine.GetAttribute(iParentInstance, "RelatingPropertyDefinition", IfcEngine.SdaiType.Instance, out propertyInstances);

            if (IsInstanceOf(propertyInstances, "IFCELEMENTQUANTITY"))
            {
                IFCTreeItem ifcPropertySetTreeItem = new IFCTreeItem();
                ifcPropertySetTreeItem.instance = propertyInstances;

                CreateTreeItem(ifcParent, ifcPropertySetTreeItem);

                // check for quantity
                IntPtr quantitiesInstance;
                _ifcEngine.GetAttribute(propertyInstances, "Quantities", IfcEngine.SdaiType.Aggregation, out quantitiesInstance);

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

                var iQuantitiesCount = _ifcEngine.GetMemberCount(quantitiesInstance);
                for (int iQuantity = 0; iQuantity < iQuantitiesCount.ToInt32(); iQuantity++)
                {
                    var iQuantityInstance = IntPtr.Zero;
                    _ifcEngine.GetAggregationElement(quantitiesInstance, iQuantity, IfcEngine.SdaiType.Instance, out iQuantityInstance);

                    IFCTreeItem ifcQuantityTreeItem = new IFCTreeItem();
                    ifcQuantityTreeItem.instance = iQuantityInstance;

                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYLENGTH"))
                    {
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYLENGTH");
                    }
                    else
                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYAREA"))
                    {
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYAREA");
                    }
                    else
                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYVOLUME"))
                    {
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYVOLUME");
                    }
                    else
                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYCOUNT"))
                    {
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYCOUNT");
                    }
                    else
                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYWEIGTH"))
                    {
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYWEIGTH");
                    }
                    else
                    if (IsInstanceOf(iQuantityInstance, "IFCQUANTITYTIME"))
                    {
                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcQuantityTreeItem, "IFCQUANTITYTIME");
                    }
                } // for (int iQuantity = ...
            }
            else
            {
                if (IsInstanceOf(propertyInstances, "IFCPROPERTYSET"))
                {
                    IFCTreeItem ifcPropertySetTreeItem = new IFCTreeItem();
                    ifcPropertySetTreeItem.instance = propertyInstances;

                    CreateTreeItem(ifcParent, ifcPropertySetTreeItem);

                    // check for quantity
                    IntPtr propertiesInstance;
                    _ifcEngine.GetAttribute(propertyInstances, "HasProperties", IfcEngine.SdaiType.Aggregation, out propertiesInstance);

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

                    var iPropertiesCount = _ifcEngine.GetMemberCount(propertiesInstance);
                    for (int iProperty = 0; iProperty < iPropertiesCount.ToInt32(); iProperty++)
                    {
                        var iPropertyInstance = IntPtr.Zero;
                        _ifcEngine.GetAggregationElement(propertiesInstance, iProperty, IfcEngine.SdaiType.Instance, out iPropertyInstance);

                        if (!IsInstanceOf(iPropertyInstance, "IFCPROPERTYSINGLEVALUE"))
                        {
                            continue;
                        }

                        IFCTreeItem ifcPropertyTreeItem = new IFCTreeItem();
                        ifcPropertyTreeItem.instance = iPropertyInstance;

                        CreatePropertyTreeItem(ifcPropertySetTreeItem, ifcPropertyTreeItem, "IFCPROPERTYSINGLEVALUE");
                    } // for (int iProperty = ...
                }
            }
        }
示例#24
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcTreeItem"></param>
        /// <param name="iParentInstance"></param>
        void searchDeeper(IFCTreeItem ifcTreeItem, IntPtr iParentInstance)
        {
            IntPtr styledByItem;
            _ifcEngine.GetAttribute(iParentInstance, "StyledByItem", IfcEngine.SdaiType.Instance, out styledByItem);

            if (styledByItem != IntPtr.Zero) {
                getRGB_styledItem(ifcTreeItem, styledByItem);
                if (ifcTreeItem.ifcColor != null) {
                    return;
                }
            }

            if (IsInstanceOf(iParentInstance, "IFCBOOLEANCLIPPINGRESULT")) {
                IntPtr firstOperand;
                _ifcEngine.GetAttribute(iParentInstance, "FirstOperand", IfcEngine.SdaiType.Instance, out firstOperand);

                if (firstOperand != IntPtr.Zero) {
                    searchDeeper(ifcTreeItem, firstOperand);
                }
            } // if (IsInstanceOf(iParentInstance, "IFCBOOLEANCLIPPINGRESULT"))
            else {
                if (IsInstanceOf(iParentInstance, "IFCMAPPEDITEM")) {
                    IntPtr mappingSource;
                    _ifcEngine.GetAttribute(iParentInstance, "MappingSource", IfcEngine.SdaiType.Instance, out mappingSource);

                    IntPtr mappedRepresentation;
                    _ifcEngine.GetAttribute(mappingSource, "MappedRepresentation", IfcEngine.SdaiType.Instance, out mappedRepresentation);

                    if (mappedRepresentation != IntPtr.Zero) {
                        IntPtr representationIdentifier;
                        _ifcEngine.GetAttribute(mappedRepresentation, "RepresentationIdentifier", IfcEngine.SdaiType.Unicode, out representationIdentifier);

                        if (Marshal.PtrToStringUni(representationIdentifier) == "Body") {
                            IntPtr itemsInstance;
                            _ifcEngine.GetAttribute(mappedRepresentation, "Items", IfcEngine.SdaiType.Aggregation, out itemsInstance);

                            var iItemsCount = _ifcEngine.GetMemberCount(itemsInstance);
                            for (int iItem = 0; iItem < iItemsCount.ToInt32(); iItem++) {
                                var iItemInstance = IntPtr.Zero;
                                _ifcEngine.GetAggregationElement(itemsInstance, iItem, IfcEngine.SdaiType.Instance, out iItemInstance);

                                styledByItem = IntPtr.Zero;
                                _ifcEngine.GetAttribute(iItemInstance, "StyledByItem", IfcEngine.SdaiType.Instance, out styledByItem);

                                if (styledByItem != IntPtr.Zero) {
                                    getRGB_styledItem(ifcTreeItem, styledByItem);
                                } else {
                                    searchDeeper(ifcTreeItem, iItemInstance);
                                } // else if (iItemInstance != 0)

                                if (ifcTreeItem.ifcColor != null) {
                                    return;
                                }
                            } // for (int iItem = ...
                        } // if (Marshal.PtrToStringAnsi(representationIdentifier) == "Body")
                    } // if (mappedRepresentation != IntPtr.Zero)
                } // if (IsInstanceOf(iParentInstance, "IFCMAPPEDITEM"))
            } // else if (IsInstanceOf(iParentInstance, "IFCBOOLEANCLIPPINGRESULT"))
        }
示例#25
0
        /// <summary>
        /// Helper
        /// </summary>
        /// <param name="ifcParent"></param>
        /// <param name="ifcItem"></param>
        private void CreatePropertyTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem, string strProperty)
        {
            IntPtr ifcType    = _ifcEngine.GetInstanceType(ifcItem.instance);
            string strIfcType = Marshal.PtrToStringAnsi(ifcType);

            IntPtr name;

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

            string strName = Marshal.PtrToStringUni(name);

            string strValue = string.Empty;

            switch (strProperty)
            {
            case "IFCQUANTITYLENGTH": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "LengthValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            case "IFCQUANTITYAREA": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "AreaValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            case "IFCQUANTITYVOLUME": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "VolumeValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            case "IFCQUANTITYCOUNT": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "CountValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            case "IFCQUANTITYWEIGTH": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "WeigthValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            case "IFCQUANTITYTIME": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "TimeValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            case "IFCPROPERTYSINGLEVALUE": {
                IntPtr value;
                _ifcEngine.GetAttribute(ifcItem.instance, "NominalValue", IfcEngine.SdaiType.Unicode, out value);

                strValue = Marshal.PtrToStringUni(value);
            }
            break;

            default:
                throw new Exception("Unknown property.");
            } // switch (strProperty)

            string strItemText = "'" + (string.IsNullOrEmpty(strName) ? "<name>" : strName) +
                                 "' = '" + (string.IsNullOrEmpty(strValue) ? "<value>" : strValue) +
                                 "' (" + 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
                ifcItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray);
            }
        }
示例#26
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 = ...
        }