Developer documentation | Axl-2.5.1

axlFieldParametricSurfaceReader.cpp
Go to the documentation of this file.
1 /* axlFieldParametricCurveReader.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 
16 #include "axlReader.h"
17 
20 
21 #include <dtkCoreSupport/dtkAbstractData.h>
22 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
23 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
24 
25 // /////////////////////////////////////////////////////////////////
26 // axlFieldParametricCurveReader
27 // /////////////////////////////////////////////////////////////////
28 
30 {
31  this->setObjectName(this->description());
32 }
33 
35 {
36 
37 }
38 
40 {
41  return "axlFieldParametricCurveReader";
42 }
43 
45 {
46  return "axlFieldParametricCurveReader";
47 }
48 
50 {
51  return QStringList() << "axlFieldParametricCurve";
52 }
53 
55 {
56  return dtkAbstractDataFactory::instance()->registerDataReaderType("axlFieldParametricCurveReader", QStringList(), createaxlFieldParametricCurveReader);
57 }
58 
59 bool axlFieldParametricCurveReader::accept(const QDomNode& node)
60 {
61  QDomElement element = node.toElement();
62 
63  if(element.tagName() != "field")
64  return false;
65 
66  return true;
67 }
68 
69 bool axlFieldParametricCurveReader::reject(const QDomNode& node)
70 {
71  return !this->accept(node);
72 }
73 
74 
75 //read only one special field :axlFieldParametricCurve.
77 {
78 
79  qDebug() << Q_FUNC_INFO << "enter";
80  QDomElement element = node.toElement();
81  axlFieldParametricCurve *field = NULL;
82 
83  // field type : the type corresponds to the identifier, use factory to initialize field.
84  QString type = element.attribute("type");
85  if(!type.isEmpty())
86  {
87  field = dynamic_cast<axlFieldParametricCurve *>(dtkAbstractDataFactory::instance()->create(type));
88  }
89 
91  QString name = element.attribute("name");
92  if(!name.isEmpty())
93  {
94  field->setObjectName(name);
95  }
96 
98  QString typeField = element.attribute("valueType");
99  if(!typeField.isEmpty()){
100  if(typeField == "int"){
102  }else if(typeField == "float"){
104  }else{
106  }
107  }
108 
109 
111  QString support = element.attribute("support");
112  if(support == "point"){
114  }else if(support == "cell"){
116  }else{
118  }
119 
121  QString kind = element.attribute("kind");
122  if(kind == "scalar"){
124  }else if(kind == "vector"){
126  }else{
128  }
129 
130 
132  QDomNodeList listFunction = element.elementsByTagName("curve");
133  QDomElement functionDescription = listFunction.at(0).toElement();
134 
135  dtkAbstractData *data = NULL;
136  // test for all reader registered in the factory
137  foreach(QString reader, dtkAbstractDataFactory::instance()->readers()) {
138  axlAbstractDataReader *axl_reader = dynamic_cast<axlAbstractDataReader *>(dtkAbstractDataFactory::instance()->reader(reader));
139  data = this->dataByReader(axl_reader, functionDescription);
140  delete axl_reader;
141 
142  if(data){
143  axlAbstractData *function = dynamic_cast<axlAbstractData *>(data);
144  field->setFunction(function);
145  }
146  }
147 
148 
149  field->update();
150  return field;
151 
152 
153 }
154 
155 dtkAbstractData *axlFieldParametricCurveReader::dataByReader(axlAbstractDataReader *axl_reader, const QDomNode& node)
156 {
157  if(!axl_reader)
158  return NULL;
159 
160  if(!axl_reader->accept(node))
161  return NULL;
162 
163  axl_reader->dtkAbstractDataReader::read(this->file());
164 
165  if(dtkAbstractData *data = axl_reader->read(node))
166  return data;
167 
168 
169  return NULL;
170 }
171 
172 
173 
174 dtkAbstractDataReader *createaxlFieldParametricCurveReader(void)
175 {
177 }
178 
Class axlFieldParametricCurve defines an API for field which owns a BSpline curve.
axlAbstractData * read(const QDomNode &node)
dtkAbstractDataReader * createaxlFieldParametricCurveReader(void)
dtkAbstractData * dataByReader(axlAbstractDataReader *axl_reader, const QDomNode &node)
virtual axlAbstractData * read(const QDomNode &node)=0
void setFunction(axlAbstractData *data)
Sets the Bspline function which determines the values of the BSpline field.
virtual void setType(Type type)
Sets the type of the field which can be either int, float or double.
virtual void setSupport(Support support)
virtual bool accept(const QDomNode &node)=0
virtual void setKind(Kind kind)
Sets the kind of the field which can be either scalar, vector or tensor.
Class axlAbstractData defines an API for all type of axel data.