コード例 #1
0
        public bool calcSegment()
        {
            TBPoint.allPoints.Clear();
            resetBoundarires();
            resetContours();
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            if (this.contours.Count <= 0)
            {
                ed.WriteMessage("this.contours.Count <= 0");
                return(false);
            }
            if (this.originalBoundarys.Count <= 0)
            {
                ed.WriteMessage("this.originalBoundarys.Count <= 0");
                return(false);
            }
            for (int i = 0; i < this.contours.Count; i++)
            {
                try
                {
                    TBPLine contour = this.contours[i].tbPLine;
                    if (contour.isClosed)
                    {
                        continue;
                    }
                    for (int j = 0; j < originalBoundarys.Count; j++)
                    {
                        TBPLine boundary = originalBoundarys[j];
                        contour.calcIntersection(boundary);
                    }
                    if (contour.intersectPoints.Count == 1)
                    {
                        if (PointUtil.equal2(contour.intersectPoints[0].acPoint, contour.acPline.StartPoint))
                        {
                            contour.intersectPoints.Add(TBPoint.getNewTBPoint(contour.acPline.EndPoint));
                        }
                        else
                        {
                            contour.intersectPoints.Add(TBPoint.getNewTBPoint(contour.acPline.StartPoint));
                        }
                    }
                    contour.sortPoints();
                    contour.divide();
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage("125 i:" + i + "," + ex.Message);
                }
                //ed.WriteMessage(" " + i);
            }
            for (int j = 0; j < originalBoundarys.Count; j++)
            {
                TBPLine b = originalBoundarys[j];
                b.sortPoints();
                b.divide();
            }
            for (int n = 0; n < TBPoint.allPoints.Count; n++)
            {
                TBPoint.allPoints[n].sort();
            }
            return(true);
        }