Ejemplo n.º 1
0
        public static Loop getBoundary(TBPLineSegment startSeg, object userData)
        {
            Editor ed         = Application.DocumentManager.MdiActiveDocument.Editor;
            Loop   resultLoop = new Loop();

            resultLoop.userData = userData;
            List <LoopSeg> loopSegs = resultLoop.segments;
            //result2 = new List<Point3d>();
            //result.Add(startSeg);
            double         scanAngle   = 0;
            TBPLineSegment previousSeg = startSeg;
            TBPoint        startPoint;
            TBPoint        nextp = startSeg.nextPoint(out startPoint);

            if (nextp == null)
            {
                return(null);
            }
            scanAngle += startSeg.scanAngle(startPoint);
            //result2.Add(startPoint.acPoint);
            loopSegs.Add(new LoopSeg(startSeg, startPoint));
            resultLoop.startPoint = startPoint;
            while (nextp != null)
            {
                TBPLineSegment nextSeg = nextp.nextSegment(previousSeg);
                if (nextSeg == startSeg)
                {
                    throw new System.Exception("TraceBoundary 39");
                }
                scanAngle += nextSeg.scanAngle(nextp);
                scanAngle += previousSeg.scanAngle(nextSeg, nextp);
                loopSegs.Add(new LoopSeg(nextSeg, nextp));
                nextp = nextSeg.nextPoint(nextp);
                if (nextp == null)
                {
                    return(null);
                    //throw new System.Exception("TraceBoundary 44");
                }
                previousSeg = nextSeg;
                if (nextp == startPoint)
                {
                    scanAngle += previousSeg.scanAngle(startSeg, startPoint);
                    break;
                }
            }
            resultLoop.scanAngle = scanAngle;
            if (resultLoop.segments.Count <= 1)
            {
            }
            if (scanAngle <= 0)
            {
                ed.WriteMessage("\nangle:" + scanAngle + "\n" + startSeg.toString());
            }
            return(resultLoop);
        }
Ejemplo n.º 2
0
 public double scanAngle(TBPoint startp)
 {//闭合情况下,没有计算末尾到开始的角度
     if (startp == this.StartPoint)
     {
         return(this.scanAngle());
     }
     else if (startp == this.EndPoint)
     {
         TBPLineSegment reverse = this.newReverse();
         return(reverse.scanAngle());
     }
     else
     {
         throw new System.Exception("TBPLineSegment 69");
     }
 }