Kstars

test-htmesh.cpp
1#include <iostream>
2
3#include "HTMesh.h"
4#include "MeshIterator.h"
5
6int main()
7{
8 int level = 5;
9 printf("level = %d\n", level);
10 HTMesh *mesh = new HTMesh(level, level);
11 mesh->setDebug(17);
12
13 double ra = 6.75 * 15.;
14 double dec = -16.72;
15
16 //Lookup the triangle containing (ra,dec)
17 long id = mesh->index(ra, dec);
18 const char *name = mesh->indexToName(id);
19 printf("(%8.4f %8.4f): %s\n", ra, dec, name);
20
21 double vr1, vd1, vr2, vd2, vr3, vd3;
22 mesh->vertices(id, &vr1, &vd1, &vr2, &vd2, &vr3, &vd3);
23
24 printf("\nThe three vertices of %s are:\n", name);
25 printf(" (%6.2f, %6.2f)\n", vr1, vd1);
26 printf(" (%6.2f, %6.2f)\n", vr2, vd2);
27 printf(" (%6.2f, %6.2f)\n", vr3, vd3);
28
29 printf("\n");
30 //Loop over triangles within one degree of (ra,dec)
31
32 double radius = 2.0;
33 //printf("Leak test! ...\n");
34 for (int ii = 0; ii < 1; ii++)
35 {
36 mesh->intersect(ra, dec, ra - radius, dec, ra - radius, dec + radius);
37 mesh->intersect(ra, dec, ra - radius, dec, ra - radius, dec + radius, ra, dec + radius);
38
39 mesh->intersect(ra, dec, radius);
40 //continue;
41
42 MeshIterator iterator(mesh);
43
44 printf("Number of trixels = %d\n\n", mesh->intersectSize());
45 printf("Triangles within %5.2f degrees of (%6.2f, %6.2f)\n", radius, ra, dec);
46
47 while (iterator.hasNext())
48 {
49 printf("%s\n", mesh->indexToName(iterator.next()));
50 }
51 }
52
53 double ra1, dec1, ra2, dec2;
54 ra1 = 275.874939;
55 ra2 = 274.882451;
56 dec1 = -82.470360;
57 dec2 = -82.482475;
58
59 printf("Testing Line intersection: (%f, %f) -->\n", ra1, dec1);
60 printf(" (%f, %f)\n", ra2, dec2);
61
62 mesh->intersect(ra1, dec1, ra2, dec2);
63 printf("found %d trixels\n", mesh->intersectSize());
64
65 return 0;
66}
HTMesh was originally intended to be a simple interface to the HTM library for the KStars project tha...
Definition HTMesh.h:57
void setDebug(int debug)
sets the debug level which is used to print out intermediate results in the line intersection routine...
Definition HTMesh.h:127
Trixel index(double ra, double dec) const
returns the index of the trixel that contains the specified point.
Definition HTMesh.cpp:72
int intersectSize(BufNum bufNum=0)
returns the number of trixels in the result buffer bufNum.
Definition HTMesh.cpp:262
void intersect(double ra, double dec, double radius, BufNum bufNum=0)
NOTE: The intersect() routines below are all used to find the trixels needed to cover a geometric obj...
Definition HTMesh.cpp:104
MeshIterator is a very lightweight class used to iterate over the result set of an HTMesh intersectio...
QStringView level(QStringView ifopt)
QString name(StandardAction id)
QTextStream & dec(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.