-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhpQueryDisc.cc
143 lines (90 loc) · 2.99 KB
/
hpQueryDisc.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include<iostream>
#include"pointing.h"
#include"vec3.h"
#include"healpix_base.h"
#include"wstp.h"
extern "C"{
void hpAng2Pix(double theta,double phi, int order){
pointing pos(theta,phi);
long pixel;
Healpix_Ordering_Scheme scheme=NEST;
T_Healpix_Base<long> base(order,scheme);
pixel=base.ang2pix(pos);
WSPutInteger64(stdlink, pixel);
return;
}
}
extern "C"{
void hpPix2Ang(long pixel, int order){
pointing pos;
Healpix_Ordering_Scheme scheme=NEST;
T_Healpix_Base<long> base(order,scheme);
pos=base.pix2ang(pixel);
std::vector<double> poslist={pos.theta,pos.phi};
WSPutReal64List(stdlink, poslist.data(),(int) poslist.size());
return;
}
}
extern "C"{
void hpPix2AngRing(long pixel, int order){
pointing pos;
Healpix_Ordering_Scheme scheme=RING;
T_Healpix_Base<long> base(order,scheme);
pos=base.pix2ang(pixel);
std::vector<double> poslist={pos.theta,pos.phi};
WSPutReal64List(stdlink, poslist.data(),(int) poslist.size());
return;
}
}
extern "C"{
void hpQueryDisc(double theta,double phi,double radius, int order){
pointing pos(theta,phi);
Healpix_Ordering_Scheme scheme=RING;
rangeset<long> poslist;
T_Healpix_Base<long> base(order,scheme);
base.query_disc(pos,radius,poslist);
std::vector<long> pixlist;
poslist.toVector(pixlist);
WSPutInteger64List(stdlink, pixlist.data(), (int) pixlist.size());
return;
}
}
extern "C"{
void hpQueryPolygon(double * vertices, long verticeslen, int order){
std::vector<pointing> vertex;
vertex.reserve(verticeslen/2);
for (int ii=0; ii<verticeslen; ii=ii+2) {
pointing vertexPointing(vertices[ii],vertices[ii+1]);
vertex.push_back(vertexPointing);
}
//Healpix_Ordering_Scheme scheme=RING;
rangeset<long> poslist;
T_Healpix_Base<long> base(order,RING);
base.query_polygon(vertex, poslist);
std::vector<long> pixlist;
poslist.toVector(pixlist);
WSPutInteger64List(stdlink, pixlist.data(), (int) pixlist.size());
return;
}
}
#if WINDOWS_WSTP
#if __BORLANDC__
#pragma argsused
#endif
int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
{
char buff[512];
char FAR * buff_start = buff;
char FAR * argv[32];
char FAR * FAR * argv_end = argv + 32;
hinstPrevious = hinstPrevious; /* suppress warning */
if (!WSInitializeIcon(hinstCurrent, nCmdShow)) return 1;
WSScanString(argv, &argv_end, &lpszCmdLine, &buff_start);
return WSMain((int)(argv_end - argv), argv);
}
#else
int main(int argc, char* argv[])
{
return WSMain(argc, argv);
}
#endif