/// <summary> /// Creates IfcAxis2Placement3D object. /// </summary> /// <param name="file"> /// The IFC file. /// </param> /// <param name="origin"> /// The origin. /// </param> /// <param name="zDirection"> /// The Z direction. /// </param> /// <param name="xDirection"> /// The X direction. /// </param> /// <returns> /// The handle. /// </returns> public static IFCAnyHandle CreateAxis(IFCFile file, XYZ origin, XYZ zDirection, XYZ xDirection) { IFCAnyHandle direction = null; IFCAnyHandle refDirection = null; IFCAnyHandle location = null; if (origin != null) { IList <double> measure = new List <double>(); measure.Add(origin.X); measure.Add(origin.Y); measure.Add(origin.Z); location = CreateCartesianPoint(file, measure); } else { location = ExporterIFCUtils.GetGlobal3DOriginHandle(); } bool exportzDirectionAndxDirection = (zDirection != null && xDirection != null && (!MathUtil.IsAlmostEqual(zDirection[2], 1.0) || !MathUtil.IsAlmostEqual(xDirection[0], 1.0))); if (exportzDirectionAndxDirection) { IList <double> axisPts = new List <double>(); axisPts.Add(zDirection.X); axisPts.Add(zDirection.Y); axisPts.Add(zDirection.Z); direction = CreateDirection(file, axisPts); } if (exportzDirectionAndxDirection) { IList <double> axisPts = new List <double>(); axisPts.Add(xDirection.X); axisPts.Add(xDirection.Y); axisPts.Add(xDirection.Z); refDirection = CreateDirection(file, axisPts); } return(IFCInstanceExporter.CreateAxis2Placement3D(file, location, direction, refDirection)); }
/// <summary> /// Creates an IfcAxis2Placement3D object. /// </summary> /// <param name="file">The file.</param> /// <param name="location">The origin. If null, it will use the global origin handle.</param> /// <param name="axis">The Z direction.</param> /// <param name="refDirection">The X direction.</param> /// <returns>the handle.</returns> public static IFCAnyHandle CreateAxis2Placement3D(IFCFile file, XYZ location, XYZ axis, XYZ refDirection) { IFCAnyHandle locationHandle = null; if (location != null) { List <double> measure = new List <double>(); measure.Add(location.X); measure.Add(location.Y); measure.Add(location.Z); locationHandle = CreateCartesianPoint(file, measure); } else { locationHandle = ExporterIFCUtils.GetGlobal3DOriginHandle(); } bool exportDirAndRef = (axis != null && refDirection != null && (!MathUtil.IsAlmostEqual(axis[2], 1.0) || !MathUtil.IsAlmostEqual(refDirection[0], 1.0))); if ((axis != null) ^ (refDirection != null)) { exportDirAndRef = false; } IFCAnyHandle axisHandle = null; if (exportDirAndRef) { List <double> measure = new List <double>(); measure.Add(axis.X); measure.Add(axis.Y); measure.Add(axis.Z); axisHandle = CreateDirection(file, measure); } IFCAnyHandle refDirectionHandle = null; if (exportDirAndRef) { List <double> measure = new List <double>(); measure.Add(refDirection.X); measure.Add(refDirection.Y); measure.Add(refDirection.Z); refDirectionHandle = CreateDirection(file, measure); } return(IFCInstanceExporter.CreateAxis2Placement3D(file, locationHandle, axisHandle, refDirectionHandle)); }
/// <summary> /// Creates IfcCartesianPoint object. /// </summary> /// <param name="file"> /// The IFC file. /// </param> /// <param name="measure"> /// The list of doubles to create the Cartesian point. /// </param> /// <returns> /// The handle. /// </returns> public static IFCAnyHandle CreateCartesianPoint(IFCFile file, IList <double> measure) { IList <double> cleanMeasure = new List <double>(); foreach (double value in measure) { double ceilMeasure = Math.Ceiling(value); double floorMeasure = Math.Floor(value); if (MathUtil.IsAlmostEqual(value, ceilMeasure)) { cleanMeasure.Add(ceilMeasure); } else if (MathUtil.IsAlmostEqual(value, floorMeasure)) { cleanMeasure.Add(floorMeasure); } else { cleanMeasure.Add(value); } } if (MathUtil.IsAlmostZero(cleanMeasure[0]) && MathUtil.IsAlmostZero(cleanMeasure[1])) { if (measure.Count == 2) { return(ExporterIFCUtils.GetGlobal2DOriginHandle()); } if (measure.Count == 3 && MathUtil.IsAlmostZero(cleanMeasure[2])) { return(ExporterIFCUtils.GetGlobal3DOriginHandle()); } } IFCAnyHandle pointHandle = IFCInstanceExporter.CreateCartesianPoint(file, cleanMeasure); return(pointHandle); }