Exemple #1
0
        /// <summary>
        /// Will do a warmup run to let the JVM optimize the triangulation code -- or would if this were Java --MM
        /// </summary>
        public static void Warmup()
        {
#if false
            /*
             * After a method is run 10000 times, the Hotspot compiler will compile
             * it into native code. Periodically, the Hotspot compiler may recompile
             * the method. After an unspecified amount of time, then the compilation
             * system should become quiet.
             */
            Polygon poly = PolygonGenerator.RandomCircleSweep2(50, 50000);
            TriangulationProcess process = new TriangulationProcess();
            process.triangulate(poly);
#endif
        }
        private static List <Triangle2> DelaunayOfPolygon(List <Point2D> points)
        {
            var pts = points.Select(p => new Poly2Tri.Triangulation.Polygon.PolygonPoint(p.x, p.y)).ToList();

            Poly2Tri.Triangulation.Polygon.Polygon set = new Poly2Tri.Triangulation.Polygon.Polygon(pts);

            DTSweepContext tcx = new DTSweepContext();

            tcx.PrepareTriangulation(set);
            DTSweep.Triangulate(tcx);

            var triangles = new List <Triangle2>();

            foreach (DelaunayTriangle triangle in set.Triangles)
            {
                List <Point2D> tri = new List <Point2D>();
                foreach (TriangulationPoint p in triangle.Points)
                {
                    tri.Add(new Point2D(p.X, p.Y));
                }
                triangles.Add(new Triangle2(tri[0], tri[1], tri[2]));
            }
            return(triangles);
        }
Exemple #3
0
 public static void Triangulate(Polygon p)
 {
     Triangulate(_defaultAlgorithm, p);
 }