Exemplo n.º 1
0
        override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            HashSet <IFCData> styles = IFCAnyHandleUtil.GetAggregateAttribute <HashSet <IFCData> >(item, "Styles");

            if (styles != null)
            {
                foreach (IFCData styleData in styles)
                {
                    if (styleData.PrimitiveType == IFCDataPrimitiveType.Instance)
                    {
                        IFCAnyHandle style = styleData.AsInstance();
                        try
                        {
                            IFCPresentationStyle presentationStyle = IFCPresentationStyle.ProcessIFCPresentationStyle(style);
                            if (presentationStyle != null)
                            {
                                Styles.Add(presentationStyle);
                            }
                        }
                        catch (Exception ex)
                        {
                            Importer.TheLog.LogError(item.StepId, ex.Message, false);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes an IFC property enumerated value.
        /// </summary>
        /// <param name="propertyEnumeratedValue">The IfcPropertyEnumeratedValue object.</param>
        void ProcessIFCPropertyEnumeratedValue(IFCAnyHandle propertyEnumeratedValue)
        {
            List <IFCData> enumValues = IFCAnyHandleUtil.GetAggregateAttribute <List <IFCData> >(propertyEnumeratedValue, "EnumerationValues");

            foreach (IFCData value in enumValues)
            {
                IFCPropertyValues.Add(new IFCPropertyValue(this, value));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Processes an IFC property list value.
        /// </summary>
        /// <param name="propertyListValue">The IfcPropertyListValue object.</param>
        void ProcessIFCPropertyListValue(IFCAnyHandle propertyListValue)
        {
            List <IFCData> listValues = IFCAnyHandleUtil.GetAggregateAttribute <List <IFCData> >(propertyListValue, "ListValues");

            foreach (IFCData value in listValues)
            {
                IFCPropertyValues.Add(new IFCPropertyValue(this, value));
            }
            ProcessIFCSimplePropertyUnit(this, propertyListValue);
        }
Exemplo n.º 4
0
        protected override void Process(IFCAnyHandle ifcCurve)
        {
            base.Process(ifcCurve);

            IFCAnyHandle points = IFCAnyHandleUtil.GetInstanceAttribute(ifcCurve, "Points");

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(points))
            {
                Importer.TheLog.LogMissingRequiredAttributeError(ifcCurve, "Points", true);
                return;
            }

            IList <IFCData> segments = null;

            try
            {
                // The Segments attribute is new to IFC4 Add1, and we don't know that we may have a
                // vanilla IFC4 file.  If we can't find the attribute, we will assume the points represent
                // the vertices of a polyline.
                segments = IFCAnyHandleUtil.GetAggregateAttribute <List <IFCData> >(ifcCurve, "Segments");
            }
            catch (Exception ex)
            {
                if (IFCImportFile.HasUndefinedAttribute(ex))
                {
                    IFCImportFile.TheFile.DowngradeIFC4SchemaTo(IFCSchemaVersion.IFC4);
                }
                else
                {
                    throw ex;
                }
            }

            IFCCartesianPointList pointList     = IFCCartesianPointList.ProcessIFCCartesianPointList(points);
            IList <XYZ>           pointListXYZs = pointList.CoordList;
            int numPoints = pointListXYZs.Count;

            CurveLoop   curveLoop = null;
            IList <XYZ> pointXYZs = null;

            if (segments == null)
            {
                // Simple case: no segment information, just treat the curve as a polyline.
                pointXYZs = pointListXYZs;
                curveLoop = IFCGeometryUtil.CreatePolyCurveLoop(pointXYZs, null, Id, false);
            }
            else
            {
                curveLoop = new CurveLoop();

                // Assure that we don't add the same point twice for a polyline segment.  This could
                // happen by error, or, e.g., there are two IfcLineIndex segments in a row (although
                // this could also be considered an error condition.)
                int lastIndex = -1;

                // The list of all of the points, in the order that they are added.  This can be
                // used as a backup representation.
                pointXYZs = new List <XYZ>();

                IList <XYZ> currentLineSegmentPoints = new List <XYZ>();
                foreach (IFCData segment in segments)
                {
                    string indexType = ValidateSegment(segment);
                    if (indexType == null)
                    {
                        Importer.TheLog.LogError(Id, "Unknown segment type in IfcIndexedPolyCurve.", false);
                        continue;
                    }

                    IFCAggregate segmentInfo = segment.AsAggregate();

                    if (indexType.Equals("IfcLineIndex", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (IFCData segmentInfoIndex in segmentInfo)
                        {
                            int?currentIndex = GetValidIndex(segmentInfoIndex, numPoints);
                            if (currentIndex == null)
                            {
                                continue;
                            }

                            int validCurrentIndex = currentIndex.Value;
                            if (lastIndex != validCurrentIndex)
                            {
                                pointXYZs.Add(pointListXYZs[validCurrentIndex]);
                                currentLineSegmentPoints.Add(pointListXYZs[validCurrentIndex]);
                                lastIndex = validCurrentIndex;
                            }
                        }
                    }
                    else if (indexType.Equals("IfcArcIndex", StringComparison.OrdinalIgnoreCase))
                    {
                        // Create any line segments that haven't been already created.
                        CreateLineSegments(curveLoop, currentLineSegmentPoints);

                        if (segmentInfo.Count != 3)
                        {
                            Importer.TheLog.LogError(Id, "Invalid IfcArcIndex in IfcIndexedPolyCurve.", false);
                            continue;
                        }

                        int?startIndex = GetValidIndex(segmentInfo[0], numPoints);
                        int?pointIndex = GetValidIndex(segmentInfo[1], numPoints);
                        int?endIndex   = GetValidIndex(segmentInfo[2], numPoints);

                        if (startIndex == null || pointIndex == null || endIndex == null)
                        {
                            continue;
                        }

                        Arc arcSegment = null;
                        XYZ startPoint = pointListXYZs[startIndex.Value];
                        XYZ pointOnArc = pointListXYZs[pointIndex.Value];
                        XYZ endPoint   = pointListXYZs[endIndex.Value];
                        try
                        {
                            arcSegment = Arc.Create(startPoint, pointOnArc, endPoint);
                            if (arcSegment != null)
                            {
                                curveLoop.Append(arcSegment);
                            }
                        }
                        catch
                        {
                            // We won't do anything here; it may be that the arc is very small, and can
                            // be repaired as a gap in the curve loop.  If it can't, this will fail later.
                            // We will monitor usage to see if anything more needs to be done here.
                        }

                        if (lastIndex != startIndex.Value)
                        {
                            pointXYZs.Add(startPoint);
                        }
                        pointXYZs.Add(pointOnArc);
                        pointXYZs.Add(endPoint);
                        lastIndex = endIndex.Value;
                    }
                    else
                    {
                        Importer.TheLog.LogError(Id, "Unsupported segment type in IfcIndexedPolyCurve.", false);
                        continue;
                    }
                }

                // Create any line segments that haven't been already created.
                CreateLineSegments(curveLoop, currentLineSegmentPoints);
            }

            SetCurveLoop(curveLoop, pointXYZs);
        }