27 #include <dtkCoreSupport/dtkAbstractData.h>
28 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
47 return "axlMeshWriter";
52 return "axlMeshWriter";
57 return QStringList() <<
"axlMesh";
62 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlMeshWriter", QStringList(),
createaxlMeshWriter);
76 return !this->
accept(data);
84 QDomElement meshElement = doc->createElement(
"mesh");
85 QString name = data->name();
87 meshElement.setAttribute(
"name",name);
90 meshElement.setAttribute(
"size", QString::number(mesh->
size()));
95 QColor qcolor = mesh->
color();
96 QTextStream(&color) << QString::number(qcolor.red()) <<
" "
97 << QString::number(qcolor.green()) <<
" "
98 << QString::number(qcolor.blue()) <<
" "
99 << QString::number(mesh->
opacity());
101 meshElement.setAttribute(
"color", color);
104 QString shader = mesh->
shader();
105 QFileInfo shaderFileInfo(shader);
107 meshElement.setAttribute(
"shader", shaderFileInfo.fileName());
111 QDomElement count= doc->createElement(
"count");
113 QTextStream(&countStr) << QString::number(mesh->
vertex_count())
115 <<
" " << QString::number(mesh->
face_count());
117 QDomText countDomText = doc->createTextNode(countStr);
118 count.appendChild(countDomText);
119 meshElement.appendChild(count);
122 QDomElement points = doc->createElement(
"points");
124 points.setAttribute(
"color",
"rgb");
128 QTextStream(&pointsText)<<
"\n " << QString::number(mesh->
vertexX(i)) <<
" "<< QString::number(mesh->
vertexY(i)) <<
" "<< QString::number(mesh->
vertexZ(i));
130 QTextStream(&pointsText)<<
" " << QString::number(mesh->
colorR(i)) <<
" "<< QString::number(mesh->
colorG(i)) <<
" "<< QString::number(mesh->
colorB(i));
133 QTextStream(&pointsText)<<
"\n";
134 QDomText pointsDomText = doc->createTextNode(pointsText);
135 points.appendChild(pointsDomText);
136 meshElement.appendChild(points);
140 QDomElement colors = doc->createElement(
"colors");
144 QTextStream(&colorsText) <<
"\n " << QString::number(mesh->
colorR(i)) <<
" "<< QString::number(mesh->
colorG(i)) <<
" "<< QString::number(mesh->
colorB(i));
146 QTextStream(&colorsText)<<
"\n";
147 QDomText colorsDomText = doc->createTextNode(colorsText);
148 colors.appendChild(colorsDomText);
149 meshElement.appendChild(colors);
210 QDomElement edges = doc->createElement(
"edges");
212 for(
int i = 0 ; i < mesh->
edge_count(); i++) {
214 QTextStream(&edgesText)<<
"\n " << QString::number(e.size());
215 for (
int j=0;j<e.size();j++)
216 QTextStream(&edgesText)<<
" " << QString::number(e.at(j));
218 QTextStream(&edgesText)<<
"\n";
219 QDomText edgesDomText = doc->createTextNode(edgesText);
220 edges.appendChild(edgesDomText);
221 meshElement.appendChild(edges);
226 QDomElement faces = doc->createElement(
"faces");
229 QVector<int> f = mesh->
face(i);
230 QTextStream(&facesText)<<
"\n " << QString::number(f.size());
231 for(
int l=0; l < f.size(); l++)
232 QTextStream(&facesText) <<
" " << QString::number(f.at(l));
234 QTextStream(&facesText)<<
"\n";
235 QDomText facesDomText = doc->createTextNode(facesText);
236 faces.appendChild(facesDomText);
237 meshElement.appendChild(faces);
242 if(!mesh->
fields().isEmpty()){
245 QDomElement fieldElement = field_writer->
write(doc, field);
246 meshElement.appendChild(fieldElement);
255 QDomElement axlMeshWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
262 if(!axl_writer->
accept(data))
265 element = axl_writer->
write(doc, data);
double vertexZ(const int &ind) const
return Z coordinates of vertex with index ind.
int face_count(void) const
bool accept(dtkAbstractData *data)
bool reject(dtkAbstractData *data)
int colorG(const int &ind)
return int Green component of color with index ind.
virtual bool accept(dtkAbstractData *data)=0
QVector< int > Edge
An edge is represented by a sequence of vertices.
static axlFieldWritersFactory * instance(void)
virtual QString identifier(void) const
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
QStringList handled(void) const
int edge_count(void) const
dtkAbstractDataWriter * create(const QString &interface_name)
double vertexY(const int &ind) const
return Y coordinates of vertex with index ind.
QString description(void) const
QString identifier(void) const
int colorR(const int &ind)
return int Red component of color with index ind.
Class axlAbstractField defines an API for arrays of numeric data.
dtkAbstractDataWriter * createaxlMeshWriter(void)
static bool registered(void)
bool color_used(void) const
int colorB(const int &ind)
Return int Blue component of color with index ind.
int color_count(void) const
QList< axlAbstractField * > fields(void)
double vertexX(const int &ind) const
Return X coordinates of vertex with index ind.
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
int vertex_count(void) const
Class axlMesh defines a piecewise-linear 3D object.