コード例 #1
0
        /// <summary>
        /// Processes measure with unit.
        /// </summary>
        /// <param name="measureUnitHnd">The measure unit handle.</param>
        void ProcessIFCMeasureWithUnit(IFCAnyHandle measureUnitHnd)
        {
            double baseScale = 0.0;

            IFCData ifcData = measureUnitHnd.GetAttribute("ValueComponent");

            if (!ifcData.HasValue)
            {
                throw new InvalidOperationException("#" + measureUnitHnd.StepId + ": Missing required attribute ValueComponent.");
            }

            if (ifcData.PrimitiveType == IFCDataPrimitiveType.Double)
            {
                baseScale = ifcData.AsDouble();
            }
            else if (ifcData.PrimitiveType == IFCDataPrimitiveType.Integer)
            {
                baseScale = (double)ifcData.AsInteger();
            }

            if (MathUtil.IsAlmostZero(baseScale))
            {
                throw new InvalidOperationException("#" + measureUnitHnd.StepId + ": ValueComponent should not be almost zero.");
            }

            IFCAnyHandle unitHnd = IFCImportHandleUtil.GetRequiredInstanceAttribute(measureUnitHnd, "UnitComponent", true);

            IFCUnit unit = ProcessIFCUnit(unitHnd);

            CopyUnit(unit);
            ScaleFactor = unit.ScaleFactor * baseScale;
        }
コード例 #2
0
        private int?GetValidIndex(IFCData segmentInfoIndex, int maxValue)
        {
            // Index starts at 1.
            int currentIndex = segmentInfoIndex.AsInteger() - 1;

            if (currentIndex < 0 || currentIndex >= maxValue)
            {
                // TODO: warn.
                return(null);
            }
            return(currentIndex);
        }
コード例 #3
0
ファイル: IFCAnyHandleUtil.cs プロジェクト: whztt07/BIM-IFC
        /// <summary>
        /// Gets an arbitrary integer attribute.
        /// </summary>
        /// <param name="name">The handle.</param>
        /// <param name="name">The attribute name.</param>
        /// <returns>The integer.</returns>
        public static int?GetIntAttribute(IFCAnyHandle hnd, string name)
        {
            if (hnd == null)
            {
                throw new ArgumentNullException("hnd");
            }

            if (!hnd.HasValue)
            {
                throw new ArgumentException("Invalid handle.");
            }

            IFCData ifcData = hnd.GetAttribute(name);

            if (ifcData.PrimitiveType == IFCDataPrimitiveType.Integer)
            {
                return(ifcData.AsInteger());
            }

            return(null);
        }