mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.upptst
git-svn-id: svn://ultimatepp.org/upp/trunk@15749 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d5882da4c0
commit
d180ced830
2 changed files with 51 additions and 0 deletions
10
upptst/Delaunay/Delaunay.upp
Normal file
10
upptst/Delaunay/Delaunay.upp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
uses
|
||||
CtrlLib,
|
||||
Geom;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
41
upptst/Delaunay/main.cpp
Normal file
41
upptst/Delaunay/main.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <Geom/Geom.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct MyApp : TopWindow {
|
||||
virtual void Paint(Draw& w)
|
||||
{
|
||||
Array<Pointf> 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue