19 #include <dtkCoreSupport/dtkAbstractData.h>
20 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
40 return "axlVolumeDiscreteReader";
45 return "axlVolumeDiscreteReader";
50 return QStringList() <<
"axlVolumeDiscrete";
60 QDomElement element = node.toElement();
62 if(element.tagName() !=
"volume")
65 if(element.attribute(
"type") !=
"discrete")
79 return !this->
accept(node);
84 QDomElement element = node.toElement();
88 QString name = element.attribute(
"name");
91 currentVolume->setObjectName(name);
95 QDomNodeList dimension = element.elementsByTagName(
"dimension");
96 if(!dimension.isEmpty()){
97 QDomElement dimensionElement = dimension.at(0).toElement();
99 QStringList dimensions = dimensionElement.text().simplified().split(QRegExp(
"\\s+"));
101 if(dimensions.size() == 3)
103 currentVolume->
setDimensions(dimensions[0].toInt(),dimensions[1].toInt(),dimensions[2].toInt());
109 QDomNodeList values = element.elementsByTagName(
"values");
111 if(!values.isEmpty()){
112 QDomElement scalarElement = values.at(0).toElement();
113 scalar = scalarElement.text().simplified().split(QRegExp(
"\\s+"));
120 for(
int i = 0;i < nx;i++){
121 for(
int j = 0;j < ny;j++){
122 for(
int k = 0;k < nz;k++){
123 number = scalar[nx*ny*k+ nx*j + i].toDouble();
124 currentVolume->
setValue(number,i,j,k);
129 return currentVolume;
139 if(!axl_reader->
accept(node))
142 axl_reader->dtkAbstractDataReader::read(this->file());
axlVolumeDiscreteReader(void)
QStringList handled(void) const
axlAbstractData * read(const QDomNode &node)
bool reject(const QDomNode &node)
int yDimension(void) const
void setValue(double value, int i, int j, int k)
static bool registered(void)
virtual axlAbstractData * read(const QDomNode &node)=0
int xDimension(void) const
QString description(void) const
dtkAbstractDataReader * createaxlVolumeDiscreteReader(void)
QString identifier(void) const
int zDimension(void) const
void setDimensions(unsigned int x, unsigned int y, unsigned int z)
bool hasChildNode(QDomElement element, const QString &tag)
virtual bool accept(const QDomNode &node)=0
bool accept(const QDomNode &node)
axlAbstractData * dataByReader(axlAbstractDataReader *axl_reader, const QDomNode &node)
Class axlAbstractData defines an API for all type of axel data.
~axlVolumeDiscreteReader(void)
static dtkAbstractDataFactory * dataFactSingleton