21 #include <dtkCoreSupport/dtkAbstractData.h>
22 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
40 return "axlShapeWriter";
44 return "axlShapeWriter";
48 return QStringList() <<
"axlShape";
52 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlShapeWriter", QStringList(),
createaxlShapeWriter);
64 return !this->
accept(data);
71 QDomElement shapeElement = doc->createElement(
"shape");
72 shapeElement.setAttribute(
"name", shape->name());
75 shapeElement.setAttribute(
"size", QString::number(shape->
size()));
78 QColor qcolor = shape->
color();
80 QTextStream(&color) << QString::number(qcolor.red()) <<
" "
81 << QString::number(qcolor.green()) <<
" "
82 << QString::number(qcolor.blue()) <<
" "
83 << QString::number(shape->
opacity());
84 shapeElement.setAttribute(
"color", color);
87 QString shader = shape->
shader();
88 QFileInfo shaderFileInfo(shader);
89 shapeElement.setAttribute(
"shader", shaderFileInfo.fileName());
93 shapeElement.setAttribute(
"nb_edges", shape->
getEdgeCount());
94 shapeElement.setAttribute(
"nb_faces", shape->
getFaceCount());
97 QVector<axlPoint*> allVertices = shape->
getVertices();
98 QDomElement verticesElement = doc->createElement(
"vertices");
99 for (
int k = 0; k < allVertices.size(); k++) {
100 axlPoint* currVertex = allVertices.at(k);
101 QString coordsString = QString::number(currVertex->
x()) +
" "
102 + QString::number(currVertex->
y()) +
" "
103 + QString::number(currVertex->
z()) +
"\n\t";
104 QDomText coordsDomText = doc->createTextNode(coordsString);
105 verticesElement.appendChild(coordsDomText);
107 shapeElement.appendChild(verticesElement);
110 QVector<axlShape::Edge*> allEdges = shape->
getEdges();
111 QDomElement edgesElement = doc->createElement(
"edges");
112 for (
int k = 0; k < allEdges.size(); k++) {
113 QDomElement edgeElement = doc->createElement(
"edge");
114 edgeElement.setAttribute(
"id", k);
120 QString curveWriterTag = curve->identifier()+
"Writer";
122 QDomElement curveElement = curveWriter->
write(doc, curve);
125 edgeElement.appendChild(curveElement);
126 edgeElement.setAttribute(
"type", curve->identifier());
133 edgesElement.appendChild(edgeElement);
135 shapeElement.appendChild(edgesElement);
138 QVector<axlShape::Face*> allFaces = shape->
getFaces();
139 QDomElement facesElement = doc->createElement(
"faces");
140 for (
int k = 0; k < allFaces.size(); k++) {
141 QDomElement faceElement = doc->createElement(
"face");
142 faceElement.setAttribute(
"id", k);
145 QVector<axlShape::Loop*> currLoops = currFace->
loops;
147 QDomElement faceSurfaceElement = doc->createElement(
"face_surface");
149 QString surfaceWriterTag = surface->identifier()+
"Writer";
152 QDomElement surfaceElement = surfaceWriter->
write(doc, surface);
154 faceElement.appendChild(surfaceElement);
156 dtkWarn() << surfaceWriterTag <<
"not supported yet.";
159 faceElement.setAttribute(
"type", surface->identifier());
162 for (
int i = 0; i < currLoops.size(); i++) {
163 QDomElement loopElement = doc->createElement(
"loop");
164 loopElement.setAttribute(
"id", i);
167 QVector<int> currEdges = currLoop->
edges;
168 QVector<bool> currOrientations = currLoop->
orientations;
170 for (
int j = 0; j < currEdges.size(); j++) {
171 QDomElement edgeElement = doc->createElement(
"edge");
172 edgeElement.setAttribute(
"id", currEdges.at(j));
174 bool currOrientation = currOrientations.at(j);
175 edgeElement.setAttribute(
"orientation", currOrientation);
177 loopElement.appendChild(edgeElement);
179 faceElement.appendChild(loopElement);
181 facesElement.appendChild(faceElement);
183 shapeElement.appendChild(facesElement);
188 QDomElement axlShapeWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data) {
194 if(!axl_writer->
accept(data))
197 element = axl_writer->
write(doc, data);
Class axlPoint defines 3D points.
axlAbstractCurveParametric * curve
Pointer to the parametric curve supporting the edge, of type axlAbstractCurveParametric.
int indexStartVertex
Index of the starting point of the edge in the array of vertices of the axlShape. ...
QVector< int > edges
Vector of indices of the edges of the loop in the array of edges of the axlShape. ...
virtual bool accept(dtkAbstractData *data)=0
QVector< Face * > getFaces(void) const
QVector< Edge * > getEdges(void) const
int getFaceCount(void) const
QString identifier(void) const
int getEdgeCount(void) const
QString description(void) const
int getVertexCount(void) const
Generic interface for parametric curve.
int indexEndVertex
Index of the ending point of the edge in the array of vertices of the axlShape.
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
QVector< bool > orientations
Vector of booleans of the same size as edges: true means the direct orientation, false is the reverse...
axlAbstractSurfaceParametric * surface
Pointer to the supporting surface of type axlAbstractSurfaceParametric.
static bool registered(void)
bool reject(dtkAbstractData *data)
QVector< Loop * > loops
Vector of all the loops defining the face.
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
QVector< axlPoint * > getVertices(void) const
dtkAbstractDataWriter * createaxlShapeWriter(void)
bool accept(dtkAbstractData *data)
virtual ~axlShapeWriter(void)
QStringList handled(void) const