Beispiel #1
0
        /// <summary>
        /// Draws the shading overhang by a list of Overhangs
        /// </summary>
        /// <param name="shadingOverhangsList"></param>
        /// <returns></returns>
        private static List <PolyCurve> Draw(List <ShadingOverhang> shadingOverhangsList)
        {
            var rectangles = new List <PolyCurve>();

            foreach (ShadingOverhang shadingOverhang in shadingOverhangsList)
            {
                //expects fenestrationSurface to be defined like:   3   2
                //                                                  0   1
                //find a coordinateSystem where the fenestration Surface lies in
                var vec1   = Vector.ByTwoPoints(shadingOverhang.FenestrationSurface.Surface.Vertices[0].PointGeometry, shadingOverhang.FenestrationSurface.Surface.Vertices[1].PointGeometry);
                var vec2   = Vector.ByTwoPoints(shadingOverhang.FenestrationSurface.Surface.Vertices[0].PointGeometry, shadingOverhang.FenestrationSurface.Surface.Vertices[3].PointGeometry);
                var length = vec1.Length;
                //calculate new points for the ShadingOverhang
                var points      = new List <Point>();
                var coordSystem = CoordinateSystem.ByOriginVectors(shadingOverhang.FenestrationSurface.Surface.Vertices[3].PointGeometry, vec1, vec2);
                points.Add(Point.ByCartesianCoordinates(coordSystem, -shadingOverhang.Extension, shadingOverhang.Height));
                points.Add(Point.ByCartesianCoordinates(coordSystem, -shadingOverhang.Extension, shadingOverhang.Height, shadingOverhang.Depth));
                points.Add(Point.ByCartesianCoordinates(coordSystem, length + shadingOverhang.Extension, shadingOverhang.Height, shadingOverhang.Depth));
                points.Add(Point.ByCartesianCoordinates(coordSystem, length + shadingOverhang.Extension, shadingOverhang.Height));
                PolyCurve rectangle = PolyCurve.ByPoints(points, true);
                rectangles.Add(rectangle);
            }//foreach

            return(rectangles);
        } //Draw ShadingOverhang
Beispiel #2
0
        /// <summary>
        /// SpecklePolyline to DS Rectangle if closed , four points and sides parallel;
        /// DS Polygon if closed or DS Polycurve otherwise
        /// </summary>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static Curve ToNative(this SpecklePolyline polyline)
        {
            var points    = polyline.Value.ToPoints();
            var polycurve = PolyCurve.ByPoints(polyline.Value.ToPoints());

            // If closed and planar, make polygon
            if (polyline.Closed && polycurve.IsPlanar)
            {
                polycurve.Dispose(); // geometry not needed. Freeing memory.
                double dot = Vector.ByTwoPoints(points[0], points[1]).Dot(Vector.ByTwoPoints(points[1], points[2]));

                if (points.Count() == 4 && Threshold(dot, 0))
                {
                    return(Rectangle.ByCornerPoints(points).SetSpeckleProperties <Rectangle>(polyline.Properties));
                }
                else
                {
                    return(Polygon.ByPoints(polyline.Value.ToPoints()).SetSpeckleProperties <Polygon>(polyline.Properties));
                }
            }
            else
            {
                return(polycurve.SetSpeckleProperties <PolyCurve>(polyline.Properties));
            }
        }
Beispiel #3
0
        public static Autodesk.DesignScript.Geometry.PolyCurve ToProtoType(this Autodesk.Revit.DB.PolyLine geom,
                                                                           bool performHostUnitConversion = true)
        {
            var converted = PolyCurve.ByPoints(geom.GetCoordinates().Select(x => Autodesk.DesignScript.Geometry.Point.ByCoordinates(x.X, x.Y, x.Z)).ToArray());

            return(performHostUnitConversion ? converted.InDynamoUnits() : converted);
        }
        //MAKE POLYGON BASED ON POINT COORDS
        public static PolyCurve PolyCurveFromPoints(List <Point2d> pointCoordList)
        {
            PolyCurve    pCurve;
            List <Point> pointList = new List <Point>();

            for (int i = 0; i < pointCoordList.Count; i++)
            {
                pointList.Add(Point.ByCoordinates(pointCoordList[i].X, pointCoordList[i].Y));
                if (i == pointCoordList.Count - 1)
                {
                    pointList.Add(Point.ByCoordinates(pointCoordList[0].X, pointCoordList[0].Y));
                }
            }

            try
            {
                pCurve = PolyCurve.ByPoints(pointList);
            }
            catch (System.Exception)
            {
                pCurve = null;
                //throw;
            }

            return(pCurve);
        }
Beispiel #5
0
        /// <summary>
        /// Private method to retrieve Baseline PolyCurves.
        /// </summary>
        /// <returns>A list of PolyCurves for each BaselineRegion.</returns>
        /// <remarks>In case of large dataset, the Geometry Working Range wiill return a warning. Set the Geometry Working Range to Medium.</remarks>
        private IList <PolyCurve> BaselinePolyCurves()
        {
            Utils.Log(string.Format("Baseline.BaselinePolyCurves started...", ""));

            IList <PolyCurve> polyCurves = new List <PolyCurve>();

            foreach (BaselineRegion blr in this.GetBaselineRegions())
            {
                IList <Point> baseLinePoints = new List <Point>();

                foreach (double station in blr.Stations)
                {
                    baseLinePoints.Add(this.PointByStationOffsetElevation(station, 0, 0));
                }

                polyCurves.Add(PolyCurve.ByPoints(baseLinePoints));

                foreach (var p in baseLinePoints)
                {
                    if (p != null)
                    {
                        p.Dispose();
                    }
                }
            }

            Utils.Log(string.Format("Baseline.BaselinePolyCurves completed.", ""));

            return(polyCurves);
        }
        public static Content.Annotation InkToPolyCurve(this PdfDictionary annotation)
        {
            PdfArray datarray = annotation.GetAsArray(PdfName.INKLIST);

            if (datarray == null || datarray.Size == 0)
            {
                return(null);
            }

            PdfArray data = datarray[0] as PdfArray;

            List <Point> points = new List <Point>();

            for (int j = 0; j < data.Size - 1; j = j + 2)
            {
                points.Add(Point.ByCoordinates(data[j].ToDouble(), data[j + 1].ToDouble()));
            }

            if (points.First().IsAlmostEqualTo(points.Last()))
            {
                points.RemoveAt(points.Count - 1);
            }

            return(new Content.Annotation(annotation, PolyCurve.ByPoints(points, false)));
        }
Beispiel #7
0
        protected override (Curve boundary, List <Curve> holes) CreateBaseCurves()
        {
            Curve boundary = null;

            if (UsesDepth)
            {
                var points = new[]
                {
                    Point.ByCoordinates(0, 0),
                    Point.ByCoordinates(Width, 0),
                    Point.ByCoordinates(Width, Depth),
                    Point.ByCoordinates(Depth, Depth),
                    Point.ByCoordinates(Depth, Length),
                    Point.ByCoordinates(0, Length)
                };

                boundary = PolyCurve.ByPoints(points, connectLastToFirst: true);

                points.ForEach(p => p.Dispose());
            }
            else
            {
                // L is too chunky - make a box.

                boundary = Rectangle.ByWidthLength(BaseCenter, Width, Length);
            }

            return(boundary, default);
        }
Beispiel #8
0
    /// <summary>
    ///     A hyperbolic spiral is a transcendental plane curve also known as a reciprocal spiral, this the opposite of an Archimedean spiral and is a type of Cotes' spiral.
    /// </summary>
    /// <param name="angle">360 completes 1 circulation</param>
    /// <param name="innerScale">Changing this will expand the inner circular part of the spiral</param>
    /// <search>Hyperbolic,cotes,archimedes</search>
    public static PolyCurve Hyperbolic(double angle = 3600, double innerScale = 100)
    {
        if (angle == 0.0)
        {
            throw new ArgumentException("The angle value can't be 0.", "angle");
        }

        if (angle < 0.0)
        {
            angle = angle * -1;
        }

        int numPts = 1000;

        angle = degToRad(angle);

        var pts = new List <Point>();

        for (int i = 30; i < numPts; ++i)
        {
            double currAngle = (double)i / 1000.0 * angle;
            double radius    = innerScale / currAngle;

            double xVal = radius * Math.Cos(currAngle);
            double yVal = radius * Math.Sin(currAngle);

            pts.Add(Point.ByCoordinates(xVal, yVal, 0));
        }

        return(PolyCurve.ByPoints(pts));
    }
Beispiel #9
0
        /// <exclude />
        private Element ToHorizontalFloor(FloorType floorType, Level level)
        {
            Utils.Log(string.Format("MultiPoint.ToHorizontalFloor started...", ""));

            try
            {
                if (!SessionVariables.ParametersCreated)
                {
                    UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument);
                }

                PolyCurve outline = PolyCurve.ByPoints(this.ShapePoints.Points.Select(p => p.RevitPoint).ToList(), true);

                outline = PolyCurve.ByJoinedCurves(outline.PullOntoPlane(Plane.XY()).Explode().Cast <Curve>().ToList());

                var output = Floor.ByOutlineTypeAndLevel(outline, floorType, level);

                output.SetParameterByName(ADSK_Parameters.Instance.MultiPoint.Name, SerializeJSON());

                Utils.Log(string.Format("MultiPoint.ToHorizontalFloor completed.", ""));

                return(output);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: MultiPoint.ToHorizontalFloor {0}", ex.Message));
                throw ex;
            }
        }
        public static Dictionary <string, object> DeconstructMesh(Mesh mesh)
        {
            List <List <uint> > faceIndexes = new List <List <uint> >();

            IndexGroup[] ig       = mesh.FaceIndices;
            Point[]      vertices = mesh.VertexPositions;

            List <PolyCurve> edges = new List <PolyCurve>();

            for (int i = 0; i < ig.Length; i++)
            {
                if (ig[i].Count == 3)
                {
                    faceIndexes.Add(new List <uint> {
                        ig[i].A, ig[i].B, ig[i].C
                    });
                }

                if (ig[i].Count == 4)
                {
                    faceIndexes.Add(new List <uint> {
                        ig[i].A, ig[i].B, ig[i].C, ig[i].D
                    });
                }
            }

            for (int i = 0; i < faceIndexes.Count; i++)
            {
                for (int j = 0; j < faceIndexes[i].Count; j++)
                {
                    if (faceIndexes[i].Count == 3)
                    {
                        Point[] verts = new Point[3];
                        verts[0] = vertices[(int)faceIndexes[i][0]];
                        verts[1] = vertices[(int)faceIndexes[i][1]];
                        verts[2] = vertices[(int)faceIndexes[i][2]];
                        edges.Add(PolyCurve.ByPoints(verts));
                    }

                    if (faceIndexes[i].Count == 4)
                    {
                        Point[] verts = new Point[4];
                        verts[0] = vertices[(int)faceIndexes[i][0]];
                        verts[1] = vertices[(int)faceIndexes[i][1]];
                        verts[2] = vertices[(int)faceIndexes[i][2]];
                        verts[3] = vertices[(int)faceIndexes[i][3]];
                        edges.Add(PolyCurve.ByPoints(verts));
                    }
                }
            }

            return(new Dictionary <string, object>
            {
                { "Vertices", mesh.VertexPositions },
                { "FaceIndexes", faceIndexes },
                { "Edges", edges },
                { "Normals", mesh.VertexNormals }
            });
        }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LandFeatureline"/> class.
        /// </summary>
        /// <param name="fl">The AeccLandFeatureline.</param>
        /// <param name="style">The style name.</param>
        internal LandFeatureline(AeccLandFeatureLine fl, string style = "")
        {
            if (fl == null)
            {
                return;
            }

            this._featureline  = fl;
            this._name         = fl.Name;
            this._minGrade     = fl.MiniGrade;
            this._minElevation = fl.MiniElevation;
            this._maxElevation = fl.MaxElevation;
            this._maxGrade     = fl.MaxGrade;

            this._style = style;

            // Andrew Milford - Using reflection does not crash Dynamo
            Type fltype = fl.GetType();

            if (fltype != null)
            {
                try
                {
                    dynamic coord = fltype.InvokeMember("GetPoints",
                                                        BindingFlags.InvokeMethod,
                                                        System.Type.DefaultBinder,
                                                        fl,
                                                        new object[] { AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI });

                    IList <Point> points = new List <Point>();

                    for (int i = 0; i < coord.Length; i = i + 3)
                    {
                        double x = coord[i];
                        double y = coord[i + 1];
                        double z = coord[i + 2];

                        points.Add(Point.ByCoordinates(x, y, z));
                    }

                    if (points.Count > 1)
                    {
                        try
                        {
                            PolyCurve pc = PolyCurve.ByPoints(Point.PruneDuplicates(points));
                            this._polycurve = pc;
                        }
                        catch
                        {
                            // Not all Polycurves are branching
                            this._polycurve = null;
                        }
                    }
                }
                catch { }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Gets a PolyCurve obtained by applying the offset and elevation displacement to each point of the Featureline PolyCurve.
        /// </summary>
        /// <param name="offset">The offset.</param>
        /// <param name="elevation">The elevation.</param>
        /// <returns></returns>
        public PolyCurve GetPolyCurveByOffsetElevation(double offset, double elevation)
        {
            Utils.Log(string.Format("Featureline.GetPolyCurveByOffsetElevation started...", ""));

            double startStation = this.Start; //  soeStart[0];
            double endStation   = this.End;   //  soeEnd[0];

            IList <double> stations = new List <double>()
            {
                startStation
            };

            foreach (double s in this.Baseline.Stations.Where(s => s >= startStation && s <= endStation))
            {
                stations.Add(s);
            }

            stations.Add(endStation);

            Point p = Point.ByCoordinates(offset, 0, elevation);

            CoordinateSystem cs = null;

            IList <Point> points = new List <Point>();

            foreach (double s in stations)
            {
                cs = this.CoordinateSystemByStation(s);
                points.Add(p.Transform(cs) as Point);
            }

            points = Point.PruneDuplicates(points);  // TODO this is slow

            PolyCurve res = null;

            if (points.Count > 1)
            {
                res = PolyCurve.ByPoints(points);
            }

            Utils.Log(string.Format("{0}", res));

            if (p != null)
            {
                p.Dispose();
            }

            if (cs != null)
            {
                cs.Dispose();
            }

            Utils.Log(string.Format("Featureline.GetPolyCurveByOffsetElevation completed.", ""));

            return(res);
        }
        /// <summary>
        /// SpecklePolyline to DS Rectangle if closed , four points and sides parallel;
        /// DS Polygon if closed or DS Polycurve otherwise
        /// </summary>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static Curve ToNative(this SpecklePolyline polyline)
        {
            var points = polyline.Value.ToPoints();

            if (polyline.Closed)
            {
                return(PolyCurve.ByPoints(points).CloseWithLine().SetSpeckleProperties <PolyCurve>(polyline.Properties));
            }
            return(PolyCurve.ByPoints(points).SetSpeckleProperties <PolyCurve>(polyline.Properties));
        }
        /// <summary>
        /// SpecklePolyline to DS Rectangle if closed , four points and sides parallel;
        /// DS Polygon if closed or DS Polycurve otherwise
        /// </summary>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public DS.Curve PolylineToNative(Polyline polyline)
        {
            var points = ArrayToPointList(polyline.value, polyline.units);

            if (polyline.closed)
            {
                return(DS.PolyCurve.ByPoints(points).CloseWithLine()
                       .SetDynamoProperties <DS.PolyCurve>(GetDynamicMembersFromBase(polyline)));
            }

            return(PolyCurve.ByPoints(points).SetDynamoProperties <PolyCurve>(GetDynamicMembersFromBase(polyline)));
        }
        public override List <object> CreateGeometryObjects(List <Node> allNodes)
        {
            List <Point> points = new List <Point>();

            for (int i = 0; i < NodeCount; i++)
            {
                points.Add(allNodes[NodeIndices[i]].Position.ToPoint());
            }
            return(new List <object> {
                PolyCurve.ByPoints(points, Loop)
            });
        }
        public override List <Geometry> GetGeometries(List <Node> allNodes)
        {
            List <Point> points = new List <Point>();

            for (int i = 0; i < NodeCount; i++)
            {
                points.Add(allNodes[NodeIndices[i]].Position.ToPoint());
            }
            return(new List <Geometry> {
                PolyCurve.ByPoints(points)
            });
        }
Beispiel #17
0
        private Dictionary <string, object> TestCorridorInfo_Old(string code)
        {
            IList <string[]>             corridorCodes        = new List <string[]>();
            IList <IList <Featureline> > corridorFeaturelines = new List <IList <Featureline> >();

            foreach (Baseline bl in this.Baselines)
            {
                IList <Featureline> blFeaturelines = new List <Featureline>();

                var b = bl._baseline;

                foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol)
                {
                    foreach (AeccFeatureLine f in coll)
                    {
                        if (f.CodeName == code)
                        {
                            IList <Point> featureline = new List <Point>();

                            foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
                            {
                                Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

                                featureline.Add(point);
                            }

                            featureline = Point.PruneDuplicates(featureline);

                            PolyCurve pc = PolyCurve.ByPoints(featureline);

                            var offset = bl.GetArrayStationOffsetElevationByPoint(pc.PointAtParameter(0.5))[1];

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(bl, pc, f.CodeName, side));
                        }
                    }
                }

                corridorFeaturelines.Add(blFeaturelines);
            }

            return(new Dictionary <string, object>()
            {
                { "Featurelines", corridorFeaturelines }
            });
        }
Beispiel #18
0
        public IList <LandFeatureline> GetLandFeaturelines(string xmlPath = "")
        {
            Utils.Log(string.Format("CivilDocument.GetLandFeaturelines started...", ""));

            if (string.IsNullOrEmpty(xmlPath))
            {
                xmlPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "LandFeatureLinesReport.xml");
            }

            bool result = this.SendCommand("-ExportLandFeatureLinesToXml\n");

            IList <LandFeatureline> output = new List <LandFeatureline>();

            if (result)
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlPath);

                AcadDatabase   db = this._document as AcadDatabase;
                AcadModelSpace ms = db.ModelSpace;

                foreach (AcadEntity e in ms)
                {
                    if (e.EntityName.ToLower().Contains("featureline"))
                    {
                        AeccLandFeatureLine f = e as AeccLandFeatureLine;

                        XmlElement fe = xmlDoc.GetElementsByTagName("FeatureLine").Cast <XmlElement>().First(x => x.Attributes["Name"].Value == f.Name);

                        IList <Point> points = new List <Point>();

                        foreach (XmlElement p in fe.GetElementsByTagName("Point"))
                        {
                            double x = Convert.ToDouble(p.Attributes["X"].Value);
                            double y = Convert.ToDouble(p.Attributes["Y"].Value);
                            double z = Convert.ToDouble(p.Attributes["Z"].Value);

                            points.Add(Point.ByCoordinates(x, y, z));
                        }

                        PolyCurve pc    = PolyCurve.ByPoints(points);
                        string    style = fe.Attributes["Style"].Value;

                        output.Add(new LandFeatureline(f, pc, style));
                    }
                }

                Utils.Log(string.Format("CivilDocument.GetLandFeaturelines completed.", ""));
            }

            return(output);
        }
Beispiel #19
0
        /// <summary>
        /// Creates a Radiance Polygon.
        /// </summary>
        /// <param name="material">Material of the Polygon</param>
        /// <param name="name">Name of the Polygon</param>
        /// <param name="points">List of Points that define the Polygon (need to be planar).</param>
        /// <returns></returns>
        public static Objects.Polygon Polygon(string material, string name, List <Point> points)
        {
            //Check if points are planar
            var pcurve = PolyCurve.ByPoints(points);

            if (!pcurve.IsPlanar)
            {
                throw new ArgumentException("Points do not define a planar polygon!");
            }

            //Create new Polygon.
            return(new Objects.Polygon(material, name, points));
        }
Beispiel #20
0
        public void BeforeTest()
        {
            surface = Surface.ByPatch(PolyCurve.ByPoints(new List <Point>
            {
                Point.ByCoordinates(0, 0, 0),
                Point.ByCoordinates(27.129, 25.08, 0),
                Point.ByCoordinates(10.318, 36.351, 0),
                Point.ByCoordinates(-7.419, 16.573, 0)
            }, true));

            List <double> newRange = DSCore.Math.RemapRange(new List <double> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            }, 0, 1) as List <double>;

            uParams = newRange;
            vParams = newRange;
        }
Beispiel #21
0
        /// <summary>
        /// Gets list of shape polygons at a given record index.
        /// </summary>
        /// <param name="index">Record index for the shape</param>
        /// <returns>List of PolyCurve</returns>
        public IEnumerable <Curve> GetShapeAtRecord(int index)
        {
            return(ShapeData[index].Select(pts =>
            {
                var points = pts.Select(p => Point.ByCoordinates(p.X, p.Y, p.Z)).ToList();

                var pts0 = points.Where((x, i) => i == 0 || !(x.IsAlmostEqualTo(points[i - 1]))).ToList();

                var polygon = PolyCurve.ByPoints(pts0);
                foreach (var item in points)
                {
                    item.Dispose();
                }

                return polygon;
            }));
        }
Beispiel #22
0
        /// <summary>
        /// Converts the MultiPoint into a floor of the specified type.
        /// </summary>
        /// <param name="floorType">Type of the floor.</param>
        /// <param name="level">The level.</param>
        /// <param name="structural">if set to <c>true</c> [structural].</param>
        /// <returns></returns>
        public Element ToFloor(FloorType floorType, Level level, bool structural = true)
        {
            Utils.Log(string.Format("MultiPoint.ToFloor started...", ""));

            try
            {
                if (!SessionVariables.ParametersCreated)
                {
                    UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument);
                }

                PolyCurve outline = PolyCurve.ByPoints(this.ShapePoints.Points.Select(p => p.RevitPoint).ToList(), true);

                if (null == outline)
                {
                    System.Windows.Forms.MessageBox.Show("Outline is null");
                }

                Element output = null;

                try
                {
                    output = SlopedFloor.ByOutlineTypeAndLevel(outline, floorType, level, structural);
                }
                catch (Exception ex)
                {
                    Utils.Log(string.Format("ERROR: MultiPoint.ToFloor {0}", ex.Message));

                    output = Floor.ByOutlineTypeAndLevel(outline, floorType, level);
                }

                output.SetParameterByName(ADSK_Parameters.Instance.MultiPoint.Name, this.SerializeJSON());
                output.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1);
                output.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0);

                Utils.Log(string.Format("MultiPoint.ToFloor completed.", ""));

                return(output);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: MultiPoint.ToFloor {0}", ex.Message));
                throw ex;
            }
        }
Beispiel #23
0
    /// <summary>
    ///     Fermat's spiral (also known as a parabolic spiral) follows the equation r = +/- Theta^0.5
    /// </summary>
    /// <param name="angle">360 completes 1 circulation</param>
    /// <search>golden,fibonacci</search>
    public static PolyCurve Fermat(double angle = 3600)
    {
        if (angle == 0.0)
        {
            throw new ArgumentException("The angle value can't be 0.", "angle");
        }

        if (angle < 0.0)
        {
            angle = angle * -1;
        }

        int numPts = 1000;

        angle = degToRad(angle);

        var pts = new List <Point>();

        for (int i = numPts - 1; i >= 0; --i)
        {
            double currAngle = (double)i / 1000.0 * angle;
            double radius    = Math.Sqrt(currAngle);

            double xVal = radius * Math.Cos(currAngle);
            double yVal = radius * Math.Sin(currAngle);
            pts.Add(Point.ByCoordinates(-xVal, -yVal, 0));
        }

        for (int i = 1; i < numPts; ++i)
        {
            double currAngle = (double)i / 1000.0 * angle;
            double radius    = Math.Sqrt(currAngle);

            double xVal = radius * Math.Cos(currAngle);
            double yVal = radius * Math.Sin(currAngle);
            pts.Add(Point.ByCoordinates(xVal, yVal, 0));
        }

        return(PolyCurve.ByPoints(pts));
    }
Beispiel #24
0
        /// <summary>
        /// Gets a PolyCurve obtained by applying the offset and elevation displacement to each point of the Featureline PolyCurve.
        /// </summary>
        /// <param name="offset">The offset.</param>
        /// <param name="elevation">The elevation.</param>
        /// <returns></returns>
        public PolyCurve GetPolyCurveByOffsetElevation(double offset, double elevation)
        {
            Utils.Log(string.Format("Featureline.GetPolyCurveByOffsetElevation started...", ""));

            //double[] soeStart = this.GetStationOffsetElevationByPoint(this.Curve.StartPoint);
            //double[] soeEnd = this.GetStationOffsetElevationByPoint(this.Curve.EndPoint);
            double startStation = this.Start; //  soeStart[0];
            double endStation   = this.End;   //  soeEnd[0];

            IList <double> stations = new List <double>()
            {
                startStation
            };

            foreach (double s in this.Baseline.Stations.Where(s => s >= startStation && s <= endStation))
            {
                stations.Add(s);
            }

            stations.Add(endStation);

            Point p = Point.ByCoordinates(offset, 0, elevation);

            IList <Point> points = new List <Point>();

            foreach (double s in stations)
            {
                points.Add(p.Transform(this.CoordinateSystemByStation(s)) as Point);
            }

            p.Dispose();

            points = Point.PruneDuplicates(points);

            Utils.Log(string.Format("Featureline.GetPolyCurveByOffsetElevation completed.", ""));

            return(PolyCurve.ByPoints(points));
        }
        public static Content.Annotation ToPolyCurve(this PdfDictionary annotation, bool close)
        {
            PdfArray data = annotation.GetAsArray(PdfName.VERTICES);

            if (data == null)
            {
                return(null);
            }

            List <Point> points = new List <Point>();

            for (int j = 0; j < data.Size - 1; j = j + 2)
            {
                points.Add(Point.ByCoordinates(data[j].ToDouble(), data[j + 1].ToDouble()));
            }

            if (points.First().IsAlmostEqualTo(points.Last()))
            {
                points.RemoveAt(points.Count - 1);
            }

            return(new Content.Annotation(annotation, PolyCurve.ByPoints(points, close)));
        }
Beispiel #26
0
        /// <summary>
        /// Gets the featurelines by code
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <returns></returns>
        private IList <IList <Featureline> > GetFeaturelinesByCode_(string code)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCode({0}) Started...", code));

            IList <IList <Featureline> > blFeaturelines = new List <IList <Featureline> >();

            var b = this._baseline;

            // 20190121 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: {0}", ex.Message));
            }

            Dictionary <int, Dictionary <double, Point> > cFLs = new Dictionary <int, Dictionary <double, Point> >();

            int i = 0;

            if (fs != null)
            {
                Utils.Log(string.Format("Featurelines in region: {0}", fs.Count));

                foreach (var fl in fs.Cast <AeccFeatureLine>())
                {
                    Dictionary <double, Point> points = new Dictionary <double, Point>();

                    foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                    {
                        var p = pt.XYZ;

                        try
                        {
                            points.Add(Math.Round(pt.Station, 5), Point.ByCoordinates(p[0], p[1], p[2]));
                        }
                        catch (Exception ex)
                        {
                            Utils.Log(string.Format("ERROR: {0}", ex.Message));
                        }
                    }

                    cFLs.Add(i, points);

                    ++i;
                }
            }


            if (cFLs.Count > 0)
            {
                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    Utils.Log(string.Format("Processing region {0}...", regionIndex));

                    IList <Featureline> regFeaturelines = new List <Featureline>();

                    foreach (var k in cFLs.Keys)
                    {
                        IList <Point> points = new List <Point>();

                        var pts = cFLs[k];

                        if (pts.Keys.Count == 0)
                        {
                            continue;
                        }

                        foreach (double s in region.GetSortedStations())
                        {
                            var st = Math.Round(s, 5);

                            Point p = null;

                            if (pts.TryGetValue(st, out p))
                            {
                                points.Add(p);
                            }
                        }

                        points = Point.PruneDuplicates(points);

                        if (points.Count > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            regFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }

                    blFeaturelines.Add(regFeaturelines);

                    Utils.Log(string.Format("Region {0} completed.", regionIndex));

                    regionIndex++;
                }
            }

            // 20190121 -- End

            #region OLDCODE

            //int regionIndex = 0;

            //foreach (AeccBaselineRegion region in b.BaselineRegions)
            //{
            //    IList<Featureline> regFeaturelines = new List<Featureline>();

            //    foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol.Cast<AeccFeatureLines>().Where(fl => fl.FeatureLineCodeInfo.CodeName == code))  // 1.1.0
            //    {
            //        foreach (AeccFeatureLine f in coll.Cast<AeccFeatureLine>().Where(x => x.CodeName == code))  // maybe redundant?
            //        {
            //            double start = f.FeatureLinePoints.Item(0).Station;  // 1.1.0
            //            double end = f.FeatureLinePoints.Item(f.FeatureLinePoints.Count - 1).Station;  // 1.1.0

            //            bool reverse = start < end ? false : true;  // 1.1.0

            //            IList<Point> points = new List<Point>();

            //            foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
            //            {
            //                Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

            //                double s = Math.Round(p.Station, 5);  // 1.1.0

            //                if (s >= region.StartStation || Math.Abs(s - region.StartStation) < 0.001)
            //                {
            //                    if (s <= region.EndStation || Math.Abs(s - region.EndStation) < 0.001)
            //                    {
            //                        points.Add(point);
            //                    }
            //                }
            //            }

            //            points = Point.PruneDuplicates(points);

            //            if (points.Count > 1)
            //            {
            //                PolyCurve pc = PolyCurve.ByPoints(points);

            //                if (reverse)  // 1.1.0
            //                {
            //                    pc = pc.Reverse() as PolyCurve;
            //                }

            //                double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

            //                Featureline.SideType side = Featureline.SideType.Right;

            //                if (offset < 0)
            //                {
            //                    side = Featureline.SideType.Left;
            //                }

            //                regFeaturelines.Add(new Featureline(this, pc, f.CodeName, side, regionIndex));
            //            }
            //        }
            //    }

            //    blFeaturelines.Add(regFeaturelines);

            //    regionIndex++;
            //}
            #endregion

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCode() Completed.", code));

            return(blFeaturelines);
        }
Beispiel #27
0
        /// <summary>
        /// Gets the featurelines by code and station
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <param name="station">the station used to select the featurelines.</param>
        /// <returns></returns>
        public IList <Featureline> GetFeaturelinesByCodeStation(string code, double station)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation({0}, {1}) Started...", code, station));

            IList <Featureline> blFeaturelines = new List <Featureline>();

            var b = this._baseline;

            // 20190122 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR 1: {0}", ex.Message));
            }

            if (fs != null)
            {
                AeccBaselineRegion reg = null;

                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)
                    {
                        reg = region;
                        break;
                    }

                    ++regionIndex;
                }

                if (reg != null)
                {
                    foreach (var fl in fs.Cast <AeccFeatureLine>())
                    {
                        var pts = new List <Point>();

                        foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                        {
                            if (reg.StartStation < Math.Round(pt.Station, 5) && reg.EndStation > Math.Round(pt.Station, 5) ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.StartStation) < 0.001 ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.EndStation) < 0.001)
                            {
                                var p = pt.XYZ;

                                //try
                                //{
                                //    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                //}
                                //catch { }

                                try
                                {
                                    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                }
                                catch (Exception ex)
                                {
                                    // 'System.Collections.Generic.IList<Autodesk.DesignScript.Geometry.Point>' does not contain a definition for 'Add'
                                    Utils.Log(string.Format("ERROR 2: {0}", ex.Message));
                                }
                            }
                        }

                        var points = Point.PruneDuplicates(pts);

                        if (points.Count() > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }
                }
            }

            // 20190122 -- End

            #region OLD CODE
            //int regionIndex = 0;

            //foreach (AeccBaselineRegion region in b.BaselineRegions)
            //{
            //    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)  // 1.1.0
            //    {
            //        foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol.Cast<AeccFeatureLines>().Where(fl => fl.FeatureLineCodeInfo.CodeName == code))  // 1.1.0
            //        {
            //            foreach (AeccFeatureLine f in coll.Cast<AeccFeatureLine>().Where(x => x.CodeName == code))  // maybe redundant?
            //            {
            //                double start = f.FeatureLinePoints.Item(0).Station;  // 1.1.0
            //                double end = f.FeatureLinePoints.Item(f.FeatureLinePoints.Count - 1).Station;  // 1.1.0

            //                bool reverse = start < end ? false : true;  // 1.1.0

            //                IList<Point> points = new List<Point>();

            //                foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
            //                {
            //                    Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

            //                    double s = Math.Round(p.Station, 3);  // 1.1.0

            //                    if (s >= region.StartStation || Math.Abs(s - region.StartStation) < 0.001)
            //                    {
            //                        if (s <= region.EndStation || Math.Abs(s - region.EndStation) < 0.001)
            //                        {
            //                            points.Add(point);
            //                        }
            //                    }
            //                }

            //                points = Point.PruneDuplicates(points);

            //                if (points.Count > 1)
            //                {
            //                    PolyCurve pc = PolyCurve.ByPoints(points);

            //                    if (reverse)  // 1.1.0
            //                    {
            //                        pc = pc.Reverse() as PolyCurve;
            //                    }

            //                    double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

            //                    Featureline.SideType side = Featureline.SideType.Right;

            //                    if (offset < 0)
            //                    {
            //                        side = Featureline.SideType.Left;
            //                    }

            //                    blFeaturelines.Add(new Featureline(this, pc, f.CodeName, side, regionIndex));
            //                }
            //            }
            //        }
            //    }

            //    regionIndex++;
            //}
            #endregion

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation() Completed.", code));

            return(blFeaturelines);
        }
Beispiel #28
0
        /// <summary>
        /// Returns a collection of Featurelines in the Baseline for the given code organized by regions.
        /// </summary>
        /// <param name="code">The code of the Featurelines.</param>
        /// <returns></returns>
        private IList <IList <Featureline> > GetFeaturelinesFromXML(string code)
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesFromXML started ({0})...", code));

            IList <IList <Featureline> > blFeaturelines = new List <IList <Featureline> >();
            PolyCurve pc        = null;
            double    side      = 0;
            int       ri        = -1;
            Point     lastPoint = null;


            string xmlPath = Path.Combine(Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.User), string.Format("CorridorFeatureLines_{0}.xml", this._corridor.Name));  // Revit 2020 changed the path to the temp at a session level

            Utils.Log(xmlPath);

            if (!this._corridor._corridorFeaturelinesXMLExported)
            {
                this._baseline.Alignment.Document.SendCommand(string.Format("-ExportCorridorFeatureLinesToXml\n{0}\n", this._baseline.Corridor.Handle));

                DateTime start = DateTime.Now;

                while (true)
                {
                    if (File.Exists(xmlPath))
                    {
                        if (File.GetLastWriteTime(xmlPath) > start)
                        {
                            start = File.GetLastWriteTime(xmlPath);
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                this._corridor._corridorFeaturelinesXMLExported = true;
            }

            Utils.Log("XML acquired.");

            if (File.Exists(xmlPath))
            {
                IList <Featureline> output = new List <Featureline>();

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlPath);

                foreach (XmlElement be in xmlDoc.GetElementsByTagName("Baseline")
                         .Cast <XmlElement>()
                         .Where(x => Convert.ToInt32(x.Attributes["Index"].Value) == this.Index && x.ParentNode.ParentNode.Attributes["Name"].Value == this.CorridorName))
                {
                    try
                    {
                        foreach (XmlElement fe in be.GetElementsByTagName("FeatureLine").Cast <XmlElement>().Where(x => x.Attributes["Code"].Value == code))
                        {
                            try
                            {
                                IList <Point> points = new List <Point>();

                                double isBreak = 0;
                                int    lastRi  = -1;

                                foreach (XmlElement p in fe.GetElementsByTagName("Point").Cast <XmlElement>().OrderBy(e => Convert.ToDouble(e.Attributes["Station"].Value)))
                                {
                                    try
                                    {
                                        double x = 0;
                                        double y = 0;
                                        double z = 0;
                                        double b = 0;

                                        double station = Convert.ToDouble(p.Attributes["Station"].Value);

                                        try
                                        {
                                            x = Convert.ToDouble(p.Attributes["X"].Value);
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: {0} X {1}", station, ex.Message));
                                        }

                                        try
                                        {
                                            y = Convert.ToDouble(p.Attributes["Y"].Value);
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: {0} Y {1}", station, ex.Message));
                                        }

                                        try
                                        {
                                            z = Convert.ToDouble(p.Attributes["Z"].Value);  // if Z is NaN because there is no profile associated in that station
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: {0} Z {1}", station, ex.Message));
                                        }

                                        try
                                        {
                                            b = Convert.ToDouble(p.Attributes["IsBreak"].Value);
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: {0} IsBreak {1}", station, ex.Message));
                                        }

                                        try
                                        {
                                            ri = Convert.ToInt32(p.Attributes["RegionIndex"].Value);
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: {0} RegionIndex {1}", station, ex.Message));
                                        }

                                        isBreak += b;

                                        if (ri - lastRi > 1 || b == 1)
                                        {
                                            Utils.Log(string.Format("Region change isBreak: {0}", b));

                                            if (b == 1)
                                            {
                                                lastRi = ri;

                                                if (points.Count > 0)
                                                {
                                                    points.Add(Point.ByCoordinates(x, y, z));
                                                }
                                            }
                                            else
                                            {
                                                lastRi = ri - 1;
                                            }

                                            if (points.Count > 0)
                                            {
                                                points = Point.PruneDuplicates(points).ToList();
                                            }

                                            if (points.Count > 1)
                                            {
                                                Utils.Log(string.Format("Points: {0}", points.Count));

                                                pc = PolyCurve.ByPoints(points);

                                                // int reg = this.GetBaselineRegionIndexByStation(station);

                                                try
                                                {
                                                    side = Convert.ToDouble(fe.Attributes["Side"].Value);
                                                }
                                                catch (Exception ex)
                                                {
                                                    Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML Side {0}", ex.Message));
                                                    side = 1;
                                                }

                                                output.Add(new Featureline(this, pc, code, side < 0 ? Featureline.SideType.Left : Featureline.SideType.Right, lastRi));

                                                lastPoint = points.Last();
                                                points    = new List <Point>();

                                                if (b == 0)
                                                {
                                                    points.Add(lastPoint);
                                                }

                                                //if (isBreak == 1)
                                                //{
                                                //    isBreak = 0;
                                                //}
                                            }
                                            //else
                                            //{
                                            //    if (isBreak == 1)
                                            //    {
                                            //        isBreak = 0;
                                            //    }
                                            //}
                                        }

                                        if (b != 1)
                                        {
                                            points.Add(Point.ByCoordinates(x, y, z));
                                        }

                                        // 20191005 -- START

                                        //if (isBreak == 1)
                                        //{
                                        //    Utils.Log("Break Point.");

                                        //    isBreak = 0;

                                        //    points = Point.PruneDuplicates(points);

                                        //    if (points.Count > 1)
                                        //    {
                                        //        Utils.Log(string.Format("Points: {0}", points.Count));

                                        //        pc = PolyCurve.ByPoints(points);
                                        //        //try
                                        //        //{
                                        //        //    ri = Convert.ToInt32(fe.Attributes["RegionIndex"].Value);
                                        //        //}
                                        //        //catch (Exception ex)
                                        //        //{
                                        //        //    Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML RegionIndex {0}", ex.Message));
                                        //        //    ri = -1;
                                        //        //}
                                        //        try
                                        //        {
                                        //            side = Convert.ToDouble(fe.Attributes["Side"].Value);
                                        //        }
                                        //        catch (Exception ex)
                                        //        {
                                        //            Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML Side {0}", ex.Message));
                                        //            side = 1;
                                        //        }

                                        //        output.Add(new Featureline(this, pc, code, side < 0 ? Featureline.SideType.Left : Featureline.SideType.Right, ri));
                                        //    }

                                        //    points = new List<Point>();
                                        //}

                                        // 20191005 -  END
                                    }
                                    catch (Exception ex)
                                    {
                                        Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML point failed {0} {1}", Convert.ToDouble(p.Attributes["Station"].Value), ex.Message));
                                    }
                                }

                                if (isBreak == 0 && points.Count > 0)
                                {
                                    points = Point.PruneDuplicates(points).ToList();

                                    if (points.Count > 1)
                                    {
                                        Utils.Log(string.Format("Points: {0}", points.Count));

                                        pc = PolyCurve.ByPoints(points);
                                        try
                                        {
                                            //ri = Convert.ToInt32(fe.Attributes["RegionIndex"].Value);
                                            ri = this.GetBaselineRegionIndexByStation(Convert.ToDouble(this.GetArrayStationOffsetElevationByPoint(points[points.Count / 2])[0]));
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML RegionIndex {0}", ex.Message));
                                            ri = -1;
                                        }
                                        try
                                        {
                                            side = Convert.ToDouble(fe.Attributes["Side"].Value);
                                        }
                                        catch (Exception ex)
                                        {
                                            Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML Side {0}", ex.Message));
                                            side = 1;
                                        }

                                        output.Add(new Featureline(this, pc, code, side < 0 ? Featureline.SideType.Left : Featureline.SideType.Right, ri));
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML Featureline failed {0}", ex.Message));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.Log(string.Format("ERROR: Baseline.GetFeaturelinesFromXML failed {0}", ex.Message));
                    }
                }

                blFeaturelines = output.OrderBy(f => f.BaselineRegionIndex).GroupBy(f => f.BaselineRegionIndex).Cast <IList <Featureline> >().ToList();
            }
            else
            {
                Utils.Log("ERROR: Failed to locate CorridorFeatureLines.xml in the Temp folder.");
            }

            Utils.Log(string.Format("Baseline.GetFeaturelinesFromXML completed.", ""));

            return(blFeaturelines);
        }
Beispiel #29
0
 public static Autodesk.DesignScript.Geometry.PolyCurve ToProtoType(this Autodesk.Revit.DB.PolyLine geom)
 {
     return(PolyCurve.ByPoints(geom.GetCoordinates().Select(x => Autodesk.DesignScript.Geometry.Point.ByCoordinates(x.X, x.Y, x.Z)).ToArray()));
 }
Beispiel #30
0
        protected override (Curve boundary, List <Curve> holes) CreateBaseCurves()
        {
            Curve boundary = null;

            Point[] points;

            if (IsCurved)
            {
                var holes          = new List <Curve>();
                var boundaryCurves = new List <Curve>();

                var arcHeight = Math.Min(Length, Width / 2);

                using (Plane arcCenter = Plane.ByOriginNormal(
                           Point.ByCoordinates(Width / 2, arcHeight),
                           Vector.ZAxis()))
                {
                    boundaryCurves.Add(EllipseArc.ByPlaneRadiiAngles(arcCenter, Width / 2, arcHeight, 180, 180));

                    if (UsesDepth)
                    {
                        if (arcHeight < Length)
                        {
                            // Top of U has straight parts.
                            points = new[]
                            {
                                Point.ByCoordinates(Width, arcHeight),
                                Point.ByCoordinates(Width, Length),
                                Point.ByCoordinates(Width - Depth, Length),
                                Point.ByCoordinates(Width - Depth, arcHeight)
                            };

                            boundaryCurves.Add(PolyCurve.ByPoints(points));

                            points.ForEach(p => p.Dispose());
                        }
                        else
                        {
                            points = new[]
                            {
                                Point.ByCoordinates(Width, Length),
                                Point.ByCoordinates(Width - Depth, Length)
                            };

                            // Top of U has no straight parts.
                            boundaryCurves.Add(Line.ByStartPointEndPoint(points[0], points[1]));

                            points.ForEach(p => p.Dispose());
                        }

                        boundaryCurves.Add(EllipseArc.ByPlaneRadiiAngles(arcCenter, (Width / 2) - Depth, arcHeight - Depth, 0, -180));

                        if (arcHeight < Length)
                        {
                            // Top of U has straight parts.

                            points = new[]
                            {
                                Point.ByCoordinates(Depth, arcHeight),
                                Point.ByCoordinates(Depth, Length),
                                Point.ByCoordinates(0, Length),
                                Point.ByCoordinates(0, arcHeight)
                            };

                            boundaryCurves.Add(PolyCurve.ByPoints(points));

                            points.ForEach(p => p.Dispose());
                        }
                        else
                        {
                            // Top of U has no straight parts.

                            points = new[]
                            {
                                Point.ByCoordinates(Depth, Length),
                                Point.ByCoordinates(0, Length)
                            };

                            boundaryCurves.Add(Line.ByStartPointEndPoint(points[0], points[1]));

                            points.ForEach(p => p.Dispose());
                        }
                    }
                    else
                    {
                        // U has no interior.

                        if (arcHeight < Length)
                        {
                            points = new[]
                            {
                                Point.ByCoordinates(Width, arcHeight),
                                Point.ByCoordinates(Width, Length),
                                Point.ByCoordinates(0, Length),
                                Point.ByCoordinates(0, arcHeight)
                            };

                            boundaryCurves.Add(PolyCurve.ByPoints(points));

                            points.ForEach(p => p.Dispose());
                        }
                        else
                        {
                            points = new[]
                            {
                                Point.ByCoordinates(Width, Length),
                                Point.ByCoordinates(0, Length)
                            };

                            boundaryCurves.Add(Line.ByStartPointEndPoint(points[0], points[1]));

                            points.ForEach(p => p.Dispose());
                        }
                    }
                }

                boundary = PolyCurve.ByJoinedCurves(boundaryCurves);
            }
            else
            {
                // Straight U

                if (UsesDepth)
                {
                    points = new[]
                    {
                        Point.ByCoordinates(0, 0),
                        Point.ByCoordinates(Width, 0),
                        Point.ByCoordinates(Width, Length),
                        Point.ByCoordinates(Width - Depth, Length),
                        Point.ByCoordinates(Width - Depth, Depth),
                        Point.ByCoordinates(Depth, Depth),
                        Point.ByCoordinates(Depth, Length),
                        Point.ByCoordinates(0, Length)
                    };

                    boundary = PolyCurve.ByPoints(points, connectLastToFirst: true);

                    points.ForEach(p => p.Dispose());
                }
                else
                {
                    // Solid straight U (rectangle)

                    points = new[]
                    {
                        Point.ByCoordinates(0, 0),
                        Point.ByCoordinates(Width, 0),
                        Point.ByCoordinates(Width, Length),
                        Point.ByCoordinates(0, Length)
                    };

                    boundary = PolyCurve.ByPoints(points, connectLastToFirst: true);

                    points.ForEach(p => p.Dispose());
                }
            }

            return(boundary, default);
        }