49 #include <QTextStream>
50 #include <QStringList>
52 #include <QRegularExpression>
62 using namespace FSLIB;
63 using namespace Eigen;
78 const MatrixX3f &p_pos,
79 const VectorXd &p_values,
81 const QString &p_name,
83 : vertices(p_vertices)
106 pos = MatrixX3f(0,3);
151 return MatrixX3i(0,3);
153 MatrixX3i tris(p_matTris.rows(),3);
156 verts.reserve(this->
vertices.size());
157 for(qint32 i = 0; i < this->
vertices.size(); ++i)
158 verts.insert(this->vertices[i]);
164 for(qint32 i = 0; i < p_matTris.rows(); ++i)
166 if(verts.contains(p_matTris(i,0)) || verts.contains(p_matTris(i,1)) || verts.contains(p_matTris(i,2)))
168 tris.row(t_size) = p_matTris.row(i);
173 tris.conservativeResize(t_size, 3);
184 if(p_sFileName.mid(p_sFileName.size()-6,6).compare(
".label") != 0)
186 qWarning(
"Given file (%s) is not a .label file!\n", p_sFileName.toUtf8().constData());
190 printf(
"Reading label...");
191 QFile t_File(p_sFileName);
193 if (!t_File.open(QIODevice::ReadOnly | QIODevice::Text))
195 qWarning(
"\tError: Couldn't open the label file\n");
199 QTextStream t_TextStream(&t_File);
201 QString
comment = t_TextStream.readLine();
202 qint32 nv = t_TextStream.readLine().toInt();
204 MatrixXd data(nv, 5);
210 for(qint32 i = 0; i < nv; ++i)
214 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
215 auto skip = QString::SkipEmptyParts;
217 auto skip = Qt::SkipEmptyParts;
220 list = t_TextStream.readLine().split(QRegularExpression(
"\\s+"), skip);
222 for(qint32 j = 0; j < list.size(); ++j)
224 value = list[j].toDouble(&isNumber);
227 data(i, count) = value;
234 if(t_File.fileName().contains(
"lh."))
243 p_Label.
vertices = data.cast<
int>().block(0,0,data.rows(),1);
244 p_Label.
pos = data.cast<
float>().block(0,1,data.rows(),3).array() * 1e-3f;
245 p_Label.
values = data.block(0,4,data.rows(),1);
247 if(t_File.fileName().contains(
"lh.label"))
249 QStringList tmpList = t_File.fileName().split(
"lh.")[0].split(QRegularExpression(
"\\W+"));
250 p_Label.
name = tmpList[tmpList.size()-1];
252 else if(t_File.fileName().contains(
"lh."))
253 p_Label.
name = t_File.fileName().split(
"lh.")[1].split(QRegularExpression(
"\\W+"))[0];