Exemplo n.º 1
0
    candidatePointInfo getCandidateConvexPoint(zz2DPoint lPointToSolve)
    {
        candidatePointInfo lCandidatePointInfo=new candidatePointInfo();
        PointIterator lConvexIterator = new PointIterator();
        lConvexIterator.addPolygon(mOutSidePoint.getConvexPoints());
        foreach (var lHole in mHolePoint)
        {
            lConvexIterator.addPolygon(lHole.getConvexPoints());
        }

        while (lConvexIterator.moveNext() != null)
        {
            zz2DPoint lNowPoint = lConvexIterator.nowPointDate.point;
            if (canLink(lPointToSolve, lNowPoint))
            {

                var lNewCandidatePointInfo = new candidatePointInfo(lConvexIterator.nowPointDate);
                lNewCandidatePointInfo.scoresUp();

                if (isConcaveCleared(lPointToSolve, lNowPoint))
                {
                    lNewCandidatePointInfo.scoresUp(candidatePointInfo.scoresOfClearSelfConcave);
                }

                if (lNewCandidatePointInfo.scores > lCandidatePointInfo.scores)
                    lCandidatePointInfo = lNewCandidatePointInfo;

                if (lCandidatePointInfo.scores
                    > candidatePointInfo.scoresOfClearSelfConcave)
                    break;

            }
        }
        return lCandidatePointInfo;
    }
Exemplo n.º 2
0
    candidatePointInfo getCandidateConcavePoint(out PointDate lPointDataToSolve)
    {
        var lCandidatePointInfo = new candidatePointInfo();

        PointIterator lConcaveIterator = new PointIterator();
        lConcaveIterator.addPolygon(mOutSidePoint.getConcavePoints());
        foreach (var lHole in mHolePoint)
        {
            lConcaveIterator.addPolygon(lHole.getConcavePoints());
        }

        lPointDataToSolve = lConcaveIterator.moveNext();
        //if(lPointDataToSolve==null)
        //{
        //    //无凹点,返回自身所有的点
        //    return new zzSimplyPolygon[] { mOutSidePoint };
        //}

        zz2DPoint lPointToSolve = lPointDataToSolve.point;

        //遍历凹点
        while (lConcaveIterator.moveNext() != null)
        {
            zz2DPoint lNowPoint = lConcaveIterator.nowPointDate.point;
            if (canLink(lPointToSolve, lNowPoint))
            {

                var lNewCandidatePointInfo = new candidatePointInfo(lConcaveIterator.nowPointDate);
                lNewCandidatePointInfo.scoresUp();

                //对结果评分
                if (isConcaveCleared(lPointToSolve, lNowPoint))
                {
                    lNewCandidatePointInfo.scoresUp(candidatePointInfo.scoresOfClearSelfConcave);
                }

                if (isConcaveCleared(lNowPoint, lPointToSolve))
                {
                    lNewCandidatePointInfo.scoresUp(candidatePointInfo.scoresOfClearOtherConcave);
                }

                //优于前次结果,则替代之前的
                if (lNewCandidatePointInfo.scores > lCandidatePointInfo.scores)
                    lCandidatePointInfo = lNewCandidatePointInfo;

                //连接获得高分时,则不再遍历
                if (lCandidatePointInfo.scores
                    > candidatePointInfo.scoresOfClearSelfConcave + candidatePointInfo.scoresOfClearOtherConcave)
                    break;

            }
        }
        return lCandidatePointInfo;
    }