Esempio n. 1
0
 public static Loop getMinBoundary(TBPLineSegment startSeg, object userData /*,out List<Point3d> result2*/)
 {
     try
     {
         Loop b = getBoundary(startSeg, userData);
         if (b != null && b.segments.Count == 1)
         {
             return(b);
         }
         if (b != null && b.scanAngle > 0)
         {
             return(b);
         }
         else
         {
             b = getBoundary(startSeg, userData);
             if (b != null && b.scanAngle > 0)
             {
                 return(b);
             }
         }
     }
     catch (System.Exception ex)
     {
     }
     return(null);
 }
Esempio n. 2
0
        public double scanAngle(TBPLineSegment second, TBPoint interPoint)
        {
            Point3d        p1, p2, p3;
            TBPLineSegment s1 = null;
            TBPLineSegment s2 = null;

            if ((interPoint == this.StartPoint) && (this.StartPoint == second.StartPoint))
            {
                s1 = this.newReverse();
                s2 = second;
            }
            else if ((interPoint == this.StartPoint) && (this.StartPoint == second.EndPoint))
            {
                s1 = this.newReverse();
                s2 = second.newReverse();
            }
            else if ((interPoint == this.EndPoint) && (this.EndPoint == second.StartPoint))
            {
                s1 = this;
                s2 = second;
            }
            else if ((interPoint == this.EndPoint) && (this.EndPoint == second.EndPoint))
            {
                s1 = this;
                s2 = second.newReverse();
            }
            p1 = s1.acPline.GetPointAtParameter(this.acPline.EndParam - 1);
            p2 = s1.EndPoint.acPoint;
            p3 = s2.acPline.GetPointAtParameter(1);
            return(AngleUtil.scanAngle(p1, p2, p3));
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        int getIndex(TBPLineSegment seed)
        {
            int r = this.SegmentedPLines.FindIndex(item =>
            {
                if (item == seed)
                {
                    return(true);
                }
                return(false);
            });

            return(r);
        }
Esempio n. 5
0
 public static Loop getClosedBoundary(TBPLine pl, object userData)
 {
     if (pl.acPline.Closed || pl.IsLooped)
     {
         Loop           l    = new Loop();
         TBPLineSegment tbpl = new TBPLineSegment(pl.acPline);
         LoopSeg        ls   = new LoopSeg(tbpl, LineDirection.positive);
         l.segments.Add(ls);
         l.startPoint = tbpl.StartPoint;
         l.userData   = userData;
         return(l);
     }
     return(null);
 }
Esempio n. 6
0
        public TBPLineSegment newReverse()
        {
            Point3dCollection ps = new Point3dCollection();

            for (int i = (int)this.acPline.EndParam; i >= 0; i--)
            {
                ps.Add(this.acPline.GetPointAtParameter(i));
            }
            TBPLineSegment newSeg = new TBPLineSegment(new Polyline3d(Poly3dType.SimplePoly, ps, false), this.endPoint, this.startPoint);

            //newSeg.StartPoint = this.EndPoint;
            //newSeg.EndPoint = this.StartPoint;
            return(newSeg);
        }
Esempio n. 7
0
 public LoopSeg(TBPLineSegment seg, TBPoint startP)
 {
     segment = seg;
     if (startP == seg.StartPoint)
     {
         direction = LineDirection.positive;
     }
     else if (startP == seg.EndPoint)
     {
         direction = LineDirection.negtive;
     }
     else
     {
         throw new System.Exception("BoundarySeg.cs 39");
     }
 }
Esempio n. 8
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");
     }
 }
Esempio n. 9
0
        public List <Point3d> getInnerPoints(TBPoint startp)
        {
            TBPLineSegment seg = this;

            if (startp == this.StartPoint)
            {
            }
            else if (startp == this.EndPoint)
            {
                seg = this.newReverse();
            }
            else
            {
                return(null);
            }
            return(seg.getInnerPoints());
        }
Esempio n. 10
0
 public TBPoint getIntersectPoint(TBPLineSegment second)
 {
     if (this.StartPoint == second.StartPoint)
     {
         return(this.StartPoint);
     }
     else if (this.StartPoint == second.EndPoint)
     {
         return(this.StartPoint);
     }
     else if (this.EndPoint == second.StartPoint || this.EndPoint == second.EndPoint)
     {
         return(this.EndPoint);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 11
0
        public TBPLineSegment nextSegment(TBPLineSegment seg)
        {
            int index = getIndex(seg);

            if (index < 0)
            {
                throw new System.Exception("TBPoint 51.index<0");
            }
            int previousIndex = -1;

            if (index == 0)
            {
                previousIndex = this.SegmentedPLines.Count - 1;
            }
            else
            {
                previousIndex = index - 1;
            }
            return(this.SegmentedPLines[previousIndex]);
        }
Esempio n. 12
0
        public static Loop getMaxBoundary(TBPLineSegment startSeg, object userData)
        {
            Loop b = getBoundary(startSeg, userData);

            if (b != null && b.segments.Count == 1)
            {
                return(b);
            }
            if (b != null && b.scanAngle < 0)
            {
                return(b);
            }
            else
            {
                b = getBoundary(startSeg, userData);
                if (b != null && b.scanAngle < 0)
                {
                    return(b);
                }
            }
            return(null);
        }
Esempio n. 13
0
        public void divide()
        {
            this.SegmentedPlines = new List <TBPLineSegment>();
            ObjectId layerId = My.LayerUtil.CreateLayer("segment", 255, false);

            try
            {
                Document acDoc   = Application.DocumentManager.MdiActiveDocument;
                Database acCurDb = acDoc.Database;

                /*using (Transaction tran = acCurDb.TransactionManager.StartTransaction())
                 * {
                 *  BlockTable bt = tran.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                 *  BlockTableRecord modelSpace = tran.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;*/
                if (intersectPoints.Count <= 0)
                {
                    return;
                }
                for (int i = 0; i < intersectPoints.Count - 1; i++)
                {
                    TBPoint p1 = intersectPoints[i];
                    TBPoint p2 = intersectPoints[i + 1];

                    Point3dCollection vertexes = new Point3dCollection();
                    //My.MyDBUtility.addPolyline3d(segmentedPl, layerId);
                    //ObjectId oid = modelSpace.AppendEntity(segmentedPl);
                    //tran.AddNewlyCreatedDBObject(segmentedPl, true);
                    vertexes.Add(p1.acPoint);
                    //segmentedPl.AppendVertex(vertex);
                    int n           = 0;
                    int vertexCount = 1;
                    while (true)
                    {
                        double nextP;
                        if (Math.Ceiling(p1.TempParam) - p1.TempParam < 1e-10)
                        {
                            nextP = Math.Ceiling(p1.TempParam) + (++n);
                        }
                        else
                        {
                            nextP = Math.Ceiling(p1.TempParam) + (n++);
                        }

                        if (nextP - p2.TempParam > 1e-10)
                        {
                            break;
                        }
                        else if (Math.Abs(nextP - p2.TempParam) <= 1e-10)
                        {
                            break;
                        }
                        //segmentedPl.AppendVertex(new PolylineVertex3d(acPline.GetPointAtParameter(nextP)));
                        vertexes.Add(acPline.GetPointAtParameter(nextP));
                        vertexCount++;
                    }
                    //segmentedPl.AppendVertex(new PolylineVertex3d(p2.acPoint));
                    vertexes.Add(p2.acPoint);
                    vertexCount++;

                    if (vertexCount >= 2)
                    {
                        Polyline3d     segmentedPl = new Polyline3d(Poly3dType.SimplePoly, vertexes, false);
                        TBPLineSegment tbpline     = new TBPLineSegment(segmentedPl, p1, p2);
                        //tbpline.StartPoint = p1;
                        //tbpline.EndPoint = p2;
                        this.SegmentedPlines.Add(tbpline);
                        //p1.SegmentedPLines.Add(tbpline);
                        //p2.SegmentedPLines.Add(tbpline);
                        p1.addSegment(tbpline);
                        p2.addSegment(tbpline);
                    }
                }
                if (this.isClosed || this.IsLooped)
                {
                    TBPoint p1 = intersectPoints[intersectPoints.Count - 1];

                    Point3dCollection vertexes = new Point3dCollection();
                    vertexes.Add(p1.acPoint);

                    My.PolylineUtil.getPointsBetween2Point(acPline, p1.TempParam, acPline.EndParam, vertexes);
                    vertexes.Add(acPline.StartPoint);

                    TBPoint p2 = intersectPoints[0];
                    My.PolylineUtil.getPointsBetween2Point(acPline, 0, p2.TempParam, vertexes);
                    vertexes.Add(p2.acPoint);

                    if (vertexes.Count >= 2)
                    {
                        Polyline3d     segmentedPl = new Polyline3d(Poly3dType.SimplePoly, vertexes, false);
                        TBPLineSegment tbpline     = new TBPLineSegment(segmentedPl, p1, p2);
                        this.SegmentedPlines.Add(tbpline);
                        p1.addSegment(tbpline);
                        p2.addSegment(tbpline);
                    }
                }


                //tran.Commit();
                //}
            }
            catch (System.Exception ex)
            {
            }
        }
Esempio n. 14
0
 public void addSegment(TBPLineSegment seg)
 {
     segmentedPLines.Add(seg);
 }
Esempio n. 15
0
 public LoopSeg(TBPLineSegment seg, LineDirection dir)
 {
     segment   = seg;
     direction = dir;
 }