Example #1
0
        public static EditResult CutSegment(CadObjectDB db, MarkSegment seg, Vector3d p)
        {
            EditResult result = new EditResult();

            if (seg.Figure.Type != CadFigure.Types.POLY_LINES)
            {
                return(result);
            }

            CrossInfo ci = CadMath.PerpendicularCrossSeg(seg.pA.vector, seg.pB.vector, p);

            if (!ci.IsCross)
            {
                return(result);
            }

            CadFigure org = db.GetFigure(seg.FigureID);

            int a = Math.Min(seg.PtIndexA, seg.PtIndexB);
            int b = Math.Max(seg.PtIndexA, seg.PtIndexB);


            CadFigure fa = db.NewFigure(CadFigure.Types.POLY_LINES);
            CadFigure fb = db.NewFigure(CadFigure.Types.POLY_LINES);

            fa.AddPoints(org.PointList, 0, a + 1);
            fa.AddPoint(new CadVertex(ci.CrossPoint));

            fb.AddPoint(new CadVertex(ci.CrossPoint));
            fb.AddPoints(org.PointList, b);

            if (org.IsLoop)
            {
                fb.AddPoint(fa.GetPointAt(0));
            }

            result.AddList.Add(new EditResult.Item(seg.LayerID, fa));
            result.AddList.Add(new EditResult.Item(seg.LayerID, fb));
            result.RemoveList.Add(new EditResult.Item(org.LayerID, org));

            return(result);
        }
Example #2
0
        public override void Redo(CadObjectDB db)
        {
            CadFigure fig = db.GetFigure(FigureID);

            fig.AddPoint(Point);
        }