59 QList<QVector<float> > &outputPoints,
60 const QStringList &names,
74 VectorXf r0 = VectorXf::Zero(3);
78 float xmin,xmax,ymin,ymax;
80 int nchan = inputPoints.size();
82 MatrixXf rrs(nchan,3);
87 std::cout <<
"No input points to lay out.\n";
92 for(k = 0; k<nchan; k++) {
93 rrs(k,0) = inputPoints.at(k)[0];
94 rrs(k,1) = inputPoints.at(k)[1];
95 rrs(k,2) = inputPoints.at(k)[2];
98 std::cout <<
"Channels found for layout: " << nchan <<
"\n";
102 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 <<
"; tradius: " << rad <<
"\n";
117 for (k = 0; k < nchan; k++) {
118 rr = r0 -
static_cast<VectorXf
>(rrs.row(k));
119 sphere_coord(rr[0],rr[1],rr[2],&rad,&th,&phi);
120 xx[k] = prad*(2.0*th/
M_PI)*cos(phi);
121 yy[k] = prad*(2.0*th/
M_PI)*sin(phi);
130 for(k = 1; k < nchan; k++) {
133 else if (xx[k] < xmin)
137 else if (yy[k] < ymin)
141 if(xmin == xmax || ymin == ymax) {
142 std::cout<<
"Cannot make a layout. All positions are identical\n";
155 QVector<float> point;
159 if (!outFile.open(QIODevice::WriteOnly)) {
160 std::cout <<
"Could not open output file!\n";
164 out.setDevice(&outFile);
167#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
171 out <<
"0.000000 0.000000 0.000000 0.000000" << endl;
173 for(k = 0; k < nchan; k++) {
177 point.append(-(xx[k]-0.5*w));
179 point.append(xx[k]-0.5*w);
182 point.append(-(yy[k]-0.5*h));
184 point.append(yy[k]-0.5*h);
186 outputPoints.append(point);
189 if(k < names.size()) {
190 out << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h <<
" " << names.at(k) << endl;
192 out << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h << endl;
198 std::cout <<
"Success while wrtiting to output file.\n";
209 std::vector<std::vector<float> > &outputPoints,
210 const std::vector<std::string> &names,
211 const std::string& outFilePath,
224 VectorXf r0 = VectorXf::Zero(3);
228 float xmin,xmax,ymin,ymax;
229 int nchan = inputPoints.size();
231 MatrixXf rrs(nchan,3);
236 std::cout <<
"No input points to lay out.\n";
241 for(
int k = 0; k < nchan; k++) {
242 rrs(k,0) = inputPoints.at(k)[0];
243 rrs(k,1) = inputPoints.at(k)[1];
244 rrs(k,2) = inputPoints.at(k)[2];
247 std::cout <<
"Channels found for layout: " << nchan <<
"\n";
251 std::cout <<
"Using default origin:" << r0[0] <<
", " << r0[1] <<
", " << r0[2] <<
"\n";
259 std::cout <<
"best fitting sphere:\n";
260 std::cout <<
"torigin: " << r0[0] <<
", " << r0[1] <<
", " << r0[2] << std::endl <<
"; tradius: " << rad <<
"\n";
266 for (
int k = 0; k < nchan; k++) {
267 rr = r0 -
static_cast<VectorXf
>(rrs.row(k));
268 sphere_coord(rr[0],rr[1],rr[2],&rad,&th,&phi);
269 xx[k] = prad*(2.0*th/
M_PI)*cos(phi);
270 yy[k] = prad*(2.0*th/
M_PI)*sin(phi);
279 for(
int k = 1; k < nchan; k++) {
282 else if (xx[k] < xmin)
286 else if (yy[k] < ymin)
290 if(xmin == xmax || ymin == ymax) {
291 std::cout<<
"Cannot make a layout. All positions are identical\n";
304 std::vector<float> point;
305 std::ofstream outFile;
308 outFile.open(outFilePath);
309 if (!outFile.is_open()) {
310 std::cout <<
"Could not open output file!\n";
313 outFile <<
"0.000000 0.000000 0.000000 0.000000" << std::endl;
316 for(
int k = 0; k < nchan; k++) {
320 point.push_back(-(xx[k]-0.5*w));
322 point.push_back(xx[k]-0.5*w);
325 point.push_back(-(yy[k]-0.5*h));
327 point.push_back(yy[k]-0.5*h);
329 outputPoints.push_back(point);
332 if((k) < (
int)names.size()) {
333 outFile << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h <<
" " << names.at(k) << std::endl;
335 outFile << k+1 <<
" " << point[0] <<
" " << point[1] <<
" " << w <<
" " << h << std::endl;
341 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)