Пример #1
0
        /// <summary>
        /// Returns the point within the section based off of subsection information
        /// </summary>
        /// <param name="subsec"></param>
        /// <returns></returns>
        public PointClass LocateSubSection(SubSectionClass subsec)
        {
            PointClass LocateSubSectionOut = new PointClass();
            LineClass  right  = new LineClass();
            LineClass  bottom = new LineClass();
            LineClass  second = new LineClass();
            LineClass  first  = new LineClass();
            PointClass temp   = new PointClass();

            if (IsValid())
            {
                bottom.CreateFromPoints(Corners[2], Corners[3]);
                right.CreateFromPoints(Corners[0], Corners[3]);
                first.CreateSlopePoint(right.M, bottom.CPoint((Corners[3].X - bottom.Adjustment(subsec.ROffset().X))));
                second.CreateSlopePoint(bottom.M, right.CPoint((Corners[3].X + (Math.Sign(right.M) * right.Adjustment(subsec.ROffset().Y)))));
                temp = MeasureFunctions.LineIntercection(first, second);
                LocateSubSectionOut = temp;
            }
            else
            {
                temp.X = -1;
                temp.Y = -1;
                LocateSubSectionOut = temp;
            }
            return(LocateSubSectionOut);
        }
Пример #2
0
        /// <summary>
        /// Return the subsection for a given point within the section based off midpoints.
        /// </summary>
        /// <param name="Point"></param>
        /// <returns></returns>
        public SubSectionClass Point2SubSec(PointClass Point)
        {
            SubSectionClass tSubSec    = new SubSectionClass();
            PointClass      Center     = new PointClass();
            LineClass       LineOne    = new LineClass();
            LineClass       LineTwo    = new LineClass();
            LineClass       HoriLine   = new LineClass();
            LineClass       VertLine   = new LineClass();
            LineClass       SubLineOne = new LineClass();
            LineClass       SubLineTwo = new LineClass();

            LineOne.CreateFromPoints(Corners[0], Corners[2]);
            LineTwo.CreateFromPoints(Corners[1], Corners[3]);
            Center = MeasureFunctions.LineIntercection(LineOne, LineTwo);
            LineOne.CreateFromPoints(Corners[2], Corners[3]);
            LineTwo.CreateFromPoints(Corners[0], Corners[3]);
            HoriLine.CreateSlopePoint(LineOne.M, Center);
            VertLine.CreateSlopePoint(LineTwo.M, Center);
            // find first part
            if (HoriLine.CPoint(Point.X).Y >= Point.Y)
            {
                if (VertLine.CpointXfromY(Point.Y).X >= Point.X)
                {
                    tSubSec.FirstPart = "C";
                }
                else
                {
                    tSubSec.FirstPart = "D";
                }
            }
            else if (VertLine.CpointXfromY(Point.Y).X >= Point.X)
            {
                tSubSec.FirstPart = "B";
            }
            else
            {
                tSubSec.FirstPart = "A";
            }
            // find second part of Subsection
            // start by defining center point lines
            if (tSubSec.FirstPart == "A")
            {
                LineOne.CreateFromPoints(Corners[0], Corners[1]);
                SubLineOne.CreateFromPoints(Corners[0], Corners[2]);
                SubLineTwo.CreateFromPoints(MeasureFunctions.LineIntercection(VertLine, LineOne), MeasureFunctions.LineIntercection(HoriLine, LineTwo));
                Center = MeasureFunctions.LineIntercection(SubLineOne, SubLineTwo);
                LineOne.CreateFromPoints(Corners[2], Corners[3]);
                HoriLine.CreateSlopePoint(LineOne.M, Center);
                VertLine.CreateSlopePoint(LineTwo.M, Center);
            }
            else if (tSubSec.FirstPart == "B")
            {
                LineOne.CreateFromPoints(Corners[0], Corners[1]);
                LineTwo.CreateFromPoints(Corners[1], Corners[2]);
                SubLineOne.CreateFromPoints(Corners[1], Corners[3]);
                SubLineTwo.CreateFromPoints(MeasureFunctions.LineIntercection(VertLine, LineOne), MeasureFunctions.LineIntercection(HoriLine, LineTwo));
                Center = MeasureFunctions.LineIntercection(SubLineOne, SubLineTwo);
                LineOne.CreateFromPoints(Corners[2], Corners[3]);
                LineTwo.CreateFromPoints(Corners[0], Corners[3]);
                HoriLine.CreateSlopePoint(LineOne.M, Center);
                VertLine.CreateSlopePoint(LineTwo.M, Center);
            }
            else if (tSubSec.FirstPart == "C")
            {
                LineTwo.CreateFromPoints(Corners[1], Corners[2]);
                SubLineOne.CreateFromPoints(Corners[0], Corners[2]);
                SubLineTwo.CreateFromPoints(MeasureFunctions.LineIntercection(VertLine, LineOne), MeasureFunctions.LineIntercection(HoriLine, LineTwo));
                Center = MeasureFunctions.LineIntercection(SubLineOne, SubLineTwo);
                LineOne.CreateFromPoints(Corners[2], Corners[3]);
                HoriLine.CreateSlopePoint(LineOne.M, Center);
                VertLine.CreateSlopePoint(LineTwo.M, Center);
            }
            else if (tSubSec.FirstPart == "D")
            {
                SubLineOne.CreateFromPoints(Corners[1], Corners[3]);
                SubLineTwo.CreateFromPoints(MeasureFunctions.LineIntercection(VertLine, LineOne), MeasureFunctions.LineIntercection(HoriLine, LineTwo));
                Center = MeasureFunctions.LineIntercection(SubLineOne, SubLineTwo);
                HoriLine.CreateSlopePoint(LineOne.M, Center);
                VertLine.CreateSlopePoint(LineTwo.M, Center);
            }
            // sub lines found and sub centers found
            // find second part now
            if (HoriLine.CPoint(Point.X).Y >= Point.Y)
            {
                if ((VertLine.CpointXfromY(Point.Y).X >= Point.X))
                {
                    tSubSec.SecondPart = "C";
                }
                else
                {
                    tSubSec.SecondPart = "D";
                }
            }
            else if (VertLine.CpointXfromY(Point.Y).X >= Point.X)
            {
                tSubSec.SecondPart = "B";
            }
            else
            {
                tSubSec.SecondPart = "A";
            }
            return(tSubSec);
        }