Example #1
0
        protected override void Process(IFCAnyHandle ifcCurve)
        {
            base.Process(ifcCurve);
            IFCAnyHandle pnt = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "Pnt", false);

            if (pnt == null)
            {
                return;
            }

            IFCAnyHandle dir = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "Dir", false);

            if (dir == null)
            {
                return;
            }

            XYZ pntXYZ = IFCPoint.ProcessScaledLengthIFCCartesianPoint(pnt);
            XYZ dirXYZ = IFCUnitUtil.ScaleLength(IFCPoint.ProcessIFCVector(dir));

            ParametericScaling = dirXYZ.GetLength();
            if (MathUtil.IsAlmostZero(ParametericScaling))
            {
                Importer.TheLog.LogWarning(ifcCurve.StepId, "Line has zero length, ignoring.", false);
                return;
            }

            Curve = Line.CreateUnbound(pntXYZ, dirXYZ / ParametericScaling);
        }
Example #2
0
        /// <summary>
        /// Process the IfcCartesianPointList handle.
        /// </summary>
        /// <param name="item">The handle</param>
        protected override void Process(IFCAnyHandle item)
        {
            base.Process(item);

            CoordList = new List <XYZ>();

            IList <IList <double> > coordList = IFCImportHandleUtil.GetListOfListOfDoubleAttribute(item, "CoordList");

            if (coordList != null)
            {
                foreach (IList <double> coord in coordList)
                {
                    // TODO: we expect size to be 2 or 3.  Warn if not?
                    if (coord == null)
                    {
                        continue;
                    }

                    int size = coord.Count;
                    CoordList.Add(new XYZ(
                                      (size > 0 ? IFCUnitUtil.ScaleLength(coord[0]) : 0.0),
                                      (size > 1 ? IFCUnitUtil.ScaleLength(coord[1]) : 0.0),
                                      (size > 2 ? IFCUnitUtil.ScaleLength(coord[2]) : 0.0)));
                }
            }
        }
Example #3
0
        protected override void Process(IFCAnyHandle ifcPoint)
        {
            base.Process(ifcPoint);

            XYZ unScaledPoint = IFCPoint.IFCPointToXYZ(ifcPoint);

            XYZPoint = IFCUnitUtil.ScaleLength(unScaledPoint);
        }
Example #4
0
        /// <summary>
        /// Scale the vertex according to the Project unit
        /// </summary>
        /// <param name="vertex">the vertex</param>
        /// <returns></returns>
        private XYZ applyProjectUnitScaleVertex(XYZ vertex)
        {
            double x            = IFCUnitUtil.ScaleLength(vertex.X);
            double y            = IFCUnitUtil.ScaleLength(vertex.Y);
            double z            = IFCUnitUtil.ScaleLength(vertex.Z);
            XYZ    scaledVertex = new XYZ(x, y, z);

            return(scaledVertex);
        }
Example #5
0
        protected override void Process(IFCAnyHandle ifcVertexPoint)
        {
            base.Process(ifcVertexPoint);

            IFCAnyHandle vertexGeometry         = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcVertexPoint, "VertexGeometry", true);
            XYZ          unScaledVertexGeometry = IFCPoint.ProcessIFCPoint(vertexGeometry);

            VertexGeometry = IFCUnitUtil.ScaleLength(unScaledVertexGeometry);
        }
Example #6
0
        /// <summary>
        /// Get the XYZ corresponding to the IfcCartesianPoint, scaled by the length scale.
        /// </summary>
        /// <param name="point">The IfcCartesianPoint entity handle.</param>
        /// <returns>The scaled XYZ value.</returns>
        public static XYZ ProcessScaledLengthIFCCartesianPoint(IFCAnyHandle point)
        {
            XYZ xyz = ProcessIFCCartesianPoint(point);

            if (xyz != null)
            {
                xyz = IFCUnitUtil.ScaleLength(xyz);
            }
            return(xyz);
        }
Example #7
0
        private double?GetTrimParameter(int id, IFCData trim, Curve baseCurve,
                                        IFCTrimmingPreference trimPreference, bool secondAttempt)
        {
            bool preferParam = !(trimPreference == IFCTrimmingPreference.Cartesian);

            if (secondAttempt)
            {
                preferParam = !preferParam;
            }
            double vertexEps = IFCImportFile.TheFile.VertexTolerance;

            IFCAggregate trimAggregate = trim.AsAggregate();

            foreach (IFCData trimParam in trimAggregate)
            {
                if (!preferParam && (trimParam.PrimitiveType == IFCDataPrimitiveType.Instance))
                {
                    IFCAnyHandle trimParamInstance = trimParam.AsInstance();
                    XYZ          trimParamPt       = IFCPoint.ProcessScaledLengthIFCCartesianPoint(trimParamInstance);
                    if (trimParamPt == null)
                    {
                        Importer.TheLog.LogWarning(id, "Invalid trim point for basis curve.", false);
                        continue;
                    }

                    try
                    {
                        IntersectionResult result = baseCurve.Project(trimParamPt);
                        if (result.Distance < vertexEps)
                        {
                            return(result.Parameter);
                        }

                        Importer.TheLog.LogWarning(id, "Cartesian value for trim point not on the basis curve.", false);
                    }
                    catch
                    {
                        Importer.TheLog.LogWarning(id, "Cartesian value for trim point not on the basis curve.", false);
                    }
                }
                else if (preferParam && (trimParam.PrimitiveType == IFCDataPrimitiveType.Double))
                {
                    double trimParamDouble = trimParam.AsDouble();
                    if (baseCurve.IsCyclic)
                    {
                        trimParamDouble = IFCUnitUtil.ScaleAngle(trimParamDouble);
                    }
                    else
                    {
                        trimParamDouble = IFCUnitUtil.ScaleLength(trimParamDouble);
                    }
                    return(trimParamDouble);
                }
            }

            // Try again with opposite preference.
            if (!secondAttempt)
            {
                return(GetTrimParameter(id, trim, baseCurve, trimPreference, true));
            }

            return(null);
        }