74 QList<QVector<float> > &outputPoints,
75 const QStringList &names,
89 VectorXf r0 = VectorXf::Zero(3);
93 float xmin,xmax,ymin,ymax;
95 int nchan = inputPoints.size();
97 MatrixXf rrs(nchan,3);
102 std::cout <<
"No input points to lay out.\n";
107 for(k = 0; k<nchan; k++) {
108 rrs(k,0) = inputPoints.at(k)[0];
109 rrs(k,1) = inputPoints.at(k)[1];
110 rrs(k,2) = inputPoints.at(k)[2];
113 std::cout <<
"Channels found for layout: " << nchan <<
"\n";
117 std::cout <<
"Using default origin:" << r0[0] <<
", " << r0[1] <<
", " << r0[2] <<
"\n";
125 std::cout <<
"best fitting sphere:\n";
126 std::cout <<
"torigin: " << r0[0] <<
", " << r0[1] <<
", " << r0[2] << std::endl <<
"; tradius: " << rad <<
"\n";
132 for (k = 0; k < nchan; k++) {
133 rr = r0 -
static_cast<VectorXf
>(rrs.row(k));
134 sphere_coord(rr[0],rr[1],rr[2],&rad,&th,&phi);
135 xx[k] = prad*(2.0*th/
M_PI)*cos(phi);
136 yy[k] = prad*(2.0*th/
M_PI)*sin(phi);
145 for(k = 1; k < nchan; k++) {
148 else if (xx[k] < xmin)
152 else if (yy[k] < ymin)
156 if(xmin == xmax || ymin == ymax) {
157 std::cout<<
"Cannot make a layout. All positions are identical\n";
170 QVector<float> point;
174 if (!outFile.open(QIODevice::WriteOnly)) {
175 std::cout <<
"Could not open output file!\n";
179 out.setDevice(&outFile);
182#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
186 out <<
"0.000000 0.000000 0.000000 0.000000" << endl;
188 for(k = 0; k < nchan; k++) {
192 point.append(-(xx[k]-0.5*w));
194 point.append(xx[k]-0.5*w);
197 point.append(-(yy[k]-0.5*h));
199 point.append(yy[k]-0.5*h);
201 outputPoints.append(point);
204 if(k < names.size()) {
205 out << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h <<
" " << names.at(k) << endl;
207 out << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h << endl;
213 std::cout <<
"Success while wrtiting to output file.\n";
224 std::vector<std::vector<float> > &outputPoints,
225 const std::vector<std::string> &names,
226 const std::string& outFilePath,
239 VectorXf r0 = VectorXf::Zero(3);
243 float xmin,xmax,ymin,ymax;
244 int nchan = inputPoints.size();
246 MatrixXf rrs(nchan,3);
251 std::cout <<
"No input points to lay out.\n";
256 for(
int k = 0; k < nchan; k++) {
257 rrs(k,0) = inputPoints.at(k)[0];
258 rrs(k,1) = inputPoints.at(k)[1];
259 rrs(k,2) = inputPoints.at(k)[2];
262 std::cout <<
"Channels found for layout: " << nchan <<
"\n";
266 std::cout <<
"Using default origin:" << r0[0] <<
", " << r0[1] <<
", " << r0[2] <<
"\n";
274 std::cout <<
"best fitting sphere:\n";
275 std::cout <<
"torigin: " << r0[0] <<
", " << r0[1] <<
", " << r0[2] << std::endl <<
"; tradius: " << rad <<
"\n";
281 for (
int k = 0; k < nchan; k++) {
282 rr = r0 -
static_cast<VectorXf
>(rrs.row(k));
283 sphere_coord(rr[0],rr[1],rr[2],&rad,&th,&phi);
284 xx[k] = prad*(2.0*th/
M_PI)*cos(phi);
285 yy[k] = prad*(2.0*th/
M_PI)*sin(phi);
294 for(
int k = 1; k < nchan; k++) {
297 else if (xx[k] < xmin)
301 else if (yy[k] < ymin)
305 if(xmin == xmax || ymin == ymax) {
306 std::cout<<
"Cannot make a layout. All positions are identical\n";
319 std::vector<float> point;
320 std::ofstream outFile;
323 outFile.open(outFilePath);
324 if (!outFile.is_open()) {
325 std::cout <<
"Could not open output file!\n";
328 outFile <<
"0.000000 0.000000 0.000000 0.000000" << std::endl;
331 for(
int k = 0; k < nchan; k++) {
335 point.push_back(-(xx[k]-0.5*w));
337 point.push_back(xx[k]-0.5*w);
340 point.push_back(-(yy[k]-0.5*h));
342 point.push_back(yy[k]-0.5*h);
344 outputPoints.push_back(point);
347 if((k) < (
int)names.size()) {
348 outFile << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h <<
" " << names.at(k) << std::endl;
350 outFile << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h << std::endl;
356 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)