From d180ced830954e3efd3feae25fc40d78bee12e12 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 9 Feb 2021 11:18:28 +0000 Subject: [PATCH] .upptst git-svn-id: svn://ultimatepp.org/upp/trunk@15749 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/Delaunay/Delaunay.upp | 10 +++++++++ upptst/Delaunay/main.cpp | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 upptst/Delaunay/Delaunay.upp create mode 100644 upptst/Delaunay/main.cpp diff --git a/upptst/Delaunay/Delaunay.upp b/upptst/Delaunay/Delaunay.upp new file mode 100644 index 000000000..0629a8e3a --- /dev/null +++ b/upptst/Delaunay/Delaunay.upp @@ -0,0 +1,10 @@ +uses + CtrlLib, + Geom; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/Delaunay/main.cpp b/upptst/Delaunay/main.cpp new file mode 100644 index 000000000..248d0c9e7 --- /dev/null +++ b/upptst/Delaunay/main.cpp @@ -0,0 +1,41 @@ +#include +#include + +using namespace Upp; + +struct MyApp : TopWindow { + virtual void Paint(Draw& w) + { + Array poly; + poly << Pointf(18.951605, 0.8) << Pointf(19.714577, 0.6168874) << Pointf(20.14996, 0) << Pointf(19.714577, -0.6168874) << Pointf(18.951605, -0.8) << Pointf(17.753117, 0) << Pointf(18.188618, -0.6) << Pointf(18.188618, 0.6); + + Delaunay del; + del.Build(poly); + + auto Get = [&](int i) { + Pointf fp = poly[i]; + fp.x -= 19; + return (Point)(fp * 200 + GetSize() / 2); + }; + + w.DrawRect(GetSize(), White()); + for(int i = 0; i < poly.GetCount(); i++) { + Point p = Get(i); + w.DrawRect(p.x - 3, p.y - 3, 5, 5, LtBlue()); + } + + for(int i = 0; i < del.GetCount(); i++) { + const Delaunay::Triangle& t = del[i]; + if(t.IsProper()) { + w.DrawLine(Get(t[0]), Get(t[1])); + w.DrawLine(Get(t[1]), Get(t[2])); + w.DrawLine(Get(t[2]), Get(t[0])); + } + } + } +}; + +GUI_APP_MAIN +{ + MyApp().Run(); +}