19 #include <dtkCoreSupport/dtkAbstractData.h>
20 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
38 return "axlFieldDiscreteWriter";
43 return "axlFieldDiscreteWriter";
48 return QStringList() <<
"axlAbstractField" <<
"axlAbstractFieldDiscrete" <<
"axlFieldDiscrete";
53 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlFieldDiscreteWriter", QStringList(),
createaxlFieldDiscreteWriter);
67 return !this->
accept(data);
74 QDomElement fieldElement = doc->createElement(
"field");
77 fieldElement.setAttribute(
"type", field->
identifier());
80 fieldElement.setAttribute(
"count", QString::number(field->
size()));
84 fieldElement.setAttribute(
"dimension", QString::number(1));
86 fieldElement.setAttribute(
"dimension", QString::number(3));
88 fieldElement.setAttribute(
"dimension", QString::number(9));
93 fieldElement.setAttribute(
"support",
"point");
95 fieldElement.setAttribute(
"support",
"cell");
97 fieldElement.setAttribute(
"support",
"custom");
103 for(
int i = 0 ; i < field->
size(); i++)
104 QTextStream(&fieldsText) <<
"\n " << QString::number(field->
scalar(i));
106 for(
int i = 0 ; i < field->
size(); i++)
107 QTextStream(&fieldsText) <<
"\n " << QString::number((field->
vector(i))[0]) <<
" "<< QString::number((field->
vector(i))[1]) <<
" "<< QString::number((field->
vector(i))[2]);
109 for(
int i = 0 ; i < field->
size(); i++)
110 QTextStream(&fieldsText) <<
"\n " << QString::number((field->
tensor(i))[0]) <<
" "<< QString::number((field->
tensor(i))[1]) <<
" "<< QString::number((field->
tensor(i))[2])<<
" "<< QString::number((field->
tensor(i))[3])<<
" "<< QString::number((field->
tensor(i))[4])<<
" "<< QString::number((field->
tensor(i))[5])<<
" "<< QString::number((field->
tensor(i))[6])<<
" "<< QString::number((field->
tensor(i))[7])<<
" "<< QString::number((field->
tensor(i))[8]);
114 QTextStream(&fieldsText)<<
"\n";
115 QDomText fieldsDomText = doc->createTextNode(fieldsText);
116 fieldElement.appendChild(fieldsDomText);
123 QDomElement axlFieldDiscreteWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
130 if(!axl_writer->
accept(data))
133 element = axl_writer->
write(doc, data);
dtkAbstractDataWriter * createaxlFieldDiscreteWriter(void)
virtual bool accept(dtkAbstractData *data)=0
QString identifier(void) const
bool reject(dtkAbstractData *data)
QString identifier(void) const
Returns the identifier "axlFieldDiscrete".
bool accept(dtkAbstractData *data)
virtual Support support(void)
static bool registered(void)
Class axlFieldDiscrete defines an API for arrays of numeric data.
virtual double scalar(int index)
Returns the value at index location of the scalar array.
axlFieldDiscreteWriter(void)
~axlFieldDiscreteWriter(void)
QStringList handled(void) const
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
QString description(void) const
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
virtual double * vector(int index)
Returns the value at index location of the vector array.
virtual double * tensor(int index)
Returns the value at index location of the tensor array.