Exemplo n.º 1
0
        /// <summary>
        /// Processes IfcBuilding attributes.
        /// </summary>
        /// <param name="ifcBuilding">The IfcBuilding handle.</param>
        protected override void Process(IFCAnyHandle ifcBuilding)
        {
            // TODO: process IfcBuilding specific data.
            ElevationOfRefHeight = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcBuilding, "ElevationOfRefHeight", 0.0);

            base.Process(ifcBuilding);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes an IfcDoorLiningProperties entity.
        /// </summary>
        /// <param name="ifcDoorLiningProperties">The IfcDoorLiningProperties handle.</param>
        protected override void Process(IFCAnyHandle ifcDoorLiningProperties)
        {
            base.Process(ifcDoorLiningProperties);

            if (m_DoorLiningPropertyDescs == null)
            {
                m_DoorLiningPropertyDescs = new List <Tuple <string, UnitType, AllowedValues> >();
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("LiningDepth", UnitType.UT_Length, AllowedValues.Positive));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("LiningThickness", UnitType.UT_Length, AllowedValues.Positive));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("ThresholdDepth", UnitType.UT_Length, AllowedValues.Positive));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("ThresholdThickness", UnitType.UT_Length, AllowedValues.Positive));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("TransomThickness", UnitType.UT_Length, AllowedValues.Positive));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("TransomOffset", UnitType.UT_Length, AllowedValues.All));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("LiningOffset", UnitType.UT_Length, AllowedValues.All));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("ThresholdOffset", UnitType.UT_Length, AllowedValues.All));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("CasingThickness", UnitType.UT_Length, AllowedValues.Positive));
                m_DoorLiningPropertyDescs.Add(new Tuple <string, UnitType, AllowedValues>("CasingDepth", UnitType.UT_Length, AllowedValues.Positive));
            }

            foreach (Tuple <string, UnitType, AllowedValues> propertyDesc in m_DoorLiningPropertyDescs)
            {
                // Default is nonsense value.
                double currPropertyValue = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcDoorLiningProperties, propertyDesc.Item1, -1e+30);
                if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
                {
                    DoubleProperties[propertyDesc] = currPropertyValue;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Processes an IfcWindowPanelProperties entity.
        /// </summary>
        /// <param name="ifcWindowPanelProperties">The IfcWindowPanelProperties handle.</param>
        protected override void Process(IFCAnyHandle ifcWindowPanelProperties)
        {
            base.Process(ifcWindowPanelProperties);

            string currPropertyValueString = IFCImportHandleUtil.GetOptionalStringAttribute(ifcWindowPanelProperties, "OperationType", null);

            if (!string.IsNullOrEmpty(currPropertyValueString))
            {
                StringProperties[GeneratePropertyName("OperationType")] = currPropertyValueString;
            }

            currPropertyValueString = IFCImportHandleUtil.GetOptionalStringAttribute(ifcWindowPanelProperties, "PanelPosition", null);
            if (!string.IsNullOrEmpty(currPropertyValueString))
            {
                StringProperties[GeneratePropertyName("PanelPosition")] = currPropertyValueString;
            }

            double currPropertyValue = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcWindowPanelProperties, "FrameDepth", -1e+30);

            if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
            {
                DoubleProperties[new Tuple <string, ForgeTypeId, AllowedValues>(GeneratePropertyName("FrameDepth"),
                                                                                SpecTypeId.Length, AllowedValues.Positive)] = currPropertyValue;
            }

            currPropertyValue = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcWindowPanelProperties, "FrameThickness", -1e+30);
            if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
            {
                DoubleProperties[new Tuple <string, ForgeTypeId, AllowedValues>(GeneratePropertyName("FrameThickness"),
                                                                                SpecTypeId.Length, AllowedValues.Positive)] = currPropertyValue;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Processes IfcSite attributes.
        /// </summary>
        /// <param name="ifcIFCSite">The IfcSite handle.</param>
        protected override void Process(IFCAnyHandle ifcIFCSite)
        {
            using (ActiveSiteSetter setter = new ActiveSiteSetter(this))
            {
                base.Process(ifcIFCSite);
            }

            RefElevation = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcIFCSite, "RefElevation", 0.0);

            IList <int> refLatitudeList  = IFCAnyHandleUtil.GetAggregateIntAttribute <List <int> >(ifcIFCSite, "RefLatitude");
            IList <int> refLongitudeList = IFCAnyHandleUtil.GetAggregateIntAttribute <List <int> >(ifcIFCSite, "RefLongitude");

            if (refLatitudeList != null)
            {
                RefLatitude = 0.0;
                int numLats = Math.Min(refLatitudeList.Count, 4); // Only support up to degress, minutes, seconds, and millionths of seconds.
                for (int ii = 0; ii < numLats; ii++)
                {
                    RefLatitude += ((double)refLatitudeList[ii]) / GetLatLongScale(ii);
                }
            }

            if (refLongitudeList != null)
            {
                RefLongitude = 0.0;
                int numLongs = Math.Min(refLongitudeList.Count, 4); // Only support up to degress, minutes, seconds, and millionths of seconds.
                for (int ii = 0; ii < numLongs; ii++)
                {
                    RefLongitude += ((double)refLongitudeList[ii]) / GetLatLongScale(ii);
                }
            }

            LandTitleNumber = IFCAnyHandleUtil.GetStringAttribute(ifcIFCSite, "LandTitleNumber");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Processes an IfcDoorPanelProperties entity.
        /// </summary>
        /// <param name="ifcDoorPanelProperties">The IfcDoorPanelProperties handle.</param>
        protected override void Process(IFCAnyHandle ifcDoorPanelProperties)
        {
            base.Process(ifcDoorPanelProperties);

            double currPropertyValue = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcDoorPanelProperties, "PanelDepth", -1e+30);

            if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
            {
                DoubleProperties[new Tuple <string, UnitType, AllowedValues>(GeneratePropertyName("PanelDepth"),
                                                                             UnitType.UT_Length, AllowedValues.Positive)] = currPropertyValue;
            }

            currPropertyValue = IFCImportHandleUtil.GetOptionalRealAttribute(ifcDoorPanelProperties, "PanelWidth", -1e+30);
            if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
            {
                DoubleProperties[new Tuple <string, UnitType, AllowedValues>(GeneratePropertyName("PanelWidth"),
                                                                             UnitType.UT_Length, AllowedValues.NonNegative)] = currPropertyValue;
            }

            string currPropertyValueString = IFCImportHandleUtil.GetOptionalStringAttribute(ifcDoorPanelProperties, "PanelOperation", null);

            if (!string.IsNullOrEmpty(currPropertyValueString))
            {
                StringProperties[GeneratePropertyName("PanelOperation")] = currPropertyValueString;
            }

            currPropertyValueString = IFCImportHandleUtil.GetOptionalStringAttribute(ifcDoorPanelProperties, "PanelPosition", null);
            if (!string.IsNullOrEmpty(currPropertyValueString))
            {
                StringProperties[GeneratePropertyName("PanelPosition")] = currPropertyValueString;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Processes IfcRepresentationContext attributes.
        /// </summary>
        /// <param name="ifcRepresentationContext">The IfcRepresentationContext handle.</param>
        override protected void Process(IFCAnyHandle ifcRepresentationContext)
        {
            base.Process(ifcRepresentationContext);

            Identifier = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentationContext, "ContextIdentifier", null);

            Type = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentationContext, "ContextType", null);

            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationContext, IFCEntityType.IfcGeometricRepresentationContext))
            {
                bool found = false;
                CoordinateSpaceDimension = IFCImportHandleUtil.GetRequiredIntegerAttribute(ifcRepresentationContext, "CoordinateSpaceDimension", out found);
                if (!found)
                {
                    CoordinateSpaceDimension = 3; // Don't throw, just set to default 3D.
                }
                Precision = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcRepresentationContext, "Precision", IFCImportFile.TheFile.Document.Application.VertexTolerance);

                IFCAnyHandle worldCoordinateSystem = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationContext, "WorldCoordinateSystem", false);
                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(worldCoordinateSystem))
                {
                    WorldCoordinateSystem = IFCLocation.ProcessIFCAxis2Placement(worldCoordinateSystem);
                }
                else
                {
                    WorldCoordinateSystem = Transform.Identity;
                }

                // For IfcGeometricRepresentationSubContext, it seems as if
                try
                {
                    IFCAnyHandle trueNorth = IFCImportHandleUtil.GetOptionalInstanceAttribute(ifcRepresentationContext, "TrueNorth");
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(trueNorth))
                    {
                        TrueNorth = IFCPoint.ProcessNormalizedIFCDirection(trueNorth);
                    }
                    else
                    {
                        TrueNorth = XYZ.BasisZ;
                    }
                }
                catch
                {
                    TrueNorth = XYZ.BasisZ;
                }

                if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x2 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationContext, IFCEntityType.IfcGeometricRepresentationSubContext))
                {
                    IFCAnyHandle parentContext = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationContext, "ParentContext", true);
                    ParentContext = IFCRepresentationContext.ProcessIFCRepresentationContext(parentContext);

                    TargetScale = IFCImportHandleUtil.GetOptionalPositiveRatioAttribute(ifcRepresentationContext, "TargetScale", 1.0);

                    TargetView = IFCEnums.GetSafeEnumerationAttribute <IFCGeometricProjection>(ifcRepresentationContext, "TargetView",
                                                                                               IFCGeometricProjection.NotDefined);

                    UserDefinedTargetView = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentationContext, "UserDefinedTargetView", null);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Processes IfcSite attributes.
        /// </summary>
        /// <param name="ifcIFCSite">The IfcSite handle.</param>
        protected override void Process(IFCAnyHandle ifcIFCSite)
        {
            base.Process(ifcIFCSite);

            RefElevation = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcIFCSite, "RefElevation", 0.0);

            IList <int> refLatitudeList  = IFCAnyHandleUtil.GetAggregateIntAttribute <List <int> >(ifcIFCSite, "RefLatitude");
            IList <int> refLongitudeList = IFCAnyHandleUtil.GetAggregateIntAttribute <List <int> >(ifcIFCSite, "RefLongitude");

            if (refLatitudeList != null)
            {
                m_RefLatitude = 0.0;
                double latLongScaler = 1.0;
                foreach (double latVal in refLatitudeList)
                {
                    m_RefLatitude += ((double)latVal) / latLongScaler;
                    latLongScaler *= 60.0;
                }
            }

            if (refLongitudeList != null)
            {
                m_RefLongitude = 0.0;
                double latLongScaler = 1.0;
                foreach (double longVal in refLongitudeList)
                {
                    m_RefLongitude += ((double)longVal) / latLongScaler;
                    latLongScaler  *= 60.0;
                }
            }

            m_LandTitleNumber = IFCAnyHandleUtil.GetStringAttribute(ifcIFCSite, "LandTitleNumber");
        }
      /// <summary>
      /// Processes an IfcWindowLiningProperties entity.
      /// </summary>
      /// <param name="ifcWindowLiningProperties">The IfcWindowLiningProperties handle.</param>
      protected override void Process(IFCAnyHandle ifcWindowLiningProperties)
      {
         base.Process(ifcWindowLiningProperties);

         if (m_WindowLiningPropertyDescs == null)
         {
            m_WindowLiningPropertyDescs = new List<Tuple<string, ForgeTypeId, AllowedValues>>();
            m_WindowLiningPropertyDescs.Add(Tuple.Create("LiningDepth", SpecTypeId.Length, AllowedValues.Positive));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("LiningThickness", SpecTypeId.Length, AllowedValues.Positive));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("TransomThickness", SpecTypeId.Length, AllowedValues.Positive));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("MullionThickness", SpecTypeId.Length, AllowedValues.Positive));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("FirstTransomOffset", SpecTypeId.Length, AllowedValues.NonNegative));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("SecondTransomOffset", SpecTypeId.Length, AllowedValues.NonNegative));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("FirstMullionOffset", SpecTypeId.Length, AllowedValues.NonNegative));
            m_WindowLiningPropertyDescs.Add(Tuple.Create("SecondMullionOffset", SpecTypeId.Length, AllowedValues.NonNegative));
         }

         for (int ii = 0; ii < 4; ii++)
         {
            Tuple<string, ForgeTypeId, AllowedValues> propertyDesc = m_WindowLiningPropertyDescs[ii];
            // Default is nonsense value.
            double currPropertyValue = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcWindowLiningProperties, propertyDesc.Item1, -1e+30);
            if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
               DoubleProperties[propertyDesc] = currPropertyValue;
         }

         for (int ii = 4; ii < 8; ii++)
         {
            Tuple<string, ForgeTypeId, AllowedValues> propertyDesc = m_WindowLiningPropertyDescs[ii];
            // Default is nonsense value.
            double currPropertyValue = IFCImportHandleUtil.GetOptionalDoubleAttribute(ifcWindowLiningProperties, propertyDesc.Item1, -1e+30);
            if (!MathUtil.IsAlmostEqual(currPropertyValue, -1e+30))
               DoubleProperties[propertyDesc] = currPropertyValue;
         }
      }
Exemplo n.º 9
0
        override protected void Process(IFCAnyHandle solid)
        {
            base.Process(solid);

            IFCAnyHandle directrix = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "Directrix", true);

            Directrix = IFCCurve.ProcessIFCCurve(directrix);

            bool found = false;

            Radius = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(solid, "Radius", out found);
            if (!found || !Application.IsValidThickness(Radius))
            {
                Importer.TheLog.LogError(solid.StepId, "IfcSweptDiskSolid radius is invalid, aborting.", true);
            }

            double innerRadius = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(solid, "InnerRadius", 0.0);

            if (Application.IsValidThickness(innerRadius))
            {
                if (!Application.IsValidThickness(Radius - innerRadius))
                {
                    Importer.TheLog.LogError(solid.StepId, "IfcSweptDiskSolid inner radius is too large, aborting.", true);
                }
                InnerRadius = innerRadius;
            }

            StartParameter = IFCImportHandleUtil.GetOptionalDoubleAttribute(solid, "StartParam", 0.0);
            if (StartParameter < MathUtil.Eps())
            {
                StartParameter = 0.0;
            }

            double endParameter = IFCImportHandleUtil.GetOptionalDoubleAttribute(solid, "EndParam", -1.0);

            if (!MathUtil.IsAlmostEqual(endParameter, -1.0))
            {
                if (endParameter < StartParameter + MathUtil.Eps())
                {
                    Importer.TheLog.LogWarning(solid.StepId, "IfcSweptDiskSolid swept curve end parameter less than or equal to start parameter, ignoring both.", true);
                    StartParameter = 0.0;
                }
                else
                {
                    EndParameter = endParameter;
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Processes IfcBuildingStorey attributes.
        /// </summary>
        /// <param name="ifcIFCBuildingStorey">The IfcBuildingStorey handle.</param>
        protected override void Process(IFCAnyHandle ifcIFCBuildingStorey)
        {
            base.Process(ifcIFCBuildingStorey);

            Elevation = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcIFCBuildingStorey, "Elevation", 0.0);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Processes IfcRepresentationContext attributes.
        /// </summary>
        /// <param name="ifcRepresentationContext">The IfcRepresentationContext handle.</param>
        override protected void Process(IFCAnyHandle ifcRepresentationContext)
        {
            base.Process(ifcRepresentationContext);

            Identifier = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentationContext, "ContextIdentifier", null);

            Type = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentationContext, "ContextType", null);

            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationContext, IFCEntityType.IfcGeometricRepresentationContext))
            {
                bool found = false;
                CoordinateSpaceDimension = IFCImportHandleUtil.GetRequiredIntegerAttribute(ifcRepresentationContext, "CoordinateSpaceDimension", out found);
                if (!found)
                {
                    CoordinateSpaceDimension = 3; // Don't throw, just set to default 3D.
                }
                Precision = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcRepresentationContext, "Precision", IFCImportFile.TheFile.Document.Application.VertexTolerance);

                IFCAnyHandle worldCoordinateSystem = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationContext, "WorldCoordinateSystem", false);
                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(worldCoordinateSystem))
                {
                    WorldCoordinateSystem = IFCLocation.ProcessIFCAxis2Placement(worldCoordinateSystem);
                }
                else
                {
                    WorldCoordinateSystem = Transform.Identity;
                }

                bool isSubContext = IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC2x2) &&
                                    IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationContext, IFCEntityType.IfcGeometricRepresentationSubContext);

                if (isSubContext)
                {
                    IFCAnyHandle parentContext = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationContext, "ParentContext", true);
                    ParentContext = IFCRepresentationContext.ProcessIFCRepresentationContext(parentContext);
                    TrueNorth     = ParentContext.TrueNorth;
                }
                else
                {
                    // This used to fail for IfcGeometricRepresentationSubContext, because the TrueNorth attribute was derived from
                    // the IfcGeometricRepresentationContext, and the toolkit returned what seemed to be a valid handle that actually
                    // wasn't.  The code has now been rewritten to avoid this issue, but we will keep the try/catch block in case we
                    // were also catching other serious issues.
                    try
                    {
                        // By default, True North points in the Y-Direction.
                        IFCAnyHandle trueNorth = IFCImportHandleUtil.GetOptionalInstanceAttribute(ifcRepresentationContext, "TrueNorth");
                        if (!IFCAnyHandleUtil.IsNullOrHasNoValue(trueNorth))
                        {
                            TrueNorth = IFCPoint.ProcessNormalizedIFCDirection(trueNorth);
                        }
                        else
                        {
                            TrueNorth = XYZ.BasisY;
                        }
                    }
                    catch
                    {
                        TrueNorth = XYZ.BasisY;
                    }
                }

                if (isSubContext)
                {
                    TargetScale = IFCImportHandleUtil.GetOptionalPositiveRatioAttribute(ifcRepresentationContext, "TargetScale", 1.0);

                    TargetView = IFCEnums.GetSafeEnumerationAttribute <IFCGeometricProjection>(ifcRepresentationContext, "TargetView",
                                                                                               IFCGeometricProjection.NotDefined);

                    UserDefinedTargetView = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentationContext, "UserDefinedTargetView", null);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Processes IfcSpace attributes.
        /// </summary>
        /// <param name="ifcSpace">The IfcSpace handle.</param>
        protected override void Process(IFCAnyHandle ifcSpace)
        {
            base.Process(ifcSpace);

            ElevationWithFlooring = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(ifcSpace, "ElevationWithFlooring", 0.0);
        }