public Bitmap Run() { var rando = new Random(); var pts = new Point <double> [c]; var maxx = w - 1; var maxy = h - 1; for (int i = 0; i < c; i++) { pts[i] = new Point <double> { X = rando.Next(0, maxx), Y = rando.Next(0, maxy) }; } var hull = new Quickhull <double>(pts); // TODO: improve inference here. hull.Run(); Draw(hull.Points, Color.Green); Draw(hull.Lines, Color.Red); Draw(hull.Hull, Color.Blue); return(bmp); }
public Bitmap Run() { var rando = new Random(); var pts = new Point <double> [c]; var maxx = w - 1; var maxy = h - 1; for (var i = 0; i < c; i++) { pts[i] = new Point <double> { X = rando.Next(0, maxx), Y = rando.Next(0, maxy) }; } var hull = new Quickhull <double>(pts); hull.Run(); hull.Points.Draw(Color.Green, gfx); hull.Lines.Draw(Color.Red, gfx); hull.Hull.Draw(Color.Blue, gfx); return(bmp); }
static int Main(string [] args) { bool error = false; foreach (var s in args) { switch (s) { case "--dump": Quickhull.dump_faces = true; break; default: BinaryReader bw; if (s.Substring(s.Length - 3) == ".gz") { bw = new BinaryReader(new GZipStream(File.Open(s, FileMode.Open, FileAccess.Read), CompressionMode.Decompress)); } else { bw = new BinaryReader(File.Open(s, FileMode.Open, FileAccess.Read)); } var mesh = new RawMesh(0); mesh.Read(bw); Debug.Log($"{s} - {mesh.verts.Length} points"); bw.Close(); var qh = new Quickhull(mesh); var timer = System.Diagnostics.Stopwatch.StartNew(); var hull = qh.GetHull(); error |= qh.error; timer.Stop(); Debug.Log($" - {hull.Count} faces {timer.ElapsedMilliseconds}ms"); break; } } return(error ? 1 : 0); }