60 QList<QVector<float>>& outputPoints,
61 const QStringList& names,
75 VectorXf r0 = VectorXf::Zero(3);
79 float xmin, xmax, ymin, ymax;
81 int nchan = inputPoints.size();
83 MatrixXf rrs(nchan, 3);
88 std::cout <<
"No input points to lay out.\n";
93 for (k = 0; k < nchan; k++) {
94 rrs(k, 0) = inputPoints.at(k)[0];
95 rrs(k, 1) = inputPoints.at(k)[1];
96 rrs(k, 2) = inputPoints.at(k)[2];
99 std::cout <<
"Channels found for layout: " << nchan <<
"\n";
103 std::cout <<
"Using default origin:" << r0[0] <<
", " << r0[1] <<
", " << r0[2] <<
"\n";
110 std::cout <<
"best fitting sphere:\n";
111 std::cout <<
"torigin: " << r0[0] <<
", " << r0[1] <<
", " << r0[2] << std::endl
112 <<
"; tradius: " << rad <<
"\n";
118 for (k = 0; k < nchan; k++) {
119 rr =
static_cast<VectorXf
>(rrs.row(k)) - r0;
120 sphere_coord(rr[0], rr[1], rr[2], &rad, &th, &phi);
121 xx[k] = prad * (2.0 * th /
M_PI) * cos(phi);
122 yy[k] = prad * (2.0 * th /
M_PI) * sin(phi);
131 for (k = 1; k < nchan; k++) {
134 else if (xx[k] < xmin)
138 else if (yy[k] < ymin)
142 if (xmin == xmax || ymin == ymax) {
143 std::cout <<
"Cannot make a layout. All positions are identical\n";
147 xmax = xmax + 0.6 * w;
148 xmin = xmin - 0.6 * w;
150 ymax = ymax + 0.6 * h;
151 ymin = ymin - 0.6 * h;
156 QVector<float> point;
160 if (!outFile.open(QIODevice::WriteOnly)) {
161 std::cout <<
"Could not open output file!\n";
165 out.setDevice(&outFile);
168#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
172 out <<
"0.000000 0.000000 0.000000 0.000000" << endl;
174 for (k = 0; k < nchan; k++) {
178 point.append(-(xx[k] - 0.5 * w));
180 point.append(xx[k] - 0.5 * w);
183 point.append(-(yy[k] - 0.5 * h));
185 point.append(yy[k] - 0.5 * h);
187 outputPoints.append(point);
190 if (k < names.size()) {
191 out << k + 1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h <<
" " << names.at(k) << endl;
193 out << k + 1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h << endl;
199 std::cout <<
"Success while wrtiting to output file.\n";
210 std::vector<std::vector<float>>& outputPoints,
211 const std::vector<std::string>& names,
212 const std::string& outFilePath,
225 VectorXf r0 = VectorXf::Zero(3);
229 float xmin, xmax, ymin, ymax;
232 int nchan =
static_cast<int>(inputPoints.size());
234 MatrixXf rrs(nchan, 3);
239 std::cout <<
"No input points to lay out.\n";
244 for (
int k = 0; k < nchan; k++) {
245 rrs(k, 0) = inputPoints.at(k)[0];
246 rrs(k, 1) = inputPoints.at(k)[1];
247 rrs(k, 2) = inputPoints.at(k)[2];
250 std::cout <<
"Channels found for layout: " << nchan <<
"\n";
254 std::cout <<
"Using default origin:" << r0[0] <<
", " << r0[1] <<
", " << r0[2] <<
"\n";
261 std::cout <<
"best fitting sphere:\n";
262 std::cout <<
"torigin: " << r0[0] <<
", " << r0[1] <<
", " << r0[2] << std::endl
263 <<
"; tradius: " << rad <<
"\n";
269 for (
int k = 0; k < nchan; k++) {
270 rr =
static_cast<VectorXf
>(rrs.row(k)) - r0;
271 sphere_coord(rr[0], rr[1], rr[2], &rad, &th, &phi);
272 xx[k] = prad * (2.0 * th /
M_PI) * cos(phi);
273 yy[k] = prad * (2.0 * th /
M_PI) * sin(phi);
282 for (
int k = 1; k < nchan; k++) {
285 else if (xx[k] < xmin)
289 else if (yy[k] < ymin)
293 if (xmin == xmax || ymin == ymax) {
294 std::cout <<
"Cannot make a layout. All positions are identical\n";
298 xmax = xmax + 0.6 * w;
299 xmin = xmin - 0.6 * w;
301 ymax = ymax + 0.6 * h;
302 ymin = ymin - 0.6 * h;
307 std::vector<float> point;
308 std::ofstream outFile;
311 outFile.open(outFilePath);
312 if (!outFile.is_open()) {
313 std::cout <<
"Could not open output file!\n";
316 outFile <<
"0.000000 0.000000 0.000000 0.000000" << std::endl;
319 for (
int k = 0; k < nchan; k++) {
323 point.push_back(-(xx[k] - 0.5 * w));
325 point.push_back(xx[k] - 0.5 * w);
328 point.push_back(-(yy[k] - 0.5 * h));
330 point.push_back(yy[k] - 0.5 * h);
332 outputPoints.push_back(point);
335 if ((k) < (
int)names.size()) {
336 outFile << k + 1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h <<
" " << names.at(k) << std::endl;
338 outFile << k + 1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h << std::endl;
344 std::cout <<
"Success while wrtiting to output file.\n";
static bool makeLayout(const QList< QVector< float > > &inputPoints, QList< QVector< float > > &outputPoints, const QStringList &names, QFile &outFile, bool do_fit, float prad, float w, float h, bool writeFile=false, bool mirrorXAxis=false, bool mirrorYAxis=false)