Exemplo n.º 1
0
        private List <int> DrawPolyline(LwPolyline l)
        {
            var ex = l.Explode();
            var v  = new List <Vector3Middle>();

            var i = 0;

            foreach (var en in ex)
            {
                if (en is Line line)
                {
                    var A = line.StartPoint;
                    var B = line.EndPoint;

                    if (i == 0)
                    {
                        v.Add(new Vector3Middle(A));
                        v.Add(new Vector3Middle(B));
                    }
                    else
                    {
                        var L = v[v.Count - 1].Point;

                        // if the first entity was in wrong orientation
                        if (i == 1 && !L.Equals(A, Math.Pow(10, -8)) && !L.Equals(B, Math.Pow(10, -8)))
                        {
                            ReverseFcsPolyline(v);
                        }

                        // if current entity is in wrong orientation
                        if (!L.Equals(A, Math.Pow(10, -8)))
                        {
                            v.Add(new Vector3Middle(A));
                        }
                        else
                        {
                            v.Add(new Vector3Middle(B));
                        }
                    }
                }

                else if (en is Arc arc)
                {
                    AddArcToArc(arc, i, v);
                }

                i++;
            }

            var Lc = v.Last().Point;

            if (l.IsClosed && !Lc.Equals(v[0].Point, Math.Pow(10, -8)))
            {
                v.Add(v[0]);
            }

            var ids = new List <int>();

            // drawing
            var polyline = new List <Vector3>();

            polyline.Add(v[0].Point);

            for (int j = 1; j < v.Count; j++)
            {
                var cr = v[j];

                if (cr.MiddlePoint == default)
                {
                    polyline.Add(cr.Point);
                }
                else
                {
                    if (polyline.Count > 1)
                    {
                        ids.Add(DrawCurve(polyline));
                    }

                    var A = polyline.Last();
                    var B = cr.Point;
                    var C = cr.MiddlePoint;

                    ids.Add(DrawArc(A, B, C));

                    polyline.Clear();
                    polyline.Add(B);
                }
            }

            if (polyline.Count > 1)
            {
                ids.Add(DrawCurve(polyline));
            }

            return(ids);
        }
Exemplo n.º 2
0
        private void DrawPolyline(LwPolyline l)
        {
            var ex = l.Explode();

            EntitiesToFcs(ex);
        }