Beispiel #1
0
        private static List <CrossSectionEvent> GenerateEventQueue(List <Line> meshLines, int numCrossSections)
        {
            float upperBound = float.NegativeInfinity, lowerBound = float.PositiveInfinity;
            LLRedBlackTree <CrossSectionEvent> eventQueue = new LLRedBlackTree <CrossSectionEvent>();

            for (int i = 0; i < meshLines.Count; i++)
            {
                Line line = meshLines[i];
                CrossSectionEvent point1Event = new CrossSectionEvent();
                CrossSectionEvent point2Event = new CrossSectionEvent();

                point1Event.line            = line;
                point1Event.point           = line.point1.y;
                point1Event.crossSectionCut = false;

                eventQueue.Insert(point1Event);

                point2Event.line            = line;
                point2Event.point           = line.point2.y;
                point2Event.crossSectionCut = false;

                eventQueue.Insert(point2Event);

                upperBound = Math.Max(upperBound, line.point1.y);
                upperBound = Math.Max(upperBound, line.point2.y);

                lowerBound = Math.Min(lowerBound, line.point1.y);
                lowerBound = Math.Min(lowerBound, line.point2.y);
            }

            upperBound -= float.Epsilon * 16;
            lowerBound += float.Epsilon * 16;

            float stepSize = (upperBound - lowerBound) / ((float)numCrossSections - 1);

            for (int i = 0; i < numCrossSections; i++)
            {
                CrossSectionEvent crossSectionCut = new CrossSectionEvent();
                crossSectionCut.point           = stepSize * (float)i + lowerBound;
                crossSectionCut.crossSectionCut = true;

                eventQueue.Insert(crossSectionCut);
            }

            return(eventQueue.InOrderTraversal());
        }
Beispiel #2
0
        public CrossSectionCurve(CrossSectionCurve curveToCopy)
        {
            crossSectionsTree = new LLRedBlackTree <CrossSection>();
            List <CrossSection> sections = curveToCopy.crossSectionsTree.InOrderTraversal();

            for (int i = 0; i < sections.Count; i++)
            {
                crossSectionsTree.Insert(sections[i]);
            }
        }
Beispiel #3
0
        public void AddCrossSection(CrossSection section)
        {
            crossSectionsTree.Insert(section);

            if (section.station > maxStation)
            {
                maxStation = section.station;
            }
            else if (section.station < minStation)
            {
                minStation = section.station;
            }

            crossSectionList = null;
        }