Beispiel #1
0
 public IsoBlock(InitialPt ip, double ar)
 {
     this.BasePt      = ip.Pt;
     this.WidthLine   = ip.MainAxis;
     this.widthVec    = WidthLine.UnitTangent;
     this.HeightLine  = ip.SubAxis;
     this.heightVec   = HeightLine.UnitTangent;
     this.aspectRatio = ar;
 }
Beispiel #2
0
            public InitialPt NextInitialPt()
            {
                Point3d   nextBase = BasePt + heightVec * Height;
                InitialPt nextInit = new InitialPt(nextBase, widthVec, heightVec);

                nextInit.MainAxis = new Line(nextBase, nextBase + WidthLine.UnitTangent * Width);
                nextInit.SubAxis  = new Line(nextBase, HeightLine.To);
                Line subCandidate = nextInit.SubAxis;

                if (subCandidate.Length != 0 && subCandidate.UnitTangent == -heightVec)
                {
                    nextInit.SubAxis = new Line(nextBase, nextBase);
                }

                return(nextInit);
            }
        /// <summary>
        /// 지정한 벡터를 좌표 평면 기준으로 해서 가장긴 PCX라인들을 축으로 잡습니다.
        /// </summary>
        public Isothetic DrawStrict(Point3d basePt, Vector3d axis, Vector3d perpAxis)
        {
            InitialPt strictInit = new InitialPt(basePt, axis, perpAxis);

            strictInit.SetMainAxisForStrict(boundary);

            List <IsoBlock> maxBlocks = SearchLocalMaxIso(strictInit, ConcaveCount, true);

            if (maxBlocks.Count == 0)
            {
                return(null);
            }

            Isothetic strictIso = BakeIso(maxBlocks);

            return(strictIso);
        }
        /// <summary>
        /// 지정한 라인을 축으로 기준점애서 최대내접 다각형을 그립니다.
        /// </summary>
        public Isothetic DrawStrict(Point3d basePt, Line longAxis, Line shortAxis)
        {
            InitialPt superInit = new InitialPt(basePt, longAxis.UnitTangent, shortAxis.UnitTangent);

            superInit.MainAxis = longAxis;
            superInit.SubAxis  = shortAxis;

            List <IsoBlock> maxBlocks = SearchLocalMaxIso(superInit, ConcaveCount, true);

            if (maxBlocks.Count == 0)
            {
                return(null);
            }

            Isothetic strictIso = BakeIso(maxBlocks);

            return(strictIso);
        }
        private List <IsoBlock> SearchLocalMaxIso(InitialPt initial, int concaveCount, bool isInitialPhase)
        {
            List <IsoBlock> bestBlocksL = new List <IsoBlock>();
            double          bestAreaL   = 0;

            foreach (double ratio in aspectRatio)
            {
                List <IsoBlock> tempBlocks = new List <IsoBlock>();

                IsoBlock tempBlock = new IsoBlock(initial, ratio);
                tempBlock.Inflate(boundary, boundCrv, minLength, !isInitialPhase);

                if (tempBlock.Area <= 0)
                {
                    continue;
                }

                if (concaveCount == 0)
                {
                    tempBlocks.Add(tempBlock);
                }

                else
                {
                    tempBlocks.Add(tempBlock);
                    tempBlocks.AddRange(SearchLocalMaxIso(tempBlock.NextInitialPt(), concaveCount - 1, false));
                }

                double tempArea = 0;
                tempBlocks.ForEach(n => tempArea += n.Area);

                if (tempArea > bestAreaL)
                {
                    bestBlocksL = tempBlocks;
                    bestAreaL   = tempArea;
                }
            }

            return(bestBlocksL);
        }