Ejemplo n.º 1
0
        private void CheckFigPoint(DrawContext dc, Vector3d pt, CadLayer layer, CadFigure fig, int ptIdx)
        {
            Vector3d ppt = dc.WorldPointToDevPoint(pt);

            double dx = Math.Abs(ppt.X - Target.Pos.X);
            double dy = Math.Abs(ppt.Y - Target.Pos.Y);

            CrossInfo cix = CadMath.PerpCrossLine(Target.Pos, Target.Pos + Target.DirX, ppt);
            CrossInfo ciy = CadMath.PerpCrossLine(Target.Pos, Target.Pos + Target.DirY, ppt);

            double nx = (ppt - ciy.CrossPoint).Norm(); // Cursor Y軸からの距離
            double ny = (ppt - cix.CrossPoint).Norm(); // Cursor X軸からの距離

            if (nx <= Range)
            {
                if (nx < XMatch.DistanceX || (nx == XMatch.DistanceX && ny < XMatch.DistanceY))
                {
                    XMatch = GetMarkPoint(pt, ppt, nx, ny, layer, fig, ptIdx);
                }
            }

            if (ny <= Range)
            {
                if (ny < YMatch.DistanceY || (ny == YMatch.DistanceY && nx < YMatch.DistanceX))
                {
                    YMatch = GetMarkPoint(pt, ppt, nx, ny, layer, fig, ptIdx);
                }
            }

            if (dx <= Range && dy <= Range)
            {
                double minDist = (XYMatch.DistanceX * XYMatch.DistanceX) + (XYMatch.DistanceY * XYMatch.DistanceY);
                double curDist = (dx * dx) + (dy * dy);

                if (curDist <= minDist)
                {
                    MarkPoint t = GetMarkPoint(pt, ppt, dx, dy, layer, fig, ptIdx);

                    //t.dump();

                    XYMatch = t;

                    if (!XYMatchSet.Contains(t))
                    {
                        XYMatchList.Add(XYMatch);
                        XYMatchSet.Add(XYMatch);
                        //DOut.pl($"PointSearcher XYMatchList cnt:{XYMatchList.Count}");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private MarkPoint GetMarkPoint(
            Vector3d pt, Vector3d ppt, double distx, double disty, CadLayer layer, CadFigure fig, int ptIdx)
        {
            MarkPoint mp = default;

            mp.IsValid    = true;
            mp.Layer      = layer;
            mp.Figure     = fig;
            mp.PointIndex = ptIdx;
            mp.Point      = pt;
            mp.PointScrn  = ppt;
            mp.DistanceX  = distx;
            mp.DistanceY  = disty;

            return(mp);
        }
Ejemplo n.º 3
0
        public void Set(MarkPoint mkp)
        {
            CadFigure fig        = mkp.Figure;
            int       pointIndex = mkp.PointIndex;

            int cnt = fig.PointList.Count;

            if (cnt < 2)
            {
                return;
            }

            if (!fig.IsLoop)
            {
                if (pointIndex == cnt - 1)
                {
                    Ruler[RCount] = CadRuler.Create(fig, pointIndex - 1, pointIndex);
                    RCount++;
                    return;
                }
                else if (pointIndex == 0)
                {
                    Ruler[RCount] = CadRuler.Create(fig, 1, 0);
                    RCount++;
                    return;
                }
            }

            int idx0;
            int idx1;

            idx0 = (pointIndex + cnt - 1) % cnt;
            idx1 = pointIndex;

            Debug.Assert(idx0 >= 0 && idx0 < cnt);

            Ruler[RCount] = CadRuler.Create(fig, idx0, idx1);
            RCount++;

            idx0 = (pointIndex + 1) % cnt;
            idx1 = pointIndex;

            Debug.Assert(idx0 >= 0 && idx0 < cnt);

            Ruler[RCount] = CadRuler.Create(fig, idx0, idx1);
            RCount++;
        }