20 #include <dtkCoreSupport/dtkAbstractData.h>
21 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
40 return "axlShapeBSplineWriter";
45 return "axlShapeBSplineWriter";
50 return QStringList() <<
"axlShapeBSpline";
55 return dtkAbstractDataFactory::instance()->registerDataWriterType(
"axlShapeBSplineWriter", QStringList(),
createaxlShapeBSplineWriter);
73 return !this->
accept(data);
81 QDomElement surfElement = doc->createElement(
"surface");
82 surfElement.setAttribute(
"name", surf->name());
85 surfElement.setAttribute(
"type",
"patch");
88 surfElement.setAttribute(
"size", QString::number(surf->
size()));
91 QColor qcolor = surf->
color();
93 QTextStream(&color) << QString::number(qcolor.red()) <<
" "
94 << QString::number(qcolor.green()) <<
" "
95 << QString::number(qcolor.blue()) <<
" "
96 << QString::number(surf->
opacity());
97 surfElement.setAttribute(
"color", color);
100 QString shader = surf->
shader();
101 QFileInfo shaderFileInfo(shader);
102 surfElement.setAttribute(
"shader", shaderFileInfo.fileName());
107 surfElement.setAttribute(
"nb_faces", surf->
countFaces());
108 surfElement.setAttribute(
"orderu", surf->
order_u());
109 surfElement.setAttribute(
"orderv", surf->
order_v());
112 QDomElement verticesElement = doc->createElement(
"points");
114 QString coordsString = QString::number(surf->
getCoef(k).
x()) +
" "
115 + QString::number(surf->
getCoef(k).
y()) +
" "
116 + QString::number(surf->
getCoef(k).
z()) +
"\n\t";
117 QDomText coordsDomText = doc->createTextNode(coordsString);
118 verticesElement.appendChild(coordsDomText);
120 surfElement.appendChild(verticesElement);
123 QDomElement edgesElement = doc->createElement(
"edges");
125 QDomElement edgeElement = doc->createElement(
"edge");
126 edgeElement.setAttribute(
"id", k);
130 QDomElement controlP = doc->createElement(
"controlPoints");
133 QDomText coordsDomText = doc->createTextNode(coordsString);
134 controlP.appendChild(coordsDomText);
137 edgeElement.appendChild(controlP);
138 edgeElement.setAttribute(
"tag", currEdge->
tag);
139 edgesElement.appendChild(edgeElement);
142 surfElement.appendChild(edgesElement);
145 QDomElement facesElement = doc->createElement(
"faces");
146 for (
int k = 0; k < surf->
countFaces(); k++) {
147 QDomElement faceElement = doc->createElement(
"face");
148 faceElement.setAttribute(
"id", k);
152 QDomElement controlP = doc->createElement(
"controlPoints");
155 QDomText coordsDomText = doc->createTextNode(coordsString);
156 controlP.appendChild(coordsDomText);
159 QDomElement edgeInd = doc->createElement(
"nbpts");
161 QString coordsString = QString::number(currFace->
nbpts_u) +
" " + QString::number(currFace->
nbpts_v);
162 QDomText coordsDomText = doc->createTextNode(coordsString);
163 edgeInd.appendChild(coordsDomText);
166 faceElement.appendChild(controlP);
167 faceElement.appendChild(edgeInd);
168 facesElement.appendChild(faceElement);
170 surfElement.appendChild(facesElement);
176 QDomElement axlShapeBSplineWriter::elementByWriter(
axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
183 if(!axl_writer->
accept(data))
186 element = axl_writer->
write(doc, data);
axlPoint getCoef(int index) const
Get a coefficient of the surface.
int order_u() const
Return the order of the surface for the u parameter.
Edge * getEdge(int i)
Return edge.
bool accept(dtkAbstractData *data)
int countFaces(void)
Return how many faces.
int order_v() const
Return the order of the surface for the v parameter.
QVector< int > controlPointsIndices
static bool registered(void)
bool reject(dtkAbstractData *data)
virtual bool accept(dtkAbstractData *data)=0
Face * getFace(int i)
Return face.
QStringList handled(void) const
QString description(void) const
QString identifier(void) const
dtkAbstractDataWriter * createaxlShapeBSplineWriter(void)
int countBoundaryEdges() const
Return how many edges.
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
int countControlPoints() const
Modified a coefficient of the surface.
Class axlShapeBSpline defines a set of boundary curves (Edges) and bspline surface patches (Face)...
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0
QVector< int > controlPointsIndices
QString identifier(void) const
Return the "axlShapeBSpline" identifier.Useful for data factory.