Exemplo n.º 1
0
        /// <summary>
        /// Processes IfcTypeObject attributes.
        /// </summary>
        /// <param name="ifcTypeProduct">The IfcTypeProduct handle.</param>
        protected override void Process(IFCAnyHandle ifcTypeProduct)
        {
            base.Process(ifcTypeProduct);

            Tag = IFCAnyHandleUtil.GetStringAttribute(ifcTypeProduct, "Tag");

            IList <IFCAnyHandle> representationMapsHandle = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcTypeProduct, "RepresentationMaps");

            if (representationMapsHandle != null && representationMapsHandle.Count > 0)
            {
                foreach (IFCAnyHandle representationMapHandle in representationMapsHandle)
                {
                    IFCRepresentationMap representationMap = IFCRepresentationMap.ProcessIFCRepresentationMap(representationMapHandle);
                    if (representationMap != null)
                    {
                        RepresentationMaps.Add(representationMap);

                        // Traditionally we would create a "dummy" DirectShapeType for each IfcRepresentationMap.  In the case where the IfcRepresentationMap is not used by another other IfcTypeProduct,
                        // we would like to stop creating the "dummy" DirectShapeType and store the geometry in the DirectShapeType associated with the IfcTypeProduct.  However, IfcRepresentationMap
                        // does not have an INVERSE relationship to its IfcTypeProduct(s), at least in IFC2x3.
                        // As such, we keep track of the IfcRepresentationMaps that have the relationship described above for future correspondence.
                        RegisterRepresentationMapWithTypeProject(representationMap, this);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds all related objects in IfcRelAssigns.
        /// </summary>
        /// <param name="ifcRelAssigns">The IfcRelAssigns handle.</param>
        /// <returns>The related objects, or null if not found.</returns>
        static public ICollection <IFCObjectDefinition> ProcessRelatedObjects(IFCAnyHandle ifcRelAssignsOrAggregates)
        {
            try
            {
                ValidateIFCRelAssignsOrAggregates(ifcRelAssignsOrAggregates);
            }
            catch
            {
                //LOG: ERROR: Couldn't find valid IfcRelAssignsToGroup for IfcGroup.
                return(null);
            }

            HashSet <IFCAnyHandle> relatedObjects = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                                    <HashSet <IFCAnyHandle> >(ifcRelAssignsOrAggregates, "RelatedObjects");

            // Receiving apps need to decide whether to post an error or not.
            if (relatedObjects == null)
            {
                return(null);
            }

            ICollection <IFCObjectDefinition> relatedObjectSet = new HashSet <IFCObjectDefinition>();

            foreach (IFCAnyHandle relatedObject in relatedObjects)
            {
                IFCObjectDefinition objectDefinition = IFCObjectDefinition.ProcessIFCObjectDefinition(relatedObject);
                if (objectDefinition != null)
                {
                    relatedObjectSet.Add(objectDefinition);
                }
            }

            return(relatedObjectSet);
        }
Exemplo n.º 3
0
        override protected void Process(IFCAnyHandle styledItem)
        {
            base.Process(styledItem);

            IFCAnyHandle item = IFCImportHandleUtil.GetOptionalInstanceAttribute(styledItem, "Item");

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(item))
            {
                Item = IFCRepresentationItem.ProcessIFCRepresentationItem(item);
            }

            Name = IFCImportHandleUtil.GetOptionalStringAttribute(styledItem, "Name", null);

            List <IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(styledItem, "Styles");

            if (styles == null || styles.Count == 0 || IFCAnyHandleUtil.IsNullOrHasNoValue(styles[0]))
            {
                Importer.TheLog.LogMissingRequiredAttributeError(styledItem, "Styles", true);
            }
            if (styles.Count > 1)
            {
                Importer.TheLog.LogWarning(styledItem.StepId, "Multiple presentation styles found for IfcStyledItem - using first.", false);
            }

            Styles = IFCPresentationStyleAssignment.ProcessIFCPresentationStyleAssignment(styles[0]);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Processes IfcProject attributes.
        /// </summary>
        /// <param name="ifcProjectHandle">The IfcProject handle.</param>
        protected override void Process(IFCAnyHandle ifcProjectHandle)
        {
            IFCAnyHandle unitsInContext = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcProjectHandle, "UnitsInContext", false);

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(unitsInContext))
            {
                IList <IFCAnyHandle> units = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(unitsInContext, "Units");

                if (units != null)
                {
                    m_UnitsInContext = new HashSet <IFCUnit>();

                    foreach (IFCAnyHandle unit in units)
                    {
                        IFCUnit ifcUnit = IFCImportFile.TheFile.IFCUnits.ProcessIFCProjectUnit(unit);
                        if (!IFCUnit.IsNullOrInvalid(ifcUnit))
                        {
                            m_UnitsInContext.Add(ifcUnit);
                        }
                    }
                }
                else
                {
                    Importer.TheLog.LogMissingRequiredAttributeError(unitsInContext, "Units", false);
                }
            }

            // We need to process the units before we process the rest of the file, since we will scale values as we go along.
            base.Process(ifcProjectHandle);

            // process true north - take the first valid representation context that has a true north value.
            HashSet <IFCAnyHandle> repContexts = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcProjectHandle, "RepresentationContexts");

            if (repContexts != null)
            {
                foreach (IFCAnyHandle geomRepContextHandle in repContexts)
                {
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(geomRepContextHandle) &&
                        IFCAnyHandleUtil.IsSubTypeOf(geomRepContextHandle, IFCEntityType.IfcGeometricRepresentationContext))
                    {
                        IFCAnyHandle trueNorthHandle = IFCAnyHandleUtil.GetInstanceAttribute(geomRepContextHandle, "TrueNorth");
                        if (!IFCAnyHandleUtil.IsNullOrHasNoValue(trueNorthHandle))
                        {
                            List <double> trueNorthDir = IFCAnyHandleUtil.GetAggregateDoubleAttribute <List <double> >(trueNorthHandle, "DirectionRatios");
                            if (trueNorthDir != null && trueNorthDir.Count >= 2)
                            {
                                m_TrueNorthDirection = trueNorthDir;
                                break;
                            }
                        }
                    }
                }
            }

            // Special read of IfcPresentationLayerAssignment if the INVERSE flag isn't properly set in the EXPRESS file.
            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x2)
            {
                IFCPresentationLayerAssignment.ProcessAllLayerAssignments();
            }
        }
Exemplo n.º 5
0
        private IList <IFCGridAxis> ProcessOneAxis(IFCAnyHandle ifcGrid, string axisName)
        {
            IList <IFCGridAxis> gridAxes = new List <IFCGridAxis>();

            List <IFCAnyHandle> ifcAxes = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcGrid, axisName);

            if (ifcAxes != null)
            {
                foreach (IFCAnyHandle axis in ifcAxes)
                {
                    IFCGridAxis gridAxis = IFCGridAxis.ProcessIFCGridAxis(axis);
                    if (gridAxis != null)
                    {
                        if (gridAxis.DuplicateAxisId == -1)
                        {
                            gridAxes.Add(gridAxis);
                        }
                        else
                        {
                            IFCEntity originalEntity;
                            if (IFCImportFile.TheFile.EntityMap.TryGetValue(gridAxis.DuplicateAxisId, out originalEntity))
                            {
                                IFCGridAxis originalGridAxis = originalEntity as IFCGridAxis;
                                if (originalGridAxis != null)
                                {
                                    gridAxes.Add(originalGridAxis);
                                }
                            }
                        }
                    }
                }
            }

            return(gridAxes);
        }
Exemplo n.º 6
0
        protected override void Process(IFCAnyHandle ifcCurve)
        {
            base.Process(ifcCurve);

            IList <IFCAnyHandle> points = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcCurve, "Points");
            int numPoints = points.Count;

            if (numPoints < 2)
            {
                string msg = "IfcPolyLine had " + numPoints + ", expected at least 2, ignoring";
                Importer.TheLog.LogError(Id, msg, false);
                return;
            }

            IList <XYZ> pointXYZs = new List <XYZ>();

            foreach (IFCAnyHandle point in points)
            {
                XYZ pointXYZ = IFCPoint.ProcessScaledLengthIFCCartesianPoint(point);
                pointXYZs.Add(pointXYZ);
            }

            if (pointXYZs.Count != numPoints)
            {
                Importer.TheLog.LogError(Id, "Some of the IFC points cannot be converted to Revit points", true);
            }

            CurveLoop = IFCGeometryUtil.CreatePolyCurveLoop(pointXYZs, points, Id, false);
            Curve     = IFCGeometryUtil.CreateCurveFromPolyCurveLoop(CurveLoop, pointXYZs);
        }
Exemplo n.º 7
0
        override protected void Process(IFCAnyHandle ifcPolyLoop)
        {
            base.Process(ifcPolyLoop);

            List <IFCAnyHandle> ifcPolygon =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcPolyLoop, "Polygon");

            if (ifcPolygon == null)
            {
                return; // TODO: WARN
            }
            Polygon = IFCPoint.ProcessScaledLengthIFCCartesianPoints(ifcPolygon);

            // Check for duplicate points, including wrapping around, and remove them.
            int numVertices = Polygon.Count;

            for (int ii = numVertices - 1; (ii != -1) && numVertices >= 3; ii--)
            {
                if (MathUtil.IsAlmostEqualAbsolute(Polygon[ii], Polygon[(ii + 1) % numVertices]))
                {
                    Importer.TheLog.LogError(ifcPolyLoop.StepId, "The polygon vertex at index " + ii + " is a duplicate, removing.", false);
                    Polygon.RemoveAt(ii);
                    numVertices--;
                }
            }

            if (numVertices < 3)
            {
                // This used to throw an error.  However, we found files that threw this error
                // thousands of times, causing incredibly slow links.  Instead, null out the
                // data and log an error.
                Polygon = null;
                Importer.TheLog.LogError(ifcPolyLoop.StepId, "Polygon attribute has only " + numVertices + " vertices, 3 expected.", false);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Processes IfcObjectDefinition attributes.
        /// </summary>
        /// <param name="ifcObjectDefinition">The IfcObjectDefinition handle.</param>
        protected override void Process(IFCAnyHandle ifcObjectDefinition)
        {
            base.Process(ifcObjectDefinition);

            ShapeType = GetShapeType(ifcObjectDefinition);

            // If we aren't importing this category, skip processing.
            if (!IFCCategoryUtil.CanImport(EntityType, ShapeType))
            {
                throw new InvalidOperationException("Don't Import");
            }

            // Before IFC2x3, IfcTypeObject did not have IsDecomposedBy.
            HashSet <IFCAnyHandle> elemSet = null;

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x3 || !IFCAnyHandleUtil.IsSubTypeOf(ifcObjectDefinition, IFCEntityType.IfcTypeObject))
            {
                elemSet = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                          <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "IsDecomposedBy");
            }

            if (elemSet != null)
            {
                foreach (IFCAnyHandle elem in elemSet)
                {
                    ProcessIFCRelDecomposes(elem);
                }
            }

            HashSet <IFCAnyHandle> hasAssociations = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                                     <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "HasAssociations");

            if (hasAssociations != null)
            {
                foreach (IFCAnyHandle hasAssociation in hasAssociations)
                {
                    if (IFCAnyHandleUtil.IsSubTypeOf(hasAssociation, IFCEntityType.IfcRelAssociatesMaterial))
                    {
                        ProcessIFCRelAssociatesMaterial(hasAssociation);
                    }
                    else
                    {
                        IFCImportFile.TheLog.LogUnhandledSubTypeError(hasAssociation, IFCEntityType.IfcRelAssociates, false);
                    }
                }
            }

            // The default IFC2x3_TC1.exp file does not have this INVERSE attribute correctly set.  Encapsulate this function.
            ISet <IFCAnyHandle> hasAssignments = IFCImportHandleUtil.GetHasAssignments(ifcObjectDefinition);

            if (hasAssignments != null)
            {
                foreach (IFCAnyHandle hasAssignment in hasAssignments)
                {
                    ProcessIFCRelAssigns(hasAssignment);
                }
            }

            IFCImportFile.TheLog.AddToElementCount();
        }
Exemplo n.º 9
0
        override protected void Process(IFCAnyHandle ifcManifoldSolidBrep)
        {
            base.Process(ifcManifoldSolidBrep);

            // We will not fail if the transform is not given, but instead assume it to be the identity.
            IFCAnyHandle ifcOuter = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcManifoldSolidBrep, "Outer", true);

            Outer = IFCClosedShell.ProcessIFCClosedShell(ifcOuter);

            if (IFCAnyHandleUtil.IsSubTypeOf(ifcManifoldSolidBrep, IFCEntityType.IfcFacetedBrepWithVoids))
            {
                HashSet <IFCAnyHandle> ifcVoids =
                    IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcManifoldSolidBrep, "Voids");
                if (ifcVoids != null)
                {
                    foreach (IFCAnyHandle ifcVoid in ifcVoids)
                    {
                        try
                        {
                            Inners.Add(IFCClosedShell.ProcessIFCClosedShell(ifcVoid));
                        }
                        catch
                        {
                            // LOG: WARNING: #: Invalid inner shell ifcVoid.StepId, ignoring.
                        }
                    }
                }
            }
        }
        protected override void Process(IFCAnyHandle ifcMaterialConstituentSet)
        {
            base.Process(ifcMaterialConstituentSet);

            IList <IFCAnyHandle> ifcMaterialConsitutuents =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcMaterialConstituentSet, "MaterialConstituents");

            if (ifcMaterialConsitutuents == null)
            {
                Importer.TheLog.LogError(ifcMaterialConstituentSet.Id, "Expected at least 1 MaterialConsituent, found none.", false);
                return;
            }

            foreach (IFCAnyHandle ifcMaterialConstituent in ifcMaterialConsitutuents)
            {
                IFCMaterialConstituent materialConstituent = IFCMaterialConstituent.ProcessIFCMaterialConstituent(ifcMaterialConstituent);
                if (materialConstituent != null)
                {
                    MaterialConstituents.Add(materialConstituent);
                }
            }

            Name        = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituentSet, "Name", null);
            Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituentSet, "Description", null);
        }
Exemplo n.º 11
0
        protected override void Process(IFCAnyHandle ifcMaterial)
        {
            base.Process(ifcMaterial);

            Name = IFCImportHandleUtil.GetRequiredStringAttribute(ifcMaterial, "Name", true);

            List <IFCAnyHandle> hasRepresentation = null;

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x3)
            {
                hasRepresentation = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcMaterial, "HasRepresentation");
            }

            if (hasRepresentation != null && hasRepresentation.Count == 1)
            {
                if (!IFCAnyHandleUtil.IsSubTypeOf(hasRepresentation[0], IFCEntityType.IfcMaterialDefinitionRepresentation))
                {
                    Importer.TheLog.LogUnexpectedTypeError(hasRepresentation[0], IFCEntityType.IfcMaterialDefinitionRepresentation, false);
                }
                else
                {
                    MaterialDefinitionRepresentation = IFCProductRepresentation.ProcessIFCProductRepresentation(hasRepresentation[0]);
                }
            }

            Importer.TheLog.AddToElementCount();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Processes IfcOpeningElement attributes.
        /// </summary>
        /// <param name="ifcOpeningElement">The IfcOpeningElement handle.</param>
        protected override void Process(IFCAnyHandle ifcOpeningElement)
        {
            base.Process(ifcOpeningElement);

            ICollection <IFCAnyHandle> hasFillings = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcOpeningElement, "HasFillings");

            if (hasFillings != null)
            {
                // Assume that there is only one filling for the opening, and take first found.
                foreach (IFCAnyHandle hasFilling in hasFillings)
                {
                    IFCAnyHandle relatedFillingElement = IFCAnyHandleUtil.GetInstanceAttribute(hasFilling, "RelatedBuildingElement");
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatedFillingElement))
                    {
                        continue;
                    }

                    IFCEntity filledByElement;
                    IFCImportFile.TheFile.EntityMap.TryGetValue(relatedFillingElement.StepId, out filledByElement);
                    if (filledByElement == null)
                    {
                        FilledByElement = IFCElement.ProcessIFCElement(relatedFillingElement);
                    }
                    else
                    {
                        FilledByElement = filledByElement as IFCElement;
                    }
                    FilledByElement.FillsOpening = this;
                    break;
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Processes IfcTypeObject attributes.
        /// </summary>
        /// <param name="ifcTypeObject">The IfcTypeObject handle.</param>
        protected override void Process(IFCAnyHandle ifcTypeObject)
        {
            base.Process(ifcTypeObject);

            HashSet <IFCAnyHandle> propertySets = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                                  <HashSet <IFCAnyHandle> >(ifcTypeObject, "HasPropertySets");

            if (propertySets != null)
            {
                m_IFCPropertySets = new Dictionary <string, IFCPropertySetDefinition>();

                foreach (IFCAnyHandle propertySet in propertySets)
                {
                    IFCPropertySetDefinition ifcPropertySetDefinition = IFCPropertySetDefinition.ProcessIFCPropertySetDefinition(propertySet);
                    if (ifcPropertySetDefinition != null)
                    {
                        string name = ifcPropertySetDefinition.Name;
                        if (string.IsNullOrWhiteSpace(name))
                        {
                            name = IFCAnyHandleUtil.GetEntityType(propertySet).ToString() + " " + propertySet.StepId;
                        }
                        m_IFCPropertySets[name] = ifcPropertySetDefinition;
                    }
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Processes IfcPort attributes.
        /// </summary>
        /// <param name="ifcPort">The IfcPort handle.</param>
        protected override void Process(IFCAnyHandle ifcPort)
        {
            base.Process(ifcPort);

            // We will delay processing the containment information to the PostProcess stp.  For complicated systems, creating all of these
            // during the standard Process step may result in a stack overflow.

            if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC4))
            {
                HashSet <IFCAnyHandle> containedIn = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcPort, "ContainedIn");
                if (containedIn != null && containedIn.Count != 0)
                {
                    m_ContainedInHandle = containedIn.First();
                }
            }
            else
            {
                m_ContainedInHandle = IFCAnyHandleUtil.GetInstanceAttribute(ifcPort, "ContainedIn");
            }

            HashSet <IFCAnyHandle> connectedFrom = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcPort, "ConnectedFrom");

            if (connectedFrom != null && connectedFrom.Count != 0)
            {
                m_ConnectedFromHandle = connectedFrom.First();
            }

            HashSet <IFCAnyHandle> connectedTo = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcPort, "ConnectedTo");

            if (connectedTo != null && connectedTo.Count != 0)
            {
                m_ConnectedToHandle = connectedTo.First();
            }
        }
Exemplo n.º 15
0
        override protected void Process(IFCAnyHandle ifcConnectedFaceSet)
        {
            base.Process(ifcConnectedFaceSet);

            HashSet <IFCAnyHandle> ifcCfsFaces =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcConnectedFaceSet, "CfsFaces");

            if (ifcCfsFaces == null || ifcCfsFaces.Count == 0)
            {
                throw new InvalidOperationException("#" + ifcConnectedFaceSet.StepId + ": no faces in connected face set, aborting.");
            }

            foreach (IFCAnyHandle ifcCfsFace in ifcCfsFaces)
            {
                try
                {
                    Faces.Add(IFCFace.ProcessIFCFace(ifcCfsFace));
                }
                catch
                {
                    Importer.TheLog.LogWarning(ifcCfsFace.StepId, "Invalid face, ignoring.", false);
                }
            }

            if (Faces.Count == 0)
            {
                throw new InvalidOperationException("#" + ifcConnectedFaceSet.StepId + ": no faces, aborting.");
            }
        }
Exemplo n.º 16
0
        override protected void Process(IFCAnyHandle ifcGeometricSet)
        {
            base.Process(ifcGeometricSet);

            IList <IFCAnyHandle> elements = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcGeometricSet, "Elements");

            if (elements != null)
            {
                foreach (IFCAnyHandle element in elements)
                {
                    if (IFCAnyHandleUtil.IsSubTypeOf(element, IFCEntityType.IfcCurve))
                    {
                        IFCCurve curve = IFCCurve.ProcessIFCCurve(element);
                        if (curve != null)
                        {
                            Curves.Add(curve);
                        }
                    }
                    else
                    {
                        Importer.TheLog.LogError(Id, "Unhandled entity type in IfcGeometricSet: " + IFCAnyHandleUtil.GetEntityType(element).ToString(), false);
                    }
                }
            }
        }
Exemplo n.º 17
0
        override protected void Process(IFCAnyHandle ifcPolyLoop)
        {
            base.Process(ifcPolyLoop);

            List <IFCAnyHandle> ifcPolygon =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcPolyLoop, "Polygon");

            if (ifcPolygon == null)
            {
                return; // TODO: WARN
            }
            Polygon = IFCPoint.ProcessScaledLengthIFCCartesianPoints(ifcPolygon);

            int numVertices = Polygon.Count;

            if (numVertices > 1)
            {
                if (Polygon[0].IsAlmostEqualTo(Polygon[numVertices - 1]))
                {
                    // LOG: Warning: #: First and last points are almost identical, removing extra point.
                    Polygon.RemoveAt(numVertices - 1);
                    numVertices--;
                }
            }

            if (numVertices < 3)
            {
                throw new InvalidOperationException("#" + ifcPolyLoop.StepId + ": Polygon attribute has only " + numVertices + " vertices, 3 expected.");
            }
        }
Exemplo n.º 18
0
        protected override void Process(IFCAnyHandle ifcMaterialLayerSet)
        {
            base.Process(ifcMaterialLayerSet);

            IList <IFCAnyHandle> ifcMaterialLayers =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcMaterialLayerSet, "MaterialLayers");

            if (ifcMaterialLayers == null)
            {
                Importer.TheLog.LogError(ifcMaterialLayerSet.Id, "Expected at least 1 IfcMaterialLayer, found none.", false);
                return;
            }

            foreach (IFCAnyHandle ifcMaterialLayer in ifcMaterialLayers)
            {
                IFCMaterialLayer materialLayer = null;
                if (materialLayer is IFCMaterialLayerWithOffsets)
                {
                    materialLayer = IFCMaterialLayerWithOffsets.ProcessIFCMaterialLayerWithOffsets(ifcMaterialLayer);
                }
                else
                {
                    materialLayer = IFCMaterialLayer.ProcessIFCMaterialLayer(ifcMaterialLayer);
                }

                if (materialLayer != null)
                {
                    MaterialLayers.Add(materialLayer);
                }
            }

            LayerSetName = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialLayerSet, "LayerSetName", null);
        }
Exemplo n.º 19
0
        override protected void Process(IFCAnyHandle ifcPolyLoop)
        {
            base.Process(ifcPolyLoop);

            List <IFCAnyHandle> ifcPolygon =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcPolyLoop, "Polygon");

            if (ifcPolygon == null)
            {
                return; // TODO: WARN
            }
            Polygon = IFCPoint.ProcessScaledLengthIFCCartesianPoints(ifcPolygon);

            int numVertices = Polygon.Count;

            if (numVertices > 1)
            {
                if (MathUtil.IsAlmostEqualAbsolute(Polygon[0], Polygon[numVertices - 1]))
                {
                    // LOG: Warning: #: First and last points are almost identical, removing extra point.
                    Polygon.RemoveAt(numVertices - 1);
                    numVertices--;
                }
            }

            if (numVertices < 3)
            {
                // This used to throw an error.  However, we found files that threw this error
                // thousands of times, causing incredibly slow links.  Instead, null out the
                // data and log an error.
                Polygon = null;
                Importer.TheLog.LogError(ifcPolyLoop.StepId, "Polygon attribute has only " + numVertices + " vertices, 3 expected.", false);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Processes IfcElement attributes.
        /// </summary>
        /// <param name="ifcElement">The IfcElement handle.</param>
        protected override void Process(IFCAnyHandle ifcElement)
        {
            base.Process(ifcElement);

            m_Tag = IFCAnyHandleUtil.GetStringAttribute(ifcElement, "Tag");

            ICollection <IFCAnyHandle> hasOpenings = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcElement, "HasOpenings");

            if (hasOpenings != null)
            {
                foreach (IFCAnyHandle hasOpening in hasOpenings)
                {
                    IFCAnyHandle relatedOpeningElement = IFCAnyHandleUtil.GetInstanceAttribute(hasOpening, "RelatedOpeningElement");
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatedOpeningElement))
                    {
                        continue;
                    }

                    IFCFeatureElementSubtraction opening = IFCFeatureElementSubtraction.ProcessIFCFeatureElementSubtraction(relatedOpeningElement);
                    if (opening != null)
                    {
                        opening.VoidsElement = this;
                        Openings.Add(opening);
                    }
                }
            }
        }
Exemplo n.º 21
0
        protected override void Process(IFCAnyHandle ifcPolygonalFaceSet)
        {
            base.Process(ifcPolygonalFaceSet);

            bool?closed = IFCAnyHandleUtil.GetBooleanAttribute(ifcPolygonalFaceSet, "Closed");

            if (closed != null)
            {
                Closed = closed;
            }

            IList <IFCAnyHandle> facesHnds = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcPolygonalFaceSet, "Faces");

            if (facesHnds != null)
            {
                if (facesHnds.Count > 0)
                {
                    Faces = new List <IFCIndexedPolygonalFace>();
                }
                foreach (IFCAnyHandle facesHnd in facesHnds)
                {
                    Faces.Add(IFCIndexedPolygonalFace.ProcessIFCIndexedPolygonalFace(facesHnd));
                }
            }
        }
        override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            IList <IFCAnyHandle> layerStyles = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(item, "LayerStyles");

            foreach (IFCAnyHandle layerStyle in layerStyles)
            {
                if (layerStyle == null)
                {
                    Importer.TheLog.LogNullError(IFCEntityType.IfcPresentationStyle);
                    continue;
                }

                IFCPresentationStyle presentationStyle = IFCPresentationStyle.ProcessIFCPresentationStyle(layerStyle);
                if (presentationStyle != null)
                {
                    LayerStyles.Add(presentationStyle);
                }
                else
                {
                    Importer.TheLog.LogUnhandledSubTypeError(layerStyle, "IfcPresentationStyle", false);
                }
            }
        }
        /// <summary>
        /// Processes IfcSpatialStructureElement attributes.
        /// </summary>
        /// <param name="ifcSpatialStructureElement">The IfcSpatialStructureElement handle.</param>
        protected override void Process(IFCAnyHandle ifcSpatialStructureElement)
        {
            base.Process(ifcSpatialStructureElement);

            LongName = IFCImportHandleUtil.GetOptionalStringAttribute(ifcSpatialStructureElement, "LongName", null);

            HashSet <IFCAnyHandle> elemSet =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcSpatialStructureElement, "ContainsElements");

            if (elemSet != null)
            {
                if (m_IFCProducts == null)
                {
                    m_IFCProducts = new HashSet <IFCProduct>();
                }

                foreach (IFCAnyHandle elem in elemSet)
                {
                    ProcessIFCRelContainedInSpatialStructure(elem);
                }
            }

            if (IFCImportFile.TheFile.SchemaVersion > IFCSchemaVersion.IFC2x || IFCAnyHandleUtil.IsSubTypeOf(ifcSpatialStructureElement, IFCEntityType.IfcBuilding))
            {
                HashSet <IFCAnyHandle> systemSet =
                    IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcSpatialStructureElement, "ServicedBySystems");
                if (systemSet != null)
                {
                    foreach (IFCAnyHandle system in systemSet)
                    {
                        ProcessIFCRelServicesBuildings(system);
                    }
                }
            }
        }
Exemplo n.º 24
0
        override protected void Process(IFCAnyHandle ifcFace)
        {
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcFace, IFCEntityType.IfcFaceSurface))
            {
                // Only allow IfcFaceSurface is the surface is a plane.
                IFCAnyHandle faceSurface = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcFace, "FaceSurface", false);
                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(faceSurface))
                {
                    IFCSurface surface = IFCSurface.ProcessIFCSurface(faceSurface);
                    if (!(surface is IFCPlane))
                    {
                        IFCImportFile.TheLog.LogError(ifcFace.StepId,
                                                      "cannot handle IfcFaceSurface with FaceSurface of type " + IFCAnyHandleUtil.GetEntityType(faceSurface).ToString(), true);
                    }
                }
            }

            base.Process(ifcFace);

            HashSet <IFCAnyHandle> ifcBounds =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcFace, "Bounds");

            if (ifcBounds == null || ifcBounds.Count == 0)
            {
                throw new InvalidOperationException("#" + ifcFace.StepId + ": no face boundaries, aborting.");
            }

            foreach (IFCAnyHandle ifcBound in ifcBounds)
            {
                try
                {
                    Bounds.Add(IFCFaceBound.ProcessIFCFaceBound(ifcBound));
                }
                catch
                {
                    // LOG: WARNING: #: Invalid face boundary ifcBound.StepId, ignoring.
                }
            }

            if (Bounds.Count == 0)
            {
                throw new InvalidOperationException("#" + ifcFace.StepId + ": no face boundaries, aborting.");
            }

            // Give warning if too many outer bounds.  We won't care how they are designated, regardless.
            bool hasOuter = false;

            foreach (IFCFaceBound faceBound in Bounds)
            {
                if (faceBound.IsOuter)
                {
                    if (hasOuter)
                    {
                        // LOG: WARNING: #: Too many outer boundary loops for IfcFace.
                        break;
                    }
                    hasOuter = true;
                }
            }
        }
        /// <summary>
        /// Finds contained elements.
        /// </summary>
        /// <param name="ifcRelHandle">The relation handle.</param>
        void ProcessIFCRelContainedInSpatialStructure(IFCAnyHandle ifcRelHandle)
        {
            HashSet <IFCAnyHandle> elemSet = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcRelHandle, "RelatedElements");

            if (elemSet == null)
            {
                Importer.TheLog.LogMissingRequiredAttributeError(ifcRelHandle, "RelatedElements", false);
                return;
            }

            foreach (IFCAnyHandle elem in elemSet)
            {
                try
                {
                    IFCProduct product = IFCProduct.ProcessIFCProduct(elem);
                    if (product != null)
                    {
                        product.ContainingStructure = this;
                        m_IFCProducts.Add(product);
                    }
                }
                catch (Exception ex)
                {
                    Importer.TheLog.LogError(elem.StepId, ex.Message, false);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Processes an IFC element quantity.
        /// </summary>
        /// <param name="ifcElementQuantity">The IfcElementQuantity object.</param>
        protected override void Process(IFCAnyHandle ifcElementQuantity)
        {
            base.Process(ifcElementQuantity);

            MethodOfMeasurement = IFCImportHandleUtil.GetOptionalStringAttribute(ifcElementQuantity, "MethodOfMeasurement", null);

            HashSet <IFCAnyHandle> quantities =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcElementQuantity, "Quantities");

            if (quantities != null)
            {
                m_IFCQuantities = new Dictionary <string, IFCPhysicalQuantity>();

                foreach (IFCAnyHandle quantity in quantities)
                {
                    IFCPhysicalQuantity ifcPhysicalQuantity = IFCPhysicalQuantity.ProcessIFCPhysicalQuantity(quantity);
                    if (ifcPhysicalQuantity != null)
                    {
                        m_IFCQuantities[ifcPhysicalQuantity.Name] = ifcPhysicalQuantity;
                    }
                }
            }
            else
            {
                Importer.TheLog.LogMissingRequiredAttributeError(ifcElementQuantity, "Quantities", false);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Processes IfcObject attributes.
        /// </summary>
        /// <param name="ifcObject">The IfcObject handle.</param>
        protected override void Process(IFCAnyHandle ifcObject)
        {
            base.Process(ifcObject);

            m_ObjectType = IFCAnyHandleUtil.GetStringAttribute(ifcObject, "ObjectType");

            HashSet <IFCAnyHandle> isDefinedByHandles = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                                        <HashSet <IFCAnyHandle> >(ifcObject, "IsDefinedBy");

            if (isDefinedByHandles != null)
            {
                IFCPropertySetDefinition.ResetCounters();
                foreach (IFCAnyHandle isDefinedByHandle in isDefinedByHandles)
                {
                    if (IFCAnyHandleUtil.IsSubTypeOf(isDefinedByHandle, IFCEntityType.IfcRelDefinesByProperties))
                    {
                        ProcessIFCRelDefinesByProperties(isDefinedByHandle);
                    }
                    else if (IFCAnyHandleUtil.IsSubTypeOf(isDefinedByHandle, IFCEntityType.IfcRelDefinesByType))
                    {
                        ProcessIFCRelDefinesByType(isDefinedByHandle);
                    }
                    else
                    {
                        IFCImportFile.TheLog.LogUnhandledSubTypeError(isDefinedByHandle, IFCEntityType.IfcRelDefines, false);
                    }
                }
            }
        }
Exemplo n.º 28
0
        private void ProcessIFCCompositeCurve(IFCAnyHandle ifcCurve)
        {
            IList <IFCAnyHandle> segments = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcCurve, "Segments");

            foreach (IFCAnyHandle segment in segments)
            {
                ProcessIFCCompositeCurveSegment(segment);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Adds items to a given shape handle.
        /// </summary>
        /// <param name="shape">The shape handle.</param>
        /// <param name="items">The items.</param>
        public static void AddItemsToShape(IFCAnyHandle shape, ICollection <IFCAnyHandle> items)
        {
            HashSet <IFCAnyHandle> repItemSet = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(shape, "Items");

            foreach (IFCAnyHandle repItem in items)
            {
                repItemSet.Add(repItem);
            }
            IFCAnyHandleUtil.SetAttribute(shape, "Items", repItemSet);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Processes IfcElement attributes.
        /// </summary>
        /// <param name="ifcElement">The IfcElement handle.</param>
        protected override void Process(IFCAnyHandle ifcElement)
        {
            base.Process(ifcElement);

            m_Tag = IFCAnyHandleUtil.GetStringAttribute(ifcElement, "Tag");

            ICollection <IFCAnyHandle> hasOpenings = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcElement, "HasOpenings");

            if (hasOpenings != null)
            {
                foreach (IFCAnyHandle hasOpening in hasOpenings)
                {
                    IFCAnyHandle relatedOpeningElement = IFCAnyHandleUtil.GetInstanceAttribute(hasOpening, "RelatedOpeningElement");
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatedOpeningElement))
                    {
                        continue;
                    }

                    IFCFeatureElementSubtraction opening = IFCFeatureElementSubtraction.ProcessIFCFeatureElementSubtraction(relatedOpeningElement);
                    if (opening != null)
                    {
                        opening.VoidsElement = this;
                        Openings.Add(opening);
                    }
                }
            }

            // "HasPorts" is new to IFC2x2.
            // For IFC4, "HasPorts" has moved to IfcDistributionElement.  We'll keep the check here, but we will only check it
            // if we are exporting before IFC4 or if we have an IfcDistributionElement handle.
            bool checkPorts = (IFCImportFile.TheFile.SchemaVersion > IFCSchemaVersion.IFC2x2) &&
                              (IFCImportFile.TheFile.SchemaVersion < IFCSchemaVersion.IFC4 || IFCAnyHandleUtil.IsSubTypeOf(ifcElement, IFCEntityType.IfcDistributionElement));

            if (checkPorts)
            {
                ICollection <IFCAnyHandle> hasPorts = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcElement, "HasPorts");
                if (hasPorts != null)
                {
                    foreach (IFCAnyHandle hasPort in hasPorts)
                    {
                        IFCAnyHandle relatingPort = IFCAnyHandleUtil.GetInstanceAttribute(hasPort, "RelatingPort");
                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatingPort))
                        {
                            continue;
                        }

                        IFCPort port = IFCPort.ProcessIFCPort(relatingPort);
                        if (port != null)
                        {
                            Ports.Add(port);
                        }
                    }
                }
            }
        }