Esempio n. 1
0
        // 高さが0の場合、移動方向が定まらないので
        // 投影座標系でz=0とした座標から,List[0] - List[1]への垂線を計算して
        // そこへ移動する
        private void MoveSelectedPointWithHeight(DrawContext dc, Vector3d delta)
        {
            CadSegment seg = CadUtil.PerpSeg(PointList[0], PointList[1],
                                             StoreList[2] + delta);

            PointList[2] = PointList[2].SetVector(seg.P1.vector);
            PointList[3] = PointList[3].SetVector(seg.P0.vector);
        }
Esempio n. 2
0
        public override CadSegment GetSegmentAt(int n)
        {
            CadSegment seg = default;

            seg.P0 = mPointList[SegList[n].Idx0];
            seg.P1 = mPointList[SegList[n].Idx1];

            return(seg);
        }
Esempio n. 3
0
        public override void EndCreate(DrawContext dc)
        {
            if (PointList.Count < 3)
            {
                return;
            }

            CadSegment seg = CadUtil.PerpSeg(PointList[0], PointList[1], PointList[2]);

            PointList[2] = PointList[2].SetVector(seg.P1.vector);
            PointList.Add(seg.P0);
        }
Esempio n. 4
0
        public override void EndEdit()
        {
            base.EndEdit();

            if (PointList.Count == 0)
            {
                return;
            }

            CadSegment seg = CadUtil.PerpSeg(PointList[0], PointList[1], PointList[2]);

            PointList[2] = PointList[2].SetVector(seg.P1.vector);
            PointList[3] = PointList[3].SetVector(seg.P0.vector);
        }
Esempio n. 5
0
        //
        // 点pを通り、a - b に平行で、a-bに垂直な線分を求める
        //
        //   +----------p------------+
        //   |                       |
        //   |                       |
        //   a                       b
        //
        public static CadSegment PerpSeg(CadVertex a, CadVertex b, CadVertex p)
        {
            CadSegment seg = default(CadSegment);

            seg.P0 = a;
            seg.P1 = b;

            CrossInfo ci = CadMath.PerpCrossLine(a.vector, b.vector, p.vector);

            if (ci.IsCross)
            {
                CadVertex nv = p - ci.CrossPoint;

                seg.P0 += nv;
                seg.P1 += nv;
            }

            return(seg);
        }
Esempio n. 6
0
        private void DrawDim(
            DrawContext dc,
            CadVertex a,
            CadVertex b,
            CadVertex p,
            DrawPen pen)
        {
            CadSegment seg = CadUtil.PerpSeg(a, b, p);

            dc.Drawing.DrawLine(pen, a.vector, seg.P0.vector);
            dc.Drawing.DrawLine(pen, b.vector, seg.P1.vector);

            Vector3d cp = CadMath.CenterPoint(seg.P0.vector, seg.P1.vector);

            double arrowW = ARROW_W;
            double arrowL = ARROW_LEN;

            dc.Drawing.DrawArrow(pen, cp, seg.P0.vector, ArrowTypes.CROSS, ArrowPos.END, arrowL, arrowW);
            dc.Drawing.DrawArrow(pen, cp, seg.P1.vector, ArrowTypes.CROSS, ArrowPos.END, arrowL, arrowW);
        }
Esempio n. 7
0
        void CheckFig(CadLayer layer, CadFigure fig)
        {
            int n = fig.PointCount;

            for (int i = 0; i < n; i++)
            {
                CadVertex cp = fig.PointList[i];

                CadVertex p = DC.WorldPointToDevPoint(cp);

                CadVertex d = p - TargetPoint;

                double dist = d.Norm2D();

                if (dist > Range)
                {
                    continue;
                }

                Result res = new ResultPoint(cp, dist, fig, i);
                ResultList.Add(res);
            }

            //
            // Create segment list that in range.
            // And check center point of segment
            //
            // 範囲内の線分リスト作成
            // ついでに中点のチェックも行う
            //

            n = fig.SegmentCount;

            for (int i = 0; i < n; i++)
            {
                CadSegment seg = fig.GetSegmentAt(i);

                CadVertex pw = (seg.P1 - seg.P0) / 2 + seg.P0;
                CadVertex ps = DC.WorldPointToDevPoint(pw);

                double dist = (ps - TargetPoint).Norm2D();

                if (dist <= Range)
                {
                    Result res = new ResultSegCenter(pw, dist, fig, i);
                    ResultList.Add(res);
                }

                CadVertex p0 = DC.WorldPointToDevPoint(seg.P0);
                CadVertex p1 = DC.WorldPointToDevPoint(seg.P1);

                double d = CadMath.DistancePointToSeg(p0.vector, p1.vector, TargetPoint.vector);

                if (d > Range)
                {
                    continue;
                }

                SegmentItem segItem = new SegmentItem();

                segItem.Layer      = layer;
                segItem.Fig        = fig;
                segItem.SegIndex   = i;
                segItem.ScrSegment = new CadSegment(p0, p1);

                SegList.Add(segItem);
            }
        }