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); } }