Developer documentation | Axl-2.5.1

axlFieldParametricVolumeTangentVectorReader.cpp
Go to the documentation of this file.
1 /* axlFieldParametricVolumeTangentVectorReader.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 // axlFieldParametricVolumeTangentVectorReader
27 // /////////////////////////////////////////////////////////////////
28 
30 {
31  this->setObjectName(this->description());
32 }
33 
35 {
36 
37 }
38 
40 {
41  return "axlFieldParametricVolumeTangentVectorReader";
42 }
43 
45 {
46  return "axlFieldParametricVolumeTangentVectorReader";
47 }
48 
50 {
51  return QStringList() << "axlFieldParametricVolumeTangentVector";
52 }
53 
55 {
56  return dtkAbstractDataFactory::instance()->registerDataReaderType("axlFieldParametricVolumeTangentVectorReader", QStringList(), createaxlFieldParametricVolumeTangentVectorReader);
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<axlFieldParametricVolumeTangentVector *>(dtkAbstractDataFactory::instance()->create(type));
87  }
88 
90  QString name = element.attribute("name");
91  if(!name.isEmpty())
92  {
93  field->setObjectName(name);
94  }
95 
96 
97  //Parameters
98  int number = node.childNodes().size();
99  for(int i = 0;i < number; i++){
100  QDomNode child = node.childNodes().at(i);
101  if(child.isElement() ){
102  double channel =0;
103  double value = 0;
104 
105  if(!child.toElement().attribute("channel").isEmpty())
106  channel = child.toElement().attribute("channel").toInt();
107 
108  if(!child.toElement().attribute("value").isEmpty())
109  value = child.toElement().attribute("value").toDouble();
110 
111  qDebug() << Q_FUNC_INFO << channel << value;
112  field->setParameter(value, channel);
113  }
114 
115  }
116 
117  field->update();
118  return field;
119 
120 
121 }
122 
123 dtkAbstractData *axlFieldParametricVolumeTangentVectorReader::dataByReader(axlAbstractDataReader *axl_reader, const QDomNode& node)
124 {
125  if(!axl_reader)
126  return NULL;
127 
128  if(!axl_reader->accept(node))
129  return NULL;
130 
131  axl_reader->dtkAbstractDataReader::read(this->file());
132 
133  if(dtkAbstractData *data = axl_reader->read(node))
134  return data;
135 
136 
137  return NULL;
138 }
139 
140 
141 
143 {
145 }
146 
dtkAbstractDataReader * createaxlFieldParametricVolumeTangentVectorReader(void)
dtkAbstractData * dataByReader(axlAbstractDataReader *axl_reader, const QDomNode &node)
void setParameter(double parameter, int channel)
Sets the direction parameter for the tangentVector.
int size(void)
Returns the number of values evaluated for this BSpline field on each samples of the input BSpline...
virtual axlAbstractData * read(const QDomNode &node)=0
virtual bool accept(const QDomNode &node)=0
Class axlAbstractData defines an API for all type of axel data.
Class axlFieldParametricVolumeTangentVector defines an API for field which owns a BSpline Surface as ...