コード例 #1
0
        public override double Distance(MbeGapChkObj gapObj, out Point chkPoint)
        {
            double dist = Int32.MaxValue;

            chkPoint = new Point(0, 0);
            switch (gapObj.Shape())
            {
            case MbeGapChkShape.LINE:
                dist = Util.DistancePointLine(pt,
                                              ((MbeGapChkObjLine)gapObj).p0, ((MbeGapChkObjLine)gapObj).p1,
                                              out chkPoint);
                dist -= (dia + ((MbeGapChkObjLine)gapObj).lineWidth) / 2;
                break;

            case MbeGapChkShape.POINT:
                dist = Util.DistancePointPoint(pt,
                                               ((MbeGapChkObjPoint)gapObj).pt,
                                               out chkPoint);
                dist -= (dia + ((MbeGapChkObjPoint)gapObj).dia) / 2;
                break;

            case MbeGapChkShape.RECTANGLE:
                dist = Util.DistanceRectPoint(((MbeGapChkObjRect)gapObj).rc,
                                              pt,
                                              out chkPoint);
                dist -= dia / 2;
                break;
            }
            if (dist < 0)
            {
                dist = 0;
            }
            return(dist);
        }
コード例 #2
0
        /// <summary>
        /// 線からの距離が設定値より近いかどうかの判定。
        /// </summary>
        /// <param name="gapObj"></param>
        /// <param name="chkPoint"></param>
        /// <returns></returns>
        /// <remarks>Polygonの更新時に使うために軽量化を目指す</remarks>
        public override bool IsCloseTo(MbeGapChkObj gapObj, int limit)
        {
            //Point chkPoint;
            //double dist = 3000000;
            int nDist;

            //chkPoint = new Point(0, 0);
            switch (gapObj.Shape())
            {
            case MbeGapChkShape.LINE:
                nDist = limit + (lineWidth + ((MbeGapChkObjLine)gapObj).lineWidth) / 2;
                return(Util.LineIsCloseToLine(p0, p1,
                                              ((MbeGapChkObjLine)gapObj).p0, ((MbeGapChkObjLine)gapObj).p1,
                                              nDist));

            //dist = Util.DistanceLineLine(p0, p1,
            //                            ((MbeGapChkObjLine)gapObj).p0, ((MbeGapChkObjLine)gapObj).p1,
            //                            out chkPoint);
            //dist -= (lineWidth + ((MbeGapChkObjLine)gapObj).lineWidth) / 2;
            //break;
            case MbeGapChkShape.POINT:
                nDist = limit + (lineWidth + ((MbeGapChkObjPoint)gapObj).dia) / 2;
                return(Util.PointIsCloseToLine(((MbeGapChkObjPoint)gapObj).pt,
                                               p0, p1,
                                               nDist));

            //dist = Util.DistancePointLine(((MbeGapChkObjPoint)gapObj).pt,
            //                            p0, p1,
            //                            out chkPoint);
            //dist -= (lineWidth + ((MbeGapChkObjPoint)gapObj).dia) / 2;
            //break;
            case MbeGapChkShape.RECTANGLE:
                nDist = limit + lineWidth / 2;

                return(Util.LineIsCloseToRect(((MbeGapChkObjRect)gapObj).rc,
                                              p0, p1, nDist));

                //dist = Util.DistanceRectLine(((MbeGapChkObjRect)gapObj).rc,
                //                            p0, p1,
                //                            out chkPoint);
                //dist -= lineWidth / 2;
                //break;
            }
            return(false);
        }
コード例 #3
0
        public override bool IsCloseTo(MbeGapChkObj gapObj, int limit)
        {
            int nDist;

            //double dist = Int32.MaxValue;
            //chkPoint = new Point(0,0);
            switch (gapObj.Shape())
            {
            case MbeGapChkShape.LINE:
                nDist = limit + (dia + ((MbeGapChkObjLine)gapObj).lineWidth) / 2;
                return(Util.PointIsCloseToLine(pt,
                                               ((MbeGapChkObjLine)gapObj).p0, ((MbeGapChkObjLine)gapObj).p1,
                                               nDist));

            //dist = Util.DistancePointLine(pt,
            //                            ((MbeGapChkObjLine)gapObj).p0,((MbeGapChkObjLine)gapObj).p1,
            //                            out chkPoint);
            //dist -= (dia + ((MbeGapChkObjLine)gapObj).lineWidth)/2;
            //break;
            case MbeGapChkShape.POINT:
                nDist = limit + (dia + ((MbeGapChkObjPoint)gapObj).dia) / 2;
                return(Util.PointIsCloseToPoint(pt,
                                                ((MbeGapChkObjPoint)gapObj).pt,
                                                nDist));

            //dist = Util.DistancePointPoint(pt,
            //                            ((MbeGapChkObjPoint)gapObj).pt,
            //                            out chkPoint);
            //dist -= (dia+((MbeGapChkObjPoint)gapObj).dia)/2;
            //break;
            case MbeGapChkShape.RECTANGLE:
                nDist = limit + dia / 2;
                return(Util.PointIsCloseToRect(((MbeGapChkObjRect)gapObj).rc,
                                               pt,
                                               nDist));
                //dist = Util.DistanceRectPoint(((MbeGapChkObjRect)gapObj).rc,
                //                                pt,
                //                                out chkPoint);
                //dist -= dia/2;
                //break;
            }
            return(false);
        }
コード例 #4
0
        public override bool IsCloseTo(MbeGapChkObj gapObj, int limit)
        {
            int nDist;

            //double dist = Int32.MaxValue; //3000000;
            //chkPoint = new Point(0,0);
            switch (gapObj.Shape())
            {
            case MbeGapChkShape.LINE:
                nDist = limit + ((MbeGapChkObjLine)gapObj).lineWidth / 2;
                return(Util.LineIsCloseToRect(rc, ((MbeGapChkObjLine)gapObj).p0, ((MbeGapChkObjLine)gapObj).p1, nDist));

            //dist = Util.DistanceRectLine(rc,
            //                        ((MbeGapChkObjLine)gapObj).p0,((MbeGapChkObjLine)gapObj).p1,
            //                        out chkPoint);
            //dist -= ((MbeGapChkObjLine)gapObj).lineWidth/2;
            //break;
            case MbeGapChkShape.POINT:
                nDist = limit + ((MbeGapChkObjPoint)gapObj).dia / 2;
                return(Util.PointIsCloseToRect(rc, ((MbeGapChkObjPoint)gapObj).pt, nDist));

            //dist = Util.DistanceRectPoint(rc,
            //                            ((MbeGapChkObjPoint)gapObj).pt,
            //                            out chkPoint);
            //dist -= ((MbeGapChkObjPoint)gapObj).dia/2;
            //break;
            case MbeGapChkShape.RECTANGLE:
                nDist = limit;
                return(Util.RectIsCloseToRect(rc,
                                              ((MbeGapChkObjRect)gapObj).rc,
                                              nDist));
                //dist = Util.DistanceRectRect(rc,
                //                            ((MbeGapChkObjRect)gapObj).rc,
                //                            out chkPoint);
                //break;
            }
            return(false);
            //if(dist<0) dist = 0;
            //return dist;
        }
コード例 #5
0
 public abstract bool IsCloseTo(MbeGapChkObj gapObj, int limit);
コード例 #6
0
 public abstract double Distance(MbeGapChkObj gapObj, out Point chkPoint);
コード例 #7
0
 public void Add(MbeGapChkObj obj)
 {
     chkObjLList.AddLast(obj);
 }