private List <InitialPt> FindFootOfPerp(Line perpBase, Vector3d perpDirection, AngleTagVertex perpStart, bool perpInvert)
            {
                List <InitialPt> footOfPerps = new List <InitialPt>();

                if (!VectorTools.IsBetweenVector(perpStart.PreVec, perpStart.PostVec, perpDirection))
                {
                    return(footOfPerps);
                }

                Line    crossLay    = new Line(perpStart.Pt, perpStart.Pt + perpDirection);
                Point3d crossOnBase = CCXTools.GetCrossPt(perpBase, crossLay);

                if (crossOnBase == Point3d.Unset || boundCrv.Contains(crossOnBase) == PointContainment.Outside)
                {
                    return(footOfPerps);
                }

                Polyline perpLinePoly = new Polyline {
                    crossOnBase, perpStart.Pt
                };

                Vector3d perpVec = perpStart.Pt - crossOnBase;

                if (perpInvert)
                {
                    perpVec = -perpVec;
                }

                if (!CCXTools.IsIntersectCrv(perpLinePoly, boundary, false))
                {
                    footOfPerps.Add(new InitialPt(crossOnBase, perpBase.UnitTangent, perpVec));
                }

                return(footOfPerps);
            }
Esempio n. 2
0
        public static List <Point3d> GetAllCrossPoints(Point3d basePt, Polyline boundary, Vector3d direction, double onTolerance)
        {
            List <Line>    boundarySeg = boundary.GetSegments().ToList();
            List <Point3d> crossPts    = new List <Point3d>();

            //testline setting
            double coverAllLength = new BoundingBox(boundary).Diagonal.Length *2;
            Line   testLine       = new Line(basePt, basePt + direction / direction.Length * coverAllLength);
            double xHi1           = Math.Max(testLine.FromX, testLine.ToX);
            double xLo1           = Math.Min(testLine.FromX, testLine.ToX);
            double yHi1           = Math.Max(testLine.FromY, testLine.ToY);
            double yLo1           = Math.Min(testLine.FromY, testLine.ToY);

            foreach (Line i in boundarySeg)
            {
                //seive1: xRange
                double xHi2 = Math.Max(i.FromX, i.ToX);
                double xLo2 = Math.Min(i.FromX, i.ToX);

                if (xHi1 > xHi2)
                {
                    if (xLo1 > xHi2)
                    {
                        continue;
                    }
                }

                if (xHi2 > xHi1)
                {
                    if (xLo2 > xHi1)
                    {
                        continue;
                    }
                }

                //seive2: yRange
                double yHi2 = Math.Max(i.FromY, i.ToY);
                double yLo2 = Math.Min(i.FromY, i.ToY);

                if (yHi1 > yHi2)
                {
                    if (yLo1 > yHi2)
                    {
                        continue;
                    }
                }

                if (yHi2 > yHi1)
                {
                    if (yLo2 > yHi1)
                    {
                        continue;
                    }
                }

                Point3d tempCrossPt = CCXTools.GetCrossPt(testLine, i);

                if (IsPtOnLine(tempCrossPt, testLine, onTolerance) && IsPtOnLine(tempCrossPt, i, onTolerance))
                {
                    crossPts.Add(tempCrossPt);
                }
            }

            return(crossPts);
        }
Esempio n. 3
0
            //main
            public void Inflate(Polyline boundary, Curve boundCrv, double minLength, bool applyMinToUpper)
            {
                bool   isInsideBound = false;
                double tempLoBound   = minLength;
                double tempUpBound   = WidthLine.Length;

                if (applyMinToUpper)
                {
                    tempUpBound -= minLength;
                }

                if (HeightLine.Length < 0.5 || WidthLine.Length < 0.5) //start seive: zeroLine
                {
                    return;
                }
                if (tempUpBound < minLength) //start seive: initial width < minLength
                {
                    return;
                }

                double loopBreaker = 0;

                while (tempLoBound <= tempUpBound)
                {
                    if (loopBreaker == 10)
                    {
                        break;
                    }

                    loopBreaker++;

                    double tempWidth  = (tempLoBound + tempUpBound) / 2;
                    double tempHeight = tempWidth / aspectRatio;

                    if (tempWidth < minLength) //mid seive
                    {
                        tempLoBound = minLength;
                        continue;
                    }

                    //counter-clockwise
                    Point3d p1 = BasePt;
                    Point3d p2 = BasePt + widthVec * tempWidth;
                    Point3d p3 = BasePt + widthVec * tempWidth + heightVec * tempHeight;
                    Point3d p4 = BasePt + heightVec * tempHeight;

                    Polyline tempBlock = new Polyline {
                        p1, p2, p3, p4, p1
                    };

                    if (boundCrv.Contains(p3) == PointContainment.Outside)
                    {
                        tempUpBound = tempWidth;
                        continue;
                    }

                    if (CCXTools.IsIntersectCrv(tempBlock, boundary, false))
                    {
                        tempUpBound = tempWidth;
                    }

                    else
                    {
                        isInsideBound = true;
                        tempLoBound   = tempWidth;
                    }
                }

                if (!isInsideBound) //end seive: intersection
                {
                    return;
                }

                if (tempLoBound / aspectRatio < minLength) //end seive: height
                {
                    return;
                }

                Width  = tempLoBound;
                Height = tempLoBound / aspectRatio;
            }