49 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
50 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
51 #include <dtkCoreSupport/dtkAbstractDataReader.h>
63 class axlReaderPrivate
66 QList<axlAbstractData *> dataList;
92 if(d->dataList.size() > index){
93 return d->dataList.at(index);
104 QDomDocument domdocument(
"axl");
108 if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
109 QMessageBox::information(0,
"Axel",
"Error of reading",
"&Ok", 0);
113 if(!domdocument.setContent(&f)) {
114 QMessageBox::information(0,
"Axel", file +
" is not a valid Axel file",
"&Ok", 0);
120 QDomNode n = domdocument.firstChildElement(
"axl").firstChild();
123 bool sameName =
false;
124 while (!n.isNull()) {
127 dtkAbstractData *readData = this->
read(n);
128 if(
axlAbstractData *axldata = dynamic_cast<axlAbstractData *>(readData)){
131 if(!d->dataList.isEmpty() && axldata->name() != axldata->identifier() && !sameName){
133 if(listData->name() == axldata->name() ){
136 if(!sameName && dynamic_cast<axlDataDynamic *>(listData)){
139 if(dataD->
outputs(i)->name() == axldata->name()){
147 if(!dynamic_cast<axlAbstractField *>(axldata)){
148 d->dataList << axldata;
153 if (n.toElement().tagName() ==
"view")
154 view = n.toElement();
159 dtkWarn() << Q_FUNC_INFO <<
"reads" <<d->dataList.size()<<
"object(s)";
161 int sizeList = d->dataList.size();
162 for(
int i = 0; i < sizeList; i++){
163 if(!d->dataList.at(i)->fields().isEmpty()){
165 QList<axlAbstractData *>a;
166 a << d->dataList.at(i);
173 if (view.tagName() ==
"view")
178 dtkWarn()<<
"\e[1;31m Two or more objects have the same name in"<< file<<
" (name changed) \e[0m";
189 foreach(QString reader, dtkAbstractDataFactory::instance()->readers()) {
190 dtkWarn()<<
"reader"<<reader;
192 data = this->dataByReader(axl_reader, node);
203 data = this->dataByReader(axl_cone_reader, node);
204 delete axl_cone_reader;
210 data = this->dataByReader(axl_cylinder_reader, node);
211 delete axl_cylinder_reader;
217 data = this->dataByReader(axl_torus_reader, node);
218 delete axl_torus_reader;
224 data = this->dataByReader(axl_arc_reader, node);
225 delete axl_arc_reader;
231 data = this->dataByReader(axl_shape_reader, node);
232 delete axl_shape_reader;
238 data = this->dataByReader(axl_ellipsoid_reader, node);
239 delete axl_ellipsoid_reader;
246 data = this->dataByReader(axl_line_reader, node);
247 delete axl_line_reader;
254 data = this->dataByReader(axl_plane_reader, node);
255 delete axl_plane_reader;
261 data = this->dataByReader(axl_point_reader, node);
262 delete axl_point_reader;
278 data = this->dataByReader(axl_sphere_reader, node);
280 delete axl_sphere_reader;
286 data = this->dataByReader(axl_composite_reader, node);
287 delete axl_composite_reader;
293 data = this->dataByReader(axl_dynamic_reader, node);
297 data = axl_dynamic_reader->
readInputs(axldata, node, d->dataList);
300 delete axl_dynamic_reader;
303 data = this->dataByReader(axl_mesh_reader, node);
304 delete axl_mesh_reader;
314 if(!axl_reader->
accept(node))
317 dtkWarn()<<
"data accepted";
319 axl_reader->dtkAbstractDataReader::read(d->filename);
332 QFile filename(file);
333 if (filename.open(QFile::ReadOnly))
335 QTextStream in(&filename);
341 bool intConvert =
false;
347 QVector<int> currentFace;
348 int currentFaceSize = 0;
349 int currentFaceIndex = 0;
351 format = in.readLine(75);
353 if(format.startsWith(
"OFF") || format.startsWith(
"off") || format.startsWith(
"Off"))
363 vertexCount = format.toInt(&intConvert);
372 for(
int i = 0 ; i < vertexCount ; i++)
384 qDebug()<<
"axlReader::importOFF"<< faceCount+edgeCount;
386 for(
int i = 0 ; i < faceCount+edgeCount ; i++)
390 in >> currentFaceSize;
392 if(currentFaceSize == 1){
393 for(
int j = 0 ; j < 2 ; j++)
396 in >> currentFaceIndex;
397 currentFace << currentFaceIndex;
405 for(
int j = 0 ; j < currentFaceSize ; j++)
408 in >> currentFaceIndex;
409 currentFace << currentFaceIndex;
bool importOFF(const QString &file)
int face_count(void) const
bool vertex_show(void) const
void push_back_edge(int, int)
virtual int numberOfChannels(void)
Return the number of output(s);.
void dataSceneRead(QDomElement)
axlAbstractData * outputs(void)
Return the first output of the list.
bool edge_show(void) const
QList< axlAbstractData * > dataSet(void)
Class axlDataDynamic defines a dynamic object.
void dataSetInserted(QList< axlAbstractData * > dataSet)
int edge_count(void) const
virtual axlAbstractData * read(const QDomNode &node)=0
Class axlAbstractField defines an API for arrays of numeric data.
bool face_show(void) const
bool read(const QString &file)
void push_back_face(const Face &face)
axlAbstractData * readInputs(axlDataDynamic *data, const QDomNode &node, const QList< axlAbstractData * > &list)
Construct an axlAbstractData from a node and a list of data.
virtual bool accept(const QDomNode &node)=0
axlAbstractData * data(int index)
void dataSetFieldsChanged(QList< axlAbstractData * > dataSet, QString fieldName)
int vertex_count(void) const
Class axlAbstractData defines an API for all type of axel data.
Class axlMesh defines a piecewise-linear 3D object.
void push_back_vertex(const double &x, const double &y, const double &z)
Add a new vertex to the mesh.