// Build a list of x-monotone mountains private void CreateMountains() { foreach (Edge edge in _edgeList) { if (edge.MPoints.Count > 2) { MonotoneMountain mountain = new MonotoneMountain(); // Sorting is a perfromance hit. Literature says this can be accomplised in // linear time, although I don't see a way around using traditional methods // when using a randomized incremental algorithm // Insertion sort is one of the fastest algorithms for sorting arrays containing // fewer than ten elements, or for lists that are already mostly sorted. List <Point> points = new List <Point>(edge.MPoints); // ****************** // *ACK* // Lambda Expression non-delagate not supported in WinRT // points.Sort((p1, p2) => p1.X.CompareTo(p2.X)); // ****************** //points.Sort((p1, p2) => p1.X.CompareTo(p2.X)); foreach (Point p in points) { mountain.Add(p); } // Triangulate monotone mountain mountain.Process(); // Extract the triangles into a single list foreach (List <Point> t in mountain.Triangles) { Triangles.Add(t); } _xMonoPoly.Add(mountain); } } }
// Build a list of x-monotone mountains private void createMountains() { //NOTE FPE: Python here foreach (Edge edge in edgeList) { if (edge.mPoints.Count > 2) { MonotoneMountain mountain = new MonotoneMountain(); // Sorting is a perfromance hit. Literature says this can be accomplised in // linear time, although I don't see a way around using traditional methods // when using a randomized incremental algorithm // Insertion sort is one of the fastest algorithms for sorting arrays containing // fewer than ten elements, or for lists that are already mostly sorted. List <Point> points = new List <Point>(edge.mPoints); points.Sort(new sorter()); foreach (Point p in points) { mountain.add(p); } // Triangulate monotone mountain mountain.process(); // Extract the triangles into a single list foreach (List <Point> t in mountain.triangles) { polygons.Add(t); } xMonoPoly.Add(mountain); } } //NOTE FPE: Scala here //int i = 0; //while (i < edgeList.Count) //{ // Edge s = edgeList[i]; // //NOTE FPE: > 0 in scala and > 2 in python? // if (s.mPoints.Count > 0) // { // MonotoneMountain mountain = new MonotoneMountain(); // List<Point> k; // // Sorting is a perfromance hit. Literature says this can be accomplised in // // linear time, although I don't see a way around using traditional methods // // when using a randomized incremental algorithm // //if(s.mPoints.Count < 10) // // Insertion sort is one of the fastest algorithms for sorting arrays containing // // fewer than ten elements, or for lists that are already mostly sorted. // //k = Util.insertSort((p1: Point, p2: Point) => p1 < p2)(s.mPoints).toList // //else // //k = Util.msort((p1: Point, p2: Point) => p1 < p2)(s.mPoints.toList) // k = new List<Point>(s.mPoints); // k.Sort(new sort()); // //val points = s.p :: k ::: List(s.q) // List<Point> points = new List<Point>(); // points.Add(s.p); // points.AddRange(k); // points.Add(s.q); // int j = 0; // while (j < points.Count) // { // mountain.add(points[j]); // j += 1; // } // // Triangulate monotone mountain // mountain.process(); // // Extract the triangles into a single list // j = 0; // while (j < mountain.triangles.Count) // { // polygons.Add(mountain.triangles[j]); // j += 1; // } // xMonoPoly.Add(mountain); // } // i += 1; //} }