Пример #1
0
        private IEnumerable <MeshPoint[]> getContours(MeshComponent component)
        {
            var circles = new List <MeshPoint[]>();

            var processedPoints = new HashSet <MeshPoint>();

            foreach (var point in component.Points)
            {
                if (!processedPoints.Add(point))
                {
                    continue;
                }

                var circle = new List <MeshPoint>();
                circle.Add(point);

                var currentPoint = point.Neighbours.First();
                while (currentPoint != point)
                {
                    //loop through the whole circle
                    var incomingPoint = circle[circle.Count - 1];
                    circle.Add(currentPoint);
                    processedPoints.Add(currentPoint);

                    currentPoint = currentPoint.GetOtherNeighbour(incomingPoint);
                }

                circles.Add(circle.ToArray());
            }

            return(circles);
        }
Пример #2
0
        private void clusterComponents()
        {
            var processedPoints = new HashSet <MeshPoint>();
            var workList        = new Queue <MeshPoint>();

            foreach (var meshPoint in ActiveMeshPoints)
            {
                if (processedPoints.Add(meshPoint))
                {
                    workList.Enqueue(meshPoint);
                }

                var component = new MeshComponent();
                while (workList.Count > 0)
                {
                    var point = workList.Dequeue();
                    component.Add(point);

                    foreach (var neighbour in point.Neighbours)
                    {
                        if (processedPoints.Add(neighbour))
                        {
                            workList.Enqueue(neighbour);
                        }
                    }
                }
            }
        }
Пример #3
0
        internal void Accept(MeshComponent component)
        {
            foreach (var point in component._points)
            {
                Add(point);
            }

            component._points.Clear();
        }
Пример #4
0
        private void orientComponentEdges(MeshComponent component)
        {
            foreach (var nonOrientedPoint in component.NonOrientedPoints)
            {
                var root = nonOrientedPoint;
                while (true)
                {
                    var nextTarget = root.NextNonOrientedTarget();
                    if (nextTarget == null)
                    {
                        //all the circle is oriented
                        break;
                    }

                    root.OrientEdgeTo(nextTarget);
                    root = nextTarget;
                }
            }
        }