Developer documentation | Axl-2.5.1

axlFieldParametricSurfaceTangentVectorReader.cpp
Go to the documentation of this file.
1 /* axlFieldParametricSurfaceTangentVectorReader.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 // axlFieldParametricSurfaceTangentVectorReader
27 // /////////////////////////////////////////////////////////////////
28 
30 {
31  this->setObjectName(this->description());
32 }
33 
35 {
36 
37 }
38 
40 {
41  return "axlFieldParametricSurfaceTangentVectorReader";
42 }
43 
45 {
46  return "axlFieldParametricSurfaceTangentVectorReader";
47 }
48 
50 {
51  return QStringList() << "axlFieldParametricSurfaceTangentVector";
52 }
53 
55 {
56  return dtkAbstractDataFactory::instance()->registerDataReaderType("axlFieldParametricSurfaceTangentVectorReader", QStringList(), createaxlFieldParametricSurfaceTangentVectorReader);
57 }
58 
60 {
61  QDomElement element = node.toElement();
62 
63  if(element.tagName() != "field")
64  return false;
65 
66  return true;
67 }
68 
70 {
71  return !this->accept(node);
72 }
73 
74 
75 //read only one special field :axlFieldSpatialPointDistance.
77 {
78 
79  QDomElement element = node.toElement();
81 
82  // field type : the type corresponds to the identifier, use factory to initialize field.
83  QString type = element.attribute("type");
84  if(!type.isEmpty())
85  {
86  field = dynamic_cast<axlFieldParametricSurfaceTangentVector *>(dtkAbstractDataFactory::instance()->create(type));
87  }
88 
90  QString name = element.attribute("name");
91  if(!name.isEmpty())
92  {
93  field->setObjectName(name);
94  }
95 
96  //Parameters
97  int number = node.childNodes().size();
98  for(int i = 0;i < number; i++){
99  QDomNode child = node.childNodes().at(i);
100  if(child.isElement() ){
101  double channel =0;
102  double value = 0;
103 
104  if(!child.toElement().attribute("channel").isEmpty())
105  channel = child.toElement().attribute("channel").toInt();
106 
107  if(!child.toElement().attribute("value").isEmpty())
108  value = child.toElement().attribute("value").toDouble();
109 
110  qDebug() << Q_FUNC_INFO << channel << value;
111  field->setParameter(value, channel);
112  }
113 
114  }
115 
116  field->update();
117  return field;
118 
119 
120 }
121 
123 {
124  if(!axl_reader)
125  return NULL;
126 
127  if(!axl_reader->accept(node))
128  return NULL;
129 
130  axl_reader->dtkAbstractDataReader::read(this->file());
131 
132  if(dtkAbstractData *data = axl_reader->read(node))
133  return data;
134 
135 
136  return NULL;
137 }
138 
139 
140 
142 {
144 }
145 
146 
dtkAbstractDataReader * createaxlFieldParametricSurfaceTangentVectorReader(void)
dtkAbstractData * dataByReader(axlAbstractDataReader *axl_reader, const QDomNode &node)
virtual axlAbstractData * read(const QDomNode &node)=0
int size(void)
Returns the number of values evaluated for this BSpline field on each samples of the input BSpline...
Class axlFieldParametricSurfaceTangentVector defines an API for field which owns a BSpline Surface as...
void setParameter(double parameter, int channel)
Sets the direction parameter for the tangentVector.
virtual bool accept(const QDomNode &node)=0
Class axlAbstractData defines an API for all type of axel data.