Example #1
0
        public int LoadLinesData()
        {
            Lines.Clear();
            LinesDict.Clear();
            int res = 0;

            using (var trans = Ac.StartTransaction())
            {
                var acLines = trans.GetAllEntities <Line>();
                Ac.InitProgress(AppServices.Strings.LoadingLines, acLines.Count());
                foreach (var acLn in acLines)
                {
                    if (acLn.Length < 0.000001)
                    {
                        continue;
                    }
                    var ln    = new AcPolygonSegment(acLn);
                    var lnRev = ln.Reverse();

                    Lines.Add(ln);
                    LinesDict.AddListItem(ln.StartPoint.Id(), ln);

                    // Trzeba dodać odwrotną linię, bo nie zawsze startPoint jest
                    // z tej strony, z której bym chciał
                    Lines.Add(lnRev);
                    LinesDict.AddListItem(lnRev.StartPoint.Id(), lnRev);


                    res++;
                    Ac.SetProgress(res);
                }
                Ac.ClearProgress();
            }
            return(res);
        }
Example #2
0
        private List <AcPolygonSegment> GetEndPointLines(AcPolygonSegment currentSegment)
        {
            List <AcPolygonSegment> res = new List <AcPolygonSegment>();
            string endPointId           = currentSegment.EndPoint.Id();
            var    endPointLines        = LinesDict.GetList(endPointId);

            foreach (var ln in endPointLines)
            {
                // Usuń linie, które są takie same jak currentSegment
                if (ln.Id == currentSegment.Id)
                {
                    continue;
                }
                if (ln.Reverse().Id == currentSegment.Id)
                {
                    continue;
                }
                res.Add(ln);
            }
            return(res);
        }
Example #3
0
        private AcPolygonSegment GetNextLine(List <AcPolygonSegment> lines, AcPolygonSegment currentSegment)
        {
            Angle azimuth0 = currentSegment.Azimuth - new Angle(180, 0, 0);

            // UpdateTempAzimuths
            foreach (var ln in lines)
            {
                ln.TempAzimuth = ln.Azimuth - azimuth0;
            }

            // Get Next Line, TempAzimuth = Max
            AcPolygonSegment nextLine = lines.First();

            foreach (var ln in lines)
            {
                if (ln.TempAzimuth.AsRad > nextLine.TempAzimuth.AsRad)
                {
                    nextLine = ln;
                }
            }
            return(nextLine);
        }
Example #4
0
        private bool BuildPolygon(Polyline polyline, Point2d startPoint, AcPolygonSegment currentSegment)
        {
            if (currentSegment.EndPoint.Id() == startPoint.Id())
            {
                return(true);
            }
            // Nie dodawaj ostatniego zdublowanego wertexu, bo potem przy zmianie początku polilini ID się nie zgadzają

            polyline.AddVertex(currentSegment.EndPoint);

            var endPointLines = GetEndPointLines(currentSegment);

            if (endPointLines.Count < 1)
            {
                return(false);
            }



            AcPolygonSegment nextLine = GetNextLine(endPointLines, currentSegment);

            return(BuildPolygon(polyline, startPoint, nextLine));
        }